@jadujoel/web-audio-clip-node 0.1.1 → 0.1.2

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