@storyblok/astro 2.0.0 → 2.0.2

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.
@@ -0,0 +1,3281 @@
1
+ /// <reference types="node" />
2
+
3
+ import type { Agent } from 'node:http';
4
+ import type { BuildOptions as BuildOptions_2 } from 'esbuild';
5
+ import type { ClientRequest } from 'node:http';
6
+ import type { ClientRequestArgs } from 'node:http';
7
+ import { ConnectedPayload } from "../../types/hmrPayload";
8
+ import { CustomEventMap } from "../../types/customEvent";
9
+ import { CustomPayload } from "../../types/hmrPayload";
10
+ import type { CustomPluginOptions } from 'rollup';
11
+ import type { Duplex } from 'node:stream';
12
+ import type { DuplexOptions } from 'node:stream';
13
+ import { ErrorPayload } from "../../types/hmrPayload";
14
+ import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
15
+ import { version as esbuildVersion } from 'esbuild';
16
+ import { EventEmitter } from 'node:events';
17
+ import * as events from 'node:events';
18
+ import type { ExistingRawSourceMap } from 'rollup';
19
+ import type * as fs from 'node:fs';
20
+ import { FullReloadPayload } from "../../types/hmrPayload";
21
+ import { GeneralImportGlobOptions } from "../../types/importGlob";
22
+ import type { GetManualChunk } from 'rollup';
23
+ import { HMRPayload } from "../../types/hmrPayload";
24
+ import * as http from 'node:http';
25
+ import { ImportGlobEagerFunction } from "../../types/importGlob";
26
+ import { ImportGlobFunction } from "../../types/importGlob";
27
+ import { ImportGlobOptions } from "../../types/importGlob";
28
+ import type { IncomingMessage } from 'node:http';
29
+ import { InferCustomEventPayload } from "../../types/customEvent";
30
+ import type { InputOption } from 'rollup';
31
+ import type { InputOptions } from 'rollup';
32
+ import { InvalidatePayload } from "../../types/customEvent";
33
+ import { KnownAsTypeMap } from "../../types/importGlob";
34
+ import type { LoadResult } from 'rollup';
35
+
36
+ import type { ModuleFormat } from 'rollup';
37
+ import type { ModuleInfo } from 'rollup';
38
+ import type * as net from 'node:net';
39
+ import type { ObjectHook } from 'rollup';
40
+ import type { OutgoingHttpHeaders } from 'node:http';
41
+ import type { OutputBundle } from 'rollup';
42
+ import type { OutputChunk } from 'rollup';
43
+ import type { PartialResolvedId } from 'rollup';
44
+ import type { Plugin as Plugin_3 } from 'rollup';
45
+ import type { PluginContext } from 'rollup';
46
+ import type { PluginHooks } from 'rollup';
47
+ import type * as PostCSS from 'postcss';
48
+ import { PrunePayload } from "../../types/hmrPayload";
49
+ import type { ResolveIdResult } from 'rollup';
50
+ import type { RollupError } from 'rollup';
51
+ import type { RollupOptions } from 'rollup';
52
+ import type { RollupOutput } from 'rollup';
53
+ import { VERSION as rollupVersion } from 'rollup';
54
+ import type { RollupWatcher } from 'rollup';
55
+ import type { SecureContextOptions } from 'node:tls';
56
+ import type { Server } from 'node:http';
57
+ import type { Server as Server_2 } from 'node:https';
58
+ import type { ServerOptions as ServerOptions_2 } from 'node:https';
59
+ import type { ServerResponse } from 'node:http';
60
+ import type { SourceDescription } from 'rollup';
61
+ import type { SourceMap } from 'rollup';
62
+ import type { SourceMapInput } from 'rollup';
63
+ import type * as stream from 'node:stream';
64
+ import type { TransformPluginContext } from 'rollup';
65
+ import type { TransformResult as TransformResult_2 } from 'rollup';
66
+ import type { TransformResult as TransformResult_3 } from 'esbuild';
67
+ import { Update } from "../../types/hmrPayload";
68
+ import { UpdatePayload } from "../../types/hmrPayload";
69
+ import type * as url from 'node:url';
70
+ import type { URL as URL_2 } from 'node:url';
71
+ import type { WatcherOptions } from 'rollup';
72
+ import type { ZlibOptions } from 'node:zlib';
73
+
74
+ export declare interface Alias {
75
+ find: string | RegExp
76
+ replacement: string
77
+ /**
78
+ * Instructs the plugin to use an alternative resolving algorithm,
79
+ * rather than the Rollup's resolver.
80
+ * @default null
81
+ */
82
+ customResolver?: ResolverFunction | ResolverObject | null
83
+ }
84
+
85
+ /**
86
+ * Specifies an `Object`, or an `Array` of `Object`,
87
+ * which defines aliases used to replace values in `import` or `require` statements.
88
+ * With either format, the order of the entries is important,
89
+ * in that the first defined rules are applied first.
90
+ *
91
+ * This is passed to \@rollup/plugin-alias as the "entries" field
92
+ * https://github.com/rollup/plugins/tree/master/packages/alias#entries
93
+ */
94
+ export declare type AliasOptions = readonly Alias[] | { [find: string]: string }
95
+
96
+ export declare type AnymatchFn = (testString: string) => boolean
97
+
98
+ export declare type AnymatchPattern = string | RegExp | AnymatchFn
99
+
100
+ /**
101
+ * spa: include SPA fallback middleware and configure sirv with `single: true` in preview
102
+ *
103
+ * mpa: only include non-SPA HTML middlewares
104
+ *
105
+ * custom: don't include HTML middlewares
106
+ */
107
+ export declare type AppType = 'spa' | 'mpa' | 'custom';
108
+
109
+ export declare interface AwaitWriteFinishOptions {
110
+ /**
111
+ * Amount of time in milliseconds for a file size to remain constant before emitting its event.
112
+ */
113
+ stabilityThreshold?: number
114
+
115
+ /**
116
+ * File size polling interval.
117
+ */
118
+ pollInterval?: number
119
+ }
120
+
121
+ /**
122
+ * Bundles the app for production.
123
+ * Returns a Promise containing the build result.
124
+ */
125
+ export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
126
+
127
+ export declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
128
+
129
+ export declare interface BuildOptions {
130
+ /**
131
+ * Compatibility transform target. The transform is performed with esbuild
132
+ * and the lowest supported target is es2015/es6. Note this only handles
133
+ * syntax transformation and does not cover polyfills (except for dynamic
134
+ * import)
135
+ *
136
+ * Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
137
+ * transpile targeting browsers that natively support dynamic es module imports.
138
+ * https://caniuse.com/es6-module-dynamic-import
139
+ *
140
+ * Another special value is 'esnext' - which only performs minimal transpiling
141
+ * (for minification compat) and assumes native dynamic imports support.
142
+ *
143
+ * For custom targets, see https://esbuild.github.io/api/#target and
144
+ * https://esbuild.github.io/content-types/#javascript for more details.
145
+ */
146
+ target?: 'modules' | EsbuildTransformOptions['target'] | false;
147
+ /**
148
+ * whether to inject module preload polyfill.
149
+ * Note: does not apply to library mode.
150
+ * @default true
151
+ * @deprecated use `modulePreload.polyfill` instead
152
+ */
153
+ polyfillModulePreload?: boolean;
154
+ /**
155
+ * Configure module preload
156
+ * Note: does not apply to library mode.
157
+ * @default true
158
+ */
159
+ modulePreload?: boolean | ModulePreloadOptions;
160
+ /**
161
+ * Directory relative from `root` where build output will be placed. If the
162
+ * directory exists, it will be removed before the build.
163
+ * @default 'dist'
164
+ */
165
+ outDir?: string;
166
+ /**
167
+ * Directory relative from `outDir` where the built js/css/image assets will
168
+ * be placed.
169
+ * @default 'assets'
170
+ */
171
+ assetsDir?: string;
172
+ /**
173
+ * Static asset files smaller than this number (in bytes) will be inlined as
174
+ * base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
175
+ * @default 4096
176
+ */
177
+ assetsInlineLimit?: number;
178
+ /**
179
+ * Whether to code-split CSS. When enabled, CSS in async chunks will be
180
+ * inlined as strings in the chunk and inserted via dynamically created
181
+ * style tags when the chunk is loaded.
182
+ * @default true
183
+ */
184
+ cssCodeSplit?: boolean;
185
+ /**
186
+ * An optional separate target for CSS minification.
187
+ * As esbuild only supports configuring targets to mainstream
188
+ * browsers, users may need this option when they are targeting
189
+ * a niche browser that comes with most modern JavaScript features
190
+ * but has poor CSS support, e.g. Android WeChat WebView, which
191
+ * doesn't support the #RGBA syntax.
192
+ */
193
+ cssTarget?: EsbuildTransformOptions['target'] | false;
194
+ /**
195
+ * If `true`, a separate sourcemap file will be created. If 'inline', the
196
+ * sourcemap will be appended to the resulting output file as data URI.
197
+ * 'hidden' works like `true` except that the corresponding sourcemap
198
+ * comments in the bundled files are suppressed.
199
+ * @default false
200
+ */
201
+ sourcemap?: boolean | 'inline' | 'hidden';
202
+ /**
203
+ * Set to `false` to disable minification, or specify the minifier to use.
204
+ * Available options are 'terser' or 'esbuild'.
205
+ * @default 'esbuild'
206
+ */
207
+ minify?: boolean | 'terser' | 'esbuild';
208
+ /**
209
+ * Options for terser
210
+ * https://terser.org/docs/api-reference#minify-options
211
+ */
212
+ terserOptions?: Terser.MinifyOptions;
213
+ /**
214
+ * Will be merged with internal rollup options.
215
+ * https://rollupjs.org/guide/en/#big-list-of-options
216
+ */
217
+ rollupOptions?: RollupOptions;
218
+ /**
219
+ * Options to pass on to `@rollup/plugin-commonjs`
220
+ */
221
+ commonjsOptions?: RollupCommonJSOptions;
222
+ /**
223
+ * Options to pass on to `@rollup/plugin-dynamic-import-vars`
224
+ */
225
+ dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
226
+ /**
227
+ * Whether to write bundle to disk
228
+ * @default true
229
+ */
230
+ write?: boolean;
231
+ /**
232
+ * Empty outDir on write.
233
+ * @default true when outDir is a sub directory of project root
234
+ */
235
+ emptyOutDir?: boolean | null;
236
+ /**
237
+ * Copy the public directory to outDir on write.
238
+ * @default true
239
+ * @experimental
240
+ */
241
+ copyPublicDir?: boolean;
242
+ /**
243
+ * Whether to emit a manifest.json under assets dir to map hash-less filenames
244
+ * to their hashed versions. Useful when you want to generate your own HTML
245
+ * instead of using the one generated by Vite.
246
+ *
247
+ * Example:
248
+ *
249
+ * ```json
250
+ * {
251
+ * "main.js": {
252
+ * "file": "main.68fe3fad.js",
253
+ * "css": "main.e6b63442.css",
254
+ * "imports": [...],
255
+ * "dynamicImports": [...]
256
+ * }
257
+ * }
258
+ * ```
259
+ * @default false
260
+ */
261
+ manifest?: boolean | string;
262
+ /**
263
+ * Build in library mode. The value should be the global name of the lib in
264
+ * UMD mode. This will produce esm + cjs + umd bundle formats with default
265
+ * configurations that are suitable for distributing libraries.
266
+ */
267
+ lib?: LibraryOptions | false;
268
+ /**
269
+ * Produce SSR oriented build. Note this requires specifying SSR entry via
270
+ * `rollupOptions.input`.
271
+ */
272
+ ssr?: boolean | string;
273
+ /**
274
+ * Generate SSR manifest for determining style links and asset preload
275
+ * directives in production.
276
+ */
277
+ ssrManifest?: boolean | string;
278
+ /**
279
+ * Set to false to disable reporting compressed chunk sizes.
280
+ * Can slightly improve build speed.
281
+ */
282
+ reportCompressedSize?: boolean;
283
+ /**
284
+ * Adjust chunk size warning limit (in kbs).
285
+ * @default 500
286
+ */
287
+ chunkSizeWarningLimit?: number;
288
+ /**
289
+ * Rollup watch options
290
+ * https://rollupjs.org/guide/en/#watchoptions
291
+ */
292
+ watch?: WatcherOptions | null;
293
+ }
294
+
295
+ export declare interface ChunkMetadata {
296
+ importedAssets: Set<string>;
297
+ importedCss: Set<string>;
298
+ }
299
+
300
+ export declare interface CommonServerOptions {
301
+ /**
302
+ * Specify server port. Note if the port is already being used, Vite will
303
+ * automatically try the next available port so this may not be the actual
304
+ * port the server ends up listening on.
305
+ */
306
+ port?: number;
307
+ /**
308
+ * If enabled, vite will exit if specified port is already in use
309
+ */
310
+ strictPort?: boolean;
311
+ /**
312
+ * Specify which IP addresses the server should listen on.
313
+ * Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
314
+ */
315
+ host?: string | boolean;
316
+ /**
317
+ * Enable TLS + HTTP/2.
318
+ * Note: this downgrades to TLS only when the proxy option is also used.
319
+ */
320
+ https?: boolean | ServerOptions_2;
321
+ /**
322
+ * Open browser window on startup
323
+ */
324
+ open?: boolean | string;
325
+ /**
326
+ * Configure custom proxy rules for the dev server. Expects an object
327
+ * of `{ key: options }` pairs.
328
+ * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
329
+ * Full options [here](https://github.com/http-party/node-http-proxy#options).
330
+ *
331
+ * Example `vite.config.js`:
332
+ * ``` js
333
+ * module.exports = {
334
+ * proxy: {
335
+ * // string shorthand
336
+ * '/foo': 'http://localhost:4567/foo',
337
+ * // with options
338
+ * '/api': {
339
+ * target: 'http://jsonplaceholder.typicode.com',
340
+ * changeOrigin: true,
341
+ * rewrite: path => path.replace(/^\/api/, '')
342
+ * }
343
+ * }
344
+ * }
345
+ * ```
346
+ */
347
+ proxy?: Record<string, string | ProxyOptions>;
348
+ /**
349
+ * Configure CORS for the dev server.
350
+ * Uses https://github.com/expressjs/cors.
351
+ * Set to `true` to allow all methods from any origin, or configure separately
352
+ * using an object.
353
+ */
354
+ cors?: CorsOptions | boolean;
355
+ /**
356
+ * Specify server response headers.
357
+ */
358
+ headers?: OutgoingHttpHeaders;
359
+ }
360
+
361
+ export declare interface ConfigEnv {
362
+ command: 'build' | 'serve';
363
+ mode: string;
364
+ /**
365
+ * @experimental
366
+ */
367
+ ssrBuild?: boolean;
368
+ }
369
+
370
+ export declare namespace Connect {
371
+ export type ServerHandle = HandleFunction | http.Server
372
+
373
+ export class IncomingMessage extends http.IncomingMessage {
374
+ originalUrl?: http.IncomingMessage['url'] | undefined
375
+ }
376
+
377
+ export type NextFunction = (err?: any) => void
378
+
379
+ export type SimpleHandleFunction = (
380
+ req: IncomingMessage,
381
+ res: http.ServerResponse,
382
+ ) => void
383
+ export type NextHandleFunction = (
384
+ req: IncomingMessage,
385
+ res: http.ServerResponse,
386
+ next: NextFunction,
387
+ ) => void
388
+ export type ErrorHandleFunction = (
389
+ err: any,
390
+ req: IncomingMessage,
391
+ res: http.ServerResponse,
392
+ next: NextFunction,
393
+ ) => void
394
+ export type HandleFunction =
395
+ | SimpleHandleFunction
396
+ | NextHandleFunction
397
+ | ErrorHandleFunction
398
+
399
+ export interface ServerStackItem {
400
+ route: string
401
+ handle: ServerHandle
402
+ }
403
+
404
+ export interface Server extends NodeJS.EventEmitter {
405
+ (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void
406
+
407
+ route: string
408
+ stack: ServerStackItem[]
409
+
410
+ /**
411
+ * Utilize the given middleware `handle` to the given `route`,
412
+ * defaulting to _/_. This "route" is the mount-point for the
413
+ * middleware, when given a value other than _/_ the middleware
414
+ * is only effective when that segment is present in the request's
415
+ * pathname.
416
+ *
417
+ * For example if we were to mount a function at _/admin_, it would
418
+ * be invoked on _/admin_, and _/admin/settings_, however it would
419
+ * not be invoked for _/_, or _/posts_.
420
+ */
421
+ use(fn: NextHandleFunction): Server
422
+ use(fn: HandleFunction): Server
423
+ use(route: string, fn: NextHandleFunction): Server
424
+ use(route: string, fn: HandleFunction): Server
425
+
426
+ /**
427
+ * Handle server requests, punting them down
428
+ * the middleware stack.
429
+ */
430
+ handle(
431
+ req: http.IncomingMessage,
432
+ res: http.ServerResponse,
433
+ next: Function,
434
+ ): void
435
+
436
+ /**
437
+ * Listen for connections.
438
+ *
439
+ * This method takes the same arguments
440
+ * as node's `http.Server#listen()`.
441
+ *
442
+ * HTTP and HTTPS:
443
+ *
444
+ * If you run your application both as HTTP
445
+ * and HTTPS you may wrap them individually,
446
+ * since your Connect "server" is really just
447
+ * a JavaScript `Function`.
448
+ *
449
+ * var connect = require('connect')
450
+ * , http = require('http')
451
+ * , https = require('https');
452
+ *
453
+ * var app = connect();
454
+ *
455
+ * http.createServer(app).listen(80);
456
+ * https.createServer(options, app).listen(443);
457
+ */
458
+ listen(
459
+ port: number,
460
+ hostname?: string,
461
+ backlog?: number,
462
+ callback?: Function,
463
+ ): http.Server
464
+ listen(port: number, hostname?: string, callback?: Function): http.Server
465
+ listen(path: string, callback?: Function): http.Server
466
+ listen(handle: any, listeningListener?: Function): http.Server
467
+ }
468
+ }
469
+
470
+ export { ConnectedPayload }
471
+
472
+ /**
473
+ * https://github.com/expressjs/cors#configuration-options
474
+ */
475
+ export declare interface CorsOptions {
476
+ origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
477
+ methods?: string | string[];
478
+ allowedHeaders?: string | string[];
479
+ exposedHeaders?: string | string[];
480
+ credentials?: boolean;
481
+ maxAge?: number;
482
+ preflightContinue?: boolean;
483
+ optionsSuccessStatus?: number;
484
+ }
485
+
486
+ export declare type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
487
+
488
+ export declare const createFilter: (include?: FilterPattern, exclude?: FilterPattern, options?: {
489
+ resolve?: string | false | null;
490
+ }) => (id: string | unknown) => boolean;
491
+
492
+ export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
493
+
494
+ export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
495
+
496
+ export declare interface CSSModulesOptions {
497
+ getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
498
+ scopeBehaviour?: 'global' | 'local';
499
+ globalModulePaths?: RegExp[];
500
+ generateScopedName?: string | ((name: string, filename: string, css: string) => string);
501
+ hashPrefix?: string;
502
+ /**
503
+ * default: undefined
504
+ */
505
+ localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
506
+ }
507
+
508
+ export declare interface CSSOptions {
509
+ /**
510
+ * https://github.com/css-modules/postcss-modules
511
+ */
512
+ modules?: CSSModulesOptions | false;
513
+ preprocessorOptions?: Record<string, any>;
514
+ postcss?: string | (PostCSS.ProcessOptions & {
515
+ plugins?: PostCSS.AcceptedPlugin[];
516
+ });
517
+ /**
518
+ * Enables css sourcemaps during dev
519
+ * @default false
520
+ * @experimental
521
+ */
522
+ devSourcemap?: boolean;
523
+ }
524
+
525
+ export { CustomEventMap }
526
+
527
+ export { CustomPayload }
528
+
529
+ /**
530
+ * Type helper to make it easier to use vite.config.ts
531
+ * accepts a direct {@link UserConfig} object, or a function that returns it.
532
+ * The function receives a {@link ConfigEnv} object that exposes two properties:
533
+ * `command` (either `'build'` or `'serve'`), and `mode`.
534
+ */
535
+ export declare function defineConfig(config: UserConfigExport): UserConfigExport;
536
+
537
+ export declare interface DepOptimizationConfig {
538
+ /**
539
+ * Force optimize listed dependencies (must be resolvable import paths,
540
+ * cannot be globs).
541
+ */
542
+ include?: string[];
543
+ /**
544
+ * Do not optimize these dependencies (must be resolvable import paths,
545
+ * cannot be globs).
546
+ */
547
+ exclude?: string[];
548
+ /**
549
+ * Force ESM interop when importing for these dependencies. Some legacy
550
+ * packages advertise themselves as ESM but use `require` internally
551
+ * @experimental
552
+ */
553
+ needsInterop?: string[];
554
+ /**
555
+ * Options to pass to esbuild during the dep scanning and optimization
556
+ *
557
+ * Certain options are omitted since changing them would not be compatible
558
+ * with Vite's dep optimization.
559
+ *
560
+ * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
561
+ * - `plugins` are merged with Vite's dep plugin
562
+ *
563
+ * https://esbuild.github.io/api
564
+ */
565
+ esbuildOptions?: Omit<BuildOptions_2, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
566
+ /**
567
+ * List of file extensions that can be optimized. A corresponding esbuild
568
+ * plugin must exist to handle the specific extension.
569
+ *
570
+ * By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
571
+ * allows specifying additional extensions.
572
+ *
573
+ * @experimental
574
+ */
575
+ extensions?: string[];
576
+ /**
577
+ * Disables dependencies optimizations, true disables the optimizer during
578
+ * build and dev. Pass 'build' or 'dev' to only disable the optimizer in
579
+ * one of the modes. Deps optimization is enabled by default in dev only.
580
+ * @default 'build'
581
+ * @experimental
582
+ */
583
+ disabled?: boolean | 'build' | 'dev';
584
+ }
585
+
586
+ export declare interface DepOptimizationMetadata {
587
+ /**
588
+ * The main hash is determined by user config and dependency lockfiles.
589
+ * This is checked on server startup to avoid unnecessary re-bundles.
590
+ */
591
+ hash: string;
592
+ /**
593
+ * The browser hash is determined by the main hash plus additional dependencies
594
+ * discovered at runtime. This is used to invalidate browser requests to
595
+ * optimized deps.
596
+ */
597
+ browserHash: string;
598
+ /**
599
+ * Metadata for each already optimized dependency
600
+ */
601
+ optimized: Record<string, OptimizedDepInfo>;
602
+ /**
603
+ * Metadata for non-entry optimized chunks and dynamic imports
604
+ */
605
+ chunks: Record<string, OptimizedDepInfo>;
606
+ /**
607
+ * Metadata for each newly discovered dependency after processing
608
+ */
609
+ discovered: Record<string, OptimizedDepInfo>;
610
+ /**
611
+ * OptimizedDepInfo list
612
+ */
613
+ depInfoList: OptimizedDepInfo[];
614
+ }
615
+
616
+ export declare type DepOptimizationOptions = DepOptimizationConfig & {
617
+ /**
618
+ * By default, Vite will crawl your `index.html` to detect dependencies that
619
+ * need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
620
+ * will crawl those entry points instead.
621
+ *
622
+ * If neither of these fit your needs, you can specify custom entries using
623
+ * this option - the value should be a fast-glob pattern or array of patterns
624
+ * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
625
+ * vite project root. This will overwrite default entries inference.
626
+ */
627
+ entries?: string | string[];
628
+ /**
629
+ * Force dep pre-optimization regardless of whether deps have changed.
630
+ * @experimental
631
+ */
632
+ force?: boolean;
633
+ };
634
+
635
+ export declare interface DepOptimizationProcessing {
636
+ promise: Promise<void>;
637
+ resolve: () => void;
638
+ }
639
+
640
+ export declare interface DepOptimizationResult {
641
+ metadata: DepOptimizationMetadata;
642
+ /**
643
+ * When doing a re-run, if there are newly discovered dependencies
644
+ * the page reload will be delayed until the next rerun so we need
645
+ * to be able to discard the result
646
+ */
647
+ commit: () => Promise<void>;
648
+ cancel: () => void;
649
+ }
650
+
651
+ export declare interface DepsOptimizer {
652
+ metadata: DepOptimizationMetadata;
653
+ scanProcessing?: Promise<void>;
654
+ registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
655
+ run: () => void;
656
+ isOptimizedDepFile: (id: string) => boolean;
657
+ isOptimizedDepUrl: (url: string) => boolean;
658
+ getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
659
+ delayDepsOptimizerUntil: (id: string, done: () => Promise<any>) => void;
660
+ registerWorkersSource: (id: string) => void;
661
+ resetRegisteredIds: () => void;
662
+ ensureFirstRun: () => void;
663
+ close: () => Promise<void>;
664
+ options: DepOptimizationOptions;
665
+ }
666
+
667
+ export { ErrorPayload }
668
+
669
+ export declare interface ESBuildOptions extends EsbuildTransformOptions {
670
+ include?: string | RegExp | string[] | RegExp[];
671
+ exclude?: string | RegExp | string[] | RegExp[];
672
+ jsxInject?: string;
673
+ /**
674
+ * This option is not respected. Use `build.minify` instead.
675
+ */
676
+ minify?: never;
677
+ }
678
+
679
+ export { EsbuildTransformOptions }
680
+
681
+ export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
682
+ map: SourceMap;
683
+ };
684
+
685
+ export { esbuildVersion }
686
+
687
+ export declare interface ExperimentalOptions {
688
+ /**
689
+ * Append fake `&lang.(ext)` when queries are specified, to preserve the file extension for following plugins to process.
690
+ *
691
+ * @experimental
692
+ * @default false
693
+ */
694
+ importGlobRestoreExtension?: boolean;
695
+ /**
696
+ * Allow finegrain control over assets and public files paths
697
+ *
698
+ * @experimental
699
+ */
700
+ renderBuiltUrl?: RenderBuiltAssetUrl;
701
+ /**
702
+ * Enables support of HMR partial accept via `import.meta.hot.acceptExports`.
703
+ *
704
+ * @experimental
705
+ * @default false
706
+ */
707
+ hmrPartialAccept?: boolean;
708
+ }
709
+
710
+ export declare type ExportsData = {
711
+ hasImports: boolean;
712
+ exports: readonly string[];
713
+ facade: boolean;
714
+ hasReExports?: boolean;
715
+ jsxLoader?: boolean;
716
+ };
717
+
718
+ export declare interface FileSystemServeOptions {
719
+ /**
720
+ * Strictly restrict file accessing outside of allowing paths.
721
+ *
722
+ * Set to `false` to disable the warning
723
+ *
724
+ * @default true
725
+ */
726
+ strict?: boolean;
727
+ /**
728
+ * Restrict accessing files outside the allowed directories.
729
+ *
730
+ * Accepts absolute path or a path relative to project root.
731
+ * Will try to search up for workspace root by default.
732
+ */
733
+ allow?: string[];
734
+ /**
735
+ * Restrict accessing files that matches the patterns.
736
+ *
737
+ * This will have higher priority than `allow`.
738
+ * picomatch patterns are supported.
739
+ *
740
+ * @default ['.env', '.env.*', '*.crt', '*.pem']
741
+ */
742
+ deny?: string[];
743
+ }
744
+
745
+ /**
746
+ * Inlined to keep `@rollup/pluginutils` in devDependencies
747
+ */
748
+ export declare type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
749
+
750
+ export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
751
+
752
+ export declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
753
+ options: WatchOptions
754
+
755
+ /**
756
+ * Constructs a new FSWatcher instance with optional WatchOptions parameter.
757
+ */
758
+ constructor(options?: WatchOptions)
759
+
760
+ /**
761
+ * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
762
+ * string.
763
+ */
764
+ add(paths: string | ReadonlyArray<string>): this
765
+
766
+ /**
767
+ * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
768
+ * string.
769
+ */
770
+ unwatch(paths: string | ReadonlyArray<string>): this
771
+
772
+ /**
773
+ * Returns an object representing all the paths on the file system being watched by this
774
+ * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
775
+ * the `cwd` option was used), and the values are arrays of the names of the items contained in
776
+ * each directory.
777
+ */
778
+ getWatched(): {
779
+ [directory: string]: string[]
780
+ }
781
+
782
+ /**
783
+ * Removes all listeners from watched files.
784
+ */
785
+ close(): Promise<void>
786
+
787
+ on(
788
+ event: 'add' | 'addDir' | 'change',
789
+ listener: (path: string, stats?: fs.Stats) => void,
790
+ ): this
791
+
792
+ on(
793
+ event: 'all',
794
+ listener: (
795
+ eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir',
796
+ path: string,
797
+ stats?: fs.Stats,
798
+ ) => void,
799
+ ): this
800
+
801
+ /**
802
+ * Error occurred
803
+ */
804
+ on(event: 'error', listener: (error: Error) => void): this
805
+
806
+ /**
807
+ * Exposes the native Node `fs.FSWatcher events`
808
+ */
809
+ on(
810
+ event: 'raw',
811
+ listener: (eventName: string, path: string, details: any) => void,
812
+ ): this
813
+
814
+ /**
815
+ * Fires when the initial scan is complete
816
+ */
817
+ on(event: 'ready', listener: () => void): this
818
+
819
+ on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this
820
+
821
+ on(event: string, listener: (...args: any[]) => void): this
822
+ }
823
+
824
+ export { FullReloadPayload }
825
+
826
+ export { GeneralImportGlobOptions }
827
+
828
+ export declare function getDepOptimizationConfig(config: ResolvedConfig, ssr: boolean): DepOptimizationConfig;
829
+
830
+ export declare interface HmrContext {
831
+ file: string;
832
+ timestamp: number;
833
+ modules: Array<ModuleNode>;
834
+ read: () => string | Promise<string>;
835
+ server: ViteDevServer;
836
+ }
837
+
838
+ export declare interface HmrOptions {
839
+ protocol?: string;
840
+ host?: string;
841
+ port?: number;
842
+ clientPort?: number;
843
+ path?: string;
844
+ timeout?: number;
845
+ overlay?: boolean;
846
+ server?: Server;
847
+ }
848
+
849
+ export { HMRPayload }
850
+
851
+ export declare type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
852
+
853
+ export declare interface HtmlTagDescriptor {
854
+ tag: string;
855
+ attrs?: Record<string, string | boolean | undefined>;
856
+ children?: string | HtmlTagDescriptor[];
857
+ /**
858
+ * default: 'head-prepend'
859
+ */
860
+ injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
861
+ }
862
+
863
+ export declare namespace HttpProxy {
864
+ export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed
865
+
866
+ export type ProxyTargetUrl = string | Partial<url.Url>
867
+
868
+ export interface ProxyTargetDetailed {
869
+ host: string
870
+ port: number
871
+ protocol?: string | undefined
872
+ hostname?: string | undefined
873
+ socketPath?: string | undefined
874
+ key?: string | undefined
875
+ passphrase?: string | undefined
876
+ pfx?: Buffer | string | undefined
877
+ cert?: string | undefined
878
+ ca?: string | undefined
879
+ ciphers?: string | undefined
880
+ secureProtocol?: string | undefined
881
+ }
882
+
883
+ export type ErrorCallback = (
884
+ err: Error,
885
+ req: http.IncomingMessage,
886
+ res: http.ServerResponse,
887
+ target?: ProxyTargetUrl,
888
+ ) => void
889
+
890
+ export class Server extends events.EventEmitter {
891
+ /**
892
+ * Creates the proxy server with specified options.
893
+ * @param options - Config object passed to the proxy
894
+ */
895
+ constructor(options?: ServerOptions)
896
+
897
+ /**
898
+ * Used for proxying regular HTTP(S) requests
899
+ * @param req - Client request.
900
+ * @param res - Client response.
901
+ * @param options - Additional options.
902
+ */
903
+ web(
904
+ req: http.IncomingMessage,
905
+ res: http.ServerResponse,
906
+ options?: ServerOptions,
907
+ callback?: ErrorCallback,
908
+ ): void
909
+
910
+ /**
911
+ * Used for proxying regular HTTP(S) requests
912
+ * @param req - Client request.
913
+ * @param socket - Client socket.
914
+ * @param head - Client head.
915
+ * @param options - Additional options.
916
+ */
917
+ ws(
918
+ req: http.IncomingMessage,
919
+ socket: unknown,
920
+ head: unknown,
921
+ options?: ServerOptions,
922
+ callback?: ErrorCallback,
923
+ ): void
924
+
925
+ /**
926
+ * A function that wraps the object in a webserver, for your convenience
927
+ * @param port - Port to listen on
928
+ */
929
+ listen(port: number): Server
930
+
931
+ /**
932
+ * A function that closes the inner webserver and stops listening on given port
933
+ */
934
+ close(callback?: () => void): void
935
+
936
+ /**
937
+ * Creates the proxy server with specified options.
938
+ * @param options - Config object passed to the proxy
939
+ * @returns Proxy object with handlers for `ws` and `web` requests
940
+ */
941
+ static createProxyServer(options?: ServerOptions): Server
942
+
943
+ /**
944
+ * Creates the proxy server with specified options.
945
+ * @param options - Config object passed to the proxy
946
+ * @returns Proxy object with handlers for `ws` and `web` requests
947
+ */
948
+ static createServer(options?: ServerOptions): Server
949
+
950
+ /**
951
+ * Creates the proxy server with specified options.
952
+ * @param options - Config object passed to the proxy
953
+ * @returns Proxy object with handlers for `ws` and `web` requests
954
+ */
955
+ static createProxy(options?: ServerOptions): Server
956
+
957
+ addListener(event: string, listener: () => void): this
958
+ on(event: string, listener: () => void): this
959
+ on(event: 'error', listener: ErrorCallback): this
960
+ on(
961
+ event: 'start',
962
+ listener: (
963
+ req: http.IncomingMessage,
964
+ res: http.ServerResponse,
965
+ target: ProxyTargetUrl,
966
+ ) => void,
967
+ ): this
968
+ on(
969
+ event: 'proxyReq',
970
+ listener: (
971
+ proxyReq: http.ClientRequest,
972
+ req: http.IncomingMessage,
973
+ res: http.ServerResponse,
974
+ options: ServerOptions,
975
+ ) => void,
976
+ ): this
977
+ on(
978
+ event: 'proxyRes',
979
+ listener: (
980
+ proxyRes: http.IncomingMessage,
981
+ req: http.IncomingMessage,
982
+ res: http.ServerResponse,
983
+ ) => void,
984
+ ): this
985
+ on(
986
+ event: 'proxyReqWs',
987
+ listener: (
988
+ proxyReq: http.ClientRequest,
989
+ req: http.IncomingMessage,
990
+ socket: net.Socket,
991
+ options: ServerOptions,
992
+ head: any,
993
+ ) => void,
994
+ ): this
995
+ on(
996
+ event: 'econnreset',
997
+ listener: (
998
+ err: Error,
999
+ req: http.IncomingMessage,
1000
+ res: http.ServerResponse,
1001
+ target: ProxyTargetUrl,
1002
+ ) => void,
1003
+ ): this
1004
+ on(
1005
+ event: 'end',
1006
+ listener: (
1007
+ req: http.IncomingMessage,
1008
+ res: http.ServerResponse,
1009
+ proxyRes: http.IncomingMessage,
1010
+ ) => void,
1011
+ ): this
1012
+ on(
1013
+ event: 'close',
1014
+ listener: (
1015
+ proxyRes: http.IncomingMessage,
1016
+ proxySocket: net.Socket,
1017
+ proxyHead: any,
1018
+ ) => void,
1019
+ ): this
1020
+
1021
+ once(event: string, listener: () => void): this
1022
+ removeListener(event: string, listener: () => void): this
1023
+ removeAllListeners(event?: string): this
1024
+ getMaxListeners(): number
1025
+ setMaxListeners(n: number): this
1026
+ listeners(event: string): Array<() => void>
1027
+ emit(event: string, ...args: any[]): boolean
1028
+ listenerCount(type: string): number
1029
+ }
1030
+
1031
+ export interface ServerOptions {
1032
+ /** URL string to be parsed with the url module. */
1033
+ target?: ProxyTarget | undefined
1034
+ /** URL string to be parsed with the url module. */
1035
+ forward?: ProxyTargetUrl | undefined
1036
+ /** Object to be passed to http(s).request. */
1037
+ agent?: any
1038
+ /** Object to be passed to https.createServer(). */
1039
+ ssl?: any
1040
+ /** If you want to proxy websockets. */
1041
+ ws?: boolean | undefined
1042
+ /** Adds x- forward headers. */
1043
+ xfwd?: boolean | undefined
1044
+ /** Verify SSL certificate. */
1045
+ secure?: boolean | undefined
1046
+ /** Explicitly specify if we are proxying to another proxy. */
1047
+ toProxy?: boolean | undefined
1048
+ /** Specify whether you want to prepend the target's path to the proxy path. */
1049
+ prependPath?: boolean | undefined
1050
+ /** Specify whether you want to ignore the proxy path of the incoming request. */
1051
+ ignorePath?: boolean | undefined
1052
+ /** Local interface string to bind for outgoing connections. */
1053
+ localAddress?: string | undefined
1054
+ /** Changes the origin of the host header to the target URL. */
1055
+ changeOrigin?: boolean | undefined
1056
+ /** specify whether you want to keep letter case of response header key */
1057
+ preserveHeaderKeyCase?: boolean | undefined
1058
+ /** Basic authentication i.e. 'user:password' to compute an Authorization header. */
1059
+ auth?: string | undefined
1060
+ /** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
1061
+ hostRewrite?: string | undefined
1062
+ /** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
1063
+ autoRewrite?: boolean | undefined
1064
+ /** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
1065
+ protocolRewrite?: string | undefined
1066
+ /** rewrites domain of set-cookie headers. */
1067
+ cookieDomainRewrite?:
1068
+ | false
1069
+ | string
1070
+ | { [oldDomain: string]: string }
1071
+ | undefined
1072
+ /** rewrites path of set-cookie headers. Default: false */
1073
+ cookiePathRewrite?:
1074
+ | false
1075
+ | string
1076
+ | { [oldPath: string]: string }
1077
+ | undefined
1078
+ /** object with extra headers to be added to target requests. */
1079
+ headers?: { [header: string]: string } | undefined
1080
+ /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
1081
+ proxyTimeout?: number | undefined
1082
+ /** Timeout (in milliseconds) for incoming requests */
1083
+ timeout?: number | undefined
1084
+ /** Specify whether you want to follow redirects. Default: false */
1085
+ followRedirects?: boolean | undefined
1086
+ /** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
1087
+ selfHandleResponse?: boolean | undefined
1088
+ /** Buffer */
1089
+ buffer?: stream.Stream | undefined
1090
+ }
1091
+ }
1092
+
1093
+ export { ImportGlobEagerFunction }
1094
+
1095
+ export { ImportGlobFunction }
1096
+
1097
+ export { ImportGlobOptions }
1098
+
1099
+ export declare type IndexHtmlTransform = IndexHtmlTransformHook | {
1100
+ order?: 'pre' | 'post' | null;
1101
+ /**
1102
+ * @deprecated renamed to `order`
1103
+ */
1104
+ enforce?: 'pre' | 'post';
1105
+ /**
1106
+ * @deprecated renamed to `handler`
1107
+ */
1108
+ transform: IndexHtmlTransformHook;
1109
+ } | {
1110
+ order?: 'pre' | 'post' | null;
1111
+ /**
1112
+ * @deprecated renamed to `order`
1113
+ */
1114
+ enforce?: 'pre' | 'post';
1115
+ handler: IndexHtmlTransformHook;
1116
+ };
1117
+
1118
+ export declare interface IndexHtmlTransformContext {
1119
+ /**
1120
+ * public path when served
1121
+ */
1122
+ path: string;
1123
+ /**
1124
+ * filename on disk
1125
+ */
1126
+ filename: string;
1127
+ server?: ViteDevServer;
1128
+ bundle?: OutputBundle;
1129
+ chunk?: OutputChunk;
1130
+ originalUrl?: string;
1131
+ }
1132
+
1133
+ export declare type IndexHtmlTransformHook = (this: void, html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
1134
+
1135
+ export declare type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
1136
+ html: string;
1137
+ tags: HtmlTagDescriptor[];
1138
+ };
1139
+
1140
+ export { InferCustomEventPayload }
1141
+
1142
+ export declare interface InlineConfig extends UserConfig {
1143
+ configFile?: string | false;
1144
+ envFile?: false;
1145
+ }
1146
+
1147
+ export declare interface InternalResolveOptions extends Required<ResolveOptions> {
1148
+ root: string;
1149
+ isBuild: boolean;
1150
+ isProduction: boolean;
1151
+ ssrConfig?: SSROptions;
1152
+ packageCache?: PackageCache;
1153
+ /**
1154
+ * src code mode also attempts the following:
1155
+ * - resolving /xxx as URLs
1156
+ * - resolving bare imports from optimized deps
1157
+ */
1158
+ asSrc?: boolean;
1159
+ tryIndex?: boolean;
1160
+ tryPrefix?: string;
1161
+ skipPackageJson?: boolean;
1162
+ preferRelative?: boolean;
1163
+ isRequire?: boolean;
1164
+ isFromTsImporter?: boolean;
1165
+ tryEsmOnly?: boolean;
1166
+ scan?: boolean;
1167
+ ssrOptimizeCheck?: boolean;
1168
+ getDepsOptimizer?: (ssr: boolean) => DepsOptimizer | undefined;
1169
+ shouldExternalize?: (id: string) => boolean | undefined;
1170
+ }
1171
+
1172
+ export { InvalidatePayload }
1173
+
1174
+ export declare const isCSSRequest: (request: string) => boolean;
1175
+
1176
+ export declare function isDepsOptimizerEnabled(config: ResolvedConfig, ssr: boolean): boolean;
1177
+
1178
+ export declare interface JsonOptions {
1179
+ /**
1180
+ * Generate a named export for every property of the JSON object
1181
+ * @default true
1182
+ */
1183
+ namedExports?: boolean;
1184
+ /**
1185
+ * Generate performant output as JSON.parse("stringified").
1186
+ * Enabling this will disable namedExports.
1187
+ * @default false
1188
+ */
1189
+ stringify?: boolean;
1190
+ }
1191
+
1192
+ export { KnownAsTypeMap }
1193
+
1194
+ export declare interface LegacyOptions {
1195
+ /**
1196
+ * Revert vite build --ssr to the v2.9 strategy. Use CJS SSR build and v2.9 externalization heuristics
1197
+ *
1198
+ * @experimental
1199
+ * @deprecated
1200
+ * @default false
1201
+ */
1202
+ buildSsrCjsExternalHeuristics?: boolean;
1203
+ }
1204
+
1205
+ export declare type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
1206
+
1207
+ export declare interface LibraryOptions {
1208
+ /**
1209
+ * Path of library entry
1210
+ */
1211
+ entry: InputOption;
1212
+ /**
1213
+ * The name of the exposed global variable. Required when the `formats` option includes
1214
+ * `umd` or `iife`
1215
+ */
1216
+ name?: string;
1217
+ /**
1218
+ * Output bundle formats
1219
+ * @default ['es', 'umd']
1220
+ */
1221
+ formats?: LibraryFormats[];
1222
+ /**
1223
+ * The name of the package file output. The default file name is the name option
1224
+ * of the project package.json. It can also be defined as a function taking the
1225
+ * format as an argument.
1226
+ */
1227
+ fileName?: string | ((format: ModuleFormat, entryName: string) => string);
1228
+ }
1229
+
1230
+ export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
1231
+ path: string;
1232
+ config: UserConfig;
1233
+ dependencies: string[];
1234
+ } | null>;
1235
+
1236
+ export declare function loadEnv(mode: string, envDir: string, prefixes?: string | string[]): Record<string, string>;
1237
+
1238
+ export declare interface LogErrorOptions extends LogOptions {
1239
+ error?: Error | RollupError | null;
1240
+ }
1241
+
1242
+ export declare interface Logger {
1243
+ info(msg: string, options?: LogOptions): void;
1244
+ warn(msg: string, options?: LogOptions): void;
1245
+ warnOnce(msg: string, options?: LogOptions): void;
1246
+ error(msg: string, options?: LogErrorOptions): void;
1247
+ clearScreen(type: LogType): void;
1248
+ hasErrorLogged(error: Error | RollupError): boolean;
1249
+ hasWarned: boolean;
1250
+ }
1251
+
1252
+ export declare interface LoggerOptions {
1253
+ prefix?: string;
1254
+ allowClearScreen?: boolean;
1255
+ customLogger?: Logger;
1256
+ }
1257
+
1258
+ export declare type LogLevel = LogType | 'silent';
1259
+
1260
+ export declare interface LogOptions {
1261
+ clear?: boolean;
1262
+ timestamp?: boolean;
1263
+ }
1264
+
1265
+ export declare type LogType = 'error' | 'warn' | 'info';
1266
+
1267
+ export declare type Manifest = Record<string, ManifestChunk>;
1268
+
1269
+ export declare interface ManifestChunk {
1270
+ src?: string;
1271
+ file: string;
1272
+ css?: string[];
1273
+ assets?: string[];
1274
+ isEntry?: boolean;
1275
+ isDynamicEntry?: boolean;
1276
+ imports?: string[];
1277
+ dynamicImports?: string[];
1278
+ }
1279
+
1280
+ export declare type MapToFunction<T> = T extends Function ? T : never
1281
+
1282
+ export declare type Matcher = AnymatchPattern | AnymatchPattern[]
1283
+
1284
+ export declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
1285
+
1286
+ export declare function mergeConfig(defaults: Record<string, any>, overrides: Record<string, any>, isRoot?: boolean): Record<string, any>;
1287
+
1288
+ export declare class ModuleGraph {
1289
+ private resolveId;
1290
+ urlToModuleMap: Map<string, ModuleNode>;
1291
+ idToModuleMap: Map<string, ModuleNode>;
1292
+ fileToModulesMap: Map<string, Set<ModuleNode>>;
1293
+ safeModulesPath: Set<string>;
1294
+ constructor(resolveId: (url: string, ssr: boolean) => Promise<PartialResolvedId | null>);
1295
+ getModuleByUrl(rawUrl: string, ssr?: boolean): Promise<ModuleNode | undefined>;
1296
+ getModuleById(id: string): ModuleNode | undefined;
1297
+ getModulesByFile(file: string): Set<ModuleNode> | undefined;
1298
+ onFileChange(file: string): void;
1299
+ invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number): void;
1300
+ invalidateAll(): void;
1301
+ /**
1302
+ * Update the module graph based on a module's updated imports information
1303
+ * If there are dependencies that no longer have any importers, they are
1304
+ * returned as a Set.
1305
+ */
1306
+ updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | ModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean, ssr?: boolean): Promise<Set<ModuleNode> | undefined>;
1307
+ ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
1308
+ createFileOnlyEntry(file: string): ModuleNode;
1309
+ resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
1310
+ }
1311
+
1312
+ export declare class ModuleNode {
1313
+ /**
1314
+ * Public served url path, starts with /
1315
+ */
1316
+ url: string;
1317
+ /**
1318
+ * Resolved file system path + query
1319
+ */
1320
+ id: string | null;
1321
+ file: string | null;
1322
+ type: 'js' | 'css';
1323
+ info?: ModuleInfo;
1324
+ meta?: Record<string, any>;
1325
+ importers: Set<ModuleNode>;
1326
+ importedModules: Set<ModuleNode>;
1327
+ acceptedHmrDeps: Set<ModuleNode>;
1328
+ acceptedHmrExports: Set<string> | null;
1329
+ importedBindings: Map<string, Set<string>> | null;
1330
+ isSelfAccepting?: boolean;
1331
+ transformResult: TransformResult | null;
1332
+ ssrTransformResult: TransformResult | null;
1333
+ ssrModule: Record<string, any> | null;
1334
+ ssrError: Error | null;
1335
+ lastHMRTimestamp: number;
1336
+ lastInvalidationTimestamp: number;
1337
+ /**
1338
+ * @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
1339
+ */
1340
+ constructor(url: string, setIsSelfAccepting?: boolean);
1341
+ }
1342
+
1343
+ export declare interface ModulePreloadOptions {
1344
+ /**
1345
+ * Whether to inject a module preload polyfill.
1346
+ * Note: does not apply to library mode.
1347
+ * @default true
1348
+ */
1349
+ polyfill?: boolean;
1350
+ /**
1351
+ * Resolve the list of dependencies to preload for a given dynamic import
1352
+ * @experimental
1353
+ */
1354
+ resolveDependencies?: ResolveModulePreloadDependenciesFn;
1355
+ }
1356
+
1357
+ export declare function normalizePath(id: string): string;
1358
+
1359
+ export declare interface OptimizedDepInfo {
1360
+ id: string;
1361
+ file: string;
1362
+ src?: string;
1363
+ needsInterop?: boolean;
1364
+ browserHash?: string;
1365
+ fileHash?: string;
1366
+ /**
1367
+ * During optimization, ids can still be resolved to their final location
1368
+ * but the bundles may not yet be saved to disk
1369
+ */
1370
+ processing?: Promise<void>;
1371
+ /**
1372
+ * ExportData cache, discovered deps will parse the src entry to get exports
1373
+ * data used both to define if interop is needed and when pre-bundling
1374
+ */
1375
+ exportsData?: Promise<ExportsData>;
1376
+ }
1377
+
1378
+ /**
1379
+ * Scan and optimize dependencies within a project.
1380
+ * Used by Vite CLI when running `vite optimize`.
1381
+ */
1382
+ export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
1383
+
1384
+ /** Cache for package.json resolution and package.json contents */
1385
+ export declare type PackageCache = Map<string, PackageData>;
1386
+
1387
+ export declare interface PackageData {
1388
+ dir: string;
1389
+ hasSideEffects: (id: string) => boolean | 'no-treeshake';
1390
+ webResolvedImports: Record<string, string | undefined>;
1391
+ nodeResolvedImports: Record<string, string | undefined>;
1392
+ setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
1393
+ getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
1394
+ data: {
1395
+ [field: string]: any;
1396
+ name: string;
1397
+ type: string;
1398
+ version: string;
1399
+ main: string;
1400
+ module: string;
1401
+ browser: string | Record<string, string | false>;
1402
+ exports: string | Record<string, any> | string[];
1403
+ dependencies: Record<string, string>;
1404
+ };
1405
+ }
1406
+
1407
+ /**
1408
+ * Vite plugins extends the Rollup plugin interface with a few extra
1409
+ * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
1410
+ * On the contrary, a Rollup plugin may or may NOT be a valid vite universal
1411
+ * plugin, since some Rollup features do not make sense in an unbundled
1412
+ * dev server context. That said, as long as a rollup plugin doesn't have strong
1413
+ * coupling between its bundle phase and output phase hooks then it should
1414
+ * just work (that means, most of them).
1415
+ *
1416
+ * By default, the plugins are run during both serve and build. When a plugin
1417
+ * is applied during serve, it will only run **non output plugin hooks** (see
1418
+ * rollup type definition of {@link rollup#PluginHooks}). You can think of the
1419
+ * dev server as only running `const bundle = rollup.rollup()` but never calling
1420
+ * `bundle.generate()`.
1421
+ *
1422
+ * A plugin that expects to have different behavior depending on serve/build can
1423
+ * export a factory function that receives the command being run via options.
1424
+ *
1425
+ * If a plugin should be applied only for server or build, a function format
1426
+ * config file can be used to conditional determine the plugins to use.
1427
+ */
1428
+ declare interface Plugin_2 extends Plugin_3 {
1429
+ /**
1430
+ * Enforce plugin invocation tier similar to webpack loaders.
1431
+ *
1432
+ * Plugin invocation order:
1433
+ * - alias resolution
1434
+ * - `enforce: 'pre'` plugins
1435
+ * - vite core plugins
1436
+ * - normal plugins
1437
+ * - vite build plugins
1438
+ * - `enforce: 'post'` plugins
1439
+ * - vite build post plugins
1440
+ */
1441
+ enforce?: 'pre' | 'post';
1442
+ /**
1443
+ * Apply the plugin only for serve or build, or on certain conditions.
1444
+ */
1445
+ apply?: 'serve' | 'build' | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);
1446
+ /**
1447
+ * Modify vite config before it's resolved. The hook can either mutate the
1448
+ * passed-in config directly, or return a partial config object that will be
1449
+ * deeply merged into existing config.
1450
+ *
1451
+ * Note: User plugins are resolved before running this hook so injecting other
1452
+ * plugins inside the `config` hook will have no effect.
1453
+ */
1454
+ config?: ObjectHook<(this: void, config: UserConfig, env: ConfigEnv) => UserConfig | null | void | Promise<UserConfig | null | void>>;
1455
+ /**
1456
+ * Use this hook to read and store the final resolved vite config.
1457
+ */
1458
+ configResolved?: ObjectHook<(this: void, config: ResolvedConfig) => void | Promise<void>>;
1459
+ /**
1460
+ * Configure the vite server. The hook receives the {@link ViteDevServer}
1461
+ * instance. This can also be used to store a reference to the server
1462
+ * for use in other hooks.
1463
+ *
1464
+ * The hooks will be called before internal middlewares are applied. A hook
1465
+ * can return a post hook that will be called after internal middlewares
1466
+ * are applied. Hook can be async functions and will be called in series.
1467
+ */
1468
+ configureServer?: ObjectHook<ServerHook>;
1469
+ /**
1470
+ * Configure the preview server. The hook receives the connect server and
1471
+ * its underlying http server.
1472
+ *
1473
+ * The hooks are called before other middlewares are applied. A hook can
1474
+ * return a post hook that will be called after other middlewares are
1475
+ * applied. Hooks can be async functions and will be called in series.
1476
+ */
1477
+ configurePreviewServer?: ObjectHook<PreviewServerHook>;
1478
+ /**
1479
+ * Transform index.html.
1480
+ * The hook receives the following arguments:
1481
+ *
1482
+ * - html: string
1483
+ * - ctx?: vite.ServerContext (only present during serve)
1484
+ * - bundle?: rollup.OutputBundle (only present during build)
1485
+ *
1486
+ * It can either return a transformed string, or a list of html tag
1487
+ * descriptors that will be injected into the `<head>` or `<body>`.
1488
+ *
1489
+ * By default the transform is applied **after** vite's internal html
1490
+ * transform. If you need to apply the transform before vite, use an object:
1491
+ * `{ order: 'pre', handler: hook }`
1492
+ */
1493
+ transformIndexHtml?: IndexHtmlTransform;
1494
+ /**
1495
+ * Perform custom handling of HMR updates.
1496
+ * The handler receives a context containing changed filename, timestamp, a
1497
+ * list of modules affected by the file change, and the dev server instance.
1498
+ *
1499
+ * - The hook can return a filtered list of modules to narrow down the update.
1500
+ * e.g. for a Vue SFC, we can narrow down the part to update by comparing
1501
+ * the descriptors.
1502
+ *
1503
+ * - The hook can also return an empty array and then perform custom updates
1504
+ * by sending a custom hmr payload via server.ws.send().
1505
+ *
1506
+ * - If the hook doesn't return a value, the hmr update will be performed as
1507
+ * normal.
1508
+ */
1509
+ handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
1510
+ /**
1511
+ * extend hooks with ssr flag
1512
+ */
1513
+ resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
1514
+ assertions: Record<string, string>;
1515
+ custom?: CustomPluginOptions;
1516
+ ssr?: boolean;
1517
+ /* Excluded from this release type: scan */
1518
+ isEntry: boolean;
1519
+ }) => Promise<ResolveIdResult> | ResolveIdResult>;
1520
+ load?: ObjectHook<(this: PluginContext, id: string, options?: {
1521
+ ssr?: boolean;
1522
+ }) => Promise<LoadResult> | LoadResult>;
1523
+ transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
1524
+ ssr?: boolean;
1525
+ }) => Promise<TransformResult_2> | TransformResult_2>;
1526
+ }
1527
+ export { Plugin_2 as Plugin }
1528
+
1529
+ export declare interface PluginContainer {
1530
+ options: InputOptions;
1531
+ getModuleInfo(id: string): ModuleInfo | null;
1532
+ buildStart(options: InputOptions): Promise<void>;
1533
+ resolveId(id: string, importer?: string, options?: {
1534
+ assertions?: Record<string, string>;
1535
+ custom?: CustomPluginOptions;
1536
+ skip?: Set<Plugin_2>;
1537
+ ssr?: boolean;
1538
+ /* Excluded from this release type: scan */
1539
+ isEntry?: boolean;
1540
+ }): Promise<PartialResolvedId | null>;
1541
+ transform(code: string, id: string, options?: {
1542
+ inMap?: SourceDescription['map'];
1543
+ ssr?: boolean;
1544
+ }): Promise<SourceDescription | null>;
1545
+ load(id: string, options?: {
1546
+ ssr?: boolean;
1547
+ }): Promise<LoadResult | null>;
1548
+ close(): Promise<void>;
1549
+ }
1550
+
1551
+ export declare interface PluginHookUtils {
1552
+ getSortedPlugins: (hookName: keyof Plugin_2) => Plugin_2[];
1553
+ getSortedPluginHooks: <K extends keyof Plugin_2>(hookName: K) => NonNullable<HookHandler<Plugin_2[K]>>[];
1554
+ }
1555
+
1556
+ export declare type PluginOption = Plugin_2 | false | null | undefined | PluginOption[] | Promise<Plugin_2 | false | null | undefined | PluginOption[]>;
1557
+
1558
+ /**
1559
+ * @experimental
1560
+ */
1561
+ export declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
1562
+
1563
+ export declare interface PreprocessCSSResult {
1564
+ code: string;
1565
+ map?: SourceMapInput;
1566
+ modules?: Record<string, string>;
1567
+ deps?: Set<string>;
1568
+ }
1569
+
1570
+ /**
1571
+ * Starts the Vite server in preview mode, to simulate a production deployment
1572
+ */
1573
+ export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>;
1574
+
1575
+ export declare interface PreviewOptions extends CommonServerOptions {
1576
+ }
1577
+
1578
+ export declare interface PreviewServer {
1579
+ /**
1580
+ * The resolved vite config object
1581
+ */
1582
+ config: ResolvedConfig;
1583
+ /**
1584
+ * native Node http server instance
1585
+ */
1586
+ httpServer: http.Server;
1587
+ /**
1588
+ * The resolved urls Vite prints on the CLI
1589
+ */
1590
+ resolvedUrls: ResolvedServerUrls;
1591
+ /**
1592
+ * Print server urls
1593
+ */
1594
+ printUrls(): void;
1595
+ }
1596
+
1597
+ export declare type PreviewServerHook = (this: void, server: {
1598
+ middlewares: Connect.Server;
1599
+ httpServer: http.Server;
1600
+ }) => (() => void) | void | Promise<(() => void) | void>;
1601
+
1602
+ export declare interface ProxyOptions extends HttpProxy.ServerOptions {
1603
+ /**
1604
+ * rewrite path
1605
+ */
1606
+ rewrite?: (path: string) => string;
1607
+ /**
1608
+ * configure the proxy server (e.g. listen to events)
1609
+ */
1610
+ configure?: (proxy: HttpProxy.Server, options: ProxyOptions) => void;
1611
+ /**
1612
+ * webpack-dev-server style bypass function
1613
+ */
1614
+ bypass?: (req: http.IncomingMessage, res: http.ServerResponse, options: ProxyOptions) => void | null | undefined | false | string;
1615
+ }
1616
+
1617
+ export { PrunePayload }
1618
+
1619
+ export declare type RenderBuiltAssetUrl = (filename: string, type: {
1620
+ type: 'asset' | 'public';
1621
+ hostId: string;
1622
+ hostType: 'js' | 'css' | 'html';
1623
+ ssr: boolean;
1624
+ }) => string | {
1625
+ relative?: boolean;
1626
+ runtime?: string;
1627
+ } | undefined;
1628
+
1629
+ /**
1630
+ * Resolve base url. Note that some users use Vite to build for non-web targets like
1631
+ * electron or expects to deploy
1632
+ */
1633
+ export declare function resolveBaseUrl(base: string | undefined, isBuild: boolean, logger: Logger): string;
1634
+
1635
+ export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string): Promise<ResolvedConfig>;
1636
+
1637
+ export declare interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
1638
+ modulePreload: false | ResolvedModulePreloadOptions;
1639
+ }
1640
+
1641
+ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
1642
+ configFile: string | undefined;
1643
+ configFileDependencies: string[];
1644
+ inlineConfig: InlineConfig;
1645
+ root: string;
1646
+ base: string;
1647
+ /* Excluded from this release type: rawBase */
1648
+ publicDir: string;
1649
+ cacheDir: string;
1650
+ command: 'build' | 'serve';
1651
+ mode: string;
1652
+ isWorker: boolean;
1653
+ /* Excluded from this release type: mainConfig */
1654
+ isProduction: boolean;
1655
+ env: Record<string, any>;
1656
+ resolve: Required<ResolveOptions> & {
1657
+ alias: Alias[];
1658
+ };
1659
+ plugins: readonly Plugin_2[];
1660
+ server: ResolvedServerOptions;
1661
+ build: ResolvedBuildOptions;
1662
+ preview: ResolvedPreviewOptions;
1663
+ ssr: ResolvedSSROptions;
1664
+ assetsInclude: (file: string) => boolean;
1665
+ logger: Logger;
1666
+ createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
1667
+ optimizeDeps: DepOptimizationOptions;
1668
+ /* Excluded from this release type: packageCache */
1669
+ worker: ResolveWorkerOptions;
1670
+ appType: AppType;
1671
+ experimental: ExperimentalOptions;
1672
+ } & PluginHookUtils>;
1673
+
1674
+ export declare interface ResolvedModulePreloadOptions {
1675
+ polyfill: boolean;
1676
+ resolveDependencies?: ResolveModulePreloadDependenciesFn;
1677
+ }
1678
+
1679
+ export declare interface ResolvedPreviewOptions extends PreviewOptions {
1680
+ }
1681
+
1682
+ export declare interface ResolvedServerOptions extends ServerOptions {
1683
+ fs: Required<FileSystemServeOptions>;
1684
+ middlewareMode: boolean;
1685
+ }
1686
+
1687
+ export declare interface ResolvedServerUrls {
1688
+ local: string[];
1689
+ network: string[];
1690
+ }
1691
+
1692
+ export declare interface ResolvedSSROptions extends SSROptions {
1693
+ target: SSRTarget;
1694
+ format: SSRFormat;
1695
+ optimizeDeps: SsrDepOptimizationOptions;
1696
+ }
1697
+
1698
+ export declare type ResolvedUrl = [
1699
+ url: string,
1700
+ resolvedId: string,
1701
+ meta: object | null | undefined
1702
+ ];
1703
+
1704
+ export declare function resolveEnvPrefix({ envPrefix, }: UserConfig): string[];
1705
+
1706
+ export declare type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
1707
+
1708
+ export declare type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
1709
+ hostId: string;
1710
+ hostType: 'html' | 'js';
1711
+ }) => string[];
1712
+
1713
+ export declare interface ResolveOptions {
1714
+ mainFields?: string[];
1715
+ /**
1716
+ * @deprecated In future, `mainFields` should be used instead.
1717
+ * @default true
1718
+ */
1719
+ browserField?: boolean;
1720
+ conditions?: string[];
1721
+ extensions?: string[];
1722
+ dedupe?: string[];
1723
+ preserveSymlinks?: boolean;
1724
+ }
1725
+
1726
+ export declare function resolvePackageData(id: string, basedir: string, preserveSymlinks?: boolean, packageCache?: PackageCache): PackageData | null;
1727
+
1728
+ export declare function resolvePackageEntry(id: string, { dir, data, setResolvedCache, getResolvedCache }: PackageData, targetWeb: boolean, options: InternalResolveOptions): string | undefined;
1729
+
1730
+ export declare type ResolverFunction = MapToFunction<PluginHooks['resolveId']>
1731
+
1732
+ export declare interface ResolverObject {
1733
+ buildStart?: PluginHooks['buildStart']
1734
+ resolveId: ResolverFunction
1735
+ }
1736
+
1737
+ export declare interface ResolveWorkerOptions extends PluginHookUtils {
1738
+ format: 'es' | 'iife';
1739
+ plugins: Plugin_2[];
1740
+ rollupOptions: RollupOptions;
1741
+ }
1742
+
1743
+ /**
1744
+ * https://github.com/rollup/plugins/blob/master/packages/commonjs/types/index.d.ts
1745
+ *
1746
+ * This source code is licensed under the MIT license found in the
1747
+ * LICENSE file at
1748
+ * https://github.com/rollup/plugins/blob/master/LICENSE
1749
+ */
1750
+ export declare interface RollupCommonJSOptions {
1751
+ /**
1752
+ * A minimatch pattern, or array of patterns, which specifies the files in
1753
+ * the build the plugin should operate on. By default, all files with
1754
+ * extension `".cjs"` or those in `extensions` are included, but you can
1755
+ * narrow this list by only including specific files. These files will be
1756
+ * analyzed and transpiled if either the analysis does not find ES module
1757
+ * specific statements or `transformMixedEsModules` is `true`.
1758
+ * @default undefined
1759
+ */
1760
+ include?: string | RegExp | readonly (string | RegExp)[]
1761
+ /**
1762
+ * A minimatch pattern, or array of patterns, which specifies the files in
1763
+ * the build the plugin should _ignore_. By default, all files with
1764
+ * extensions other than those in `extensions` or `".cjs"` are ignored, but you
1765
+ * can exclude additional files. See also the `include` option.
1766
+ * @default undefined
1767
+ */
1768
+ exclude?: string | RegExp | readonly (string | RegExp)[]
1769
+ /**
1770
+ * For extensionless imports, search for extensions other than .js in the
1771
+ * order specified. Note that you need to make sure that non-JavaScript files
1772
+ * are transpiled by another plugin first.
1773
+ * @default [ '.js' ]
1774
+ */
1775
+ extensions?: ReadonlyArray<string>
1776
+ /**
1777
+ * If true then uses of `global` won't be dealt with by this plugin
1778
+ * @default false
1779
+ */
1780
+ ignoreGlobal?: boolean
1781
+ /**
1782
+ * If false, skips source map generation for CommonJS modules. This will
1783
+ * improve performance.
1784
+ * @default true
1785
+ */
1786
+ sourceMap?: boolean
1787
+ /**
1788
+ * Some `require` calls cannot be resolved statically to be translated to
1789
+ * imports.
1790
+ * When this option is set to `false`, the generated code will either
1791
+ * directly throw an error when such a call is encountered or, when
1792
+ * `dynamicRequireTargets` is used, when such a call cannot be resolved with a
1793
+ * configured dynamic require target.
1794
+ * Setting this option to `true` will instead leave the `require` call in the
1795
+ * code or use it as a fallback for `dynamicRequireTargets`.
1796
+ * @default false
1797
+ */
1798
+ ignoreDynamicRequires?: boolean
1799
+ /**
1800
+ * Instructs the plugin whether to enable mixed module transformations. This
1801
+ * is useful in scenarios with modules that contain a mix of ES `import`
1802
+ * statements and CommonJS `require` expressions. Set to `true` if `require`
1803
+ * calls should be transformed to imports in mixed modules, or `false` if the
1804
+ * `require` expressions should survive the transformation. The latter can be
1805
+ * important if the code contains environment detection, or you are coding
1806
+ * for an environment with special treatment for `require` calls such as
1807
+ * ElectronJS. See also the `ignore` option.
1808
+ * @default false
1809
+ */
1810
+ transformMixedEsModules?: boolean
1811
+ /**
1812
+ * By default, this plugin will try to hoist `require` statements as imports
1813
+ * to the top of each file. While this works well for many code bases and
1814
+ * allows for very efficient ESM output, it does not perfectly capture
1815
+ * CommonJS semantics as the order of side effects like log statements may
1816
+ * change. But it is especially problematic when there are circular `require`
1817
+ * calls between CommonJS modules as those often rely on the lazy execution of
1818
+ * nested `require` calls.
1819
+ *
1820
+ * Setting this option to `true` will wrap all CommonJS files in functions
1821
+ * which are executed when they are required for the first time, preserving
1822
+ * NodeJS semantics. Note that this can have an impact on the size and
1823
+ * performance of the generated code.
1824
+ *
1825
+ * The default value of `"auto"` will only wrap CommonJS files when they are
1826
+ * part of a CommonJS dependency cycle, e.g. an index file that is required by
1827
+ * many of its dependencies. All other CommonJS files are hoisted. This is the
1828
+ * recommended setting for most code bases.
1829
+ *
1830
+ * `false` will entirely prevent wrapping and hoist all files. This may still
1831
+ * work depending on the nature of cyclic dependencies but will often cause
1832
+ * problems.
1833
+ *
1834
+ * You can also provide a minimatch pattern, or array of patterns, to only
1835
+ * specify a subset of files which should be wrapped in functions for proper
1836
+ * `require` semantics.
1837
+ *
1838
+ * `"debug"` works like `"auto"` but after bundling, it will display a warning
1839
+ * containing a list of ids that have been wrapped which can be used as
1840
+ * minimatch pattern for fine-tuning.
1841
+ * @default "auto"
1842
+ */
1843
+ strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[]
1844
+ /**
1845
+ * Sometimes you have to leave require statements unconverted. Pass an array
1846
+ * containing the IDs or a `id => boolean` function.
1847
+ * @default []
1848
+ */
1849
+ ignore?: ReadonlyArray<string> | ((id: string) => boolean)
1850
+ /**
1851
+ * In most cases, where `require` calls are inside a `try-catch` clause,
1852
+ * they should be left unconverted as it requires an optional dependency
1853
+ * that may or may not be installed beside the rolled up package.
1854
+ * Due to the conversion of `require` to a static `import` - the call is
1855
+ * hoisted to the top of the file, outside the `try-catch` clause.
1856
+ *
1857
+ * - `true`: Default. All `require` calls inside a `try` will be left unconverted.
1858
+ * - `false`: All `require` calls inside a `try` will be converted as if the
1859
+ * `try-catch` clause is not there.
1860
+ * - `remove`: Remove all `require` calls from inside any `try` block.
1861
+ * - `string[]`: Pass an array containing the IDs to left unconverted.
1862
+ * - `((id: string) => boolean|'remove')`: Pass a function that controls
1863
+ * individual IDs.
1864
+ *
1865
+ * @default true
1866
+ */
1867
+ ignoreTryCatch?:
1868
+ | boolean
1869
+ | 'remove'
1870
+ | ReadonlyArray<string>
1871
+ | ((id: string) => boolean | 'remove')
1872
+ /**
1873
+ * Controls how to render imports from external dependencies. By default,
1874
+ * this plugin assumes that all external dependencies are CommonJS. This
1875
+ * means they are rendered as default imports to be compatible with e.g.
1876
+ * NodeJS where ES modules can only import a default export from a CommonJS
1877
+ * dependency.
1878
+ *
1879
+ * If you set `esmExternals` to `true`, this plugin assumes that all
1880
+ * external dependencies are ES modules and respect the
1881
+ * `requireReturnsDefault` option. If that option is not set, they will be
1882
+ * rendered as namespace imports.
1883
+ *
1884
+ * You can also supply an array of ids to be treated as ES modules, or a
1885
+ * function that will be passed each external id to determine whether it is
1886
+ * an ES module.
1887
+ * @default false
1888
+ */
1889
+ esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean)
1890
+ /**
1891
+ * Controls what is returned when requiring an ES module from a CommonJS file.
1892
+ * When using the `esmExternals` option, this will also apply to external
1893
+ * modules. By default, this plugin will render those imports as namespace
1894
+ * imports i.e.
1895
+ *
1896
+ * ```js
1897
+ * // input
1898
+ * const foo = require('foo');
1899
+ *
1900
+ * // output
1901
+ * import * as foo from 'foo';
1902
+ * ```
1903
+ *
1904
+ * However, there are some situations where this may not be desired.
1905
+ * For these situations, you can change Rollup's behaviour either globally or
1906
+ * per module. To change it globally, set the `requireReturnsDefault` option
1907
+ * to one of the following values:
1908
+ *
1909
+ * - `false`: This is the default, requiring an ES module returns its
1910
+ * namespace. This is the only option that will also add a marker
1911
+ * `__esModule: true` to the namespace to support interop patterns in
1912
+ * CommonJS modules that are transpiled ES modules.
1913
+ * - `"namespace"`: Like `false`, requiring an ES module returns its
1914
+ * namespace, but the plugin does not add the `__esModule` marker and thus
1915
+ * creates more efficient code. For external dependencies when using
1916
+ * `esmExternals: true`, no additional interop code is generated.
1917
+ * - `"auto"`: This is complementary to how `output.exports: "auto"` works in
1918
+ * Rollup: If a module has a default export and no named exports, requiring
1919
+ * that module returns the default export. In all other cases, the namespace
1920
+ * is returned. For external dependencies when using `esmExternals: true`, a
1921
+ * corresponding interop helper is added.
1922
+ * - `"preferred"`: If a module has a default export, requiring that module
1923
+ * always returns the default export, no matter whether additional named
1924
+ * exports exist. This is similar to how previous versions of this plugin
1925
+ * worked. Again for external dependencies when using `esmExternals: true`,
1926
+ * an interop helper is added.
1927
+ * - `true`: This will always try to return the default export on require
1928
+ * without checking if it actually exists. This can throw at build time if
1929
+ * there is no default export. This is how external dependencies are handled
1930
+ * when `esmExternals` is not used. The advantage over the other options is
1931
+ * that, like `false`, this does not add an interop helper for external
1932
+ * dependencies, keeping the code lean.
1933
+ *
1934
+ * To change this for individual modules, you can supply a function for
1935
+ * `requireReturnsDefault` instead. This function will then be called once for
1936
+ * each required ES module or external dependency with the corresponding id
1937
+ * and allows you to return different values for different modules.
1938
+ * @default false
1939
+ */
1940
+ requireReturnsDefault?:
1941
+ | boolean
1942
+ | 'auto'
1943
+ | 'preferred'
1944
+ | 'namespace'
1945
+ | ((id: string) => boolean | 'auto' | 'preferred' | 'namespace')
1946
+
1947
+ /**
1948
+ * @default "auto"
1949
+ */
1950
+ defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto')
1951
+ /**
1952
+ * Some modules contain dynamic `require` calls, or require modules that
1953
+ * contain circular dependencies, which are not handled well by static
1954
+ * imports. Including those modules as `dynamicRequireTargets` will simulate a
1955
+ * CommonJS (NodeJS-like) environment for them with support for dynamic
1956
+ * dependencies. It also enables `strictRequires` for those modules.
1957
+ *
1958
+ * Note: In extreme cases, this feature may result in some paths being
1959
+ * rendered as absolute in the final bundle. The plugin tries to avoid
1960
+ * exposing paths from the local machine, but if you are `dynamicRequirePaths`
1961
+ * with paths that are far away from your project's folder, that may require
1962
+ * replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
1963
+ */
1964
+ dynamicRequireTargets?: string | ReadonlyArray<string>
1965
+ /**
1966
+ * To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
1967
+ * that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
1968
+ * may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
1969
+ * home directory name. By default, it uses the current working directory.
1970
+ */
1971
+ dynamicRequireRoot?: string
1972
+ }
1973
+
1974
+ export declare interface RollupDynamicImportVarsOptions {
1975
+ /**
1976
+ * Files to include in this plugin (default all).
1977
+ * @default []
1978
+ */
1979
+ include?: string | RegExp | (string | RegExp)[]
1980
+ /**
1981
+ * Files to exclude in this plugin (default none).
1982
+ * @default []
1983
+ */
1984
+ exclude?: string | RegExp | (string | RegExp)[]
1985
+ /**
1986
+ * By default, the plugin quits the build process when it encounters an error. If you set this option to true, it will throw a warning instead and leave the code untouched.
1987
+ * @default false
1988
+ */
1989
+ warnOnError?: boolean
1990
+ }
1991
+
1992
+ export { rollupVersion }
1993
+
1994
+ /**
1995
+ * Search up for the nearest workspace root
1996
+ */
1997
+ export declare function searchForWorkspaceRoot(current: string, root?: string): string;
1998
+
1999
+ export declare function send(req: IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, options: SendOptions): void;
2000
+
2001
+ export declare interface SendOptions {
2002
+ etag?: string;
2003
+ cacheControl?: string;
2004
+ headers?: OutgoingHttpHeaders;
2005
+ map?: SourceMap | null;
2006
+ }
2007
+
2008
+ export declare type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
2009
+
2010
+ export declare interface ServerOptions extends CommonServerOptions {
2011
+ /**
2012
+ * Configure HMR-specific options (port, host, path & protocol)
2013
+ */
2014
+ hmr?: HmrOptions | boolean;
2015
+ /**
2016
+ * chokidar watch options
2017
+ * https://github.com/paulmillr/chokidar#api
2018
+ */
2019
+ watch?: WatchOptions;
2020
+ /**
2021
+ * Create Vite dev server to be used as a middleware in an existing server
2022
+ */
2023
+ middlewareMode?: boolean | 'html' | 'ssr';
2024
+ /**
2025
+ * Prepend this folder to http requests, for use when proxying vite as a subfolder
2026
+ * Should start and end with the `/` character
2027
+ */
2028
+ base?: string;
2029
+ /**
2030
+ * Options for files served via '/\@fs/'.
2031
+ */
2032
+ fs?: FileSystemServeOptions;
2033
+ /**
2034
+ * Origin for the generated asset URLs.
2035
+ *
2036
+ * @example `http://127.0.0.1:8080`
2037
+ */
2038
+ origin?: string;
2039
+ /**
2040
+ * Pre-transform known direct imports
2041
+ * @default true
2042
+ */
2043
+ preTransformRequests?: boolean;
2044
+ /**
2045
+ * Force dep pre-optimization regardless of whether deps have changed.
2046
+ *
2047
+ * @deprecated Use optimizeDeps.force instead, this option may be removed
2048
+ * in a future minor version without following semver
2049
+ */
2050
+ force?: boolean;
2051
+ }
2052
+
2053
+ export declare function sortUserPlugins(plugins: (Plugin_2 | Plugin_2[])[] | undefined): [Plugin_2[], Plugin_2[], Plugin_2[]];
2054
+
2055
+ export declare function splitVendorChunk(options?: {
2056
+ cache?: SplitVendorChunkCache;
2057
+ }): GetManualChunk;
2058
+
2059
+ export declare class SplitVendorChunkCache {
2060
+ cache: Map<string, boolean>;
2061
+ constructor();
2062
+ reset(): void;
2063
+ }
2064
+
2065
+ export declare function splitVendorChunkPlugin(): Plugin_2;
2066
+
2067
+ export declare type SsrDepOptimizationOptions = DepOptimizationConfig;
2068
+
2069
+ export declare type SSRFormat = 'esm' | 'cjs';
2070
+
2071
+ export declare interface SSROptions {
2072
+ noExternal?: string | RegExp | (string | RegExp)[] | true;
2073
+ external?: string[];
2074
+ /**
2075
+ * Define the target for the ssr build. The browser field in package.json
2076
+ * is ignored for node but used if webworker is the target
2077
+ * Default: 'node'
2078
+ */
2079
+ target?: SSRTarget;
2080
+ /**
2081
+ * Define the format for the ssr build. Since Vite v3 the SSR build generates ESM by default.
2082
+ * `'cjs'` can be selected to generate a CJS build, but it isn't recommended. This option is
2083
+ * left marked as experimental to give users more time to update to ESM. CJS builds requires
2084
+ * complex externalization heuristics that aren't present in the ESM format.
2085
+ * @experimental
2086
+ */
2087
+ format?: SSRFormat;
2088
+ /**
2089
+ * Control over which dependencies are optimized during SSR and esbuild options
2090
+ * During build:
2091
+ * no external CJS dependencies are optimized by default
2092
+ * During dev:
2093
+ * explicit no external CJS dependencies are optimized by default
2094
+ * @experimental
2095
+ */
2096
+ optimizeDeps?: SsrDepOptimizationOptions;
2097
+ }
2098
+
2099
+ export declare type SSRTarget = 'node' | 'webworker';
2100
+
2101
+ export declare namespace Terser {
2102
+ export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
2103
+
2104
+ export interface ParseOptions {
2105
+ bare_returns?: boolean
2106
+ /** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
2107
+ ecma?: ECMA
2108
+ html5_comments?: boolean
2109
+ shebang?: boolean
2110
+ }
2111
+
2112
+ export interface CompressOptions {
2113
+ arguments?: boolean
2114
+ arrows?: boolean
2115
+ booleans_as_integers?: boolean
2116
+ booleans?: boolean
2117
+ collapse_vars?: boolean
2118
+ comparisons?: boolean
2119
+ computed_props?: boolean
2120
+ conditionals?: boolean
2121
+ dead_code?: boolean
2122
+ defaults?: boolean
2123
+ directives?: boolean
2124
+ drop_console?: boolean
2125
+ drop_debugger?: boolean
2126
+ ecma?: ECMA
2127
+ evaluate?: boolean
2128
+ expression?: boolean
2129
+ global_defs?: object
2130
+ hoist_funs?: boolean
2131
+ hoist_props?: boolean
2132
+ hoist_vars?: boolean
2133
+ ie8?: boolean
2134
+ if_return?: boolean
2135
+ inline?: boolean | InlineFunctions
2136
+ join_vars?: boolean
2137
+ keep_classnames?: boolean | RegExp
2138
+ keep_fargs?: boolean
2139
+ keep_fnames?: boolean | RegExp
2140
+ keep_infinity?: boolean
2141
+ loops?: boolean
2142
+ module?: boolean
2143
+ negate_iife?: boolean
2144
+ passes?: number
2145
+ properties?: boolean
2146
+ pure_funcs?: string[]
2147
+ pure_getters?: boolean | 'strict'
2148
+ reduce_funcs?: boolean
2149
+ reduce_vars?: boolean
2150
+ sequences?: boolean | number
2151
+ side_effects?: boolean
2152
+ switches?: boolean
2153
+ toplevel?: boolean
2154
+ top_retain?: null | string | string[] | RegExp
2155
+ typeofs?: boolean
2156
+ unsafe_arrows?: boolean
2157
+ unsafe?: boolean
2158
+ unsafe_comps?: boolean
2159
+ unsafe_Function?: boolean
2160
+ unsafe_math?: boolean
2161
+ unsafe_symbols?: boolean
2162
+ unsafe_methods?: boolean
2163
+ unsafe_proto?: boolean
2164
+ unsafe_regexp?: boolean
2165
+ unsafe_undefined?: boolean
2166
+ unused?: boolean
2167
+ }
2168
+
2169
+ export enum InlineFunctions {
2170
+ Disabled = 0,
2171
+ SimpleFunctions = 1,
2172
+ WithArguments = 2,
2173
+ WithArgumentsAndVariables = 3,
2174
+ }
2175
+
2176
+ export interface MangleOptions {
2177
+ eval?: boolean
2178
+ keep_classnames?: boolean | RegExp
2179
+ keep_fnames?: boolean | RegExp
2180
+ module?: boolean
2181
+ nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
2182
+ properties?: boolean | ManglePropertiesOptions
2183
+ reserved?: string[]
2184
+ safari10?: boolean
2185
+ toplevel?: boolean
2186
+ }
2187
+
2188
+ /**
2189
+ * An identifier mangler for which the output is invariant with respect to the source code.
2190
+ */
2191
+ export interface SimpleIdentifierMangler {
2192
+ /**
2193
+ * Obtains the nth most favored (usually shortest) identifier to rename a variable to.
2194
+ * The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
2195
+ * This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
2196
+ * @param n - The ordinal of the identifier.
2197
+ */
2198
+ get(n: number): string
2199
+ }
2200
+
2201
+ /**
2202
+ * An identifier mangler that leverages character frequency analysis to determine identifier precedence.
2203
+ */
2204
+ export interface WeightedIdentifierMangler extends SimpleIdentifierMangler {
2205
+ /**
2206
+ * Modifies the internal weighting of the input characters by the specified delta.
2207
+ * Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
2208
+ * @param chars - The characters to modify the weighting of.
2209
+ * @param delta - The numeric weight to add to the characters.
2210
+ */
2211
+ consider(chars: string, delta: number): number
2212
+ /**
2213
+ * Resets character weights.
2214
+ */
2215
+ reset(): void
2216
+ /**
2217
+ * Sorts identifiers by character frequency, in preparation for calls to get(n).
2218
+ */
2219
+ sort(): void
2220
+ }
2221
+
2222
+ export interface ManglePropertiesOptions {
2223
+ builtins?: boolean
2224
+ debug?: boolean
2225
+ keep_quoted?: boolean | 'strict'
2226
+ nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler
2227
+ regex?: RegExp | string
2228
+ reserved?: string[]
2229
+ }
2230
+
2231
+ export interface FormatOptions {
2232
+ ascii_only?: boolean
2233
+ /** @deprecated Not implemented anymore */
2234
+ beautify?: boolean
2235
+ braces?: boolean
2236
+ comments?:
2237
+ | boolean
2238
+ | 'all'
2239
+ | 'some'
2240
+ | RegExp
2241
+ | ((
2242
+ node: any,
2243
+ comment: {
2244
+ value: string
2245
+ type: 'comment1' | 'comment2' | 'comment3' | 'comment4'
2246
+ pos: number
2247
+ line: number
2248
+ col: number
2249
+ },
2250
+ ) => boolean)
2251
+ ecma?: ECMA
2252
+ ie8?: boolean
2253
+ keep_numbers?: boolean
2254
+ indent_level?: number
2255
+ indent_start?: number
2256
+ inline_script?: boolean
2257
+ keep_quoted_props?: boolean
2258
+ max_line_len?: number | false
2259
+ preamble?: string
2260
+ preserve_annotations?: boolean
2261
+ quote_keys?: boolean
2262
+ quote_style?: OutputQuoteStyle
2263
+ safari10?: boolean
2264
+ semicolons?: boolean
2265
+ shebang?: boolean
2266
+ shorthand?: boolean
2267
+ source_map?: SourceMapOptions
2268
+ webkit?: boolean
2269
+ width?: number
2270
+ wrap_iife?: boolean
2271
+ wrap_func_args?: boolean
2272
+ }
2273
+
2274
+ export enum OutputQuoteStyle {
2275
+ PreferDouble = 0,
2276
+ AlwaysSingle = 1,
2277
+ AlwaysDouble = 2,
2278
+ AlwaysOriginal = 3,
2279
+ }
2280
+
2281
+ export interface MinifyOptions {
2282
+ compress?: boolean | CompressOptions
2283
+ ecma?: ECMA
2284
+ enclose?: boolean | string
2285
+ ie8?: boolean
2286
+ keep_classnames?: boolean | RegExp
2287
+ keep_fnames?: boolean | RegExp
2288
+ mangle?: boolean | MangleOptions
2289
+ module?: boolean
2290
+ nameCache?: object
2291
+ format?: FormatOptions
2292
+ /** @deprecated deprecated */
2293
+ output?: FormatOptions
2294
+ parse?: ParseOptions
2295
+ safari10?: boolean
2296
+ sourceMap?: boolean | SourceMapOptions
2297
+ toplevel?: boolean
2298
+ }
2299
+
2300
+ export interface MinifyOutput {
2301
+ code?: string
2302
+ map?: object | string
2303
+ decoded_map?: object | null
2304
+ }
2305
+
2306
+ export interface SourceMapOptions {
2307
+ /** Source map object, 'inline' or source map file content */
2308
+ content?: object | string
2309
+ includeSources?: boolean
2310
+ filename?: string
2311
+ root?: string
2312
+ url?: string | 'inline'
2313
+ }
2314
+ }
2315
+
2316
+ export declare interface TransformOptions {
2317
+ ssr?: boolean;
2318
+ html?: boolean;
2319
+ }
2320
+
2321
+ export declare interface TransformResult {
2322
+ code: string;
2323
+ map: SourceMap | null;
2324
+ etag?: string;
2325
+ deps?: string[];
2326
+ dynamicDeps?: string[];
2327
+ }
2328
+
2329
+ export declare function transformWithEsbuild(code: string, filename: string, options?: EsbuildTransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
2330
+
2331
+ export { Update }
2332
+
2333
+ export { UpdatePayload }
2334
+
2335
+ export declare interface UserConfig {
2336
+ /**
2337
+ * Project root directory. Can be an absolute path, or a path relative from
2338
+ * the location of the config file itself.
2339
+ * @default process.cwd()
2340
+ */
2341
+ root?: string;
2342
+ /**
2343
+ * Base public path when served in development or production.
2344
+ * @default '/'
2345
+ */
2346
+ base?: string;
2347
+ /**
2348
+ * Directory to serve as plain static assets. Files in this directory are
2349
+ * served and copied to build dist dir as-is without transform. The value
2350
+ * can be either an absolute file system path or a path relative to project root.
2351
+ *
2352
+ * Set to `false` or an empty string to disable copied static assets to build dist dir.
2353
+ * @default 'public'
2354
+ */
2355
+ publicDir?: string | false;
2356
+ /**
2357
+ * Directory to save cache files. Files in this directory are pre-bundled
2358
+ * deps or some other cache files that generated by vite, which can improve
2359
+ * the performance. You can use `--force` flag or manually delete the directory
2360
+ * to regenerate the cache files. The value can be either an absolute file
2361
+ * system path or a path relative to project root.
2362
+ * Default to `.vite` when no `package.json` is detected.
2363
+ * @default 'node_modules/.vite'
2364
+ */
2365
+ cacheDir?: string;
2366
+ /**
2367
+ * Explicitly set a mode to run in. This will override the default mode for
2368
+ * each command, and can be overridden by the command line --mode option.
2369
+ */
2370
+ mode?: string;
2371
+ /**
2372
+ * Define global variable replacements.
2373
+ * Entries will be defined on `window` during dev and replaced during build.
2374
+ */
2375
+ define?: Record<string, any>;
2376
+ /**
2377
+ * Array of vite plugins to use.
2378
+ */
2379
+ plugins?: PluginOption[];
2380
+ /**
2381
+ * Configure resolver
2382
+ */
2383
+ resolve?: ResolveOptions & {
2384
+ alias?: AliasOptions;
2385
+ };
2386
+ /**
2387
+ * CSS related options (preprocessors and CSS modules)
2388
+ */
2389
+ css?: CSSOptions;
2390
+ /**
2391
+ * JSON loading options
2392
+ */
2393
+ json?: JsonOptions;
2394
+ /**
2395
+ * Transform options to pass to esbuild.
2396
+ * Or set to `false` to disable esbuild.
2397
+ */
2398
+ esbuild?: ESBuildOptions | false;
2399
+ /**
2400
+ * Specify additional picomatch patterns to be treated as static assets.
2401
+ */
2402
+ assetsInclude?: string | RegExp | (string | RegExp)[];
2403
+ /**
2404
+ * Server specific options, e.g. host, port, https...
2405
+ */
2406
+ server?: ServerOptions;
2407
+ /**
2408
+ * Build specific options
2409
+ */
2410
+ build?: BuildOptions;
2411
+ /**
2412
+ * Preview specific options, e.g. host, port, https...
2413
+ */
2414
+ preview?: PreviewOptions;
2415
+ /**
2416
+ * Dep optimization options
2417
+ */
2418
+ optimizeDeps?: DepOptimizationOptions;
2419
+ /**
2420
+ * SSR specific options
2421
+ */
2422
+ ssr?: SSROptions;
2423
+ /**
2424
+ * Experimental features
2425
+ *
2426
+ * Features under this field could change in the future and might NOT follow semver.
2427
+ * Please be careful and always pin Vite's version when using them.
2428
+ * @experimental
2429
+ */
2430
+ experimental?: ExperimentalOptions;
2431
+ /**
2432
+ * Legacy options
2433
+ *
2434
+ * Features under this field only follow semver for patches, they could be removed in a
2435
+ * future minor version. Please always pin Vite's version to a minor when using them.
2436
+ */
2437
+ legacy?: LegacyOptions;
2438
+ /**
2439
+ * Log level.
2440
+ * Default: 'info'
2441
+ */
2442
+ logLevel?: LogLevel;
2443
+ /**
2444
+ * Custom logger.
2445
+ */
2446
+ customLogger?: Logger;
2447
+ /**
2448
+ * Default: true
2449
+ */
2450
+ clearScreen?: boolean;
2451
+ /**
2452
+ * Environment files directory. Can be an absolute path, or a path relative from
2453
+ * the location of the config file itself.
2454
+ * @default root
2455
+ */
2456
+ envDir?: string;
2457
+ /**
2458
+ * Env variables starts with `envPrefix` will be exposed to your client source code via import.meta.env.
2459
+ * @default 'VITE_'
2460
+ */
2461
+ envPrefix?: string | string[];
2462
+ /**
2463
+ * Worker bundle options
2464
+ */
2465
+ worker?: {
2466
+ /**
2467
+ * Output format for worker bundle
2468
+ * @default 'iife'
2469
+ */
2470
+ format?: 'es' | 'iife';
2471
+ /**
2472
+ * Vite plugins that apply to worker bundle
2473
+ */
2474
+ plugins?: PluginOption[];
2475
+ /**
2476
+ * Rollup options to build worker bundle
2477
+ */
2478
+ rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
2479
+ };
2480
+ /**
2481
+ * Whether your application is a Single Page Application (SPA),
2482
+ * a Multi-Page Application (MPA), or Custom Application (SSR
2483
+ * and frameworks with custom HTML handling)
2484
+ * @default 'spa'
2485
+ */
2486
+ appType?: AppType;
2487
+ }
2488
+
2489
+ export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
2490
+
2491
+ export declare type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
2492
+
2493
+ export declare const version: string;
2494
+
2495
+ export declare interface ViteDevServer {
2496
+ /**
2497
+ * The resolved vite config object
2498
+ */
2499
+ config: ResolvedConfig;
2500
+ /**
2501
+ * A connect app instance.
2502
+ * - Can be used to attach custom middlewares to the dev server.
2503
+ * - Can also be used as the handler function of a custom http server
2504
+ * or as a middleware in any connect-style Node.js frameworks
2505
+ *
2506
+ * https://github.com/senchalabs/connect#use-middleware
2507
+ */
2508
+ middlewares: Connect.Server;
2509
+ /**
2510
+ * native Node http server instance
2511
+ * will be null in middleware mode
2512
+ */
2513
+ httpServer: http.Server | null;
2514
+ /**
2515
+ * chokidar watcher instance
2516
+ * https://github.com/paulmillr/chokidar#api
2517
+ */
2518
+ watcher: FSWatcher;
2519
+ /**
2520
+ * web socket server with `send(payload)` method
2521
+ */
2522
+ ws: WebSocketServer;
2523
+ /**
2524
+ * Rollup plugin container that can run plugin hooks on a given file
2525
+ */
2526
+ pluginContainer: PluginContainer;
2527
+ /**
2528
+ * Module graph that tracks the import relationships, url to file mapping
2529
+ * and hmr state.
2530
+ */
2531
+ moduleGraph: ModuleGraph;
2532
+ /**
2533
+ * The resolved urls Vite prints on the CLI. null in middleware mode or
2534
+ * before `server.listen` is called.
2535
+ */
2536
+ resolvedUrls: ResolvedServerUrls | null;
2537
+ /**
2538
+ * Programmatically resolve, load and transform a URL and get the result
2539
+ * without going through the http request pipeline.
2540
+ */
2541
+ transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
2542
+ /**
2543
+ * Apply vite built-in HTML transforms and any plugin HTML transforms.
2544
+ */
2545
+ transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
2546
+ /**
2547
+ * Transform module code into SSR format.
2548
+ */
2549
+ ssrTransform(code: string, inMap: SourceMap | null, url: string, originalCode?: string): Promise<TransformResult | null>;
2550
+ /**
2551
+ * Load a given URL as an instantiated module for SSR.
2552
+ */
2553
+ ssrLoadModule(url: string, opts?: {
2554
+ fixStacktrace?: boolean;
2555
+ }): Promise<Record<string, any>>;
2556
+ /**
2557
+ * Returns a fixed version of the given stack
2558
+ */
2559
+ ssrRewriteStacktrace(stack: string): string;
2560
+ /**
2561
+ * Mutates the given SSR error by rewriting the stacktrace
2562
+ */
2563
+ ssrFixStacktrace(e: Error): void;
2564
+ /**
2565
+ * Triggers HMR for a module in the module graph. You can use the `server.moduleGraph`
2566
+ * API to retrieve the module to be reloaded. If `hmr` is false, this is a no-op.
2567
+ */
2568
+ reloadModule(module: ModuleNode): Promise<void>;
2569
+ /**
2570
+ * Start the server.
2571
+ */
2572
+ listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
2573
+ /**
2574
+ * Stop the server.
2575
+ */
2576
+ close(): Promise<void>;
2577
+ /**
2578
+ * Print server urls
2579
+ */
2580
+ printUrls(): void;
2581
+ /**
2582
+ * Restart the server.
2583
+ *
2584
+ * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
2585
+ */
2586
+ restart(forceOptimize?: boolean): Promise<void>;
2587
+ /* Excluded from this release type: _importGlobMap */
2588
+ /* Excluded from this release type: _ssrExternals */
2589
+ /* Excluded from this release type: _restartPromise */
2590
+ /* Excluded from this release type: _forceOptimizeOnRestart */
2591
+ /* Excluded from this release type: _pendingRequests */
2592
+ /* Excluded from this release type: _fsDenyGlob */
2593
+ /* Excluded from this release type: _shortcutsOptions */
2594
+ }
2595
+
2596
+ export declare interface WatchOptions {
2597
+ /**
2598
+ * Indicates whether the process should continue to run as long as files are being watched. If
2599
+ * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`,
2600
+ * even if the process continues to run.
2601
+ */
2602
+ persistent?: boolean
2603
+
2604
+ /**
2605
+ * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
2606
+ * be ignored. The whole relative or absolute path is tested, not just filename. If a function
2607
+ * with two arguments is provided, it gets called twice per path - once with a single argument
2608
+ * (the path), second time with two arguments (the path and the
2609
+ * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
2610
+ */
2611
+ ignored?: Matcher
2612
+
2613
+ /**
2614
+ * If set to `false` then `add`/`addDir` events are also emitted for matching paths while
2615
+ * instantiating the watching as chokidar discovers these file paths (before the `ready` event).
2616
+ */
2617
+ ignoreInitial?: boolean
2618
+
2619
+ /**
2620
+ * When `false`, only the symlinks themselves will be watched for changes instead of following
2621
+ * the link references and bubbling events through the link's path.
2622
+ */
2623
+ followSymlinks?: boolean
2624
+
2625
+ /**
2626
+ * The base directory from which watch `paths` are to be derived. Paths emitted with events will
2627
+ * be relative to this.
2628
+ */
2629
+ cwd?: string
2630
+
2631
+ /**
2632
+ * If set to true then the strings passed to .watch() and .add() are treated as literal path
2633
+ * names, even if they look like globs.
2634
+ *
2635
+ * @default false
2636
+ */
2637
+ disableGlobbing?: boolean
2638
+
2639
+ /**
2640
+ * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
2641
+ * utilization, consider setting this to `false`. It is typically necessary to **set this to
2642
+ * `true` to successfully watch files over a network**, and it may be necessary to successfully
2643
+ * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides
2644
+ * the `useFsEvents` default.
2645
+ */
2646
+ usePolling?: boolean
2647
+
2648
+ /**
2649
+ * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
2650
+ * and `fsevents` is available this supercedes the `usePolling` setting. When set to `false` on
2651
+ * OS X, `usePolling: true` becomes the default.
2652
+ */
2653
+ useFsEvents?: boolean
2654
+
2655
+ /**
2656
+ * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
2657
+ * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
2658
+ * provided even in cases where it wasn't already available from the underlying watch events.
2659
+ */
2660
+ alwaysStat?: boolean
2661
+
2662
+ /**
2663
+ * If set, limits how many levels of subdirectories will be traversed.
2664
+ */
2665
+ depth?: number
2666
+
2667
+ /**
2668
+ * Interval of file system polling.
2669
+ */
2670
+ interval?: number
2671
+
2672
+ /**
2673
+ * Interval of file system polling for binary files. ([see list of binary extensions](https://gi
2674
+ * thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
2675
+ */
2676
+ binaryInterval?: number
2677
+
2678
+ /**
2679
+ * Indicates whether to watch files that don't have read permissions if possible. If watching
2680
+ * fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed
2681
+ * silently.
2682
+ */
2683
+ ignorePermissionErrors?: boolean
2684
+
2685
+ /**
2686
+ * `true` if `useFsEvents` and `usePolling` are `false`. Automatically filters out artifacts
2687
+ * that occur when using editors that use "atomic writes" instead of writing directly to the
2688
+ * source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change`
2689
+ * event rather than `unlink` then `add`. If the default of 100 ms does not work well for you,
2690
+ * you can override it by setting `atomic` to a custom value, in milliseconds.
2691
+ */
2692
+ atomic?: boolean | number
2693
+
2694
+ /**
2695
+ * can be set to an object in order to adjust timing params:
2696
+ */
2697
+ awaitWriteFinish?: AwaitWriteFinishOptions | boolean
2698
+ }
2699
+
2700
+ declare class WebSocket_2 extends EventEmitter {
2701
+ /** The connection is not yet open. */
2702
+ static readonly CONNECTING: 0
2703
+ /** The connection is open and ready to communicate. */
2704
+ static readonly OPEN: 1
2705
+ /** The connection is in the process of closing. */
2706
+ static readonly CLOSING: 2
2707
+ /** The connection is closed. */
2708
+ static readonly CLOSED: 3
2709
+
2710
+ binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'
2711
+ readonly bufferedAmount: number
2712
+ readonly extensions: string
2713
+ /** Indicates whether the websocket is paused */
2714
+ readonly isPaused: boolean
2715
+ readonly protocol: string
2716
+ /** The current state of the connection */
2717
+ readonly readyState:
2718
+ | typeof WebSocket_2.CONNECTING
2719
+ | typeof WebSocket_2.OPEN
2720
+ | typeof WebSocket_2.CLOSING
2721
+ | typeof WebSocket_2.CLOSED
2722
+ readonly url: string
2723
+
2724
+ /** The connection is not yet open. */
2725
+ readonly CONNECTING: 0
2726
+ /** The connection is open and ready to communicate. */
2727
+ readonly OPEN: 1
2728
+ /** The connection is in the process of closing. */
2729
+ readonly CLOSING: 2
2730
+ /** The connection is closed. */
2731
+ readonly CLOSED: 3
2732
+
2733
+ onopen: ((event: WebSocket_2.Event) => void) | null
2734
+ onerror: ((event: WebSocket_2.ErrorEvent) => void) | null
2735
+ onclose: ((event: WebSocket_2.CloseEvent) => void) | null
2736
+ onmessage: ((event: WebSocket_2.MessageEvent) => void) | null
2737
+
2738
+ constructor(address: null)
2739
+ constructor(
2740
+ address: string | URL_2,
2741
+ options?: WebSocket_2.ClientOptions | ClientRequestArgs,
2742
+ )
2743
+ constructor(
2744
+ address: string | URL_2,
2745
+ protocols?: string | string[],
2746
+ options?: WebSocket_2.ClientOptions | ClientRequestArgs,
2747
+ )
2748
+
2749
+ close(code?: number, data?: string | Buffer): void
2750
+ ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void
2751
+ pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void
2752
+ send(data: any, cb?: (err?: Error) => void): void
2753
+ send(
2754
+ data: any,
2755
+ options: {
2756
+ mask?: boolean | undefined
2757
+ binary?: boolean | undefined
2758
+ compress?: boolean | undefined
2759
+ fin?: boolean | undefined
2760
+ },
2761
+ cb?: (err?: Error) => void,
2762
+ ): void
2763
+ terminate(): void
2764
+
2765
+ /**
2766
+ * Pause the websocket causing it to stop emitting events. Some events can still be
2767
+ * emitted after this is called, until all buffered data is consumed. This method
2768
+ * is a noop if the ready state is `CONNECTING` or `CLOSED`.
2769
+ */
2770
+ pause(): void
2771
+ /**
2772
+ * Make a paused socket resume emitting events. This method is a noop if the ready
2773
+ * state is `CONNECTING` or `CLOSED`.
2774
+ */
2775
+ resume(): void
2776
+
2777
+ // HTML5 WebSocket events
2778
+ addEventListener(
2779
+ method: 'message',
2780
+ cb: (event: WebSocket_2.MessageEvent) => void,
2781
+ options?: WebSocket_2.EventListenerOptions,
2782
+ ): void
2783
+ addEventListener(
2784
+ method: 'close',
2785
+ cb: (event: WebSocket_2.CloseEvent) => void,
2786
+ options?: WebSocket_2.EventListenerOptions,
2787
+ ): void
2788
+ addEventListener(
2789
+ method: 'error',
2790
+ cb: (event: WebSocket_2.ErrorEvent) => void,
2791
+ options?: WebSocket_2.EventListenerOptions,
2792
+ ): void
2793
+ addEventListener(
2794
+ method: 'open',
2795
+ cb: (event: WebSocket_2.Event) => void,
2796
+ options?: WebSocket_2.EventListenerOptions,
2797
+ ): void
2798
+
2799
+ removeEventListener(
2800
+ method: 'message',
2801
+ cb: (event: WebSocket_2.MessageEvent) => void,
2802
+ ): void
2803
+ removeEventListener(
2804
+ method: 'close',
2805
+ cb: (event: WebSocket_2.CloseEvent) => void,
2806
+ ): void
2807
+ removeEventListener(
2808
+ method: 'error',
2809
+ cb: (event: WebSocket_2.ErrorEvent) => void,
2810
+ ): void
2811
+ removeEventListener(
2812
+ method: 'open',
2813
+ cb: (event: WebSocket_2.Event) => void,
2814
+ ): void
2815
+
2816
+ // Events
2817
+ on(
2818
+ event: 'close',
2819
+ listener: (this: WebSocket_2, code: number, reason: Buffer) => void,
2820
+ ): this
2821
+ on(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
2822
+ on(
2823
+ event: 'upgrade',
2824
+ listener: (this: WebSocket_2, request: IncomingMessage) => void,
2825
+ ): this
2826
+ on(
2827
+ event: 'message',
2828
+ listener: (
2829
+ this: WebSocket_2,
2830
+ data: WebSocket_2.RawData,
2831
+ isBinary: boolean,
2832
+ ) => void,
2833
+ ): this
2834
+ on(event: 'open', listener: (this: WebSocket_2) => void): this
2835
+ on(
2836
+ event: 'ping' | 'pong',
2837
+ listener: (this: WebSocket_2, data: Buffer) => void,
2838
+ ): this
2839
+ on(
2840
+ event: 'unexpected-response',
2841
+ listener: (
2842
+ this: WebSocket_2,
2843
+ request: ClientRequest,
2844
+ response: IncomingMessage,
2845
+ ) => void,
2846
+ ): this
2847
+ on(
2848
+ event: string | symbol,
2849
+ listener: (this: WebSocket_2, ...args: any[]) => void,
2850
+ ): this
2851
+
2852
+ once(
2853
+ event: 'close',
2854
+ listener: (this: WebSocket_2, code: number, reason: Buffer) => void,
2855
+ ): this
2856
+ once(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
2857
+ once(
2858
+ event: 'upgrade',
2859
+ listener: (this: WebSocket_2, request: IncomingMessage) => void,
2860
+ ): this
2861
+ once(
2862
+ event: 'message',
2863
+ listener: (
2864
+ this: WebSocket_2,
2865
+ data: WebSocket_2.RawData,
2866
+ isBinary: boolean,
2867
+ ) => void,
2868
+ ): this
2869
+ once(event: 'open', listener: (this: WebSocket_2) => void): this
2870
+ once(
2871
+ event: 'ping' | 'pong',
2872
+ listener: (this: WebSocket_2, data: Buffer) => void,
2873
+ ): this
2874
+ once(
2875
+ event: 'unexpected-response',
2876
+ listener: (
2877
+ this: WebSocket_2,
2878
+ request: ClientRequest,
2879
+ response: IncomingMessage,
2880
+ ) => void,
2881
+ ): this
2882
+ once(
2883
+ event: string | symbol,
2884
+ listener: (this: WebSocket_2, ...args: any[]) => void,
2885
+ ): this
2886
+
2887
+ off(
2888
+ event: 'close',
2889
+ listener: (this: WebSocket_2, code: number, reason: Buffer) => void,
2890
+ ): this
2891
+ off(event: 'error', listener: (this: WebSocket_2, err: Error) => void): this
2892
+ off(
2893
+ event: 'upgrade',
2894
+ listener: (this: WebSocket_2, request: IncomingMessage) => void,
2895
+ ): this
2896
+ off(
2897
+ event: 'message',
2898
+ listener: (
2899
+ this: WebSocket_2,
2900
+ data: WebSocket_2.RawData,
2901
+ isBinary: boolean,
2902
+ ) => void,
2903
+ ): this
2904
+ off(event: 'open', listener: (this: WebSocket_2) => void): this
2905
+ off(
2906
+ event: 'ping' | 'pong',
2907
+ listener: (this: WebSocket_2, data: Buffer) => void,
2908
+ ): this
2909
+ off(
2910
+ event: 'unexpected-response',
2911
+ listener: (
2912
+ this: WebSocket_2,
2913
+ request: ClientRequest,
2914
+ response: IncomingMessage,
2915
+ ) => void,
2916
+ ): this
2917
+ off(
2918
+ event: string | symbol,
2919
+ listener: (this: WebSocket_2, ...args: any[]) => void,
2920
+ ): this
2921
+
2922
+ addListener(
2923
+ event: 'close',
2924
+ listener: (code: number, reason: Buffer) => void,
2925
+ ): this
2926
+ addListener(event: 'error', listener: (err: Error) => void): this
2927
+ addListener(
2928
+ event: 'upgrade',
2929
+ listener: (request: IncomingMessage) => void,
2930
+ ): this
2931
+ addListener(
2932
+ event: 'message',
2933
+ listener: (data: WebSocket_2.RawData, isBinary: boolean) => void,
2934
+ ): this
2935
+ addListener(event: 'open', listener: () => void): this
2936
+ addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
2937
+ addListener(
2938
+ event: 'unexpected-response',
2939
+ listener: (request: ClientRequest, response: IncomingMessage) => void,
2940
+ ): this
2941
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this
2942
+
2943
+ removeListener(
2944
+ event: 'close',
2945
+ listener: (code: number, reason: Buffer) => void,
2946
+ ): this
2947
+ removeListener(event: 'error', listener: (err: Error) => void): this
2948
+ removeListener(
2949
+ event: 'upgrade',
2950
+ listener: (request: IncomingMessage) => void,
2951
+ ): this
2952
+ removeListener(
2953
+ event: 'message',
2954
+ listener: (data: WebSocket_2.RawData, isBinary: boolean) => void,
2955
+ ): this
2956
+ removeListener(event: 'open', listener: () => void): this
2957
+ removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this
2958
+ removeListener(
2959
+ event: 'unexpected-response',
2960
+ listener: (request: ClientRequest, response: IncomingMessage) => void,
2961
+ ): this
2962
+ removeListener(
2963
+ event: string | symbol,
2964
+ listener: (...args: any[]) => void,
2965
+ ): this
2966
+ }
2967
+
2968
+ declare namespace WebSocket_2 {
2969
+ /**
2970
+ * Data represents the raw message payload received over the WebSocket.
2971
+ */
2972
+ type RawData = Buffer | ArrayBuffer | Buffer[]
2973
+
2974
+ /**
2975
+ * Data represents the message payload received over the WebSocket.
2976
+ */
2977
+ type Data = string | Buffer | ArrayBuffer | Buffer[]
2978
+
2979
+ /**
2980
+ * CertMeta represents the accepted types for certificate & key data.
2981
+ */
2982
+ type CertMeta = string | string[] | Buffer | Buffer[]
2983
+
2984
+ /**
2985
+ * VerifyClientCallbackSync is a synchronous callback used to inspect the
2986
+ * incoming message. The return value (boolean) of the function determines
2987
+ * whether or not to accept the handshake.
2988
+ */
2989
+ type VerifyClientCallbackSync = (info: {
2990
+ origin: string
2991
+ secure: boolean
2992
+ req: IncomingMessage
2993
+ }) => boolean
2994
+
2995
+ /**
2996
+ * VerifyClientCallbackAsync is an asynchronous callback used to inspect the
2997
+ * incoming message. The return value (boolean) of the function determines
2998
+ * whether or not to accept the handshake.
2999
+ */
3000
+ type VerifyClientCallbackAsync = (
3001
+ info: { origin: string; secure: boolean; req: IncomingMessage },
3002
+ callback: (
3003
+ res: boolean,
3004
+ code?: number,
3005
+ message?: string,
3006
+ headers?: OutgoingHttpHeaders,
3007
+ ) => void,
3008
+ ) => void
3009
+
3010
+ interface ClientOptions extends SecureContextOptions {
3011
+ protocol?: string | undefined
3012
+ followRedirects?: boolean | undefined
3013
+ generateMask?(mask: Buffer): void
3014
+ handshakeTimeout?: number | undefined
3015
+ maxRedirects?: number | undefined
3016
+ perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
3017
+ localAddress?: string | undefined
3018
+ protocolVersion?: number | undefined
3019
+ headers?: { [key: string]: string } | undefined
3020
+ origin?: string | undefined
3021
+ agent?: Agent | undefined
3022
+ host?: string | undefined
3023
+ family?: number | undefined
3024
+ checkServerIdentity?(servername: string, cert: CertMeta): boolean
3025
+ rejectUnauthorized?: boolean | undefined
3026
+ maxPayload?: number | undefined
3027
+ skipUTF8Validation?: boolean | undefined
3028
+ }
3029
+
3030
+ interface PerMessageDeflateOptions {
3031
+ serverNoContextTakeover?: boolean | undefined
3032
+ clientNoContextTakeover?: boolean | undefined
3033
+ serverMaxWindowBits?: number | undefined
3034
+ clientMaxWindowBits?: number | undefined
3035
+ zlibDeflateOptions?:
3036
+ | {
3037
+ flush?: number | undefined
3038
+ finishFlush?: number | undefined
3039
+ chunkSize?: number | undefined
3040
+ windowBits?: number | undefined
3041
+ level?: number | undefined
3042
+ memLevel?: number | undefined
3043
+ strategy?: number | undefined
3044
+ dictionary?: Buffer | Buffer[] | DataView | undefined
3045
+ info?: boolean | undefined
3046
+ }
3047
+ | undefined
3048
+ zlibInflateOptions?: ZlibOptions | undefined
3049
+ threshold?: number | undefined
3050
+ concurrencyLimit?: number | undefined
3051
+ }
3052
+
3053
+ interface Event {
3054
+ type: string
3055
+ target: WebSocket
3056
+ }
3057
+
3058
+ interface ErrorEvent {
3059
+ error: any
3060
+ message: string
3061
+ type: string
3062
+ target: WebSocket
3063
+ }
3064
+
3065
+ interface CloseEvent {
3066
+ wasClean: boolean
3067
+ code: number
3068
+ reason: string
3069
+ type: string
3070
+ target: WebSocket
3071
+ }
3072
+
3073
+ interface MessageEvent {
3074
+ data: Data
3075
+ type: string
3076
+ target: WebSocket
3077
+ }
3078
+
3079
+ interface EventListenerOptions {
3080
+ once?: boolean | undefined
3081
+ }
3082
+
3083
+ interface ServerOptions {
3084
+ host?: string | undefined
3085
+ port?: number | undefined
3086
+ backlog?: number | undefined
3087
+ server?: Server | Server_2 | undefined
3088
+ verifyClient?:
3089
+ | VerifyClientCallbackAsync
3090
+ | VerifyClientCallbackSync
3091
+ | undefined
3092
+ handleProtocols?: (
3093
+ protocols: Set<string>,
3094
+ request: IncomingMessage,
3095
+ ) => string | false
3096
+ path?: string | undefined
3097
+ noServer?: boolean | undefined
3098
+ clientTracking?: boolean | undefined
3099
+ perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined
3100
+ maxPayload?: number | undefined
3101
+ skipUTF8Validation?: boolean | undefined
3102
+ WebSocket?: typeof WebSocket.WebSocket | undefined
3103
+ }
3104
+
3105
+ interface AddressInfo {
3106
+ address: string
3107
+ family: string
3108
+ port: number
3109
+ }
3110
+
3111
+ // WebSocket Server
3112
+ class Server<T extends WebSocket = WebSocket> extends EventEmitter {
3113
+ options: ServerOptions
3114
+ path: string
3115
+ clients: Set<T>
3116
+
3117
+ constructor(options?: ServerOptions, callback?: () => void)
3118
+
3119
+ address(): AddressInfo | string
3120
+ close(cb?: (err?: Error) => void): void
3121
+ handleUpgrade(
3122
+ request: IncomingMessage,
3123
+ socket: Duplex,
3124
+ upgradeHead: Buffer,
3125
+ callback: (client: T, request: IncomingMessage) => void,
3126
+ ): void
3127
+ shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
3128
+
3129
+ // Events
3130
+ on(
3131
+ event: 'connection',
3132
+ cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
3133
+ ): this
3134
+ on(event: 'error', cb: (this: Server<T>, error: Error) => void): this
3135
+ on(
3136
+ event: 'headers',
3137
+ cb: (
3138
+ this: Server<T>,
3139
+ headers: string[],
3140
+ request: IncomingMessage,
3141
+ ) => void,
3142
+ ): this
3143
+ on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
3144
+ on(
3145
+ event: string | symbol,
3146
+ listener: (this: Server<T>, ...args: any[]) => void,
3147
+ ): this
3148
+
3149
+ once(
3150
+ event: 'connection',
3151
+ cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
3152
+ ): this
3153
+ once(event: 'error', cb: (this: Server<T>, error: Error) => void): this
3154
+ once(
3155
+ event: 'headers',
3156
+ cb: (
3157
+ this: Server<T>,
3158
+ headers: string[],
3159
+ request: IncomingMessage,
3160
+ ) => void,
3161
+ ): this
3162
+ once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
3163
+ once(
3164
+ event: string | symbol,
3165
+ listener: (this: Server<T>, ...args: any[]) => void,
3166
+ ): this
3167
+
3168
+ off(
3169
+ event: 'connection',
3170
+ cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
3171
+ ): this
3172
+ off(event: 'error', cb: (this: Server<T>, error: Error) => void): this
3173
+ off(
3174
+ event: 'headers',
3175
+ cb: (
3176
+ this: Server<T>,
3177
+ headers: string[],
3178
+ request: IncomingMessage,
3179
+ ) => void,
3180
+ ): this
3181
+ off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this
3182
+ off(
3183
+ event: string | symbol,
3184
+ listener: (this: Server<T>, ...args: any[]) => void,
3185
+ ): this
3186
+
3187
+ addListener(
3188
+ event: 'connection',
3189
+ cb: (client: T, request: IncomingMessage) => void,
3190
+ ): this
3191
+ addListener(event: 'error', cb: (err: Error) => void): this
3192
+ addListener(
3193
+ event: 'headers',
3194
+ cb: (headers: string[], request: IncomingMessage) => void,
3195
+ ): this
3196
+ addListener(event: 'close' | 'listening', cb: () => void): this
3197
+ addListener(
3198
+ event: string | symbol,
3199
+ listener: (...args: any[]) => void,
3200
+ ): this
3201
+
3202
+ removeListener(event: 'connection', cb: (client: T) => void): this
3203
+ removeListener(event: 'error', cb: (err: Error) => void): this
3204
+ removeListener(
3205
+ event: 'headers',
3206
+ cb: (headers: string[], request: IncomingMessage) => void,
3207
+ ): this
3208
+ removeListener(event: 'close' | 'listening', cb: () => void): this
3209
+ removeListener(
3210
+ event: string | symbol,
3211
+ listener: (...args: any[]) => void,
3212
+ ): this
3213
+ }
3214
+
3215
+ const WebSocketServer: typeof Server
3216
+ interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
3217
+ const WebSocket: typeof WebSocketAlias
3218
+ interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
3219
+
3220
+ // WebSocket stream
3221
+ function createWebSocketStream(
3222
+ websocket: WebSocket,
3223
+ options?: DuplexOptions,
3224
+ ): Duplex
3225
+ }
3226
+ export { WebSocket_2 as WebSocket }
3227
+
3228
+ export declare const WebSocketAlias: typeof WebSocket_2;
3229
+
3230
+ export declare interface WebSocketAlias extends WebSocket_2 {}
3231
+
3232
+ export declare interface WebSocketClient {
3233
+ /**
3234
+ * Send event to the client
3235
+ */
3236
+ send(payload: HMRPayload): void;
3237
+ /**
3238
+ * Send custom event
3239
+ */
3240
+ send(event: string, payload?: CustomPayload['data']): void;
3241
+ /**
3242
+ * The raw WebSocket instance
3243
+ * @advanced
3244
+ */
3245
+ socket: WebSocket_2;
3246
+ }
3247
+
3248
+ export declare type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
3249
+
3250
+ export declare interface WebSocketServer {
3251
+ /**
3252
+ * Get all connected clients.
3253
+ */
3254
+ clients: Set<WebSocketClient>;
3255
+ /**
3256
+ * Broadcast events to all clients
3257
+ */
3258
+ send(payload: HMRPayload): void;
3259
+ /**
3260
+ * Send custom event
3261
+ */
3262
+ send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void;
3263
+ /**
3264
+ * Disconnect all clients and terminate the server.
3265
+ */
3266
+ close(): Promise<void>;
3267
+ /**
3268
+ * Handle custom event emitted by `import.meta.hot.send`
3269
+ */
3270
+ on: WebSocket_2.Server['on'] & {
3271
+ <T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
3272
+ };
3273
+ /**
3274
+ * Unregister event listener.
3275
+ */
3276
+ off: WebSocket_2.Server['off'] & {
3277
+ (event: string, listener: Function): void;
3278
+ };
3279
+ }
3280
+
3281
+ export { }