vite 2.9.0-beta.1 → 2.9.0-beta.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.
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 +17 -6
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-28bf75e1.js → dep-046b0a83.js} +1 -1
- package/dist/node/chunks/{dep-47674adb.js → dep-6899b575.js} +3 -3
- package/dist/node/chunks/{dep-62435a6f.js → dep-7a52803b.js} +17757 -13582
- package/dist/node/chunks/{dep-1cf708c4.js → dep-a96b376f.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 +146 -49
- package/dist/node/index.js +3 -2
- package/dist/node/terser.js +90 -15
- package/package.json +23 -22
- package/src/client/client.ts +27 -30
- 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
|
|
|
@@ -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 {
|
|
@@ -1171,8 +1197,9 @@ export declare class ModuleNode {
|
|
|
1171
1197
|
export declare function normalizePath(id: string): string;
|
|
1172
1198
|
|
|
1173
1199
|
export declare interface OptimizedDepInfo {
|
|
1200
|
+
id: string;
|
|
1174
1201
|
file: string;
|
|
1175
|
-
src
|
|
1202
|
+
src?: string;
|
|
1176
1203
|
needsInterop?: boolean;
|
|
1177
1204
|
browserHash?: string;
|
|
1178
1205
|
fileHash?: string;
|
|
@@ -1180,14 +1207,19 @@ export declare interface OptimizedDepInfo {
|
|
|
1180
1207
|
* During optimization, ids can still be resolved to their final location
|
|
1181
1208
|
* but the bundles may not yet be saved to disk
|
|
1182
1209
|
*/
|
|
1183
|
-
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;
|
|
1184
1217
|
}
|
|
1185
1218
|
|
|
1186
1219
|
/**
|
|
1187
1220
|
* Used by Vite CLI when running `vite optimize`
|
|
1188
1221
|
*/
|
|
1189
|
-
export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean
|
|
1190
|
-
ssr?: boolean): Promise<DepOptimizationMetadata>;
|
|
1222
|
+
export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
|
|
1191
1223
|
|
|
1192
1224
|
/** Cache for package.json resolution and package.json contents */
|
|
1193
1225
|
export declare type PackageCache = Map<string, PackageData>;
|
|
@@ -1310,6 +1342,7 @@ export declare interface Plugin extends Plugin_2 {
|
|
|
1310
1342
|
resolveId?(this: PluginContext, source: string, importer: string | undefined, options: {
|
|
1311
1343
|
custom?: CustomPluginOptions;
|
|
1312
1344
|
ssr?: boolean;
|
|
1345
|
+
/* Excluded from this release type: scan */
|
|
1313
1346
|
}): Promise<ResolveIdResult> | ResolveIdResult;
|
|
1314
1347
|
load?(this: PluginContext, id: string, options?: {
|
|
1315
1348
|
ssr?: boolean;
|
|
@@ -1326,6 +1359,7 @@ export declare interface PluginContainer {
|
|
|
1326
1359
|
resolveId(id: string, importer?: string, options?: {
|
|
1327
1360
|
skip?: Set<Plugin>;
|
|
1328
1361
|
ssr?: boolean;
|
|
1362
|
+
/* Excluded from this release type: scan */
|
|
1329
1363
|
}): Promise<PartialResolvedId | null>;
|
|
1330
1364
|
transform(code: string, id: string, options?: {
|
|
1331
1365
|
inMap?: SourceDescription['map'];
|
|
@@ -1368,7 +1402,7 @@ export declare interface PreviewServer {
|
|
|
1368
1402
|
/**
|
|
1369
1403
|
* @deprecated Use `server.printUrls()` instead
|
|
1370
1404
|
*/
|
|
1371
|
-
export declare function printHttpServerUrls(server:
|
|
1405
|
+
export declare function printHttpServerUrls(server: Server_2, config: ResolvedConfig): void;
|
|
1372
1406
|
|
|
1373
1407
|
export declare interface ProxyOptions extends HttpProxy.ServerOptions {
|
|
1374
1408
|
/**
|
|
@@ -1404,6 +1438,7 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
|
|
|
1404
1438
|
cacheDir: string;
|
|
1405
1439
|
command: 'build' | 'serve';
|
|
1406
1440
|
mode: string;
|
|
1441
|
+
isWorker: boolean;
|
|
1407
1442
|
isProduction: boolean;
|
|
1408
1443
|
env: Record<string, any>;
|
|
1409
1444
|
resolve: ResolveOptions & {
|
|
@@ -2186,12 +2221,11 @@ export declare interface ViteDevServer {
|
|
|
2186
2221
|
* @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
|
|
2187
2222
|
*/
|
|
2188
2223
|
restart(forceOptimize?: boolean): Promise<void>;
|
|
2189
|
-
/* Excluded from this release type:
|
|
2224
|
+
/* Excluded from this release type: _optimizedDeps */
|
|
2190
2225
|
/* Excluded from this release type: _ssrExternals */
|
|
2191
2226
|
/* Excluded from this release type: _globImporters */
|
|
2192
2227
|
/* Excluded from this release type: _restartPromise */
|
|
2193
2228
|
/* Excluded from this release type: _forceOptimizeOnRestart */
|
|
2194
|
-
/* Excluded from this release type: _registerMissingImport */
|
|
2195
2229
|
/* Excluded from this release type: _pendingRequests */
|
|
2196
2230
|
}
|
|
2197
2231
|
|
|
@@ -2310,6 +2344,8 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2310
2344
|
binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
|
|
2311
2345
|
readonly bufferedAmount: number
|
|
2312
2346
|
readonly extensions: string
|
|
2347
|
+
/** Indicates whether the websocket is paused */
|
|
2348
|
+
readonly isPaused: boolean
|
|
2313
2349
|
readonly protocol: string
|
|
2314
2350
|
/** The current state of the connection */
|
|
2315
2351
|
readonly readyState:
|
|
@@ -2328,11 +2364,12 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2328
2364
|
/** The connection is closed. */
|
|
2329
2365
|
readonly CLOSED: 3
|
|
2330
2366
|
|
|
2331
|
-
onopen: (event: WebSocket.Event) => void
|
|
2332
|
-
onerror: (event: WebSocket.ErrorEvent) => void
|
|
2333
|
-
onclose: (event: WebSocket.CloseEvent) => void
|
|
2334
|
-
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
|
|
2335
2371
|
|
|
2372
|
+
constructor(address: null)
|
|
2336
2373
|
constructor(
|
|
2337
2374
|
address: string | URL_2,
|
|
2338
2375
|
options?: WebSocket.ClientOptions | ClientRequestArgs
|
|
@@ -2359,6 +2396,18 @@ export declare class WebSocket extends EventEmitter {
|
|
|
2359
2396
|
): void
|
|
2360
2397
|
terminate(): void
|
|
2361
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
|
+
|
|
2362
2411
|
// HTML5 WebSocket events
|
|
2363
2412
|
addEventListener(
|
|
2364
2413
|
method: 'message',
|
|
@@ -2595,6 +2644,7 @@ export declare namespace WebSocket {
|
|
|
2595
2644
|
export interface ClientOptions extends SecureContextOptions {
|
|
2596
2645
|
protocol?: string | undefined
|
|
2597
2646
|
followRedirects?: boolean | undefined
|
|
2647
|
+
generateMask?(mask: Buffer): void
|
|
2598
2648
|
handshakeTimeout?: number | undefined
|
|
2599
2649
|
maxRedirects?: number | undefined
|
|
2600
2650
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
|
@@ -2608,6 +2658,7 @@ export declare namespace WebSocket {
|
|
|
2608
2658
|
checkServerIdentity?(servername: string, cert: CertMeta): boolean
|
|
2609
2659
|
rejectUnauthorized?: boolean | undefined
|
|
2610
2660
|
maxPayload?: number | undefined
|
|
2661
|
+
skipUTF8Validation?: boolean | undefined
|
|
2611
2662
|
}
|
|
2612
2663
|
|
|
2613
2664
|
export interface PerMessageDeflateOptions {
|
|
@@ -2667,7 +2718,7 @@ export declare namespace WebSocket {
|
|
|
2667
2718
|
host?: string | undefined
|
|
2668
2719
|
port?: number | undefined
|
|
2669
2720
|
backlog?: number | undefined
|
|
2670
|
-
server?: Server |
|
|
2721
|
+
server?: Server | Server_3 | undefined
|
|
2671
2722
|
verifyClient?:
|
|
2672
2723
|
| VerifyClientCallbackAsync
|
|
2673
2724
|
| VerifyClientCallbackSync
|
|
@@ -2682,6 +2733,7 @@ export declare namespace WebSocket {
|
|
|
2682
2733
|
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
|
|
2683
2734
|
maxPayload?: number | undefined
|
|
2684
2735
|
skipUTF8Validation?: boolean | undefined
|
|
2736
|
+
WebSocket?: typeof WebSocket.WebSocket | undefined
|
|
2685
2737
|
}
|
|
2686
2738
|
|
|
2687
2739
|
export interface AddressInfo {
|
|
@@ -2691,10 +2743,10 @@ export declare namespace WebSocket {
|
|
|
2691
2743
|
}
|
|
2692
2744
|
|
|
2693
2745
|
// WebSocket Server
|
|
2694
|
-
export class Server extends EventEmitter {
|
|
2746
|
+
export class Server<T extends WebSocket = WebSocket> extends EventEmitter {
|
|
2695
2747
|
options: ServerOptions
|
|
2696
2748
|
path: string
|
|
2697
|
-
clients: Set<
|
|
2749
|
+
clients: Set<T>
|
|
2698
2750
|
|
|
2699
2751
|
constructor(options?: ServerOptions, callback?: () => void)
|
|
2700
2752
|
|
|
@@ -2704,56 +2756,59 @@ export declare namespace WebSocket {
|
|
|
2704
2756
|
request: IncomingMessage,
|
|
2705
2757
|
socket: Duplex,
|
|
2706
2758
|
upgradeHead: Buffer,
|
|
2707
|
-
callback: (client:
|
|
2759
|
+
callback: (client: T, request: IncomingMessage) => void
|
|
2708
2760
|
): void
|
|
2709
2761
|
shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
|
|
2710
2762
|
|
|
2711
2763
|
// Events
|
|
2712
2764
|
on(
|
|
2713
2765
|
event: 'connection',
|
|
2714
|
-
cb: (this: Server
|
|
2766
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2715
2767
|
): this
|
|
2716
|
-
on(event: 'error', cb: (this: Server
|
|
2768
|
+
on(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2717
2769
|
on(
|
|
2718
2770
|
event: 'headers',
|
|
2719
|
-
cb: (this: Server
|
|
2771
|
+
cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void
|
|
2720
2772
|
): this
|
|
2721
|
-
on(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2773
|
+
on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
|
2722
2774
|
on(
|
|
2723
2775
|
event: string | symbol,
|
|
2724
|
-
listener: (this: Server
|
|
2776
|
+
listener: (this: Server<T>, ...args: any[]) => void
|
|
2725
2777
|
): this
|
|
2726
2778
|
|
|
2727
2779
|
once(
|
|
2728
2780
|
event: 'connection',
|
|
2729
|
-
cb: (this: Server
|
|
2781
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2730
2782
|
): this
|
|
2731
|
-
once(event: 'error', cb: (this: Server
|
|
2783
|
+
once(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2732
2784
|
once(
|
|
2733
2785
|
event: 'headers',
|
|
2734
|
-
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
|
|
2735
2792
|
): this
|
|
2736
|
-
once(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2737
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this
|
|
2738
2793
|
|
|
2739
2794
|
off(
|
|
2740
2795
|
event: 'connection',
|
|
2741
|
-
cb: (this: Server
|
|
2796
|
+
cb: (this: Server<T>, socket: T, request: IncomingMessage) => void
|
|
2742
2797
|
): this
|
|
2743
|
-
off(event: 'error', cb: (this: Server
|
|
2798
|
+
off(event: 'error', cb: (this: Server<T>, error: Error) => void): this
|
|
2744
2799
|
off(
|
|
2745
2800
|
event: 'headers',
|
|
2746
|
-
cb: (this: Server
|
|
2801
|
+
cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void
|
|
2747
2802
|
): this
|
|
2748
|
-
off(event: 'close' | 'listening', cb: (this: Server) => void): this
|
|
2803
|
+
off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
|
|
2749
2804
|
off(
|
|
2750
2805
|
event: string | symbol,
|
|
2751
|
-
listener: (this: Server
|
|
2806
|
+
listener: (this: Server<T>, ...args: any[]) => void
|
|
2752
2807
|
): this
|
|
2753
2808
|
|
|
2754
2809
|
addListener(
|
|
2755
2810
|
event: 'connection',
|
|
2756
|
-
cb: (client:
|
|
2811
|
+
cb: (client: T, request: IncomingMessage) => void
|
|
2757
2812
|
): this
|
|
2758
2813
|
addListener(event: 'error', cb: (err: Error) => void): this
|
|
2759
2814
|
addListener(
|
|
@@ -2766,7 +2821,7 @@ export declare namespace WebSocket {
|
|
|
2766
2821
|
listener: (...args: any[]) => void
|
|
2767
2822
|
): this
|
|
2768
2823
|
|
|
2769
|
-
removeListener(event: 'connection', cb: (client:
|
|
2824
|
+
removeListener(event: 'connection', cb: (client: T) => void): this
|
|
2770
2825
|
removeListener(event: 'error', cb: (err: Error) => void): this
|
|
2771
2826
|
removeListener(
|
|
2772
2827
|
event: 'headers',
|
|
@@ -2780,9 +2835,9 @@ export declare namespace WebSocket {
|
|
|
2780
2835
|
}
|
|
2781
2836
|
|
|
2782
2837
|
const WebSocketServer: typeof Server
|
|
2783
|
-
export
|
|
2838
|
+
export interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
|
|
2784
2839
|
const WebSocket: typeof WebSocketAlias
|
|
2785
|
-
export
|
|
2840
|
+
export interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
|
|
2786
2841
|
|
|
2787
2842
|
// WebSocket stream
|
|
2788
2843
|
export function createWebSocketStream(
|
|
@@ -2793,13 +2848,55 @@ export declare namespace WebSocket {
|
|
|
2793
2848
|
|
|
2794
2849
|
export declare const WebSocketAlias: typeof WebSocket;
|
|
2795
2850
|
|
|
2796
|
-
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;
|
|
2797
2870
|
|
|
2798
2871
|
export declare interface WebSocketServer {
|
|
2799
|
-
|
|
2800
|
-
|
|
2872
|
+
/**
|
|
2873
|
+
* Get all connected clients.
|
|
2874
|
+
*/
|
|
2875
|
+
clients: Set<WebSocketClient>;
|
|
2876
|
+
/**
|
|
2877
|
+
* Boardcast events to all clients
|
|
2878
|
+
*/
|
|
2801
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
|
+
*/
|
|
2802
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
|
+
};
|
|
2803
2900
|
}
|
|
2804
2901
|
|
|
2805
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-7a52803b.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;
|
package/dist/node/terser.js
CHANGED
|
@@ -10201,7 +10201,7 @@ function is_some_comments(comment) {
|
|
|
10201
10201
|
// multiline comment
|
|
10202
10202
|
return (
|
|
10203
10203
|
(comment.type === "comment2" || comment.type === "comment1")
|
|
10204
|
-
&& /@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
|
|
10204
|
+
&& /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
|
|
10205
10205
|
);
|
|
10206
10206
|
}
|
|
10207
10207
|
|
|
@@ -10314,8 +10314,8 @@ function OutputStream(options) {
|
|
|
10314
10314
|
var OUTPUT = new Rope();
|
|
10315
10315
|
let printed_comments = new Set();
|
|
10316
10316
|
|
|
10317
|
-
var to_utf8 = options.ascii_only ? function(str, identifier) {
|
|
10318
|
-
if (options.ecma >= 2015 && !options.safari10) {
|
|
10317
|
+
var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
|
|
10318
|
+
if (options.ecma >= 2015 && !options.safari10 && !regexp) {
|
|
10319
10319
|
str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
|
|
10320
10320
|
var code = get_full_char_code(ch, 0).toString(16);
|
|
10321
10321
|
return "\\u{" + code + "}";
|
|
@@ -11127,7 +11127,8 @@ function OutputStream(options) {
|
|
|
11127
11127
|
var p = output.parent();
|
|
11128
11128
|
if (this.args.length === 0
|
|
11129
11129
|
&& (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
|
|
11130
|
-
|| p instanceof AST_Call && p.expression === this
|
|
11130
|
+
|| p instanceof AST_Call && p.expression === this
|
|
11131
|
+
|| p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
|
|
11131
11132
|
return true;
|
|
11132
11133
|
});
|
|
11133
11134
|
|
|
@@ -12242,7 +12243,7 @@ function OutputStream(options) {
|
|
|
12242
12243
|
flags = flags ? sort_regexp_flags(flags) : "";
|
|
12243
12244
|
source = source.replace(r_slash_script, slash_script_replace);
|
|
12244
12245
|
|
|
12245
|
-
output.print(output.to_utf8(`/${source}/${flags}
|
|
12246
|
+
output.print(output.to_utf8(`/${source}/${flags}`, false, true));
|
|
12246
12247
|
|
|
12247
12248
|
const parent = output.parent();
|
|
12248
12249
|
if (
|
|
@@ -12666,6 +12667,11 @@ const MASK_EXPORT_WANT_MANGLE = 1 << 1;
|
|
|
12666
12667
|
|
|
12667
12668
|
let function_defs = null;
|
|
12668
12669
|
let unmangleable_names = null;
|
|
12670
|
+
/**
|
|
12671
|
+
* When defined, there is a function declaration somewhere that's inside of a block.
|
|
12672
|
+
* See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
|
|
12673
|
+
*/
|
|
12674
|
+
let scopes_with_block_defuns = null;
|
|
12669
12675
|
|
|
12670
12676
|
class SymbolDef {
|
|
12671
12677
|
constructor(scope, orig, init) {
|
|
@@ -13216,6 +13222,15 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
|
|
|
13216
13222
|
});
|
|
13217
13223
|
|
|
13218
13224
|
function next_mangled(scope, options) {
|
|
13225
|
+
let defun_scope;
|
|
13226
|
+
if (
|
|
13227
|
+
scopes_with_block_defuns
|
|
13228
|
+
&& (defun_scope = scope.get_defun_scope())
|
|
13229
|
+
&& scopes_with_block_defuns.has(defun_scope)
|
|
13230
|
+
) {
|
|
13231
|
+
scope = defun_scope;
|
|
13232
|
+
}
|
|
13233
|
+
|
|
13219
13234
|
var ext = scope.enclosed;
|
|
13220
13235
|
var nth_identifier = options.nth_identifier;
|
|
13221
13236
|
out: while (true) {
|
|
@@ -13350,6 +13365,13 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
|
13350
13365
|
lname = save_nesting;
|
|
13351
13366
|
return true; // don't descend again in TreeWalker
|
|
13352
13367
|
}
|
|
13368
|
+
if (
|
|
13369
|
+
node instanceof AST_Defun
|
|
13370
|
+
&& !(tw.parent() instanceof AST_Scope)
|
|
13371
|
+
) {
|
|
13372
|
+
scopes_with_block_defuns = scopes_with_block_defuns || new Set();
|
|
13373
|
+
scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
|
|
13374
|
+
}
|
|
13353
13375
|
if (node instanceof AST_Scope) {
|
|
13354
13376
|
node.variables.forEach(collect);
|
|
13355
13377
|
return;
|
|
@@ -13398,6 +13420,7 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|
|
13398
13420
|
|
|
13399
13421
|
function_defs = null;
|
|
13400
13422
|
unmangleable_names = null;
|
|
13423
|
+
scopes_with_block_defuns = null;
|
|
13401
13424
|
|
|
13402
13425
|
function collect(symbol) {
|
|
13403
13426
|
if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
|
|
@@ -30781,7 +30804,54 @@ function cache_to_json(cache) {
|
|
|
30781
30804
|
};
|
|
30782
30805
|
}
|
|
30783
30806
|
|
|
30784
|
-
|
|
30807
|
+
function log_input(files, options, fs, debug_folder) {
|
|
30808
|
+
if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
|
|
30809
|
+
return;
|
|
30810
|
+
}
|
|
30811
|
+
|
|
30812
|
+
try {
|
|
30813
|
+
fs.mkdirSync(debug_folder);
|
|
30814
|
+
} catch (e) {
|
|
30815
|
+
if (e.code !== "EEXIST") throw e;
|
|
30816
|
+
}
|
|
30817
|
+
|
|
30818
|
+
const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
|
|
30819
|
+
|
|
30820
|
+
options = options || {};
|
|
30821
|
+
|
|
30822
|
+
const options_str = JSON.stringify(options, (_key, thing) => {
|
|
30823
|
+
if (typeof thing === "function") return "[Function " + thing.toString() + "]";
|
|
30824
|
+
if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
|
|
30825
|
+
return thing;
|
|
30826
|
+
}, 4);
|
|
30827
|
+
|
|
30828
|
+
const files_str = (file) => {
|
|
30829
|
+
if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
|
|
30830
|
+
return JSON.stringify(file, null, 2);
|
|
30831
|
+
} else if (typeof file === "object") {
|
|
30832
|
+
return Object.keys(file)
|
|
30833
|
+
.map((key) => key + ": " + files_str(file[key]))
|
|
30834
|
+
.join("\n\n");
|
|
30835
|
+
} else if (typeof file === "string") {
|
|
30836
|
+
return "```\n" + file + "\n```";
|
|
30837
|
+
} else {
|
|
30838
|
+
return file; // What do?
|
|
30839
|
+
}
|
|
30840
|
+
};
|
|
30841
|
+
|
|
30842
|
+
fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
|
|
30843
|
+
}
|
|
30844
|
+
|
|
30845
|
+
async function minify(files, options, _fs_module) {
|
|
30846
|
+
if (
|
|
30847
|
+
_fs_module
|
|
30848
|
+
&& typeof process === "object"
|
|
30849
|
+
&& process.env
|
|
30850
|
+
&& typeof process.env.TERSER_DEBUG_DIR === "string"
|
|
30851
|
+
) {
|
|
30852
|
+
log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
|
|
30853
|
+
}
|
|
30854
|
+
|
|
30785
30855
|
options = defaults(options, {
|
|
30786
30856
|
compress: {},
|
|
30787
30857
|
ecma: undefined,
|
|
@@ -30804,6 +30874,7 @@ async function minify(files, options) {
|
|
|
30804
30874
|
warnings: false,
|
|
30805
30875
|
wrap: false,
|
|
30806
30876
|
}, true);
|
|
30877
|
+
|
|
30807
30878
|
var timings = options.timings && {
|
|
30808
30879
|
start: Date.now()
|
|
30809
30880
|
};
|
|
@@ -31205,7 +31276,7 @@ async function run_cli({ program, packageJson, fs, path }) {
|
|
|
31205
31276
|
|
|
31206
31277
|
let result;
|
|
31207
31278
|
try {
|
|
31208
|
-
result = await minify(files, options);
|
|
31279
|
+
result = await minify(files, options, fs);
|
|
31209
31280
|
} catch (ex) {
|
|
31210
31281
|
if (ex.name == "SyntaxError") {
|
|
31211
31282
|
print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
|
|
@@ -31268,14 +31339,18 @@ async function run_cli({ program, packageJson, fs, path }) {
|
|
|
31268
31339
|
}, 2));
|
|
31269
31340
|
} else if (program.output == "spidermonkey") {
|
|
31270
31341
|
try {
|
|
31271
|
-
const minified = await minify(
|
|
31272
|
-
|
|
31273
|
-
|
|
31274
|
-
|
|
31275
|
-
|
|
31276
|
-
|
|
31277
|
-
|
|
31278
|
-
|
|
31342
|
+
const minified = await minify(
|
|
31343
|
+
result.code,
|
|
31344
|
+
{
|
|
31345
|
+
compress: false,
|
|
31346
|
+
mangle: false,
|
|
31347
|
+
format: {
|
|
31348
|
+
ast: true,
|
|
31349
|
+
code: false
|
|
31350
|
+
}
|
|
31351
|
+
},
|
|
31352
|
+
fs
|
|
31353
|
+
);
|
|
31279
31354
|
console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
|
|
31280
31355
|
} catch (ex) {
|
|
31281
31356
|
fatal(ex);
|