@ohos-ports/rspack-core 1.7.11-beta.1 → 2.2.9-beta.0

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 (317) hide show
  1. package/README.md +11 -1
  2. package/compiled/@rspack/lite-tapable/dist/index.d.ts +190 -0
  3. package/compiled/@rspack/lite-tapable/license +22 -0
  4. package/compiled/@rspack/lite-tapable/package.json +1 -0
  5. package/compiled/@swc/types/index.d.ts +161 -11
  6. package/compiled/@swc/types/package.json +1 -1
  7. package/compiled/connect-next/index.d.ts +57 -0
  8. package/compiled/connect-next/license +26 -0
  9. package/compiled/connect-next/package.json +1 -0
  10. package/compiled/http-proxy-middleware/index.d.ts +455 -0
  11. package/compiled/{browserslist-load-config → http-proxy-middleware}/license +3 -2
  12. package/compiled/http-proxy-middleware/package.json +1 -0
  13. package/compiled/open/index.d.ts +161 -0
  14. package/compiled/open/package.json +1 -0
  15. package/compiled/tinypool/README.md +196 -2
  16. package/compiled/tinypool/dist/{common-Qw-RoVFD.js → common-Bo3KCGim.js} +4 -1
  17. package/compiled/tinypool/dist/entry/worker.js +1 -1
  18. package/compiled/tinypool/dist/index.d.ts +9 -4
  19. package/compiled/tinypool/dist/index.js +17 -53
  20. package/compiled/tinypool/package.json +22 -6
  21. package/compiled/watchpack/index.d.ts +3 -217
  22. package/compiled/watchpack/index.js +1778 -1091
  23. package/compiled/watchpack/package.json +8 -1
  24. package/compiled/watchpack/types/DirectoryWatcher.d.ts +335 -0
  25. package/compiled/watchpack/types/LinkResolver.d.ts +10 -0
  26. package/compiled/watchpack/types/getWatcherManager.d.ts +62 -0
  27. package/compiled/watchpack/types/index.d.ts +269 -0
  28. package/compiled/watchpack/types/reducePlan.d.ts +34 -0
  29. package/compiled/watchpack/types/util/globToRegExp.d.ts +2 -0
  30. package/compiled/watchpack/types/watchEventSource.d.ts +53 -0
  31. package/compiled/watchpack/types/watchpack.d.ts +2 -0
  32. package/compiled/webpack-sources/index.d.ts +61 -0
  33. package/compiled/webpack-sources/index.js +2370 -576
  34. package/compiled/webpack-sources/package.json +8 -1
  35. package/compiled/webpack-sources/types/CachedSource.d.ts +192 -0
  36. package/compiled/webpack-sources/types/CompatSource.d.ts +87 -0
  37. package/compiled/webpack-sources/types/ConcatSource.d.ts +75 -0
  38. package/compiled/webpack-sources/types/OriginalSource.d.ts +87 -0
  39. package/compiled/webpack-sources/types/PrefixSource.d.ts +59 -0
  40. package/compiled/webpack-sources/types/RawSource.d.ts +75 -0
  41. package/compiled/webpack-sources/types/ReplaceSource.d.ts +107 -0
  42. package/compiled/webpack-sources/types/SizeOnlySource.d.ts +24 -0
  43. package/compiled/webpack-sources/types/Source.d.ts +189 -0
  44. package/compiled/webpack-sources/types/SourceMapSource.d.ts +136 -0
  45. package/compiled/webpack-sources/types/helpers/createMappingsSerializer.d.ts +60 -0
  46. package/compiled/webpack-sources/types/helpers/getFromStreamChunks.d.ts +16 -0
  47. package/compiled/webpack-sources/types/helpers/getGeneratedSourceInfo.d.ts +31 -0
  48. package/compiled/webpack-sources/types/helpers/getName.d.ts +15 -0
  49. package/compiled/webpack-sources/types/helpers/getSource.d.ts +15 -0
  50. package/compiled/webpack-sources/types/helpers/readMappings.d.ts +19 -0
  51. package/compiled/webpack-sources/types/helpers/scopes.d.ts +119 -0
  52. package/compiled/webpack-sources/types/helpers/splitIntoLines.d.ts +6 -0
  53. package/compiled/webpack-sources/types/helpers/splitIntoPotentialTokens.d.ts +37 -0
  54. package/compiled/webpack-sources/types/helpers/streamAndGetSourceAndMap.d.ts +39 -0
  55. package/compiled/webpack-sources/types/helpers/streamChunks.d.ts +56 -0
  56. package/compiled/webpack-sources/types/helpers/streamChunksOfCombinedSourceMap.d.ts +42 -0
  57. package/compiled/webpack-sources/types/helpers/streamChunksOfRawSource.d.ts +16 -0
  58. package/compiled/webpack-sources/types/helpers/streamChunksOfSourceMap.d.ts +19 -0
  59. package/compiled/webpack-sources/types/helpers/stringBufferUtils.d.ts +55 -0
  60. package/compiled/webpack-sources/types/index.d.ts +50 -0
  61. package/dist/BuildInfo.d.ts +3 -1
  62. package/dist/ChunkGraph.d.ts +1 -1
  63. package/dist/CodeGenerationResults.d.ts +6 -1
  64. package/dist/Compilation.d.ts +60 -89
  65. package/dist/Compiler.d.ts +25 -22
  66. package/dist/ContextModuleFactory.d.ts +2 -2
  67. package/dist/Diagnostics.d.ts +2 -6
  68. package/dist/ExecuteModulePlugin.d.ts +1 -1
  69. package/dist/ExportsInfo.d.ts +1 -1
  70. package/dist/ExternalModule.d.ts +15 -1
  71. package/dist/FileSystem.d.ts +4 -2
  72. package/dist/FileSystemDependencies.d.ts +15 -0
  73. package/dist/Module.d.ts +9 -6
  74. package/dist/ModuleGraph.d.ts +11 -8
  75. package/dist/ModuleGraphConnection.d.ts +10 -0
  76. package/dist/Modules.d.ts +3 -0
  77. package/dist/MultiCompiler.d.ts +9 -9
  78. package/dist/MultiStats.d.ts +3 -3
  79. package/dist/MultiWatching.d.ts +3 -3
  80. package/dist/NativeWatchFileSystem.d.ts +31 -2
  81. package/dist/NormalModule.d.ts +4 -5
  82. package/dist/NormalModuleFactory.d.ts +5 -4
  83. package/dist/Resolver.d.ts +10 -2
  84. package/dist/ResolverFactory.d.ts +2 -2
  85. package/dist/RuntimeGlobals.d.ts +61 -56
  86. package/dist/RuntimeModule.d.ts +3 -3
  87. package/dist/RuntimeTemplate.d.ts +151 -0
  88. package/dist/Stats.d.ts +4 -4
  89. package/dist/VirtualModulesPlugin.d.ts +1 -1
  90. package/dist/Watching.d.ts +5 -5
  91. package/dist/builtin-loader/lightningcss/index.d.ts +11 -14
  92. package/dist/builtin-loader/lightningcss/target.d.ts +4 -0
  93. package/dist/builtin-loader/swc/index.d.ts +3 -5
  94. package/dist/builtin-loader/swc/pluginImport.d.ts +1 -1
  95. package/dist/builtin-loader/swc/types.d.ts +36 -65
  96. package/dist/builtin-plugin/APIPlugin.d.ts +3 -3
  97. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +3 -3
  98. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +3 -3
  99. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +3 -3
  100. package/dist/builtin-plugin/BannerPlugin.d.ts +3 -3
  101. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +3 -3
  102. package/dist/builtin-plugin/CaseSensitivePlugin.d.ts +3 -3
  103. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +3 -3
  104. package/dist/builtin-plugin/CircularCheckRspackPlugin.d.ts +33 -0
  105. package/dist/builtin-plugin/CircularDependencyRspackPlugin.d.ts +10 -4
  106. package/dist/builtin-plugin/CircularModulesInfoPlugin.d.ts +7 -0
  107. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +3 -3
  108. package/dist/builtin-plugin/CompactHashedChunkIdsPlugin.d.ts +12 -0
  109. package/dist/builtin-plugin/CompactHashedModuleIdsPlugin.d.ts +12 -0
  110. package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +3 -3
  111. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +3 -3
  112. package/dist/builtin-plugin/CssChunkingPlugin.d.ts +3 -3
  113. package/dist/builtin-plugin/CssHttpExternalsRspackPlugin.d.ts +9 -0
  114. package/dist/builtin-plugin/CssModulesPlugin.d.ts +3 -3
  115. package/dist/builtin-plugin/DataUriPlugin.d.ts +3 -3
  116. package/dist/builtin-plugin/DefinePlugin.d.ts +3 -3
  117. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +2 -2
  118. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +13 -2
  119. package/dist/builtin-plugin/DllEntryPlugin.d.ts +3 -3
  120. package/dist/builtin-plugin/DllReferenceAgencyPlugin.d.ts +3 -3
  121. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +4 -4
  122. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +3 -3
  123. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +2 -2
  124. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +2 -2
  125. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
  126. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +3 -3
  127. package/dist/builtin-plugin/EntryPlugin.d.ts +4 -4
  128. package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +7 -2
  129. package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +9 -0
  130. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +3 -3
  131. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +3 -3
  132. package/dist/builtin-plugin/ExternalsPlugin.d.ts +4 -3
  133. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +3 -3
  134. package/dist/builtin-plugin/FileUriPlugin.d.ts +3 -3
  135. package/dist/builtin-plugin/FlagAllModulesAsUsedPlugin.d.ts +3 -3
  136. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +3 -3
  137. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +2 -2
  138. package/dist/builtin-plugin/HashedModuleIdsPlugin.d.ts +10 -0
  139. package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +2 -2
  140. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +5 -5
  141. package/dist/builtin-plugin/HttpUriPlugin.d.ts +7 -3
  142. package/dist/builtin-plugin/IgnorePlugin.d.ts +3 -3
  143. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +3 -3
  144. package/dist/builtin-plugin/InlineExportsPlugin.d.ts +3 -3
  145. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +21 -6
  146. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +2 -2
  147. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +3 -3
  148. package/dist/builtin-plugin/LibManifestPlugin.d.ts +3 -3
  149. package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +7 -11
  150. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +3 -3
  151. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +2 -2
  152. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +3 -3
  153. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +3 -3
  154. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +2 -2
  155. package/dist/builtin-plugin/ModuleInfoHeaderPlugin.d.ts +3 -3
  156. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +3 -3
  157. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +3 -3
  158. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +2 -2
  159. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +2 -2
  160. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.d.ts +3 -3
  161. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +3 -3
  162. package/dist/builtin-plugin/NormalModuleReplacementPlugin.d.ts +4 -4
  163. package/dist/builtin-plugin/OccurrenceChunkIdsPlugin.d.ts +3 -3
  164. package/dist/builtin-plugin/ProgressPlugin.d.ts +8 -7
  165. package/dist/builtin-plugin/ProvidePlugin.d.ts +3 -3
  166. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +15 -4
  167. package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +3 -3
  168. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +3 -3
  169. package/dist/builtin-plugin/RsdoctorPlugin.d.ts +8 -11
  170. package/dist/builtin-plugin/RslibPlugin.d.ts +5 -6
  171. package/dist/builtin-plugin/RstestPlugin.d.ts +3 -4
  172. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +3 -3
  173. package/dist/builtin-plugin/RuntimePlugin.d.ts +7 -11
  174. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +9 -9
  175. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +5 -5
  176. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +3 -3
  177. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +6 -5
  178. package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +2 -2
  179. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +7 -6
  180. package/dist/builtin-plugin/SyncModuleIdsPlugin.d.ts +16 -0
  181. package/dist/builtin-plugin/URLPlugin.d.ts +3 -3
  182. package/dist/builtin-plugin/WorkerPlugin.d.ts +4 -4
  183. package/dist/builtin-plugin/base.d.ts +3 -3
  184. package/dist/builtin-plugin/css-extract/index.d.ts +3 -3
  185. package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
  186. package/dist/builtin-plugin/css-extract/utils.d.ts +8 -1
  187. package/dist/builtin-plugin/html-plugin/hooks.d.ts +3 -3
  188. package/dist/builtin-plugin/html-plugin/index.d.ts +2 -2
  189. package/dist/builtin-plugin/html-plugin/options.d.ts +2 -7
  190. package/dist/builtin-plugin/html-plugin/plugin.d.ts +5 -9
  191. package/dist/builtin-plugin/html-plugin/taps.d.ts +1 -1
  192. package/dist/builtin-plugin/index.d.ts +92 -84
  193. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +6 -6
  194. package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +4 -4
  195. package/dist/builtin-plugin/rsc/Coordinator.d.ts +8 -0
  196. package/dist/builtin-plugin/rsc/RscClientPlugin.d.ts +13 -0
  197. package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +47 -0
  198. package/dist/builtin-plugin/rsc/index.d.ts +24 -0
  199. package/dist/checkNodeVersion.d.ts +1 -0
  200. package/dist/config/adapter.d.ts +4 -4
  201. package/dist/config/adapterRuleUse.d.ts +89 -55
  202. package/dist/config/browserslistTargetHandler.d.ts +1 -1
  203. package/dist/config/defaults.d.ts +5 -3
  204. package/dist/config/devServer.d.ts +103 -238
  205. package/dist/config/index.d.ts +5 -5
  206. package/dist/config/normalization.d.ts +26 -47
  207. package/dist/config/target.d.ts +19 -12
  208. package/dist/config/types.d.ts +615 -256
  209. package/dist/container/ContainerPlugin.d.ts +4 -4
  210. package/dist/container/ContainerReferencePlugin.d.ts +4 -4
  211. package/dist/container/ModuleFederationManifestPlugin.d.ts +12 -5
  212. package/dist/container/ModuleFederationPlugin.d.ts +22 -5
  213. package/dist/container/ModuleFederationPluginV1.d.ts +10 -6
  214. package/dist/container/ModuleFederationRuntimePlugin.d.ts +3 -3
  215. package/dist/cssExtractHmr.js +2 -27
  216. package/dist/cssExtractLoader.js +24 -65
  217. package/dist/exports.d.ts +98 -84
  218. package/dist/index.d.ts +4 -3
  219. package/dist/index.js +14201 -11810
  220. package/dist/lib/AbstractMethodError.d.ts +1 -1
  221. package/dist/lib/Cache.d.ts +5 -2
  222. package/dist/lib/CacheFacade.d.ts +4 -4
  223. package/dist/lib/DllPlugin.d.ts +2 -2
  224. package/dist/lib/DllReferencePlugin.d.ts +3 -3
  225. package/dist/lib/EntryOptionPlugin.d.ts +2 -2
  226. package/dist/lib/EnvironmentPlugin.d.ts +3 -3
  227. package/dist/lib/HookWebpackError.d.ts +2 -3
  228. package/dist/lib/IgnoreWarningsPlugin.d.ts +1 -1
  229. package/dist/lib/LoaderOptionsPlugin.d.ts +2 -2
  230. package/dist/lib/LoaderTargetPlugin.d.ts +2 -2
  231. package/dist/lib/WebpackError.d.ts +2 -2
  232. package/dist/lib/cache/MemoryCachePlugin.d.ts +1 -1
  233. package/dist/lib/cache/getLazyHashedEtag.d.ts +2 -2
  234. package/dist/lib/cache/mergeEtags.d.ts +1 -2
  235. package/dist/loader-runner/ModuleError.d.ts +1 -1
  236. package/dist/loader-runner/cache.d.ts +27 -0
  237. package/dist/loader-runner/dependencies.d.ts +23 -0
  238. package/dist/loader-runner/index.d.ts +10 -11
  239. package/dist/loader-runner/loadLoader.d.ts +2 -2
  240. package/dist/loader-runner/service.d.ts +10 -1
  241. package/dist/loader-runner/utils.d.ts +3 -3
  242. package/dist/loader-runner/worker.d.ts +1 -1
  243. package/dist/logging/createConsoleLogger.d.ts +2 -2
  244. package/dist/l~0.js +34 -0
  245. package/dist/l~3.js +34 -0
  246. package/dist/moduleFederationDefaultRuntime.js +1 -1
  247. package/dist/node/NodeEnvironmentPlugin.d.ts +2 -2
  248. package/dist/node/NodeTemplatePlugin.d.ts +1 -1
  249. package/dist/node/NodeWatchFileSystem.d.ts +15 -3
  250. package/dist/node/nodeConsole.d.ts +1 -1
  251. package/dist/rspack.d.ts +7 -8
  252. package/dist/rspackOptionsApply.d.ts +1 -1
  253. package/dist/runtime/cssExtractHmr.d.ts +2 -2
  254. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +1 -2
  255. package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
  256. package/dist/sharing/ConsumeSharedPlugin.d.ts +18 -6
  257. package/dist/sharing/IndependentSharedPlugin.d.ts +37 -0
  258. package/dist/sharing/ProvideSharedPlugin.d.ts +22 -3
  259. package/dist/sharing/SharePlugin.d.ts +51 -3
  260. package/dist/sharing/ShareRuntimePlugin.d.ts +2 -2
  261. package/dist/sharing/SharedContainerPlugin.d.ts +23 -0
  262. package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +14 -0
  263. package/dist/sharing/TreeShakingSharedPlugin.d.ts +19 -0
  264. package/dist/sharing/utils.d.ts +1 -0
  265. package/dist/stats/DefaultStatsFactoryPlugin.d.ts +1 -1
  266. package/dist/stats/DefaultStatsPresetPlugin.d.ts +1 -1
  267. package/dist/stats/DefaultStatsPrinterPlugin.d.ts +1 -1
  268. package/dist/stats/StatsFactory.d.ts +7 -5
  269. package/dist/stats/StatsPrinter.d.ts +7 -7
  270. package/dist/stats/statsFactoryUtils.d.ts +15 -19
  271. package/dist/swc.d.ts +2 -2
  272. package/dist/taps/compilation.d.ts +1 -1
  273. package/dist/taps/compiler.d.ts +1 -1
  274. package/dist/taps/contextModuleFactory.d.ts +1 -1
  275. package/dist/taps/externalModule.d.ts +2 -0
  276. package/dist/taps/index.d.ts +7 -6
  277. package/dist/taps/javascriptModules.d.ts +1 -1
  278. package/dist/taps/normalModuleFactory.d.ts +1 -1
  279. package/dist/taps/types.d.ts +2 -2
  280. package/dist/trace/index.d.ts +1 -0
  281. package/dist/trace/traceHookPlugin.d.ts +1 -1
  282. package/dist/util/bindingHelpers.d.ts +7 -0
  283. package/dist/util/comparators.d.ts +1 -1
  284. package/dist/util/createHash.d.ts +2 -2
  285. package/dist/util/fs.d.ts +19 -18
  286. package/dist/util/hash/md4.d.ts +1 -1
  287. package/dist/util/hash/xxhash64.d.ts +1 -1
  288. package/dist/util/identifier.d.ts +35 -9
  289. package/dist/util/index.d.ts +2 -2
  290. package/dist/util/source.d.ts +3 -3
  291. package/dist/util/supportsColor.d.ts +6 -0
  292. package/dist/util/targetsVersion.d.ts +2 -0
  293. package/dist/util/validateConfig.d.ts +1 -1
  294. package/dist/util/watchTimeInfo.d.ts +7 -0
  295. package/dist/web/JsonpTemplatePlugin.d.ts +13 -0
  296. package/dist/webworker/WebWorkerTemplatePlugin.d.ts +13 -0
  297. package/dist/worker.js +935 -907
  298. package/hot/dev-server.js +12 -11
  299. package/hot/emitter.js +3 -1
  300. package/hot/lazy-compilation-node.js +4 -1
  301. package/hot/lazy-compilation-web.js +2 -3
  302. package/hot/log-apply-result.js +8 -5
  303. package/hot/log.js +18 -10
  304. package/hot/only-dev-server.js +13 -12
  305. package/hot/poll.js +10 -9
  306. package/hot/signal.js +12 -10
  307. package/module.d.ts +39 -2
  308. package/package.json +15 -39
  309. package/compiled/browserslist-load-config/index.d.ts +0 -21
  310. package/compiled/browserslist-load-config/index.js +0 -252
  311. package/compiled/browserslist-load-config/package.json +0 -1
  312. package/compiled/webpack-sources/types.d.ts +0 -458
  313. package/dist/builtin-loader/index.d.ts +0 -1
  314. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +0 -7
  315. package/dist/container/index.d.ts +0 -4
  316. package/dist/util/MergeCaller.d.ts +0 -10
  317. package/dist/util/fake.d.ts +0 -14
@@ -0,0 +1,455 @@
1
+ import * as http from 'node:http';
2
+ import http__default, { ServerResponse, IncomingMessage } from 'node:http';
3
+ import * as net from 'node:net';
4
+ import net__default, { Socket } from 'node:net';
5
+ import http2, { Http2ServerResponse, Http2ServerRequest } from 'node:http2';
6
+ import { EventEmitter } from 'node:events';
7
+ import * as stream from 'node:stream';
8
+
9
+ interface ProxyTargetDetailed {
10
+ host?: string;
11
+ port?: number | string;
12
+ protocol?: string;
13
+ hostname?: string;
14
+ pathname?: string;
15
+ socketPath?: string;
16
+ key?: string;
17
+ passphrase?: string;
18
+ pfx?: Buffer | string;
19
+ cert?: string;
20
+ ca?: string;
21
+ ciphers?: string;
22
+ secureProtocol?: string;
23
+ }
24
+ type ProxyTarget = string | URL | ProxyTargetDetailed;
25
+ interface ProxyServerOptions {
26
+ /** URL string to be parsed. */
27
+ target?: ProxyTarget;
28
+ /** URL string to be parsed. */
29
+ forward?: ProxyTarget;
30
+ /** Object to be passed to http(s).request. */
31
+ agent?: any;
32
+ /** Enable HTTP/2 listener, default is `false` */
33
+ http2?: boolean;
34
+ /** Object to be passed to https.createServer()
35
+ * or http2.createSecureServer() if the `http2` option is enabled
36
+ */
37
+ ssl?: any;
38
+ /** If you want to proxy websockets. */
39
+ ws?: boolean;
40
+ /** Adds x- forward headers. */
41
+ xfwd?: boolean;
42
+ /** Verify SSL certificate. */
43
+ secure?: boolean;
44
+ /** Explicitly specify if we are proxying to another proxy. */
45
+ toProxy?: boolean;
46
+ /** Specify whether you want to prepend the target's path to the proxy path. */
47
+ prependPath?: boolean;
48
+ /** Specify whether you want to ignore the proxy path of the incoming request. */
49
+ ignorePath?: boolean;
50
+ /** Local interface string to bind for outgoing connections. */
51
+ localAddress?: string;
52
+ /** Changes the origin of the host header to the target URL. */
53
+ changeOrigin?: boolean;
54
+ /** specify whether you want to keep letter case of response header key */
55
+ preserveHeaderKeyCase?: boolean;
56
+ /** Basic authentication i.e. 'user:password' to compute an Authorization header. */
57
+ auth?: string;
58
+ /** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
59
+ hostRewrite?: string;
60
+ /** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
61
+ autoRewrite?: boolean;
62
+ /** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
63
+ protocolRewrite?: string;
64
+ /** Rewrites domain of set-cookie headers. */
65
+ cookieDomainRewrite?: false | string | {
66
+ [oldDomain: string]: string;
67
+ };
68
+ /** Rewrites path of set-cookie headers. Default: false */
69
+ cookiePathRewrite?: false | string | {
70
+ [oldPath: string]: string;
71
+ };
72
+ /** Object with extra headers to be added to target requests. */
73
+ headers?: {
74
+ [header: string]: string;
75
+ };
76
+ /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
77
+ proxyTimeout?: number;
78
+ /** Timeout (in milliseconds) for incoming requests */
79
+ timeout?: number;
80
+ /** 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 */
81
+ selfHandleResponse?: boolean;
82
+ /** Follow HTTP redirects from target. `true` = max 5 hops; number = custom max. */
83
+ followRedirects?: boolean | number;
84
+ /** Buffer */
85
+ buffer?: stream.Stream;
86
+ }
87
+ type ResOfType<T extends "web" | "ws"> = T extends "ws" ? T extends "web" ? ServerResponse | Http2ServerResponse | Socket : Socket : T extends "web" ? ServerResponse | Http2ServerResponse : never;
88
+ type ProxyMiddleware<T extends ServerResponse | Http2ServerResponse | Socket> = (req: IncomingMessage | Http2ServerRequest, res: T, opts: ProxyServerOptions & {
89
+ target: URL | ProxyTargetDetailed;
90
+ forward: URL;
91
+ }, server: ProxyServer<IncomingMessage | Http2ServerRequest, ServerResponse | Http2ServerResponse>, head?: Buffer, callback?: (err: any, req: IncomingMessage | Http2ServerRequest, socket: T, url?: any) => void) => void | true;
92
+ interface ProxyServerEventMap<Req extends http__default.IncomingMessage | http2.Http2ServerRequest = http__default.IncomingMessage, Res extends http__default.ServerResponse | http2.Http2ServerResponse = http__default.ServerResponse> {
93
+ error: [err: Error, req?: Req, res?: Res | net__default.Socket, target?: URL | ProxyTarget];
94
+ start: [req: Req, res: Res, target: URL | ProxyTarget];
95
+ econnreset: [err: Error, req: Req, res: Res, target: URL | ProxyTarget];
96
+ proxyReq: [proxyReq: http__default.ClientRequest, req: Req, res: Res, options: ProxyServerOptions];
97
+ proxyReqWs: [proxyReq: http__default.ClientRequest, req: Req, socket: net__default.Socket, options: ProxyServerOptions, head: any];
98
+ proxyRes: [proxyRes: http__default.IncomingMessage, req: Req, res: Res];
99
+ end: [req: Req, res: Res, proxyRes: http__default.IncomingMessage];
100
+ open: [proxySocket: net__default.Socket];
101
+ /** @deprecated */
102
+ proxySocket: [proxySocket: net__default.Socket];
103
+ close: [proxyRes: Req, proxySocket: net__default.Socket, proxyHead: any];
104
+ }
105
+ declare class ProxyServer<Req extends http__default.IncomingMessage | http2.Http2ServerRequest = http__default.IncomingMessage, Res extends http__default.ServerResponse | http2.Http2ServerResponse = http__default.ServerResponse> extends EventEmitter<ProxyServerEventMap<Req, Res>> {
106
+ private _server?;
107
+ _webPasses: ProxyMiddleware<http__default.ServerResponse>[];
108
+ _wsPasses: ProxyMiddleware<net__default.Socket>[];
109
+ options: ProxyServerOptions;
110
+ web: (req: Req, res: Res, opts?: ProxyServerOptions, head?: any) => Promise<void>;
111
+ ws: (req: Req, socket: net__default.Socket, opts: ProxyServerOptions, head?: any) => Promise<void>;
112
+ /**
113
+ * Creates the proxy server with specified options.
114
+ * @param options - Config object passed to the proxy
115
+ */
116
+ constructor(options?: ProxyServerOptions);
117
+ /**
118
+ * A function that wraps the object in a webserver, for your convenience
119
+ * @param port - Port to listen on
120
+ * @param hostname - The hostname to listen on
121
+ * @param listeningListener - A callback function that is called when the server starts listening
122
+ */
123
+ listen(port: number, hostname?: string, listeningListener?: () => void): this;
124
+ /**
125
+ * A function that closes the inner webserver and stops listening on given port
126
+ */
127
+ close(callback?: () => void): void;
128
+ before<Type extends "ws" | "web">(type: Type, passName: string, pass: ProxyMiddleware<ResOfType<Type>>): void;
129
+ after<Type extends "ws" | "web">(type: Type, passName: string, pass: ProxyMiddleware<ResOfType<Type>>): void;
130
+ /** @internal */
131
+ _getPasses<Type extends "ws" | "web">(type: Type): ProxyMiddleware<ResOfType<Type>>[];
132
+ }
133
+
134
+ /**
135
+ * Based on definition by DefinitelyTyped:
136
+ * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6f529c6c67a447190f86bfbf894d1061e41e07b7/types/http-proxy-middleware/index.d.ts
137
+ */
138
+
139
+ type NextFunction<T = (err?: any) => void> = T;
140
+ interface RequestHandler<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse, TNext = NextFunction> {
141
+ (req: TReq, res: TRes, next?: TNext): Promise<void>;
142
+ upgrade: (req: TReq, socket: net.Socket, head: Buffer) => void;
143
+ }
144
+ type Filter<TReq extends http.IncomingMessage = http.IncomingMessage> = string | string[] | ((pathname: string, req: TReq) => boolean | string | RegExpMatchArray | null);
145
+ /**
146
+ * @see {@link https://github.com/chimurai/http-proxy-middleware/tree/master#defineplugin-helper `definePlugin()`} to define a http-proxy-middleware plugin.
147
+ */
148
+ interface Plugin<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> {
149
+ (proxyServer: ProxyServer<TReq, TRes>, options: Options<TReq, TRes>): void;
150
+ }
151
+ interface OnProxyEvent<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> {
152
+ error?: (err: Error, req: TReq, res: TRes | net.Socket, target?: string | Partial<URL>) => void;
153
+ proxyReq?: (proxyReq: http.ClientRequest, req: TReq, res: TRes, options: ProxyServerOptions) => void;
154
+ proxyReqWs?: (proxyReq: http.ClientRequest, req: TReq, socket: net.Socket, options: ProxyServerOptions, head: any) => void;
155
+ proxyRes?: (proxyRes: TReq, req: TReq, res: TRes) => void | Promise<void>;
156
+ open?: (proxySocket: net.Socket) => void;
157
+ close?: (proxyRes: TReq, proxySocket: net.Socket, proxyHead: any) => void;
158
+ start?: (req: TReq, res: TRes, target: string | Partial<URL>) => void;
159
+ end?: (req: TReq, res: TRes, proxyRes: TReq) => void;
160
+ econnreset?: (err: Error, req: TReq, res: TRes, target: string | Partial<URL>) => void;
161
+ }
162
+ type Logger = Pick<Console, 'info' | 'warn' | 'error'>;
163
+ type PathRewriteConfig<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> = {
164
+ [regexp: string]: string;
165
+ } | ((path: string, req: TReq,
166
+ /** `res` is undefined in WebSocket upgrade flows. */
167
+ res?: TRes | undefined, options?: Options<TReq, TRes>) => string | undefined) | ((path: string, req: TReq,
168
+ /** `res` is undefined in WebSocket upgrade flows. */
169
+ res?: TRes | undefined, options?: Options<TReq, TRes>) => Promise<string | undefined>);
170
+ interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> extends ProxyServerOptions {
171
+ /**
172
+ * Narrow down requests to proxy or not.
173
+ * Filter on {@link http.IncomingMessage.url `pathname`} which is relative to the proxy's "mounting" point in the server.
174
+ * Or use the {@link http.IncomingMessage `req`} object for more complex filtering.
175
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathFilter.md
176
+ * @since v3.0.0
177
+ */
178
+ pathFilter?: Filter<TReq>;
179
+ /**
180
+ * Modify request paths before requests are send to the target.
181
+ * @example
182
+ * ```js
183
+ * createProxyMiddleware({
184
+ * pathRewrite: {
185
+ * '^/api/old-path': '/api/new-path', // rewrite path
186
+ * }
187
+ * });
188
+ * ```
189
+ * @since v0.15.0
190
+ * @since v0.21.0 - support `async` function
191
+ * @since v4.1.0 - `res` and `options` parameters added to custom function
192
+ *
193
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathRewrite.md
194
+ */
195
+ pathRewrite?: PathRewriteConfig<TReq, TRes>;
196
+ /**
197
+ * Access the internal `httpxy` server instance to customize behavior
198
+ *
199
+ * @example
200
+ * ```js
201
+ * createProxyMiddleware({
202
+ * plugins: [(proxyServer, options) => {
203
+ * proxyServer.on('error', (error, req, res) => {
204
+ * console.error(error);
205
+ * });
206
+ * }]
207
+ * });
208
+ * ```
209
+ * @link https://github.com/chimurai/http-proxy-middleware#plugins-array
210
+ * @since v3.0.0
211
+ */
212
+ plugins?: Plugin<TReq, TRes>[];
213
+ /**
214
+ * Eject pre-configured plugins.
215
+ * NOTE: register your own error handlers to prevent server from crashing.
216
+ *
217
+ * @link https://github.com/chimurai/http-proxy-middleware#ejectplugins-boolean-default-false
218
+ * @since v3.0.0
219
+ */
220
+ ejectPlugins?: boolean;
221
+ /**
222
+ * Listen to `httpxy` events
223
+ * @see {@link OnProxyEvent} for available events
224
+ * @example
225
+ * ```js
226
+ * createProxyMiddleware({
227
+ * on: {
228
+ * error: (error, req, res, target) => {
229
+ * console.error(error);
230
+ * }
231
+ * }
232
+ * });
233
+ * ```
234
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/proxy-events.md
235
+ * @since v3.0.0
236
+ */
237
+ on?: OnProxyEvent<TReq, TRes>;
238
+ /**
239
+ * Dynamically set the {@link Options.target `options.target`}.
240
+ *
241
+ * @example
242
+ * ```js
243
+ * createProxyMiddleware({
244
+ * router: async (req, res, options) => {
245
+ * return 'http://127:0.0.1:3000';
246
+ * }
247
+ * });
248
+ * ```
249
+ *
250
+ * @since v0.16.0
251
+ * @since v4.1.0 - `res` and `options` parameters added to router function signature
252
+ *
253
+ * NOTE: `res` is undefined in WebSocket upgrade flows.
254
+ *
255
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/router.md
256
+ */
257
+ router?: Record<string, ProxyServerOptions['target']> | ((req: TReq, res: TRes | undefined, options: Options<TReq, TRes>) => ProxyServerOptions['target']) | ((req: TReq, res: TRes | undefined, options: Options<TReq, TRes>) => Promise<ProxyServerOptions['target']>);
258
+ /**
259
+ * Log information from http-proxy-middleware
260
+ * @example
261
+ * ```js
262
+ * createProxyMiddleware({
263
+ * logger: console
264
+ * });
265
+ * ```
266
+ * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/logger.md
267
+ * @since v3.0.0
268
+ */
269
+ logger?: Logger;
270
+ }
271
+
272
+ /**
273
+ * Create proxy middleware for Express-like servers. ([list of servers with examples](https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/servers.md))
274
+ *
275
+ * @example Basic proxy to a single target.
276
+ * ```ts
277
+ * import { createProxyMiddleware } from 'http-proxy-middleware';
278
+ *
279
+ * const proxy = createProxyMiddleware({
280
+ * target: 'http://www.example.org',
281
+ * changeOrigin: true,
282
+ * });
283
+ * ```
284
+ *
285
+ * @example Proxy only matching paths and rewrite the forwarded path.
286
+ * ```ts
287
+ * import { createProxyMiddleware } from 'http-proxy-middleware';
288
+ *
289
+ * const proxy = createProxyMiddleware({
290
+ * target: 'http://localhost:3000',
291
+ * pathFilter: '/api',
292
+ * pathRewrite: {
293
+ * '^/api/': '/',
294
+ * },
295
+ * });
296
+ * ```
297
+ *
298
+ * @example Native path rewrite by mounting at a route (alternative to `pathRewrite`).
299
+ * ```ts
300
+ * import express from 'express';
301
+ * import { createProxyMiddleware } from 'http-proxy-middleware';
302
+ *
303
+ * const app = express();
304
+ * app.use(
305
+ * '/users',
306
+ * createProxyMiddleware({
307
+ * target: 'http://jsonplaceholder.typicode.com/users',
308
+ * changeOrigin: true,
309
+ * }),
310
+ * );
311
+ * ```
312
+ *
313
+ * @example Use framework-specific request/response types (Express).
314
+ * ```ts
315
+ * import type { Request, Response } from 'express';
316
+ * import { createProxyMiddleware } from 'http-proxy-middleware';
317
+ *
318
+ * const proxy = createProxyMiddleware<Request, Response>({
319
+ * target: 'http://www.example.org/api',
320
+ * changeOrigin: true,
321
+ * });
322
+ * ```
323
+ *
324
+ * @example Intercept and modify a proxied response body.
325
+ * ```ts
326
+ * import { createProxyMiddleware, responseInterceptor } from 'http-proxy-middleware';
327
+ *
328
+ * const proxy = createProxyMiddleware({
329
+ * target: 'http://www.example.org',
330
+ * selfHandleResponse: true,
331
+ * on: {
332
+ * proxyRes: responseInterceptor(async (responseBuffer) => {
333
+ * const response = responseBuffer.toString('utf8');
334
+ * return response.replace('Hello', 'Goodbye');
335
+ * }),
336
+ * },
337
+ * });
338
+ * ```
339
+ *
340
+ * @see https://github.com/chimurai/http-proxy-middleware/
341
+ * @see https://github.com/chimurai/http-proxy-middleware/#basic-usage
342
+ * @see https://github.com/chimurai/http-proxy-middleware/#intercept-and-manipulate-responses
343
+ * @see https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/servers.md
344
+ * @see https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathFilter.md
345
+ * @see https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathRewrite.md
346
+ * @see https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/response-interceptor.md
347
+ */
348
+ declare function createProxyMiddleware<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse, TNext = NextFunction>(options: Options<TReq, TRes>): RequestHandler<TReq, TRes, TNext>;
349
+
350
+ type Interceptor<TReq = http.IncomingMessage, TRes = http.ServerResponse> = (buffer: Buffer, proxyRes: http.IncomingMessage, req: TReq, res: TRes) => Promise<Buffer | string>;
351
+ /**
352
+ * Intercept responses from upstream.
353
+ * Automatically decompress (deflate, gzip, brotli, zstd).
354
+ * Give developer the opportunity to modify intercepted Buffer and http.ServerResponse
355
+ *
356
+ * NOTE: must set options.selfHandleResponse=true (prevent automatic call of res.end())
357
+ *
358
+ * @example
359
+ *
360
+ * ```ts
361
+ * createProxyMiddleware({
362
+ * target: 'http://example.com',
363
+ * selfHandleResponse: true, // MUST set selfHandleResponse=true
364
+ * on: {
365
+ * proxyRes: responseInterceptor(async (buffer, proxyRes, req, res) => {
366
+ * // modify intercepted buffer and return modified buffer
367
+ * const modifiedBuffer = Buffer.from(buffer.toString().replace(/Example/g, 'Demo'), 'utf8');
368
+ * return modifiedBuffer;
369
+ * }),
370
+ * }
371
+ * });
372
+ * ```
373
+ */
374
+ declare function responseInterceptor<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse>(interceptor: Interceptor<TReq, TRes>): (proxyRes: http.IncomingMessage, req: TReq, res: TRes) => Promise<void>;
375
+
376
+ type BodyParserLikeRequest = http.IncomingMessage & {
377
+ body?: any;
378
+ };
379
+ /**
380
+ * Fix proxied body if bodyParser is involved.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * createProxyMiddleware({
385
+ * target: 'http://example.com',
386
+ * on: {
387
+ * proxyReq: fixRequestBody,
388
+ * }
389
+ * });
390
+ * ```
391
+ *
392
+ * Alternative solution without using `fixRequestBody()`: put `http-proxy-middleware` before `bodyParser` in the middleware stack.
393
+ *
394
+ * @see {@link https://github.com/chimurai/http-proxy-middleware/issues/40 Github issue #40 - POST request body is not proxied}
395
+ */
396
+ declare function fixRequestBody<TReq extends BodyParserLikeRequest = BodyParserLikeRequest>(proxyReq: http.ClientRequest, req: TReq): void;
397
+
398
+ /**
399
+ * Helper function to define a http-proxy-middleware plugin
400
+ * @see proxyServer {@link ProxyServer} - proxy server instance to which the plugin is being applied
401
+ * @see options {@link Options} - options object passed to `createProxyMiddleware`
402
+ *
403
+ * @example defining a plugin
404
+ * ```js
405
+ * export const myPlugin = definePlugin((proxyServer, options) => {
406
+ * // plugin implementation
407
+ * });
408
+ * ```
409
+ *
410
+ * @example using a plugin
411
+ * ```js
412
+ * createProxyMiddleware({
413
+ * target: 'http://example.com',
414
+ * plugins: [myPlugin],
415
+ * });
416
+ * ```
417
+ *
418
+ * @since 4.1.0
419
+ */
420
+ declare function definePlugin<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse>(fn: Plugin<TReq, TRes>): Plugin<TReq, TRes>;
421
+
422
+ /**
423
+ * Subscribe to {@link https://github.com/unjs/httpxy#events `httpxy` error events} to prevent server from crashing.
424
+ * Errors are logged with {@link https://www.npmjs.com/package/debug debug} library.
425
+ */
426
+ declare const debugProxyErrorsPlugin: Plugin;
427
+
428
+ declare const errorResponsePlugin: Plugin;
429
+
430
+ declare const loggerPlugin: Plugin;
431
+
432
+ /**
433
+ * Implements option.on object to subscribe to `httpxy` events.
434
+ *
435
+ * @example
436
+ * ```js
437
+ * createProxyMiddleware({
438
+ * on: {
439
+ * error: (error, req, res, target) => {},
440
+ * proxyReq: (proxyReq, req, res, options) => {},
441
+ * proxyReqWs: (proxyReq, req, socket, options) => {},
442
+ * proxyRes: (proxyRes, req, res) => {},
443
+ * open: (proxySocket) => {},
444
+ * close: (proxyRes, proxySocket, proxyHead) => {},
445
+ * start: (req, res, target) => {},
446
+ * end: (req, res, proxyRes) => {},
447
+ * econnreset: (error, req, res, target) => {},
448
+ * }
449
+ * });
450
+ * ```
451
+ */
452
+ declare const proxyEventsPlugin: Plugin;
453
+
454
+ export { createProxyMiddleware, debugProxyErrorsPlugin, definePlugin, errorResponsePlugin, fixRequestBody, loggerPlugin, proxyEventsPlugin, responseInterceptor };
455
+ export type { Filter, OnProxyEvent, Options, Plugin, RequestHandler };
@@ -1,6 +1,6 @@
1
- MIT License
1
+ The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Rspack Contrib
3
+ Copyright (c) 2015 Steven Chim
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
+
@@ -0,0 +1 @@
1
+ {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.2.0","license":"MIT","types":"index.d.ts","type":"module"}
@@ -0,0 +1,161 @@
1
+ import { ChildProcess } from 'node:child_process';
2
+
3
+ type Options = {
4
+ /**
5
+ Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
6
+
7
+ Note that it waits for the app to exit, not just for the window to close.
8
+
9
+ On Windows, you have to explicitly specify an app for it to be able to wait.
10
+
11
+ **Warning:** When opening URLs in browsers while the browser is already running, the `wait` option will not work as expected. Browsers use a single-instance architecture where new URLs are passed to the existing process, causing the command to exit immediately. Use the `newInstance` option on macOS to force a new browser instance, or avoid using `wait` with browsers.
12
+
13
+ @default false
14
+ */
15
+ readonly wait?: boolean;
16
+
17
+ /**
18
+ __macOS only__
19
+
20
+ Do not bring the app to the foreground.
21
+
22
+ @default false
23
+ */
24
+ readonly background?: boolean;
25
+
26
+ /**
27
+ __macOS only__
28
+
29
+ Open a new instance of the app even it's already running.
30
+
31
+ A new instance is always opened on other platforms.
32
+
33
+ @default false
34
+ */
35
+ readonly newInstance?: boolean;
36
+
37
+ /**
38
+ Specify the `name` of the app to open the `target` with, and optionally, app `arguments`. `app` can be an array of apps to try to open and `name` can be an array of app names to try. If each app fails, the last error will be thrown.
39
+
40
+ The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use `apps` which auto-detects the correct binary to use.
41
+
42
+ You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
43
+
44
+ The app `arguments` are app dependent. Check the app's documentation for what arguments it accepts.
45
+ */
46
+ readonly app?: App | readonly App[];
47
+
48
+ /**
49
+ Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
50
+
51
+ We do not recommend setting this option. The convention for success is exit code zero.
52
+
53
+ @default false
54
+ */
55
+ readonly allowNonzeroExitCode?: boolean;
56
+ };
57
+
58
+ type OpenAppOptions = {
59
+ /**
60
+ Arguments passed to the app.
61
+
62
+ These arguments are app dependent. Check the app's documentation for what arguments it accepts.
63
+ */
64
+ readonly arguments?: readonly string[];
65
+ } & Omit<Options, 'app'>;
66
+
67
+ type AppName =
68
+ | 'chrome'
69
+ | 'brave'
70
+ | 'firefox'
71
+ | 'edge'
72
+ | 'browser'
73
+ | 'browserPrivate';
74
+
75
+ type App = {
76
+ name: string | readonly string[];
77
+ arguments?: readonly string[];
78
+ };
79
+
80
+ /**
81
+ An object containing auto-detected binary names for common apps. Useful to work around cross-platform differences.
82
+
83
+ @example
84
+ ```
85
+ import open, {apps} from 'open';
86
+
87
+ await open('https://google.com', {
88
+ app: {
89
+ name: apps.chrome
90
+ }
91
+ });
92
+ ```
93
+ */
94
+ declare const apps: Record<AppName, string | readonly string[]>;
95
+
96
+ /**
97
+ Open stuff like URLs, files, executables. Cross-platform.
98
+
99
+ Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
100
+
101
+ @param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
102
+ @returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
103
+
104
+ @example
105
+ ```
106
+ import open, {apps} from 'open';
107
+
108
+ // Opens the image in the default image viewer.
109
+ await open('unicorn.png', {wait: true});
110
+ console.log('The image viewer app quit');
111
+
112
+ // Opens the URL in the default browser.
113
+ await open('https://sindresorhus.com');
114
+
115
+ // Opens the URL in a specified browser.
116
+ await open('https://sindresorhus.com', {app: {name: 'firefox'}});
117
+
118
+ // Specify app arguments.
119
+ await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
120
+
121
+ // Opens the URL in the default browser in incognito mode.
122
+ await open('https://sindresorhus.com', {app: {name: apps.browserPrivate}});
123
+ ```
124
+ */
125
+ declare function open(
126
+ target: string,
127
+ options?: Options
128
+ ): Promise<ChildProcess>;
129
+
130
+ /**
131
+ Open an app. Cross-platform.
132
+
133
+ Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
134
+
135
+ @param name - The app you want to open. Can be either builtin supported `apps` names or other name supported in platform.
136
+ @returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
137
+
138
+ @example
139
+ ```
140
+ import open, {openApp, apps} from 'open';
141
+
142
+ // Open Firefox.
143
+ await openApp(apps.firefox);
144
+
145
+ // Open Chrome in incognito mode.
146
+ await openApp(apps.chrome, {arguments: ['--incognito']});
147
+
148
+ // Open default browser.
149
+ await openApp(apps.browser);
150
+
151
+ // Open default browser in incognito mode.
152
+ await openApp(apps.browserPrivate);
153
+
154
+ // Open Xcode.
155
+ await openApp('xcode');
156
+ ```
157
+ */
158
+ declare function openApp(name: App['name'], options?: OpenAppOptions): Promise<ChildProcess>;
159
+
160
+ export { apps, open as default, openApp };
161
+ export type { App, AppName, OpenAppOptions, Options };
@@ -0,0 +1 @@
1
+ {"name":"open","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"version":"11.0.4","funding":"https://github.com/sponsors/sindresorhus","license":"MIT","types":"index.d.ts","type":"module"}