vite 2.9.7 → 3.0.0-alpha.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.
@@ -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 Plugin_2 } from 'rollup';
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,18 +36,18 @@ 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 'esbuild';
47
- import type { TransformResult as TransformResult_3 } from 'rollup';
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';
50
+ import type { Worker as Worker_2 } from 'okie';
51
51
  import type { ZlibOptions } from 'zlib';
52
52
 
53
53
  export declare interface Alias {
@@ -95,11 +95,6 @@ export declare interface AwaitWriteFinishOptions {
95
95
  export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
96
96
 
97
97
  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
98
  /**
104
99
  * Compatibility transform target. The transform is performed with esbuild
105
100
  * and the lowest supported target is es2015/es6. Note this only handles
@@ -123,13 +118,6 @@ export declare interface BuildOptions {
123
118
  * @default true
124
119
  */
125
120
  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
121
  /**
134
122
  * Directory relative from `root` where build output will be placed. If the
135
123
  * directory exists, it will be removed before the build.
@@ -183,10 +171,6 @@ export declare interface BuildOptions {
183
171
  * https://terser.org/docs/api-reference#minify-options
184
172
  */
185
173
  terserOptions?: Terser.MinifyOptions;
186
- /**
187
- * @deprecated Vite now uses esbuild for CSS minification.
188
- */
189
- cleanCssOptions?: any;
190
174
  /**
191
175
  * Will be merged with internal rollup options.
192
176
  * https://rollupjs.org/guide/en/#big-list-of-options
@@ -251,12 +235,6 @@ export declare interface BuildOptions {
251
235
  * Can slightly improve build speed.
252
236
  */
253
237
  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
238
  /**
261
239
  * Adjust chunk size warning limit (in kbs).
262
240
  * @default 500
@@ -574,15 +552,10 @@ export declare interface DepOptimizationOptions {
574
552
  *
575
553
  * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
576
554
  * - `plugins` are merged with Vite's dep plugin
577
- * - `keepNames` takes precedence over the deprecated `optimizeDeps.keepNames`
578
555
  *
579
556
  * https://esbuild.github.io/api
580
557
  */
581
558
  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
559
  /**
587
560
  * List of file extensions that can be optimized. A corresponding esbuild
588
561
  * plugin must exist to handle the specific extension.
@@ -613,7 +586,7 @@ export declare interface DepOptimizationResult {
613
586
  * the page reload will be delayed until the next rerun so we need
614
587
  * to be able to discard the result
615
588
  */
616
- commit: () => void;
589
+ commit: () => Promise<void>;
617
590
  cancel: () => void;
618
591
  }
619
592
 
@@ -643,10 +616,20 @@ export declare interface ESBuildOptions extends EsbuildTransformOptions {
643
616
 
644
617
  export { EsbuildTransformOptions }
645
618
 
646
- export declare type ESBuildTransformResult = Omit<TransformResult_2, 'map'> & {
619
+ export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
647
620
  map: SourceMap;
648
621
  };
649
622
 
623
+ export declare interface ExperimentalOptions {
624
+ /**
625
+ * Append fake `&lang.(ext)` when queries are specified, to preseve the file extension for following plugins to process.
626
+ *
627
+ * @experimental
628
+ * @default false
629
+ */
630
+ importGlobRestoreExtension?: boolean;
631
+ }
632
+
650
633
  export declare interface FileSystemServeOptions {
651
634
  /**
652
635
  * Strictly restrict file accessing outside of allowing paths.
@@ -670,8 +653,6 @@ export declare interface FileSystemServeOptions {
670
653
  * Glob patterns are supported.
671
654
  *
672
655
  * @default ['.env', '.env.*', '*.crt', '*.pem']
673
- *
674
- * @experimental
675
656
  */
676
657
  deny?: string[];
677
658
  }
@@ -1014,6 +995,86 @@ export declare namespace HttpProxy {
1014
995
  }
1015
996
  }
1016
997
 
998
+ export declare interface ImportGlobEagerFunction {
999
+ /**
1000
+ * 1. No generic provided, infer the type from `as`
1001
+ */
1002
+ <
1003
+ As extends string,
1004
+ T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
1005
+ >(
1006
+ glob: string | string[],
1007
+ options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
1008
+ ): Record<string, T>
1009
+ /**
1010
+ * 2. Module generic provided
1011
+ */
1012
+ <M>(
1013
+ glob: string | string[],
1014
+ options?: Omit<ImportGlobOptions<boolean, string>, 'eager'>
1015
+ ): Record<string, M>
1016
+ }
1017
+
1018
+ export declare interface ImportGlobFunction {
1019
+ /**
1020
+ * 1. No generic provided, infer the type from `eager` and `as`
1021
+ */
1022
+ <
1023
+ Eager extends boolean,
1024
+ As extends string,
1025
+ T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
1026
+ >(
1027
+ glob: string | string[],
1028
+ options?: ImportGlobOptions<Eager, As>
1029
+ ): (Eager extends true ? true : false) extends true
1030
+ ? Record<string, T>
1031
+ : Record<string, () => Promise<T>>
1032
+ /**
1033
+ * 2. Module generic provided, infer the type from `eager: false`
1034
+ */
1035
+ <M>(
1036
+ glob: string | string[],
1037
+ options?: ImportGlobOptions<false, string>
1038
+ ): Record<string, () => Promise<M>>
1039
+ /**
1040
+ * 3. Module generic provided, infer the type from `eager: true`
1041
+ */
1042
+ <M>(
1043
+ glob: string | string[],
1044
+ options: ImportGlobOptions<true, string>
1045
+ ): Record<string, M>
1046
+ }
1047
+
1048
+ export declare interface ImportGlobOptions<
1049
+ Eager extends boolean,
1050
+ AsType extends string
1051
+ > {
1052
+ /**
1053
+ * Import type for the import url.
1054
+ */
1055
+ as?: AsType
1056
+ /**
1057
+ * Import as static or dynamic
1058
+ *
1059
+ * @default false
1060
+ */
1061
+ eager?: Eager
1062
+ /**
1063
+ * Import only the specific named export. Set to `default` to import the default export.
1064
+ */
1065
+ import?: string
1066
+ /**
1067
+ * Custom queries
1068
+ */
1069
+ query?: string | Record<string, string | number | boolean>
1070
+ /**
1071
+ * Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance.
1072
+ *
1073
+ * @default false
1074
+ */
1075
+ exhaustive?: boolean
1076
+ }
1077
+
1017
1078
  export declare type IndexHtmlTransform = IndexHtmlTransformHook | {
1018
1079
  enforce?: 'pre' | 'post';
1019
1080
  transform: IndexHtmlTransformHook;
@@ -1086,6 +1147,12 @@ export declare interface JsonOptions {
1086
1147
  stringify?: boolean;
1087
1148
  }
1088
1149
 
1150
+ export declare interface KnownAsTypeMap {
1151
+ raw: string
1152
+ url: string
1153
+ worker: Worker_2<any, any>
1154
+ }
1155
+
1089
1156
  export declare type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
1090
1157
 
1091
1158
  export declare interface LibraryOptions {
@@ -1238,6 +1305,8 @@ export declare interface PackageData {
1238
1305
  getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
1239
1306
  data: {
1240
1307
  [field: string]: any;
1308
+ name: string;
1309
+ type: string;
1241
1310
  version: string;
1242
1311
  main: string;
1243
1312
  module: string;
@@ -1268,7 +1337,7 @@ export declare interface PackageData {
1268
1337
  * If a plugin should be applied only for server or build, a function format
1269
1338
  * config file can be used to conditional determine the plugins to use.
1270
1339
  */
1271
- export declare interface Plugin extends Plugin_2 {
1340
+ declare interface Plugin_2 extends Plugin_3 {
1272
1341
  /**
1273
1342
  * Enforce plugin invocation tier similar to webpack loaders.
1274
1343
  *
@@ -1309,6 +1378,15 @@ export declare interface Plugin extends Plugin_2 {
1309
1378
  * are applied. Hook can be async functions and will be called in series.
1310
1379
  */
1311
1380
  configureServer?: ServerHook;
1381
+ /**
1382
+ * Configure the preview server. The hook receives the connect server and
1383
+ * its underlying http server.
1384
+ *
1385
+ * The hooks are called before other middlewares are applied. A hook can
1386
+ * return a post hook that will be called after other middlewares are
1387
+ * applied. Hooks can be async functions and will be called in series.
1388
+ */
1389
+ configurePreviewServer?: PreviewServerHook;
1312
1390
  /**
1313
1391
  * Transform index.html.
1314
1392
  * The hook receives the following arguments:
@@ -1354,15 +1432,16 @@ export declare interface Plugin extends Plugin_2 {
1354
1432
  }): Promise<LoadResult> | LoadResult;
1355
1433
  transform?(this: TransformPluginContext, code: string, id: string, options?: {
1356
1434
  ssr?: boolean;
1357
- }): Promise<TransformResult_3> | TransformResult_3;
1435
+ }): Promise<TransformResult_2> | TransformResult_2;
1358
1436
  }
1437
+ export { Plugin_2 as Plugin }
1359
1438
 
1360
1439
  export declare interface PluginContainer {
1361
1440
  options: InputOptions;
1362
1441
  getModuleInfo(id: string): ModuleInfo | null;
1363
1442
  buildStart(options: InputOptions): Promise<void>;
1364
1443
  resolveId(id: string, importer?: string, options?: {
1365
- skip?: Set<Plugin>;
1444
+ skip?: Set<Plugin_2>;
1366
1445
  ssr?: boolean;
1367
1446
  /* Excluded from this release type: scan */
1368
1447
  }): Promise<PartialResolvedId | null>;
@@ -1376,13 +1455,12 @@ export declare interface PluginContainer {
1376
1455
  close(): Promise<void>;
1377
1456
  }
1378
1457
 
1379
- export declare type PluginOption = Plugin | false | null | undefined | PluginOption[];
1458
+ export declare type PluginOption = Plugin_2 | false | null | undefined | PluginOption[];
1380
1459
 
1381
1460
  /**
1382
1461
  * Starts the Vite server in preview mode, to simulate a production deployment
1383
- * @experimental
1384
1462
  */
1385
- export declare function preview(inlineConfig: InlineConfig): Promise<PreviewServer>;
1463
+ export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>;
1386
1464
 
1387
1465
  export declare interface PreviewOptions extends CommonServerOptions {
1388
1466
  }
@@ -1402,10 +1480,10 @@ export declare interface PreviewServer {
1402
1480
  printUrls: () => void;
1403
1481
  }
1404
1482
 
1405
- /**
1406
- * @deprecated Use `server.printUrls()` instead
1407
- */
1408
- export declare function printHttpServerUrls(server: Server_3, config: ResolvedConfig): void;
1483
+ export declare type PreviewServerHook = (server: {
1484
+ middlewares: Connect.Server;
1485
+ httpServer: http.Server;
1486
+ }) => (() => void) | void | Promise<(() => void) | void>;
1409
1487
 
1410
1488
  export declare interface ProxyOptions extends HttpProxy.ServerOptions {
1411
1489
  /**
@@ -1429,9 +1507,9 @@ export declare interface PrunePayload {
1429
1507
 
1430
1508
  export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
1431
1509
 
1432
- export declare type ResolvedBuildOptions = Required<Omit<BuildOptions, 'base' | 'cleanCssOptions' | 'polyfillDynamicImport' | 'brotliSize'>>;
1510
+ export declare type ResolvedBuildOptions = Required<BuildOptions>;
1433
1511
 
1434
- export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alias' | 'dedupe' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
1512
+ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
1435
1513
  configFile: string | undefined;
1436
1514
  configFileDependencies: string[];
1437
1515
  inlineConfig: InlineConfig;
@@ -1442,19 +1520,20 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
1442
1520
  command: 'build' | 'serve';
1443
1521
  mode: string;
1444
1522
  isWorker: boolean;
1523
+ /* Excluded from this release type: mainConfig */
1445
1524
  isProduction: boolean;
1446
1525
  env: Record<string, any>;
1447
1526
  resolve: ResolveOptions & {
1448
1527
  alias: Alias[];
1449
1528
  };
1450
- plugins: readonly Plugin[];
1529
+ plugins: readonly Plugin_2[];
1451
1530
  server: ResolvedServerOptions;
1452
1531
  build: ResolvedBuildOptions;
1453
1532
  preview: ResolvedPreviewOptions;
1454
1533
  assetsInclude: (file: string) => boolean;
1455
1534
  logger: Logger;
1456
1535
  createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
1457
- optimizeDeps: Omit<DepOptimizationOptions, 'keepNames'>;
1536
+ optimizeDeps: DepOptimizationOptions;
1458
1537
  /* Excluded from this release type: packageCache */
1459
1538
  worker: ResolveWorkerOptions;
1460
1539
  }>;
@@ -1497,7 +1576,7 @@ export declare interface ResolverObject {
1497
1576
 
1498
1577
  export declare interface ResolveWorkerOptions {
1499
1578
  format: 'es' | 'iife';
1500
- plugins: Plugin[];
1579
+ plugins: Plugin_2[];
1501
1580
  rollupOptions: RollupOptions;
1502
1581
  }
1503
1582
 
@@ -1753,14 +1832,12 @@ export declare interface ServerOptions extends CommonServerOptions {
1753
1832
  origin?: string;
1754
1833
  /**
1755
1834
  * Pre-transform known direct imports
1756
- *
1757
- * @experimental this option is experimental and might be changed in the future
1758
1835
  * @default true
1759
1836
  */
1760
1837
  preTransformRequests?: boolean;
1761
1838
  }
1762
1839
 
1763
- export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
1840
+ export declare function sortUserPlugins(plugins: (Plugin_2 | Plugin_2[])[] | undefined): [Plugin_2[], Plugin_2[], Plugin_2[]];
1764
1841
 
1765
1842
  export declare function splitVendorChunk(options?: {
1766
1843
  cache?: SplitVendorChunkCache;
@@ -1772,7 +1849,7 @@ export declare class SplitVendorChunkCache {
1772
1849
  reset(): void;
1773
1850
  }
1774
1851
 
1775
- export declare function splitVendorChunkPlugin(): Plugin;
1852
+ export declare function splitVendorChunkPlugin(): Plugin_2;
1776
1853
 
1777
1854
  export declare interface SSROptions {
1778
1855
  external?: string[];
@@ -1938,8 +2015,6 @@ export declare namespace Terser {
1938
2015
  module?: boolean
1939
2016
  nameCache?: object
1940
2017
  format?: FormatOptions
1941
- /** @deprecated use format instead */
1942
- output?: FormatOptions
1943
2018
  parse?: ParseOptions
1944
2019
  safari10?: boolean
1945
2020
  sourceMap?: boolean | SourceMapOptions
@@ -2072,7 +2147,18 @@ export declare interface UserConfig {
2072
2147
  * Dep optimization options
2073
2148
  */
2074
2149
  optimizeDeps?: DepOptimizationOptions;
2075
- /* Excluded from this release type: ssr */
2150
+ /**
2151
+ * SSR specific options
2152
+ */
2153
+ ssr?: SSROptions;
2154
+ /**
2155
+ * Experimental features
2156
+ *
2157
+ * Features under this field are addressed to be changed that might NOT follow semver.
2158
+ * Please be careful and always pin Vite's version when using them.
2159
+ * @experimental
2160
+ */
2161
+ experimental?: ExperimentalOptions;
2076
2162
  /**
2077
2163
  * Log level.
2078
2164
  * Default: 'info'
@@ -2097,17 +2183,6 @@ export declare interface UserConfig {
2097
2183
  * @default 'VITE_'
2098
2184
  */
2099
2185
  envPrefix?: string | string[];
2100
- /**
2101
- * Import aliases
2102
- * @deprecated use `resolve.alias` instead
2103
- */
2104
- alias?: AliasOptions;
2105
- /**
2106
- * Force Vite to always resolve listed dependencies to the same copy (from
2107
- * project root).
2108
- * @deprecated use `resolve.dedupe` instead
2109
- */
2110
- dedupe?: string[];
2111
2186
  /**
2112
2187
  * Worker bundle options
2113
2188
  */
@@ -2146,10 +2221,6 @@ export declare interface ViteDevServer {
2146
2221
  * https://github.com/senchalabs/connect#use-middleware
2147
2222
  */
2148
2223
  middlewares: Connect.Server;
2149
- /**
2150
- * @deprecated use `server.middlewares` instead
2151
- */
2152
- app: Connect.Server;
2153
2224
  /**
2154
2225
  * native Node http server instance
2155
2226
  * will be null in middleware mode
@@ -2182,16 +2253,8 @@ export declare interface ViteDevServer {
2182
2253
  * Apply vite built-in HTML transforms and any plugin HTML transforms.
2183
2254
  */
2184
2255
  transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
2185
- /**
2186
- * Util for transforming a file with esbuild.
2187
- * Can be useful for certain plugins.
2188
- *
2189
- * @deprecated import `transformWithEsbuild` from `vite` instead
2190
- */
2191
- transformWithEsbuild(code: string, filename: string, options?: EsbuildTransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
2192
2256
  /**
2193
2257
  * Transform module code into SSR format.
2194
- * @experimental
2195
2258
  */
2196
2259
  ssrTransform(code: string, inMap: SourceMap | null, url: string): Promise<TransformResult | null>;
2197
2260
  /**
@@ -2227,8 +2290,8 @@ export declare interface ViteDevServer {
2227
2290
  */
2228
2291
  restart(forceOptimize?: boolean): Promise<void>;
2229
2292
  /* Excluded from this release type: _optimizedDeps */
2293
+ /* Excluded from this release type: _importGlobMap */
2230
2294
  /* Excluded from this release type: _ssrExternals */
2231
- /* Excluded from this release type: _globImporters */
2232
2295
  /* Excluded from this release type: _restartPromise */
2233
2296
  /* Excluded from this release type: _forceOptimizeOnRestart */
2234
2297
  /* Excluded from this release type: _pendingRequests */
@@ -2270,8 +2333,10 @@ export declare interface WatchOptions {
2270
2333
  cwd?: string
2271
2334
 
2272
2335
  /**
2273
- * If set to true then the strings passed to .watch() and .add() are treated as literal path
2274
- * names, even if they look like globs. Default: false.
2336
+ * If set to true then the strings passed to .watch() and .add() are treated as literal path
2337
+ * names, even if they look like globs.
2338
+ *
2339
+ * @default false
2275
2340
  */
2276
2341
  disableGlobbing?: boolean
2277
2342
 
@@ -2336,7 +2401,7 @@ export declare interface WatchOptions {
2336
2401
  awaitWriteFinish?: AwaitWriteFinishOptions | boolean
2337
2402
  }
2338
2403
 
2339
- export declare class WebSocket extends EventEmitter {
2404
+ declare class WebSocket_2 extends EventEmitter {
2340
2405
  /** The connection is not yet open. */
2341
2406
  static readonly CONNECTING: 0
2342
2407
  /** The connection is open and ready to communicate. */
@@ -2354,10 +2419,10 @@ export declare class WebSocket extends EventEmitter {
2354
2419
  readonly protocol: string
2355
2420
  /** The current state of the connection */
2356
2421
  readonly readyState:
2357
- | typeof WebSocket.CONNECTING
2358
- | typeof WebSocket.OPEN
2359
- | typeof WebSocket.CLOSING
2360
- | typeof WebSocket.CLOSED
2422
+ | typeof WebSocket_2.CONNECTING
2423
+ | typeof WebSocket_2.OPEN
2424
+ | typeof WebSocket_2.CLOSING
2425
+ | typeof WebSocket_2.CLOSED
2361
2426
  readonly url: string
2362
2427
 
2363
2428
  /** The connection is not yet open. */
@@ -2369,20 +2434,20 @@ export declare class WebSocket extends EventEmitter {
2369
2434
  /** The connection is closed. */
2370
2435
  readonly CLOSED: 3
2371
2436
 
2372
- onopen: ((event: WebSocket.Event) => void) | null
2373
- onerror: ((event: WebSocket.ErrorEvent) => void) | null
2374
- onclose: ((event: WebSocket.CloseEvent) => void) | null
2375
- onmessage: ((event: WebSocket.MessageEvent) => void) | null
2437
+ onopen: ((event: WebSocket_2.Event) => void) | null
2438
+ onerror: ((event: WebSocket_2.ErrorEvent) => void) | null
2439
+ onclose: ((event: WebSocket_2.CloseEvent) => void) | null
2440
+ onmessage: ((event: WebSocket_2.MessageEvent) => void) | null
2376
2441
 
2377
2442
  constructor(address: null)
2378
2443
  constructor(
2379
2444
  address: string | URL_2,
2380
- options?: WebSocket.ClientOptions | ClientRequestArgs
2445
+ options?: WebSocket_2.ClientOptions | ClientRequestArgs
2381
2446
  )
2382
2447
  constructor(
2383
2448
  address: string | URL_2,
2384
2449
  protocols?: string | string[],
2385
- options?: WebSocket.ClientOptions | ClientRequestArgs
2450
+ options?: WebSocket_2.ClientOptions | ClientRequestArgs
2386
2451
  )
2387
2452
 
2388
2453
  close(code?: number, data?: string | Buffer): void
@@ -2416,146 +2481,146 @@ export declare class WebSocket extends EventEmitter {
2416
2481
  // HTML5 WebSocket events
2417
2482
  addEventListener(
2418
2483
  method: 'message',
2419
- cb: (event: WebSocket.MessageEvent) => void,
2420
- options?: WebSocket.EventListenerOptions
2484
+ cb: (event: WebSocket_2.MessageEvent) => void,
2485
+ options?: WebSocket_2.EventListenerOptions
2421
2486
  ): void
2422
2487
  addEventListener(
2423
2488
  method: 'close',
2424
- cb: (event: WebSocket.CloseEvent) => void,
2425
- options?: WebSocket.EventListenerOptions
2489
+ cb: (event: WebSocket_2.CloseEvent) => void,
2490
+ options?: WebSocket_2.EventListenerOptions
2426
2491
  ): void
2427
2492
  addEventListener(
2428
2493
  method: 'error',
2429
- cb: (event: WebSocket.ErrorEvent) => void,
2430
- options?: WebSocket.EventListenerOptions
2494
+ cb: (event: WebSocket_2.ErrorEvent) => void,
2495
+ options?: WebSocket_2.EventListenerOptions
2431
2496
  ): void
2432
2497
  addEventListener(
2433
2498
  method: 'open',
2434
- cb: (event: WebSocket.Event) => void,
2435
- options?: WebSocket.EventListenerOptions
2499
+ cb: (event: WebSocket_2.Event) => void,
2500
+ options?: WebSocket_2.EventListenerOptions
2436
2501
  ): void
2437
2502
 
2438
2503
  removeEventListener(
2439
2504
  method: 'message',
2440
- cb: (event: WebSocket.MessageEvent) => void
2505
+ cb: (event: WebSocket_2.MessageEvent) => void
2441
2506
  ): void
2442
2507
  removeEventListener(
2443
2508
  method: 'close',
2444
- cb: (event: WebSocket.CloseEvent) => void
2509
+ cb: (event: WebSocket_2.CloseEvent) => void
2445
2510
  ): void
2446
2511
  removeEventListener(
2447
2512
  method: 'error',
2448
- cb: (event: WebSocket.ErrorEvent) => void
2513
+ cb: (event: WebSocket_2.ErrorEvent) => void
2449
2514
  ): void
2450
2515
  removeEventListener(
2451
2516
  method: 'open',
2452
- cb: (event: WebSocket.Event) => void
2517
+ cb: (event: WebSocket_2.Event) => void
2453
2518
  ): void
2454
2519
 
2455
2520
  // Events
2456
2521
  on(
2457
2522
  event: 'close',
2458
- listener: (this: WebSocket, code: number, reason: Buffer) => void
2523
+ listener: (this: WebSocket_2, code: number, reason: Buffer) => void
2459
2524
  ): this
2460
- on(event: 'error', listener: (this: WebSocket, err: Error) => void): this
2525
+ on(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
2461
2526
  on(
2462
2527
  event: 'upgrade',
2463
- listener: (this: WebSocket, request: IncomingMessage) => void
2528
+ listener: (this: WebSocket_2, request: IncomingMessage) => void
2464
2529
  ): this
2465
2530
  on(
2466
2531
  event: 'message',
2467
2532
  listener: (
2468
- this: WebSocket,
2469
- data: WebSocket.RawData,
2533
+ this: WebSocket_2,
2534
+ data: WebSocket_2.RawData,
2470
2535
  isBinary: boolean
2471
2536
  ) => void
2472
2537
  ): this
2473
- on(event: 'open', listener: (this: WebSocket) => void): this
2538
+ on(event: 'open', listener: (this: WebSocket_2) => void): this
2474
2539
  on(
2475
2540
  event: 'ping' | 'pong',
2476
- listener: (this: WebSocket, data: Buffer) => void
2541
+ listener: (this: WebSocket_2, data: Buffer) => void
2477
2542
  ): this
2478
2543
  on(
2479
2544
  event: 'unexpected-response',
2480
2545
  listener: (
2481
- this: WebSocket,
2546
+ this: WebSocket_2,
2482
2547
  request: ClientRequest,
2483
2548
  response: IncomingMessage
2484
2549
  ) => void
2485
2550
  ): this
2486
2551
  on(
2487
2552
  event: string | symbol,
2488
- listener: (this: WebSocket, ...args: any[]) => void
2553
+ listener: (this: WebSocket_2, ...args: any[]) => void
2489
2554
  ): this
2490
2555
 
2491
2556
  once(
2492
2557
  event: 'close',
2493
- listener: (this: WebSocket, code: number, reason: Buffer) => void
2558
+ listener: (this: WebSocket_2, code: number, reason: Buffer) => void
2494
2559
  ): this
2495
- once(event: 'error', listener: (this: WebSocket, err: Error) => void): this
2560
+ once(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
2496
2561
  once(
2497
2562
  event: 'upgrade',
2498
- listener: (this: WebSocket, request: IncomingMessage) => void
2563
+ listener: (this: WebSocket_2, request: IncomingMessage) => void
2499
2564
  ): this
2500
2565
  once(
2501
2566
  event: 'message',
2502
2567
  listener: (
2503
- this: WebSocket,
2504
- data: WebSocket.RawData,
2568
+ this: WebSocket_2,
2569
+ data: WebSocket_2.RawData,
2505
2570
  isBinary: boolean
2506
2571
  ) => void
2507
2572
  ): this
2508
- once(event: 'open', listener: (this: WebSocket) => void): this
2573
+ once(event: 'open', listener: (this: WebSocket_2) => void): this
2509
2574
  once(
2510
2575
  event: 'ping' | 'pong',
2511
- listener: (this: WebSocket, data: Buffer) => void
2576
+ listener: (this: WebSocket_2, data: Buffer) => void
2512
2577
  ): this
2513
2578
  once(
2514
2579
  event: 'unexpected-response',
2515
2580
  listener: (
2516
- this: WebSocket,
2581
+ this: WebSocket_2,
2517
2582
  request: ClientRequest,
2518
2583
  response: IncomingMessage
2519
2584
  ) => void
2520
2585
  ): this
2521
2586
  once(
2522
2587
  event: string | symbol,
2523
- listener: (this: WebSocket, ...args: any[]) => void
2588
+ listener: (this: WebSocket_2, ...args: any[]) => void
2524
2589
  ): this
2525
2590
 
2526
2591
  off(
2527
2592
  event: 'close',
2528
- listener: (this: WebSocket, code: number, reason: Buffer) => void
2593
+ listener: (this: WebSocket_2, code: number, reason: Buffer) => void
2529
2594
  ): this
2530
- off(event: 'error', listener: (this: WebSocket, err: Error) => void): this
2595
+ off(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
2531
2596
  off(
2532
2597
  event: 'upgrade',
2533
- listener: (this: WebSocket, request: IncomingMessage) => void
2598
+ listener: (this: WebSocket_2, request: IncomingMessage) => void
2534
2599
  ): this
2535
2600
  off(
2536
2601
  event: 'message',
2537
2602
  listener: (
2538
- this: WebSocket,
2539
- data: WebSocket.RawData,
2603
+ this: WebSocket_2,
2604
+ data: WebSocket_2.RawData,
2540
2605
  isBinary: boolean
2541
2606
  ) => void
2542
2607
  ): this
2543
- off(event: 'open', listener: (this: WebSocket) => void): this
2608
+ off(event: 'open', listener: (this: WebSocket_2) => void): this
2544
2609
  off(
2545
2610
  event: 'ping' | 'pong',
2546
- listener: (this: WebSocket, data: Buffer) => void
2611
+ listener: (this: WebSocket_2, data: Buffer) => void
2547
2612
  ): this
2548
2613
  off(
2549
2614
  event: 'unexpected-response',
2550
2615
  listener: (
2551
- this: WebSocket,
2616
+ this: WebSocket_2,
2552
2617
  request: ClientRequest,
2553
2618
  response: IncomingMessage
2554
2619
  ) => void
2555
2620
  ): this
2556
2621
  off(
2557
2622
  event: string | symbol,
2558
- listener: (this: WebSocket, ...args: any[]) => void
2623
+ listener: (this: WebSocket_2, ...args: any[]) => void
2559
2624
  ): this
2560
2625
 
2561
2626
  addListener(
@@ -2569,7 +2634,7 @@ export declare class WebSocket extends EventEmitter {
2569
2634
  ): this
2570
2635
  addListener(
2571
2636
  event: 'message',
2572
- listener: (data: WebSocket.RawData, isBinary: boolean) => void
2637
+ listener: (data: WebSocket_2.RawData, isBinary: boolean) => void
2573
2638
  ): this
2574
2639
  addListener(event: 'open', listener: () => void): this
2575
2640
  addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
@@ -2590,7 +2655,7 @@ export declare class WebSocket extends EventEmitter {
2590
2655
  ): this
2591
2656
  removeListener(
2592
2657
  event: 'message',
2593
- listener: (data: WebSocket.RawData, isBinary: boolean) => void
2658
+ listener: (data: WebSocket_2.RawData, isBinary: boolean) => void
2594
2659
  ): this
2595
2660
  removeListener(event: 'open', listener: () => void): this
2596
2661
  removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
@@ -2604,28 +2669,28 @@ export declare class WebSocket extends EventEmitter {
2604
2669
  ): this
2605
2670
  }
2606
2671
 
2607
- export declare namespace WebSocket {
2672
+ declare namespace WebSocket_2 {
2608
2673
  /**
2609
2674
  * Data represents the raw message payload received over the WebSocket.
2610
2675
  */
2611
- export type RawData = Buffer | ArrayBuffer | Buffer[]
2676
+ type RawData = Buffer | ArrayBuffer | Buffer[]
2612
2677
 
2613
2678
  /**
2614
2679
  * Data represents the message payload received over the WebSocket.
2615
2680
  */
2616
- export type Data = string | Buffer | ArrayBuffer | Buffer[]
2681
+ type Data = string | Buffer | ArrayBuffer | Buffer[]
2617
2682
 
2618
2683
  /**
2619
2684
  * CertMeta represents the accepted types for certificate & key data.
2620
2685
  */
2621
- export type CertMeta = string | string[] | Buffer | Buffer[]
2686
+ type CertMeta = string | string[] | Buffer | Buffer[]
2622
2687
 
2623
2688
  /**
2624
2689
  * VerifyClientCallbackSync is a synchronous callback used to inspect the
2625
2690
  * incoming message. The return value (boolean) of the function determines
2626
2691
  * whether or not to accept the handshake.
2627
2692
  */
2628
- export type VerifyClientCallbackSync = (info: {
2693
+ type VerifyClientCallbackSync = (info: {
2629
2694
  origin: string
2630
2695
  secure: boolean
2631
2696
  req: IncomingMessage
@@ -2636,7 +2701,7 @@ export declare namespace WebSocket {
2636
2701
  * incoming message. The return value (boolean) of the function determines
2637
2702
  * whether or not to accept the handshake.
2638
2703
  */
2639
- export type VerifyClientCallbackAsync = (
2704
+ type VerifyClientCallbackAsync = (
2640
2705
  info: { origin: string; secure: boolean; req: IncomingMessage },
2641
2706
  callback: (
2642
2707
  res: boolean,
@@ -2646,7 +2711,7 @@ export declare namespace WebSocket {
2646
2711
  ) => void
2647
2712
  ) => void
2648
2713
 
2649
- export interface ClientOptions extends SecureContextOptions {
2714
+ interface ClientOptions extends SecureContextOptions {
2650
2715
  protocol?: string | undefined
2651
2716
  followRedirects?: boolean | undefined
2652
2717
  generateMask?(mask: Buffer): void
@@ -2666,7 +2731,7 @@ export declare namespace WebSocket {
2666
2731
  skipUTF8Validation?: boolean | undefined
2667
2732
  }
2668
2733
 
2669
- export interface PerMessageDeflateOptions {
2734
+ interface PerMessageDeflateOptions {
2670
2735
  serverNoContextTakeover?: boolean | undefined
2671
2736
  clientNoContextTakeover?: boolean | undefined
2672
2737
  serverMaxWindowBits?: number | undefined
@@ -2689,19 +2754,19 @@ export declare namespace WebSocket {
2689
2754
  concurrencyLimit?: number | undefined
2690
2755
  }
2691
2756
 
2692
- export interface Event {
2757
+ interface Event {
2693
2758
  type: string
2694
2759
  target: WebSocket
2695
2760
  }
2696
2761
 
2697
- export interface ErrorEvent {
2762
+ interface ErrorEvent {
2698
2763
  error: any
2699
2764
  message: string
2700
2765
  type: string
2701
2766
  target: WebSocket
2702
2767
  }
2703
2768
 
2704
- export interface CloseEvent {
2769
+ interface CloseEvent {
2705
2770
  wasClean: boolean
2706
2771
  code: number
2707
2772
  reason: string
@@ -2709,17 +2774,17 @@ export declare namespace WebSocket {
2709
2774
  target: WebSocket
2710
2775
  }
2711
2776
 
2712
- export interface MessageEvent {
2777
+ interface MessageEvent {
2713
2778
  data: Data
2714
2779
  type: string
2715
2780
  target: WebSocket
2716
2781
  }
2717
2782
 
2718
- export interface EventListenerOptions {
2783
+ interface EventListenerOptions {
2719
2784
  once?: boolean | undefined
2720
2785
  }
2721
2786
 
2722
- export interface ServerOptions {
2787
+ interface ServerOptions {
2723
2788
  host?: string | undefined
2724
2789
  port?: number | undefined
2725
2790
  backlog?: number | undefined
@@ -2741,14 +2806,14 @@ export declare namespace WebSocket {
2741
2806
  WebSocket?: typeof WebSocket.WebSocket | undefined
2742
2807
  }
2743
2808
 
2744
- export interface AddressInfo {
2809
+ interface AddressInfo {
2745
2810
  address: string
2746
2811
  family: string
2747
2812
  port: number
2748
2813
  }
2749
2814
 
2750
2815
  // WebSocket Server
2751
- export class Server<T extends WebSocket = WebSocket> extends EventEmitter {
2816
+ class Server<T extends WebSocket = WebSocket> extends EventEmitter {
2752
2817
  options: ServerOptions
2753
2818
  path: string
2754
2819
  clients: Set<T>
@@ -2840,20 +2905,21 @@ export declare namespace WebSocket {
2840
2905
  }
2841
2906
 
2842
2907
  const WebSocketServer: typeof Server
2843
- export interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
2908
+ interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
2844
2909
  const WebSocket: typeof WebSocketAlias
2845
- export interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
2910
+ interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
2846
2911
 
2847
2912
  // WebSocket stream
2848
- export function createWebSocketStream(
2913
+ function createWebSocketStream(
2849
2914
  websocket: WebSocket,
2850
2915
  options?: DuplexOptions
2851
2916
  ): Duplex
2852
2917
  }
2918
+ export { WebSocket_2 as WebSocket }
2853
2919
 
2854
- export declare const WebSocketAlias: typeof WebSocket;
2920
+ export declare const WebSocketAlias: typeof WebSocket_2;
2855
2921
 
2856
- export declare interface WebSocketAlias extends WebSocket {}
2922
+ export declare interface WebSocketAlias extends WebSocket_2 {}
2857
2923
 
2858
2924
  export declare interface WebSocketClient {
2859
2925
  /**
@@ -2868,7 +2934,7 @@ export declare interface WebSocketClient {
2868
2934
  * The raw WebSocket instance
2869
2935
  * @advanced
2870
2936
  */
2871
- socket: WebSocket;
2937
+ socket: WebSocket_2;
2872
2938
  }
2873
2939
 
2874
2940
  export declare type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
@@ -2893,13 +2959,13 @@ export declare interface WebSocketServer {
2893
2959
  /**
2894
2960
  * Handle custom event emitted by `import.meta.hot.send`
2895
2961
  */
2896
- on: WebSocket.Server['on'] & {
2962
+ on: WebSocket_2.Server['on'] & {
2897
2963
  <T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
2898
2964
  };
2899
2965
  /**
2900
2966
  * Unregister event listener.
2901
2967
  */
2902
- off: WebSocket.Server['off'] & {
2968
+ off: WebSocket_2.Server['off'] & {
2903
2969
  (event: string, listener: Function): void;
2904
2970
  };
2905
2971
  }