create-microact-app 1.0.1

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