ipsased
Version:
UI toolkit monorepo containing a React component library, UI utilities, a drag-and-drop library, and more
1,458 lines (1,328 loc) • 122 kB
TypeScript
/// <reference types="node" />
import type { Agent } from 'node:http';
import type { BuildOptions as BuildOptions_2 } from 'esbuild';
import { ChunkMetadata } from "../../types/metadata.js";
import type { ClientRequest } from 'node:http';
import type { ClientRequestArgs } from 'node:http';
import { ConnectedPayload } from "../../types/hmrPayload.js";
import { CustomEventMap } from "../../types/customEvent.js";
import { CustomPayload } from "../../types/hmrPayload.js";
import type { CustomPluginOptions } from 'rollup';
import type { Duplex } from 'node:stream';
import type { DuplexOptions } from 'node:stream';
import { ErrorPayload } from "../../types/hmrPayload.js";
import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
import { version as esbuildVersion } from 'esbuild';
import { EventEmitter } from 'node:events';
import * as events from 'node:events';
import type { ExistingRawSourceMap } from 'rollup';
import type * as fs from 'node:fs';
import { FullReloadPayload } from "../../types/hmrPayload.js";
import { GeneralImportGlobOptions } from "../../types/importGlob.js";
import type { GetManualChunk } from 'rollup';
import { HMRPayload } from "../../types/hmrPayload.js";
import * as http from 'node:http';
import { ImportGlobEagerFunction } from "../../types/importGlob.js";
import { ImportGlobFunction } from "../../types/importGlob.js";
import { ImportGlobOptions } from "../../types/importGlob.js";
import type { IncomingMessage } from 'node:http';
import { InferCustomEventPayload } from "../../types/customEvent.js";
import type { InputOption } from 'rollup';
import type { InputOptions } from 'rollup';
import { InvalidatePayload } from "../../types/customEvent.js";
import { KnownAsTypeMap } from "../../types/importGlob.js";
import type { LoadResult } from 'rollup';
import type { ModuleFormat } from 'rollup';
import type { ModuleInfo } from 'rollup';
import type * as net from 'node:net';
import type { ObjectHook } from 'rollup';
import type { OutgoingHttpHeaders } from 'node:http';
import type { OutputBundle } from 'rollup';
import type { OutputChunk } from 'rollup';
import type { PartialResolvedId } from 'rollup';
import type { Plugin as Plugin_3 } from 'rollup';
import type { PluginContext } from 'rollup';
import type { PluginHooks } from 'rollup';
import type * as PostCSS from 'postcss';
import { PrunePayload } from "../../types/hmrPayload.js";
import type { ResolveIdResult } from 'rollup';
import type * as Rollup from 'rollup';
import type { RollupError } from 'rollup';
import type { RollupOptions } from 'rollup';
import type { RollupOutput } from 'rollup';
import { VERSION as rollupVersion } from 'rollup';
import type { RollupWatcher } from 'rollup';
import type { SecureContextOptions } from 'node:tls';
import type { Server } from 'node:http';
import type { Server as Server_2 } from 'node:https';
import type { ServerOptions as ServerOptions_2 } from 'node:https';
import type { ServerResponse } from 'node:http';
import type { SourceDescription } from 'rollup';
import type { SourceMap } from 'rollup';
import type { SourceMapInput } from 'rollup';
import type * as stream from 'node:stream';
import type { TransformPluginContext } from 'rollup';
import type { TransformResult as TransformResult_2 } from 'rollup';
import type { TransformResult as TransformResult_3 } from 'esbuild';
import { Update } from "../../types/hmrPayload.js";
import { UpdatePayload } from "../../types/hmrPayload.js";
import type * as url from 'node:url';
import type { URL as URL_2 } from 'node:url';
import type { WatcherOptions } from 'rollup';
import type { ZlibOptions } from 'node:zlib';
export declare interface Alias {
find: string | RegExp
replacement: string
/**
* Instructs the plugin to use an alternative resolving algorithm,
* rather than the Rollup's resolver.
* @default null
*/
customResolver?: ResolverFunction | ResolverObject | null
}
/**
* Specifies an `Object`, or an `Array` of `Object`,
* which defines aliases used to replace values in `import` or `require` statements.
* With either format, the order of the entries is important,
* in that the first defined rules are applied first.
*
* This is passed to \@rollup/plugin-alias as the "entries" field
* https://github.com/rollup/plugins/tree/master/packages/alias#entries
*/
export declare type AliasOptions = readonly Alias[] | { [find: string]: string }
export declare type AnymatchFn = (testString: string) => boolean
export declare type AnymatchPattern = string | RegExp | AnymatchFn
/**
* spa: include SPA fallback middleware and configure sirv with `single: true` in preview
*
* mpa: only include non-SPA HTML middlewares
*
* custom: don't include HTML middlewares
*/
export declare type AppType = 'spa' | 'mpa' | 'custom';
export declare interface AwaitWriteFinishOptions {
/**
* Amount of time in milliseconds for a file size to remain constant before emitting its event.
*/
stabilityThreshold?: number
/**
* File size polling interval.
*/
pollInterval?: number
}
/**
* Bundles the app for production.
* Returns a Promise containing the build result.
*/
export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
export declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
export declare interface BuildOptions {
/**
* Compatibility transform target. The transform is performed with esbuild
* and the lowest supported target is es2015/es6. Note this only handles
* syntax transformation and does not cover polyfills (except for dynamic
* import)
*
* Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
* transpile targeting browsers that natively support dynamic es module imports.
* https://caniuse.com/es6-module-dynamic-import
*
* Another special value is 'esnext' - which only performs minimal transpiling
* (for minification compat) and assumes native dynamic imports support.
*
* For custom targets, see https://esbuild.github.io/api/#target and
* https://esbuild.github.io/content-types/#javascript for more details.
* @default 'modules'
*/
target?: 'modules' | EsbuildTransformOptions['target'] | false;
/**
* whether to inject module preload polyfill.
* Note: does not apply to library mode.
* @default true
* @deprecated use `modulePreload.polyfill` instead
*/
polyfillModulePreload?: boolean;
/**
* Configure module preload
* Note: does not apply to library mode.
* @default true
*/
modulePreload?: boolean | ModulePreloadOptions;
/**
* Directory relative from `root` where build output will be placed. If the
* directory exists, it will be removed before the build.
* @default 'dist'
*/
outDir?: string;
/**
* Directory relative from `outDir` where the built js/css/image assets will
* be placed.
* @default 'assets'
*/
assetsDir?: string;
/**
* Static asset files smaller than this number (in bytes) will be inlined as
* base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
* @default 4096
*/
assetsInlineLimit?: number;
/**
* Whether to code-split CSS. When enabled, CSS in async chunks will be
* inlined as strings in the chunk and inserted via dynamically created
* style tags when the chunk is loaded.
* @default true
*/
cssCodeSplit?: boolean;
/**
* An optional separate target for CSS minification.
* As esbuild only supports configuring targets to mainstream
* browsers, users may need this option when they are targeting
* a niche browser that comes with most modern JavaScript features
* but has poor CSS support, e.g. Android WeChat WebView, which
* doesn't support the #RGBA syntax.
* @default target
*/
cssTarget?: EsbuildTransformOptions['target'] | false;
/**
* Override CSS minification specifically instead of defaulting to `build.minify`,
* so you can configure minification for JS and CSS separately.
* @default 'esbuild'
*/
cssMinify?: boolean | 'esbuild' | 'lightningcss';
/**
* If `true`, a separate sourcemap file will be created. If 'inline', the
* sourcemap will be appended to the resulting output file as data URI.
* 'hidden' works like `true` except that the corresponding sourcemap
* comments in the bundled files are suppressed.
* @default false
*/
sourcemap?: boolean | 'inline' | 'hidden';
/**
* Set to `false` to disable minification, or specify the minifier to use.
* Available options are 'terser' or 'esbuild'.
* @default 'esbuild'
*/
minify?: boolean | 'terser' | 'esbuild';
/**
* Options for terser
* https://terser.org/docs/api-reference#minify-options
*/
terserOptions?: Terser.MinifyOptions;
/**
* Will be merged with internal rollup options.
* https://rollupjs.org/configuration-options/
*/
rollupOptions?: RollupOptions;
/**
* Options to pass on to `@rollup/plugin-commonjs`
*/
commonjsOptions?: RollupCommonJSOptions;
/**
* Options to pass on to `@rollup/plugin-dynamic-import-vars`
*/
dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
/**
* Whether to write bundle to disk
* @default true
*/
write?: boolean;
/**
* Empty outDir on write.
* @default true when outDir is a sub directory of project root
*/
emptyOutDir?: boolean | null;
/**
* Copy the public directory to outDir on write.
* @default true
* @experimental
*/
copyPublicDir?: boolean;
/**
* Whether to emit a manifest.json under assets dir to map hash-less filenames
* to their hashed versions. Useful when you want to generate your own HTML
* instead of using the one generated by Vite.
*
* Example:
*
* ```json
* {
* "main.js": {
* "file": "main.68fe3fad.js",
* "css": "main.e6b63442.css",
* "imports": [...],
* "dynamicImports": [...]
* }
* }
* ```
* @default false
*/
manifest?: boolean | string;
/**
* Build in library mode. The value should be the global name of the lib in
* UMD mode. This will produce esm + cjs + umd bundle formats with default
* configurations that are suitable for distributing libraries.
* @default false
*/
lib?: LibraryOptions | false;
/**
* Produce SSR oriented build. Note this requires specifying SSR entry via
* `rollupOptions.input`.
* @default false
*/
ssr?: boolean | string;
/**
* Generate SSR manifest for determining style links and asset preload
* directives in production.
* @default false
*/
ssrManifest?: boolean | string;
/**
* Emit assets during SSR.
* @experimental
* @default false
*/
ssrEmitAssets?: boolean;
/**
* Set to false to disable reporting compressed chunk sizes.
* Can slightly improve build speed.
* @default true
*/
reportCompressedSize?: boolean;
/**
* Adjust chunk size warning limit (in kbs).
* @default 500
*/
chunkSizeWarningLimit?: number;
/**
* Rollup watch options
* https://rollupjs.org/configuration-options/#watch
* @default null
*/
watch?: WatcherOptions | null;
}
export { ChunkMetadata }
export declare interface CommonServerOptions {
/**
* Specify server port. Note if the port is already being used, Vite will
* automatically try the next available port so this may not be the actual
* port the server ends up listening on.
*/
port?: number;
/**
* If enabled, vite will exit if specified port is already in use
*/
strictPort?: boolean;
/**
* Specify which IP addresses the server should listen on.
* Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
*/
host?: string | boolean;
/**
* Enable TLS + HTTP/2.
* Note: this downgrades to TLS only when the proxy option is also used.
*/
https?: boolean | ServerOptions_2;
/**
* Open browser window on startup
*/
open?: boolean | string;
/**
* Configure custom proxy rules for the dev server. Expects an object
* of `{ key: options }` pairs.
* Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
* Full options [here](https://github.com/http-party/node-http-proxy#options).
*
* Example `vite.config.js`:
* ``` js
* module.exports = {
* proxy: {
* // string shorthand
* '/foo': 'http://localhost:4567/foo',
* // with options
* '/api': {
* target: 'http://jsonplaceholder.typicode.com',
* changeOrigin: true,
* rewrite: path => path.replace(/^\/api/, '')
* }
* }
* }
* ```
*/
proxy?: Record<string, string | ProxyOptions>;
/**
* Configure CORS for the dev server.
* Uses https://github.com/expressjs/cors.
* Set to `true` to allow all methods from any origin, or configure separately
* using an object.
*/
cors?: CorsOptions | boolean;
/**
* Specify server response headers.
*/
headers?: OutgoingHttpHeaders;
}
export declare interface ConfigEnv {
command: 'build' | 'serve';
mode: string;
/**
* @experimental
*/
ssrBuild?: boolean;
}
export declare namespace Connect {
export type ServerHandle = HandleFunction | http.Server
export class IncomingMessage extends http.IncomingMessage {
originalUrl?: http.IncomingMessage['url'] | undefined
}
export type NextFunction = (err?: any) => void
export type SimpleHandleFunction = (
req: IncomingMessage,
res: http.ServerResponse,
) => void
export type NextHandleFunction = (
req: IncomingMessage,
res: http.ServerResponse,
next: NextFunction,
) => void
export type ErrorHandleFunction = (
err: any,
req: IncomingMessage,
res: http.ServerResponse,
next: NextFunction,
) => void
export type HandleFunction =
| SimpleHandleFunction
| NextHandleFunction
| ErrorHandleFunction
export interface ServerStackItem {
route: string
handle: ServerHandle
}
export interface Server extends NodeJS.EventEmitter {
(req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void
route: string
stack: ServerStackItem[]
/**
* Utilize the given middleware `handle` to the given `route`,
* defaulting to _/_. This "route" is the mount-point for the
* middleware, when given a value other than _/_ the middleware
* is only effective when that segment is present in the request's
* pathname.
*
* For example if we were to mount a function at _/admin_, it would
* be invoked on _/admin_, and _/admin/settings_, however it would
* not be invoked for _/_, or _/posts_.
*/
use(fn: NextHandleFunction): Server
use(fn: HandleFunction): Server
use(route: string, fn: NextHandleFunction): Server
use(route: string, fn: HandleFunction): Server
/**
* Handle server requests, punting them down
* the middleware stack.
*/
handle(
req: http.IncomingMessage,
res: http.ServerResponse,
next: Function,
): void
/**
* Listen for connections.
*
* This method takes the same arguments
* as node's `http.Server#listen()`.
*
* HTTP and HTTPS:
*
* If you run your application both as HTTP
* and HTTPS you may wrap them individually,
* since your Connect "server" is really just
* a JavaScript `Function`.
*
* var connect = require('connect')
* , http = require('http')
* , https = require('https');
*
* var app = connect();
*
* http.createServer(app).listen(80);
* https.createServer(options, app).listen(443);
*/
listen(
port: number,
hostname?: string,
backlog?: number,
callback?: Function,
): http.Server
listen(port: number, hostname?: string, callback?: Function): http.Server
listen(path: string, callback?: Function): http.Server
listen(handle: any, listeningListener?: Function): http.Server
}
}
export { ConnectedPayload }
/**
* https://github.com/expressjs/cors#configuration-options
*/
export declare interface CorsOptions {
origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
methods?: string | string[];
allowedHeaders?: string | string[];
exposedHeaders?: string | string[];
credentials?: boolean;
maxAge?: number;
preflightContinue?: boolean;
optionsSuccessStatus?: number;
}
export declare type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
export declare const createFilter: (include?: FilterPattern, exclude?: FilterPattern, options?: {
resolve?: string | false | null;
}) => (id: string | unknown) => boolean;
export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
declare interface CSSModulesConfig {
/** The pattern to use when renaming class names and other identifiers. Default is `[hash]_[local]`. */
pattern?: string,
/** Whether to rename dashed identifiers, e.g. custom properties. */
dashedIdents?: boolean
}
export declare interface CSSModulesOptions {
getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
scopeBehaviour?: 'global' | 'local';
globalModulePaths?: RegExp[];
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
hashPrefix?: string;
/**
* default: undefined
*/
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
}
export declare interface CSSOptions {
/**
* Using lightningcss is an experimental option to handle CSS modules,
* assets and imports via Lightning CSS. It requires to install it as a
* peer dependency. This is incompatible with the use of preprocessors.
*
* @default 'postcss'
* @experimental
*/
transformer?: 'postcss' | 'lightningcss';
/**
* https://github.com/css-modules/postcss-modules
*/
modules?: CSSModulesOptions | false;
preprocessorOptions?: Record<string, any>;
postcss?: string | (PostCSS.ProcessOptions & {
plugins?: PostCSS.AcceptedPlugin[];
});
/**
* Enables css sourcemaps during dev
* @default false
* @experimental
*/
devSourcemap?: boolean;
/**
* @experimental
*/
lightningcss?: LightningCSSOptions;
}
export { CustomEventMap }
export { CustomPayload }
/**
* Type helper to make it easier to use vite.config.ts
* accepts a direct {@link UserConfig} object, or a function that returns it.
* The function receives a {@link ConfigEnv} object that exposes two properties:
* `command` (either `'build'` or `'serve'`), and `mode`.
*/
export declare function defineConfig(config: UserConfig): UserConfig;
export declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
export declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
export declare function defineConfig(config: UserConfigExport): UserConfigExport;
export declare interface DepOptimizationConfig {
/**
* Force optimize listed dependencies (must be resolvable import paths,
* cannot be globs).
*/
include?: string[];
/**
* Do not optimize these dependencies (must be resolvable import paths,
* cannot be globs).
*/
exclude?: string[];
/**
* Forces ESM interop when importing these dependencies. Some legacy
* packages advertise themselves as ESM but use `require` internally
* @experimental
*/
needsInterop?: string[];
/**
* Options to pass to esbuild during the dep scanning and optimization
*
* Certain options are omitted since changing them would not be compatible
* with Vite's dep optimization.
*
* - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
* - `plugins` are merged with Vite's dep plugin
*
* https://esbuild.github.io/api
*/
esbuildOptions?: Omit<BuildOptions_2, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
/**
* List of file extensions that can be optimized. A corresponding esbuild
* plugin must exist to handle the specific extension.
*
* By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
* allows specifying additional extensions.
*
* @experimental
*/
extensions?: string[];
/**
* Disables dependencies optimizations, true disables the optimizer during
* build and dev. Pass 'build' or 'dev' to only disable the optimizer in
* one of the modes. Deps optimization is enabled by default in dev only.
* @default 'build'
* @experimental
*/
disabled?: boolean | 'build' | 'dev';
/**
* Automatic dependency discovery. When `noDiscovery` is true, only dependencies
* listed in `include` will be optimized. The scanner isn't run for cold start
* in this case. CJS-only dependencies must be present in `include` during dev.
* @default false
* @experimental
*/
noDiscovery?: boolean;
}
export declare interface DepOptimizationMetadata {
/**
* The main hash is determined by user config and dependency lockfiles.
* This is checked on server startup to avoid unnecessary re-bundles.
*/
hash: string;
/**
* The browser hash is determined by the main hash plus additional dependencies
* discovered at runtime. This is used to invalidate browser requests to
* optimized deps.
*/
browserHash: string;
/**
* Metadata for each already optimized dependency
*/
optimized: Record<string, OptimizedDepInfo>;
/**
* Metadata for non-entry optimized chunks and dynamic imports
*/
chunks: Record<string, OptimizedDepInfo>;
/**
* Metadata for each newly discovered dependency after processing
*/
discovered: Record<string, OptimizedDepInfo>;
/**
* OptimizedDepInfo list
*/
depInfoList: OptimizedDepInfo[];
}
export declare type DepOptimizationOptions = DepOptimizationConfig & {
/**
* By default, Vite will crawl your `index.html` to detect dependencies that
* need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
* will crawl those entry points instead.
*
* If neither of these fit your needs, you can specify custom entries using
* this option - the value should be a fast-glob pattern or array of patterns
* (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
* vite project root. This will overwrite default entries inference.
*/
entries?: string | string[];
/**
* Force dep pre-optimization regardless of whether deps have changed.
* @experimental
*/
force?: boolean;
};
export declare interface DepOptimizationProcessing {
promise: Promise<void>;
resolve: () => void;
}
export declare interface DepOptimizationResult {
metadata: DepOptimizationMetadata;
/**
* When doing a re-run, if there are newly discovered dependencies
* the page reload will be delayed until the next rerun so we need
* to be able to discard the result
*/
commit: () => Promise<void>;
cancel: () => void;
}
export declare interface DepsOptimizer {
metadata: DepOptimizationMetadata;
scanProcessing?: Promise<void>;
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
run: () => void;
isOptimizedDepFile: (id: string) => boolean;
isOptimizedDepUrl: (url: string) => boolean;
getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
delayDepsOptimizerUntil: (id: string, done: () => Promise<any>) => void;
registerWorkersSource: (id: string) => void;
resetRegisteredIds: () => void;
ensureFirstRun: () => void;
close: () => Promise<void>;
options: DepOptimizationOptions;
}
declare interface Drafts {
/** Whether to enable CSS nesting. */
nesting?: boolean,
/** Whether to enable @custom-media rules. */
customMedia?: boolean
}
export { ErrorPayload }
export declare interface ESBuildOptions extends EsbuildTransformOptions {
include?: string | RegExp | string[] | RegExp[];
exclude?: string | RegExp | string[] | RegExp[];
jsxInject?: string;
/**
* This option is not respected. Use `build.minify` instead.
*/
minify?: never;
}
export { EsbuildTransformOptions }
export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
map: SourceMap;
};
export { esbuildVersion }
export declare interface ExperimentalOptions {
/**
* Append fake `&lang.(ext)` when queries are specified, to preserve the file extension for following plugins to process.
*
* @experimental
* @default false
*/
importGlobRestoreExtension?: boolean;
/**
* Allow finegrain control over assets and public files paths
*
* @experimental
*/
renderBuiltUrl?: RenderBuiltAssetUrl;
/**
* Enables support of HMR partial accept via `import.meta.hot.acceptExports`.
*
* @experimental
* @default false
*/
hmrPartialAccept?: boolean;
/**
* Skips SSR transform to make it easier to use Vite with Node ESM loaders.
* @warning Enabling this will break normal operation of Vite's SSR in development mode.
*
* @experimental
* @default false
*/
skipSsrTransform?: boolean;
}
export declare type ExportsData = {
hasImports: boolean;
exports: readonly string[];
jsxLoader?: boolean;
};
declare const enum Features {
Nesting = 1,
NotSelectorList = 2,
DirSelector = 4,
LangSelectorList = 8,
IsSelector = 16,
TextDecorationThicknessPercent = 32,
MediaIntervalSyntax = 64,
MediaRangeSyntax = 128,
CustomMediaQueries = 256,
ClampFunction = 512,
ColorFunction = 1024,
OklabColors = 2048,
LabColors = 4096,
P3Colors = 8192,
HexAlphaColors = 16384,
SpaceSeparatedColorNotation = 32768,
FontFamilySystemUi = 65536,
DoublePositionGradients = 131072,
VendorPrefixes = 262144,
LogicalProperties = 524288,
Selectors = 31,
MediaQueries = 448,
Colors = 64512,
}
export declare interface FileSystemServeOptions {
/**
* Strictly restrict file accessing outside of allowing paths.
*
* Set to `false` to disable the warning
*
* @default true
*/
strict?: boolean;
/**
* Restrict accessing files outside the allowed directories.
*
* Accepts absolute path or a path relative to project root.
* Will try to search up for workspace root by default.
*/
allow?: string[];
/**
* Restrict accessing files that matches the patterns.
*
* This will have higher priority than `allow`.
* picomatch patterns are supported.
*
* @default ['.env', '.env.*', '*.crt', '*.pem']
*/
deny?: string[];
}
/**
* Inlined to keep `@rollup/pluginutils` in devDependencies
*/
export declare type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
export declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
options: WatchOptions
/**
* Constructs a new FSWatcher instance with optional WatchOptions parameter.
*/
constructor(options?: WatchOptions)
/**
* Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
* string.
*/
add(paths: string | ReadonlyArray<string>): this
/**
* Stop watching files, directories, or glob patterns. Takes an array of strings or just one
* string.
*/
unwatch(paths: string | ReadonlyArray<string>): this
/**
* Returns an object representing all the paths on the file system being watched by this
* `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
* the `cwd` option was used), and the values are arrays of the names of the items contained in
* each directory.
*/
getWatched(): {
[directory: string]: string[]
}
/**
* Removes all listeners from watched files.
*/
close(): Promise<void>
on(
event: 'add' | 'addDir' | 'change',
listener: (path: string, stats?: fs.Stats) => void,
): this
on(
event: 'all',
listener: (
eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir',
path: string,
stats?: fs.Stats,
) => void,
): this
/**
* Error occurred
*/
on(event: 'error', listener: (error: Error) => void): this
/**
* Exposes the native Node `fs.FSWatcher events`
*/
on(
event: 'raw',
listener: (eventName: string, path: string, details: any) => void,
): this
/**
* Fires when the initial scan is complete
*/
on(event: 'ready', listener: () => void): this
on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this
on(event: string, listener: (...args: any[]) => void): this
}
export { FullReloadPayload }
export { GeneralImportGlobOptions }
export declare function getDepOptimizationConfig(config: ResolvedConfig, ssr: boolean): DepOptimizationConfig;
export declare interface HmrContext {
file: string;
timestamp: number;
modules: Array<ModuleNode>;
read: () => string | Promise<string>;
server: ViteDevServer;
}
export declare interface HmrOptions {
protocol?: string;
host?: string;
port?: number;
clientPort?: number;
path?: string;
timeout?: number;
overlay?: boolean;
server?: Server;
}
export { HMRPayload }
export declare type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
export declare interface HtmlTagDescriptor {
tag: string;
attrs?: Record<string, string | boolean | undefined>;
children?: string | HtmlTagDescriptor[];
/**
* default: 'head-prepend'
*/
injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
}
export declare namespace HttpProxy {
export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed
export type ProxyTargetUrl = string | Partial<url.Url>
export interface ProxyTargetDetailed {
host: string
port: number
protocol?: string | undefined
hostname?: string | undefined
socketPath?: string | undefined
key?: string | undefined
passphrase?: string | undefined
pfx?: Buffer | string | undefined
cert?: string | undefined
ca?: string | undefined
ciphers?: string | undefined
secureProtocol?: string | undefined
}
export type ErrorCallback = (
err: Error,
req: http.IncomingMessage,
res: http.ServerResponse,
target?: ProxyTargetUrl,
) => void
export class Server extends events.EventEmitter {
/**
* Creates the proxy server with specified options.
* @param options - Config object passed to the proxy
*/
constructor(options?: ServerOptions)
/**
* Used for proxying regular HTTP(S) requests
* @param req - Client request.
* @param res - Client response.
* @param options - Additional options.
*/
web(
req: http.IncomingMessage,
res: http.ServerResponse,
options?: ServerOptions,
callback?: ErrorCallback,
): void
/**
* Used for proxying regular HTTP(S) requests
* @param req - Client request.
* @param socket - Client socket.
* @param head - Client head.
* @param options - Additional options.
*/
ws(
req: http.IncomingMessage,
socket: unknown,
head: unknown,
options?: ServerOptions,
callback?: ErrorCallback,
): void
/**
* A function that wraps the object in a webserver, for your convenience
* @param port - Port to listen on
*/
listen(port: number): Server
/**
* A function that closes the inner webserver and stops listening on given port
*/
close(callback?: () => void): void
/**
* Creates the proxy server with specified options.
* @param options - Config object passed to the proxy
* @returns Proxy object with handlers for `ws` and `web` requests
*/
static createProxyServer(options?: ServerOptions): Server
/**
* Creates the proxy server with specified options.
* @param options - Config object passed to the proxy
* @returns Proxy object with handlers for `ws` and `web` requests
*/
static createServer(options?: ServerOptions): Server
/**
* Creates the proxy server with specified options.
* @param options - Config object passed to the proxy
* @returns Proxy object with handlers for `ws` and `web` requests
*/
static createProxy(options?: ServerOptions): Server
addListener(event: string, listener: () => void): this
on(event: string, listener: () => void): this
on(event: 'error', listener: ErrorCallback): this
on(
event: 'start',
listener: (
req: http.IncomingMessage,
res: http.ServerResponse,
target: ProxyTargetUrl,
) => void,
): this
on(
event: 'proxyReq',
listener: (
proxyReq: http.ClientRequest,
req: http.IncomingMessage,
res: http.ServerResponse,
options: ServerOptions,
) => void,
): this
on(
event: 'proxyRes',
listener: (
proxyRes: http.IncomingMessage,
req: http.IncomingMessage,
res: http.ServerResponse,
) => void,
): this
on(
event: 'proxyReqWs',
listener: (
proxyReq: http.ClientRequest,
req: http.IncomingMessage,
socket: net.Socket,
options: ServerOptions,
head: any,
) => void,
): this
on(
event: 'econnreset',
listener: (
err: Error,
req: http.IncomingMessage,
res: http.ServerResponse,
target: ProxyTargetUrl,
) => void,
): this
on(
event: 'end',
listener: (
req: http.IncomingMessage,
res: http.ServerResponse,
proxyRes: http.IncomingMessage,
) => void,
): this
on(
event: 'close',
listener: (
proxyRes: http.IncomingMessage,
proxySocket: net.Socket,
proxyHead: any,
) => void,
): this
once(event: string, listener: () => void): this
removeListener(event: string, listener: () => void): this
removeAllListeners(event?: string): this
getMaxListeners(): number
setMaxListeners(n: number): this
listeners(event: string): Array<() => void>
emit(event: string, ...args: any[]): boolean
listenerCount(type: string): number
}
export interface ServerOptions {
/** URL string to be parsed with the url module. */
target?: ProxyTarget | undefined
/** URL string to be parsed with the url module. */
forward?: ProxyTargetUrl | undefined
/** Object to be passed to http(s).request. */
agent?: any
/** Object to be passed to https.createServer(). */
ssl?: any
/** If you want to proxy websockets. */
ws?: boolean | undefined
/** Adds x- forward headers. */
xfwd?: boolean | undefined
/** Verify SSL certificate. */
secure?: boolean | undefined
/** Explicitly specify if we are proxying to another proxy. */
toProxy?: boolean | undefined
/** Specify whether you want to prepend the target's path to the proxy path. */
prependPath?: boolean | undefined
/** Specify whether you want to ignore the proxy path of the incoming request. */
ignorePath?: boolean | undefined
/** Local interface string to bind for outgoing connections. */
localAddress?: string | undefined
/** Changes the origin of the host header to the target URL. */
changeOrigin?: boolean | undefined
/** specify whether you want to keep letter case of response header key */
preserveHeaderKeyCase?: boolean | undefined
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
auth?: string | undefined
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
hostRewrite?: string | undefined
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
autoRewrite?: boolean | undefined
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
protocolRewrite?: string | undefined
/** rewrites domain of set-cookie headers. */
cookieDomainRewrite?:
| false
| string
| { [oldDomain: string]: string }
| undefined
/** rewrites path of set-cookie headers. Default: false */
cookiePathRewrite?:
| false
| string
| { [oldPath: string]: string }
| undefined
/** object with extra headers to be added to target requests. */
headers?: { [header: string]: string } | undefined
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
proxyTimeout?: number | undefined
/** Timeout (in milliseconds) for incoming requests */
timeout?: number | undefined
/** Specify whether you want to follow redirects. Default: false */
followRedirects?: boolean | undefined
/** 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 */
selfHandleResponse?: boolean | undefined
/** Buffer */
buffer?: stream.Stream | undefined
}
}
export { ImportGlobEagerFunction }
export { ImportGlobFunction }
export { ImportGlobOptions }
export declare type IndexHtmlTransform = IndexHtmlTransformHook | {
order?: 'pre' | 'post' | null;
/**
* @deprecated renamed to `order`
*/
enforce?: 'pre' | 'post';
/**
* @deprecated renamed to `handler`
*/
transform: IndexHtmlTransformHook;
} | {
order?: 'pre' | 'post' | null;
/**
* @deprecated renamed to `order`
*/
enforce?: 'pre' | 'post';
handler: IndexHtmlTransformHook;
};
export declare interface IndexHtmlTransformContext {
/**
* public path when served
*/
path: string;
/**
* filename on disk
*/
filename: string;
server?: ViteDevServer;
bundle?: OutputBundle;
chunk?: OutputChunk;
originalUrl?: string;
}
export declare type IndexHtmlTransformHook = (this: void, html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
export declare type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
html: string;
tags: HtmlTagDescriptor[];
};
export { InferCustomEventPayload }
export declare interface InlineConfig extends UserConfig {
configFile?: string | false;
envFile?: false;
}
export declare interface InternalResolveOptions extends Required<ResolveOptions> {
root: string;
isBuild: boolean;
isProduction: boolean;
ssrConfig?: SSROptions;
packageCache?: PackageCache;
/**
* src code mode also attempts the following:
* - resolving /xxx as URLs
* - resolving bare imports from optimized deps
*/
asSrc?: boolean;
tryIndex?: boolean;
tryPrefix?: string;
preferRelative?: boolean;
isRequire?: boolean;
isFromTsImporter?: boolean;
tryEsmOnly?: boolean;
scan?: boolean;
ssrOptimizeCheck?: boolean;
getDepsOptimizer?: (ssr: boolean) => DepsOptimizer | undefined;
shouldExternalize?: (id: string, importer?: string) => boolean | undefined;
/* Excluded from this release type: idOnly */
}
export { InvalidatePayload }
export declare const isCSSRequest: (request: string) => boolean;
export declare function isDepsOptimizerEnabled(config: ResolvedConfig, ssr: boolean): boolean;
/**
* Check if the url is allowed to be served, via the `server.fs` config.
*/
export declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
export declare interface JsonOptions {
/**
* Generate a named export for every property of the JSON object
* @default true
*/
namedExports?: boolean;
/**
* Generate performant output as JSON.parse("stringified").
* Enabling this will disable namedExports.
* @default false
*/
stringify?: boolean;
}
export { KnownAsTypeMap }
export declare interface LegacyOptions {
/**
* Revert vite build --ssr to the v2.9 strategy. Use CJS SSR build and v2.9 externalization heuristics
*
* @experimental
* @deprecated
* @default false
*/
buildSsrCjsExternalHeuristics?: boolean;
}
export declare type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
export declare interface LibraryOptions {
/**
* Path of library entry
*/
entry: InputOption;
/**
* The name of the exposed global variable. Required when the `formats` option includes
* `umd` or `iife`
*/
name?: string;
/**
* Output bundle formats
* @default ['es', 'umd']
*/
formats?: LibraryFormats[];
/**
* The name of the package file output. The default file name is the name option
* of the project package.json. It can also be defined as a function taking the
* format as an argument.
*/
fileName?: string | ((format: ModuleFormat, entryName: string) => string);
}
/**
* Options are spread, so you can also use options that are not typed here like
* visitor (not exposed because it would impact too much the bundle size)
*/
export declare type LightningCSSOptions = {
targets?: Targets
include?: Features
exclude?: Features
drafts?: Drafts
nonStandard?: NonStandard
pseudoClasses?: PseudoClasses
unusedSymbols?: string[]
cssModules?: CSSModulesConfig
}
export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
path: string;
config: UserConfig;
dependencies: string[];
} | null>;
export declare function loadEnv(mode: string, envDir: string, prefixes?: string | string[]): Record<string, string>;
export declare interface LogErrorOptions extends LogOptions {
error?: Error | RollupError | null;
}
export declare interface Logger {
info(msg: string, options?: LogOptions): void;
warn(msg: string, options?: LogOptions): void;
warnOnce(msg: string, options?: LogOptions): void;
error(msg: string, options?: LogErrorOptions): void;
clearScreen(type: LogType): void;
hasErrorLogged(error: Error | RollupError): boolean;
hasWarned: boolean;
}
export declare interface LoggerOptions {
prefix?: string;
allowClearScreen?: boolean;
customLogger?: Logger;
}
export declare type LogLevel = LogType | 'silent';
export declare interface LogOptions {
clear?: boolean;
timestamp?: boolean;
}
export declare type LogType = 'error' | 'warn' | 'info';
export declare type Manifest = Record<string, ManifestChunk>;
export declare interface ManifestChunk {
src?: string;
file: string;
css?: string[];
assets?: string[];
isEntry?: boolean;
isDynamicEntry?: boolean;
imports?: string[];
dynamicImports?: string[];
}
export declare type MapToFunction<T> = T extends Function ? T : never
export declare type Matcher = AnymatchPattern | AnymatchPattern[]
export declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
export declare function mergeConfig<D extends Record<string, any>, O extends Record<string, any>>(defaults: D extends Function ? never : D, overrides: O extends Function ? never : O, isRoot?: boolean): Record<string, any>;
export declare class ModuleGraph {
private resolveId;
urlToModuleMap: Map<string, ModuleNode>;
idToModuleMap: Map<string, ModuleNode>;
fileToModulesMap: Map<string, Set<ModuleNode>>;
safeModulesPath: Set<string>;
/* Excluded from this release type: _unresolvedUrlToModuleMap */
/* Excluded from this release type: _ssrUnresolvedUrlToModuleMap */
constructor(resolveId: (url: string, ssr: boolean) => Promise<PartialResolvedId | null>);
getModuleByUrl(rawUrl: string, ssr?: boolean): Promise<ModuleNode | undefined>;
getModuleById(id: string): ModuleNode | undefined;
getModulesByFile(file: string): Set<ModuleNode> | undefined;
onFileChange(file: string): void;
invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean, hmrBoundaries?: ModuleNode[]): void;
invalidateAll(): void;
/**
* Update the module graph based on a module's updated imports information
* If there are dependencies that no longer have any importers, they are
* returned as a Set.
*/
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>;
ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
/* Excluded from this release type: _ensureEntryFromUrl */
createFileOnlyEntry(file: string): ModuleNode;
resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
/* Excluded from this release type: _getUnresolvedUrlToModule */
/* Excluded from this release type: _setUnresolvedUrlToModule */
/* Excluded from this release type: _resolveUrl */
}
export declare class ModuleNode {
/**
* Public served url path, starts with /
*/
url: string;
/**
* Resolved file system path + query
*/
id: string | null;
file: string | null;
type: 'js' | 'css';
info?: ModuleInfo;
meta?: Record<string, any>;
importers: Set<ModuleNode>;
clientImportedModules: Set<ModuleNode>;
ssrImportedModules: Set<ModuleNode>;
acceptedHmrDeps: Set<ModuleNode>;
acceptedHmrExports: Set<string> | null;
importedBindings: Map<string, Set<string>> | null;
isSelfAccepting?: boolean;
transformResult: TransformResult | null;
ssrTransformResult: TransformResult | null;
ssrModule: Record<string, any> | null;
ssrError: Error | null;
lastHMRTimestamp: number;
lastInvalidationTimestamp: number;
/**
* @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
*/
constructor(url: string, setIsSelfAccepting?: