vite 2.9.0-beta.0 → 2.9.0-beta.11
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.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/LICENSE.md +1 -1
- package/dist/client/client.mjs +18 -9
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-026034b4.js → dep-3a0ad60c.js} +1 -1
- package/dist/node/chunks/{dep-229a03bb.js → dep-76a88ec8.js} +3 -3
- package/dist/node/chunks/{dep-429629d5.js → dep-7765b27c.js} +34116 -29724
- package/dist/node/chunks/{dep-5f1b3f27.js → dep-7ef2e58a.js} +116 -8
- package/dist/node/chunks/{dep-ec2e68f4.js → dep-bcc0af00.js} +103 -25
- package/dist/node/cli.js +6 -6
- package/dist/node/index.d.ts +154 -52
- package/dist/node/index.js +3 -2
- package/dist/node/terser.js +90 -15
- package/package.json +23 -22
- package/src/client/client.ts +34 -36
- package/types/customEvent.d.ts +16 -5
- package/types/hot.d.ts +25 -0
- package/types/importMeta.d.ts +1 -40
- package/types/ws.d.ts +54 -29
package/dist/node/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { DuplexOptions } from 'stream';
|
|
|
10
10
|
import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
12
12
|
import * as events from 'events';
|
|
13
|
+
import type { ExistingRawSourceMap } from 'rollup';
|
|
13
14
|
import type * as fs from 'fs';
|
|
14
15
|
import type { GetManualChunk } from 'rollup';
|
|
15
16
|
import * as http from 'http';
|
|
@@ -34,8 +35,8 @@ import type { RollupOutput } from 'rollup';
|
|
|
34
35
|
import type { RollupWatcher } from 'rollup';
|
|
35
36
|
import type { SecureContextOptions } from 'tls';
|
|
36
37
|
import type { Server } from 'http';
|
|
37
|
-
import type { Server as Server_2 } from '
|
|
38
|
-
import type { Server as Server_3 } from '
|
|
38
|
+
import type { Server as Server_2 } from 'net';
|
|
39
|
+
import type { Server as Server_3 } from 'https';
|
|
39
40
|
import type { ServerOptions as ServerOptions_2 } from 'https';
|
|
40
41
|
import type { ServerResponse } from 'http';
|
|
41
42
|
import type { SourceDescription } from 'rollup';
|
|
@@ -47,6 +48,8 @@ import type { TransformResult as TransformResult_3 } from 'rollup';
|
|
|
47
48
|
import type * as url from 'url';
|
|
48
49
|
import type { URL as URL_2 } from 'url';
|
|
49
50
|
import type { WatcherOptions } from 'rollup';
|
|
51
|
+
import type { WebSocket as WebSocket_2 } from 'ws';
|
|
52
|
+
import { WebSocketServer as WebSocketServer_2 } from 'ws';
|
|
50
53
|
import type { ZlibOptions } from 'zlib';
|
|
51
54
|
|
|
52
55
|
export declare interface Alias {
|
|
@@ -484,6 +487,19 @@ export declare interface CSSOptions {
|
|
|
484
487
|
postcss?: string | (Postcss.ProcessOptions & {
|
|
485
488
|
plugins?: Postcss.Plugin[];
|
|
486
489
|
});
|
|
490
|
+
/**
|
|
491
|
+
* Enables css sourcemaps during dev
|
|
492
|
+
* @default false
|
|
493
|
+
* @experimental
|
|
494
|
+
*/
|
|
495
|
+
devSourcemap?: boolean;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export declare interface CustomEventMap {
|
|
499
|
+
'vite:beforeUpdate': UpdatePayload
|
|
500
|
+
'vite:beforePrune': PrunePayload
|
|
501
|
+
'vite:beforeFullReload': FullReloadPayload
|
|
502
|
+
'vite:error': ErrorPayload
|
|
487
503
|
}
|
|
488
504
|
|
|
489
505
|
export declare interface CustomPayload {
|
|
@@ -516,15 +532,18 @@ export declare interface DepOptimizationMetadata {
|
|
|
516
532
|
* Metadata for each already optimized dependency
|
|
517
533
|
*/
|
|
518
534
|
optimized: Record<string, OptimizedDepInfo>;
|
|
535
|
+
/**
|
|
536
|
+
* Metadata for non-entry optimized chunks and dynamic imports
|
|
537
|
+
*/
|
|
538
|
+
chunks: Record<string, OptimizedDepInfo>;
|
|
519
539
|
/**
|
|
520
540
|
* Metadata for each newly discovered dependency after processing
|
|
521
541
|
*/
|
|
522
542
|
discovered: Record<string, OptimizedDepInfo>;
|
|
523
543
|
/**
|
|
524
|
-
*
|
|
525
|
-
* but the bundles may not yet be saved to disk
|
|
544
|
+
* OptimizedDepInfo list
|
|
526
545
|
*/
|
|
527
|
-
|
|
546
|
+
depInfoList: OptimizedDepInfo[];
|
|
528
547
|
}
|
|
529
548
|
|
|
530
549
|
export declare interface DepOptimizationOptions {
|
|
@@ -579,18 +598,19 @@ export declare interface DepOptimizationOptions {
|
|
|
579
598
|
}
|
|
580
599
|
|
|
581
600
|
export declare interface DepOptimizationProcessing {
|
|
582
|
-
promise: Promise<
|
|
583
|
-
resolve: (
|
|
601
|
+
promise: Promise<void>;
|
|
602
|
+
resolve: () => void;
|
|
584
603
|
}
|
|
585
604
|
|
|
586
605
|
export declare interface DepOptimizationResult {
|
|
606
|
+
metadata: DepOptimizationMetadata;
|
|
587
607
|
/**
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
* for large applications
|
|
608
|
+
* When doing a re-run, if there are newly discovered dependendencies
|
|
609
|
+
* the page reload will be delayed until the next rerun so we need
|
|
610
|
+
* to be able to discard the result
|
|
592
611
|
*/
|
|
593
|
-
|
|
612
|
+
commit: () => void;
|
|
613
|
+
cancel: () => void;
|
|
594
614
|
}
|
|
595
615
|
|
|
596
616
|
export declare interface ErrorPayload {
|
|
@@ -652,6 +672,8 @@ export declare interface FileSystemServeOptions {
|
|
|
652
672
|
deny?: string[];
|
|
653
673
|
}
|
|
654
674
|
|
|
675
|
+
export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): ExistingRawSourceMap;
|
|
676
|
+
|
|
655
677
|
export declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
|
|
656
678
|
options: WatchOptions
|
|
657
679
|
|
|
@@ -740,7 +762,7 @@ export declare interface HmrContext {
|
|
|
740
762
|
export declare interface HmrOptions {
|
|
741
763
|
protocol?: string;
|
|
742
764
|
host?: string;
|
|
743
|
-
port?: number
|
|
765
|
+
port?: number;
|
|
744
766
|
clientPort?: number;
|
|
745
767
|
path?: string;
|
|
746
768
|
timeout?: number;
|
|
@@ -1015,6 +1037,9 @@ export declare type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
|
|
|
1015
1037
|
tags: HtmlTagDescriptor[];
|
|
1016
1038
|
};
|
|
1017
1039
|
|
|
1040
|
+
export declare type InferCustomEventPayload<T extends string> =
|
|
1041
|
+
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
1042
|
+
|
|
1018
1043
|
export declare interface InlineConfig extends UserConfig {
|
|
1019
1044
|
configFile?: string | false;
|
|
1020
1045
|
envFile?: false;
|
|
@@ -1040,6 +1065,7 @@ export declare interface InternalResolveOptions extends ResolveOptions {
|
|
|
1040
1065
|
isRequire?: boolean;
|
|
1041
1066
|
isFromTsImporter?: boolean;
|
|
1042
1067
|
tryEsmOnly?: boolean;
|
|
1068
|
+
scan?: boolean;
|
|
1043
1069
|
}
|
|
1044
1070
|
|
|
1045
1071
|
export declare interface JsonOptions {
|
|
@@ -1130,7 +1156,7 @@ export declare class ModuleGraph {
|
|
|
1130
1156
|
getModuleById(id: string): ModuleNode | undefined;
|
|
1131
1157
|
getModulesByFile(file: string): Set<ModuleNode> | undefined;
|
|
1132
1158
|
onFileChange(file: string): void;
|
|
1133
|
-
invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode
|
|
1159
|
+
invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number): void;
|
|
1134
1160
|
invalidateAll(): void;
|
|
1135
1161
|
/**
|
|
1136
1162
|
* Update the module graph based on a module's updated imports information
|
|
@@ -1164,14 +1190,16 @@ export declare class ModuleNode {
|
|
|
1164
1190
|
ssrTransformResult: TransformResult | null;
|
|
1165
1191
|
ssrModule: Record<string, any> | null;
|
|
1166
1192
|
lastHMRTimestamp: number;
|
|
1193
|
+
lastInvalidationTimestamp: number;
|
|
1167
1194
|
constructor(url: string);
|
|
1168
1195
|
}
|
|
1169
1196
|
|
|
1170
1197
|
export declare function normalizePath(id: string): string;
|
|
1171
1198
|
|
|
1172
1199
|
export declare interface OptimizedDepInfo {
|
|
1200
|
+
id: string;
|
|
1173
1201
|
file: string;
|
|
1174
|
-
src
|
|
1202
|
+
src?: string;
|
|
1175
1203
|
needsInterop?: boolean;
|
|
1176
1204
|
browserHash?: string;
|
|
1177
1205
|
fileHash?: string;
|
|
@@ -1179,14 +1207,19 @@ export declare interface OptimizedDepInfo {
|
|
|
1179
1207
|
* During optimization, ids can still be resolved to their final location
|
|
1180
1208
|
* but the bundles may not yet be saved to disk
|
|
1181
1209
|
*/
|
|
1182
|
-
processing
|
|
1210
|
+
processing?: Promise<void>;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
export declare interface OptimizedDeps {
|
|
1214
|
+
metadata: DepOptimizationMetadata;
|
|
1215
|
+
scanProcessing?: Promise<void>;
|
|
1216
|
+
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
|
|
1183
1217
|
}
|
|
1184
1218
|
|
|
1185
1219
|
/**
|
|
1186
1220
|
* Used by Vite CLI when running `vite optimize`
|
|
1187
1221
|
*/
|
|
1188
|
-
export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean
|
|
1189
|
-
ssr?: boolean): Promise<DepOptimizationMetadata>;
|
|
1222
|
+
export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
|
|
1190
1223
|
|
|
1191
1224
|
/** Cache for package.json resolution and package.json contents */
|
|
1192
1225
|
export declare type PackageCache = Map<string, PackageData>;
|
|
@@ -1309,6 +1342,7 @@ export declare interface Plugin extends Plugin_2 {
|
|
|
1309
1342
|
resolveId?(this: PluginContext, source: string, importer: string | undefined, options: {
|
|
1310
1343
|
custom?: CustomPluginOptions;
|
|
1311
1344
|
ssr?: boolean;
|
|
1345
|
+
/* Excluded from this release type: scan */
|
|
1312
1346
|
}): Promise<ResolveIdResult> | ResolveIdResult;
|
|
1313
1347
|
load?(this: PluginContext, id: string, options?: {
|
|
1314
1348
|
ssr?: boolean;
|
|
@@ -1325,6 +1359,7 @@ export declare interface PluginContainer {
|
|
|
1325
1359
|
resolveId(id: string, importer?: string, options?: {
|
|
1326
1360
|
skip?: Set<Plugin>;
|
|
1327
1361
|
ssr?: boolean;
|
|
1362
|
+
/* Excluded from this release type: scan */
|
|
1328
1363
|
}): Promise<PartialResolvedId | null>;
|
|
1329
1364
|
transform(code: string, id: string, options?: {
|
|
1330
1365
|
inMap?: SourceDescription['map'];
|
|
@@ -1367,7 +1402,7 @@ export declare interface PreviewServer {
|
|
|
1367
1402
|
/**
|
|
1368
1403
|
* @deprecated Use `server.printUrls()` instead
|
|
1369
1404
|
*/
|
|
1370
|
-
export declare function printHttpServerUrls(server:
|
|
1405
|
+
export declare function printHttpServerUrls(server: Server_2, config: ResolvedConfig): void;
|
|
1371
1406
|
|
|
1372
1407
|
export declare interface ProxyOptions extends HttpProxy.ServerOptions {
|
|
1373
1408
|
/**
|
|
@@ -1403,6 +1438,7 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
|
|
|
1403
1438
|
cacheDir: string;
|
|
1404
1439
|
command: 'build' | 'serve';
|
|
1405
1440
|
mode: string;
|
|
1441
|
+
isWorker: boolean;
|
|
1406
1442
|
isProduction: boolean;
|
|
1407
1443
|
env: Record<string, any>;
|
|
1408
1444
|
resolve: ResolveOptions & {
|
|
@@ -2160,7 +2196,11 @@ export declare interface ViteDevServer {
|
|
|
2160
2196
|
fixStacktrace?: boolean;
|
|
2161
2197
|
}): Promise<Record<string, any>>;
|
|
2162
2198
|
/**
|
|
2163
|
-
*
|
|
2199
|
+
* Returns a fixed version of the given stack
|
|
2200
|
+
*/
|
|
2201
|
+
ssrRewriteStacktrace(stack: string): string;
|
|
2202
|
+
/**
|
|
2203
|
+
* Mutates the given SSR error by rewriting the stacktrace
|
|
2164
2204
|
*/
|
|
2165
2205
|
ssrFixStacktrace(e: Error): void;
|
|
2166
2206
|
/**
|
|
@@ -2181,12 +2221,11 @@ export declare interface ViteDevServer {
|
|
|
2181
2221
|
* @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
|
|
2182
2222
|
*/
|
|
2183
2223
|
restart(forceOptimize?: boolean): Promise<void>;
|
|
2184
|
-
/* Excluded from this release type:
|
|
2224
|
+
/* Excluded from this release type: _optimizedDeps */
|
|
2185
2225
|
/* Excluded from this release type: _ssrExternals */
|
|
2186
2226
|
/* Excluded from this release type: _globImporters */
|
|
2187
2227
|
/* Excluded from this release type: _restartPromise */
|
|
2188
2228
|
/* Excluded from this release type: _forceOptimizeOnRestart */
|
|
2189
|
-
/* Excluded from this release type: _registerMissingImport */
|
|
2190
2229
|
/* Excluded from this release type: _pendingRequests */
|
|
2191
2230
|
}
|
|
2192
2231
|
|
|
@@ -2305,6 +2344,8 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2305
2344
|
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
|
|
2306
2345
|
readonly bufferedAmount: number
|
|
2307
2346
|
readonly extensions: string
|
|
2347
|
+
/** Indicates whether the websocket is paused */
|
|
2348
|
+
readonly isPaused: boolean
|
|
2308
2349
|
readonly protocol: string
|
|
2309
2350
|
/** The current state of the connection */
|
|
2310
2351
|
readonly readyState:
|
|
@@ -2323,11 +2364,12 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2323
2364
|
/** The connection is closed. */
|
|
2324
2365
|
readonly CLOSED: 3
|
|
2325
2366
|
|
|
2326
|
-
onopen: (event: WebSocket.Event) => void
|
|
2327
|
-
onerror: (event: WebSocket.ErrorEvent) => void
|
|
2328
|
-
onclose: (event: WebSocket.CloseEvent) => void
|
|
2329
|
-
onmessage: (event: WebSocket.MessageEvent) => void
|
|
2367
|
+
onopen: ((event: WebSocket.Event) => void) | null
|
|
2368
|
+
onerror: ((event: WebSocket.ErrorEvent) => void) | null
|
|
2369
|
+
onclose: ((event: WebSocket.CloseEvent) => void) | null
|
|
2370
|
+
onmessage: ((event: WebSocket.MessageEvent) => void) | null
|
|
2330
2371
|
|
|
2372
|
+
constructor(address: null)
|
|
2331
2373
|
constructor(
|
|
2332
2374
|
address: string | URL_2,
|
|
2333
2375
|
options?: WebSocket.ClientOptions | ClientRequestArgs
|
|
@@ -2354,6 +2396,18 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2354
2396
|
): void
|
|
2355
2397
|
terminate(): void
|
|
2356
2398
|
|
|
2399
|
+
/**
|
|
2400
|
+
* Pause the websocket causing it to stop emitting events. Some events can still be
|
|
2401
|
+
* emitted after this is called, until all buffered data is consumed. This method
|
|
2402
|
+
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
|
|
2403
|
+
*/
|
|
2404
|
+
pause(): void
|
|
2405
|
+
/**
|
|
2406
|
+
* Make a paused socket resume emitting events. This method is a noop if the ready
|
|
2407
|
+
* state is `CONNECTING` or `CLOSED`.
|
|
2408
|
+
*/
|
|
2409
|
+
resume(): void
|
|
2410
|
+
|
|
2357
2411
|
// HTML5 WebSocket events
|
|
2358
2412
|
addEventListener(
|
|
2359
2413
|
method: 'message',
|
|
@@ -2590,6 +2644,7 @@ export declare namespace WebSocket {
|
|
|
2590
2644
|
export interface ClientOptions extends SecureContextOptions {
|
|
2591
2645
|
protocol?: string | undefined
|
|
2592
2646
|
followRedirects?: boolean | undefined
|
|
2647
|
+
generateMask?(mask: Buffer): void
|
|
2593
2648
|
handshakeTimeout?: number | undefined
|
|
2594
2649
|
maxRedirects?: number | undefined
|
|
2595
2650
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
|
@@ -2603,6 +2658,7 @@ export declare namespace WebSocket {
|
|
|
2603
2658
|
checkServerIdentity?(servername: string, cert: CertMeta): boolean
|
|
2604
2659
|
rejectUnauthorized?: boolean | undefined
|
|
2605
2660
|
maxPayload?: number | undefined
|
|
2661
|
+
skipUTF8Validation?: boolean | undefined
|
|
2606
2662
|
}
|
|
2607
2663
|
|
|
2608
2664
|
export interface PerMessageDeflateOptions {
|
|
@@ -2662,7 +2718,7 @@ export declare namespace WebSocket {
|
|
|
2662
2718
|
host?: string | undefined
|
|
2663
2719
|
port?: number | undefined
|
|
2664
2720
|
backlog?: number | undefined
|
|
2665
|
-
server?: Server |
|
|
2721
|
+
server?: Server | Server_3 | undefined
|
|
2666
2722
|
verifyClient?:
|
|
2667
2723
|
| VerifyClientCallbackAsync
|
|
2668
2724
|
| VerifyClientCallbackSync
|
|
@@ -2677,6 +2733,7 @@ export declare namespace WebSocket {
|
|
|
2677
2733
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
|
2678
2734
|
maxPayload?: number | undefined
|
|
2679
2735
|
skipUTF8Validation?: boolean | undefined
|
|
2736
|
+
WebSocket?: typeof WebSocket.WebSocket | undefined
|
|
2680
2737
|
}
|
|
2681
2738
|
|
|
2682
2739
|
export interface AddressInfo {
|
|
@@ -2686,10 +2743,10 @@ export declare namespace WebSocket {
|
|
|
2686
2743
|
}
|
|
2687
2744
|
|
|
2688
2745
|
// WebSocket Server
|
|
2689
|
-
export class Server extends EventEmitter {
|
|
2746
|
+
export class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
|
2690
2747
|
options: ServerOptions
|
|
2691
2748
|
path: string
|
|
2692
|
-
clients: Set<
|
|
2749
|
+
clients: Set<T>
|
|
2693
2750
|
|
|
2694
2751
|
constructor(options?: ServerOptions, callback?: () => void)
|
|
2695
2752
|
|
|
@@ -2699,56 +2756,59 @@ export declare namespace WebSocket {
|
|
|
2699
2756
|
request: IncomingMessage,
|
|
2700
2757
|
socket: Duplex,
|
|
2701
2758
|
upgradeHead: Buffer,
|
|
2702
|
-
callback: (client:
|
|
2759
|
+
callback: (client: T, request: IncomingMessage) => void
|
|
2703
2760
|
): void
|
|
2704
2761
|
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
|
|
2705
2762
|
|
|
2706
2763
|
// Events
|
|
2707
2764
|
on(
|
|
2708
2765
|
event: 'connection',
|
|
2709
|
-
cb: (this: Server
|
|
2766
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2710
2767
|
): this
|
|
2711
|
-
on(event: 'error', cb: (this: Server
|
|
2768
|
+
on(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2712
2769
|
on(
|
|
2713
2770
|
event: 'headers',
|
|
2714
|
-
cb: (this: Server
|
|
2771
|
+
cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void
|
|
2715
2772
|
): this
|
|
2716
|
-
on(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2773
|
+
on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
|
2717
2774
|
on(
|
|
2718
2775
|
event: string | symbol,
|
|
2719
|
-
listener: (this: Server
|
|
2776
|
+
listener: (this: Server<T>, ...args: any[]) => void
|
|
2720
2777
|
): this
|
|
2721
2778
|
|
|
2722
2779
|
once(
|
|
2723
2780
|
event: 'connection',
|
|
2724
|
-
cb: (this: Server
|
|
2781
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2725
2782
|
): this
|
|
2726
|
-
once(event: 'error', cb: (this: Server
|
|
2783
|
+
once(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2727
2784
|
once(
|
|
2728
2785
|
event: 'headers',
|
|
2729
|
-
cb: (this: Server
|
|
2786
|
+
cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void
|
|
2787
|
+
): this
|
|
2788
|
+
once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
|
2789
|
+
once(
|
|
2790
|
+
event: string | symbol,
|
|
2791
|
+
listener: (this: Server<T>, ...args: any[]) => void
|
|
2730
2792
|
): this
|
|
2731
|
-
once(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2732
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this
|
|
2733
2793
|
|
|
2734
2794
|
off(
|
|
2735
2795
|
event: 'connection',
|
|
2736
|
-
cb: (this: Server
|
|
2796
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2737
2797
|
): this
|
|
2738
|
-
off(event: 'error', cb: (this: Server
|
|
2798
|
+
off(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2739
2799
|
off(
|
|
2740
2800
|
event: 'headers',
|
|
2741
|
-
cb: (this: Server
|
|
2801
|
+
cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void
|
|
2742
2802
|
): this
|
|
2743
|
-
off(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2803
|
+
off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
|
2744
2804
|
off(
|
|
2745
2805
|
event: string | symbol,
|
|
2746
|
-
listener: (this: Server
|
|
2806
|
+
listener: (this: Server<T>, ...args: any[]) => void
|
|
2747
2807
|
): this
|
|
2748
2808
|
|
|
2749
2809
|
addListener(
|
|
2750
2810
|
event: 'connection',
|
|
2751
|
-
cb: (client:
|
|
2811
|
+
cb: (client: T, request: IncomingMessage) => void
|
|
2752
2812
|
): this
|
|
2753
2813
|
addListener(event: 'error', cb: (err: Error) => void): this
|
|
2754
2814
|
addListener(
|
|
@@ -2761,7 +2821,7 @@ export declare namespace WebSocket {
|
|
|
2761
2821
|
listener: (...args: any[]) => void
|
|
2762
2822
|
): this
|
|
2763
2823
|
|
|
2764
|
-
removeListener(event: 'connection', cb: (client:
|
|
2824
|
+
removeListener(event: 'connection', cb: (client: T) => void): this
|
|
2765
2825
|
removeListener(event: 'error', cb: (err: Error) => void): this
|
|
2766
2826
|
removeListener(
|
|
2767
2827
|
event: 'headers',
|
|
@@ -2775,9 +2835,9 @@ export declare namespace WebSocket {
|
|
|
2775
2835
|
}
|
|
2776
2836
|
|
|
2777
2837
|
const WebSocketServer: typeof Server
|
|
2778
|
-
export
|
|
2838
|
+
export interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
|
|
2779
2839
|
const WebSocket: typeof WebSocketAlias
|
|
2780
|
-
export
|
|
2840
|
+
export interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
|
|
2781
2841
|
|
|
2782
2842
|
// WebSocket stream
|
|
2783
2843
|
export function createWebSocketStream(
|
|
@@ -2788,13 +2848,55 @@ export declare namespace WebSocket {
|
|
|
2788
2848
|
|
|
2789
2849
|
export declare const WebSocketAlias: typeof WebSocket;
|
|
2790
2850
|
|
|
2791
|
-
export declare
|
|
2851
|
+
export declare interface WebSocketAlias extends WebSocket {}
|
|
2852
|
+
|
|
2853
|
+
export declare interface WebSocketClient {
|
|
2854
|
+
/**
|
|
2855
|
+
* Send event to the client
|
|
2856
|
+
*/
|
|
2857
|
+
send(payload: HMRPayload): void;
|
|
2858
|
+
/**
|
|
2859
|
+
* Send custom event
|
|
2860
|
+
*/
|
|
2861
|
+
send(event: string, payload?: CustomPayload['data']): void;
|
|
2862
|
+
/**
|
|
2863
|
+
* The raw WebSocket instance
|
|
2864
|
+
* @advanced
|
|
2865
|
+
*/
|
|
2866
|
+
socket: WebSocket_2;
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
export declare type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
|
|
2792
2870
|
|
|
2793
2871
|
export declare interface WebSocketServer {
|
|
2794
|
-
|
|
2795
|
-
|
|
2872
|
+
/**
|
|
2873
|
+
* Get all connected clients.
|
|
2874
|
+
*/
|
|
2875
|
+
clients: Set<WebSocketClient>;
|
|
2876
|
+
/**
|
|
2877
|
+
* Boardcast events to all clients
|
|
2878
|
+
*/
|
|
2796
2879
|
send(payload: HMRPayload): void;
|
|
2880
|
+
/**
|
|
2881
|
+
* Send custom event
|
|
2882
|
+
*/
|
|
2883
|
+
send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void;
|
|
2884
|
+
/**
|
|
2885
|
+
* Disconnect all clients and terminate the server.
|
|
2886
|
+
*/
|
|
2797
2887
|
close(): Promise<void>;
|
|
2888
|
+
/**
|
|
2889
|
+
* Handle custom event emitted by `import.meta.hot.send`
|
|
2890
|
+
*/
|
|
2891
|
+
on: WebSocketServer_2['on'] & {
|
|
2892
|
+
<T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
|
|
2893
|
+
};
|
|
2894
|
+
/**
|
|
2895
|
+
* Unregister event listener.
|
|
2896
|
+
*/
|
|
2897
|
+
off: WebSocketServer_2['off'] & {
|
|
2898
|
+
(event: string, listener: Function): void;
|
|
2899
|
+
};
|
|
2798
2900
|
}
|
|
2799
2901
|
|
|
2800
2902
|
export { }
|
package/dist/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./chunks/dep-
|
|
5
|
+
var index = require('./chunks/dep-7765b27c.js');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
8
8
|
require('tty');
|
|
@@ -21,9 +21,9 @@ require('zlib');
|
|
|
21
21
|
require('crypto');
|
|
22
22
|
require('tls');
|
|
23
23
|
require('assert');
|
|
24
|
+
require('esbuild');
|
|
24
25
|
require('buffer');
|
|
25
26
|
require('querystring');
|
|
26
|
-
require('esbuild');
|
|
27
27
|
require('child_process');
|
|
28
28
|
require('worker_threads');
|
|
29
29
|
require('readline');
|
|
@@ -137,6 +137,7 @@ exports.build = index.build;
|
|
|
137
137
|
exports.createLogger = index.createLogger;
|
|
138
138
|
exports.createServer = index.createServer;
|
|
139
139
|
exports.defineConfig = index.defineConfig;
|
|
140
|
+
exports.formatPostcssSourceMap = index.formatPostcssSourceMap;
|
|
140
141
|
exports.loadConfigFromFile = index.loadConfigFromFile;
|
|
141
142
|
exports.loadEnv = index.loadEnv;
|
|
142
143
|
exports.mergeConfig = index.mergeConfig;
|