types.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. /*
  2. * This file was automatically generated.
  3. * DO NOT MODIFY BY HAND.
  4. * Run `yarn special-lint-fix` to update
  5. */
  6. import { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } from "tapable";
  7. declare interface AliasOption {
  8. alias: string | false | string[];
  9. name: string;
  10. onlyModule?: boolean;
  11. }
  12. type AliasOptionNewRequest = string | false | string[];
  13. declare interface AliasOptions {
  14. [index: string]: AliasOptionNewRequest;
  15. }
  16. declare interface BaseResolveRequest {
  17. path: string | false;
  18. descriptionFilePath?: string;
  19. descriptionFileRoot?: string;
  20. descriptionFileData?: object;
  21. relativePath?: string;
  22. ignoreSymlinks?: boolean;
  23. fullySpecified?: boolean;
  24. }
  25. declare class CachedInputFileSystem {
  26. constructor(fileSystem?: any, duration?: any);
  27. fileSystem: any;
  28. lstat?: {
  29. (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
  30. (
  31. arg0: string,
  32. arg1: object,
  33. arg2: FileSystemCallback<string | Buffer>
  34. ): void;
  35. };
  36. lstatSync?: (arg0: string, arg1?: object) => FileSystemStats;
  37. stat: {
  38. (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
  39. (
  40. arg0: string,
  41. arg1: object,
  42. arg2: FileSystemCallback<string | Buffer>
  43. ): void;
  44. };
  45. statSync: (arg0: string, arg1?: object) => FileSystemStats;
  46. readdir: {
  47. (
  48. arg0: string,
  49. arg1: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
  50. ): void;
  51. (
  52. arg0: string,
  53. arg1: object,
  54. arg2: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
  55. ): void;
  56. };
  57. readdirSync: (
  58. arg0: string,
  59. arg1?: object
  60. ) => (string | Buffer)[] | FileSystemDirent[];
  61. readFile: {
  62. (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
  63. (
  64. arg0: string,
  65. arg1: object,
  66. arg2: FileSystemCallback<string | Buffer>
  67. ): void;
  68. };
  69. readFileSync: (arg0: string, arg1?: object) => string | Buffer;
  70. readJson?: {
  71. (arg0: string, arg1: FileSystemCallback<object>): void;
  72. (arg0: string, arg1: object, arg2: FileSystemCallback<object>): void;
  73. };
  74. readJsonSync?: (arg0: string, arg1?: object) => object;
  75. readlink: {
  76. (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
  77. (
  78. arg0: string,
  79. arg1: object,
  80. arg2: FileSystemCallback<string | Buffer>
  81. ): void;
  82. };
  83. readlinkSync: (arg0: string, arg1?: object) => string | Buffer;
  84. purge(what?: any): void;
  85. }
  86. declare class CloneBasenamePlugin {
  87. constructor(source?: any, target?: any);
  88. source: any;
  89. target: any;
  90. apply(resolver: Resolver): void;
  91. }
  92. declare interface FileSystem {
  93. readFile: {
  94. (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
  95. (
  96. arg0: string,
  97. arg1: object,
  98. arg2: FileSystemCallback<string | Buffer>
  99. ): void;
  100. };
  101. readdir: {
  102. (
  103. arg0: string,
  104. arg1: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
  105. ): void;
  106. (
  107. arg0: string,
  108. arg1: object,
  109. arg2: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
  110. ): void;
  111. };
  112. readJson?: {
  113. (arg0: string, arg1: FileSystemCallback<object>): void;
  114. (arg0: string, arg1: object, arg2: FileSystemCallback<object>): void;
  115. };
  116. readlink: {
  117. (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
  118. (
  119. arg0: string,
  120. arg1: object,
  121. arg2: FileSystemCallback<string | Buffer>
  122. ): void;
  123. };
  124. lstat?: {
  125. (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
  126. (
  127. arg0: string,
  128. arg1: object,
  129. arg2: FileSystemCallback<string | Buffer>
  130. ): void;
  131. };
  132. stat: {
  133. (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
  134. (
  135. arg0: string,
  136. arg1: object,
  137. arg2: FileSystemCallback<string | Buffer>
  138. ): void;
  139. };
  140. }
  141. declare interface FileSystemCallback<T> {
  142. (err?: null | (PossibleFileSystemError & Error), result?: T): any;
  143. }
  144. declare interface FileSystemDirent {
  145. name: string | Buffer;
  146. isDirectory: () => boolean;
  147. isFile: () => boolean;
  148. }
  149. declare interface FileSystemStats {
  150. isDirectory: () => boolean;
  151. isFile: () => boolean;
  152. }
  153. declare class LogInfoPlugin {
  154. constructor(source?: any);
  155. source: any;
  156. apply(resolver: Resolver): void;
  157. }
  158. declare interface ParsedIdentifier {
  159. request: string;
  160. query: string;
  161. fragment: string;
  162. directory: boolean;
  163. module: boolean;
  164. file: boolean;
  165. internal: boolean;
  166. }
  167. type Plugin =
  168. | { apply: (arg0: Resolver) => void }
  169. | ((this: Resolver, arg1: Resolver) => void);
  170. declare interface PnpApiImpl {
  171. resolveToUnqualified: (arg0: string, arg1: string, arg2: object) => string;
  172. }
  173. declare interface PossibleFileSystemError {
  174. code?: string;
  175. errno?: number;
  176. path?: string;
  177. syscall?: string;
  178. }
  179. /**
  180. * Resolve context
  181. */
  182. declare interface ResolveContext {
  183. contextDependencies?: WriteOnlySet<string>;
  184. /**
  185. * files that was found on file system
  186. */
  187. fileDependencies?: WriteOnlySet<string>;
  188. /**
  189. * dependencies that was not found on file system
  190. */
  191. missingDependencies?: WriteOnlySet<string>;
  192. /**
  193. * set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`,
  194. */
  195. stack?: Set<string>;
  196. /**
  197. * log function
  198. */
  199. log?: (arg0: string) => void;
  200. }
  201. declare interface ResolveOptions {
  202. alias: AliasOption[];
  203. fallback: AliasOption[];
  204. aliasFields: Set<string | string[]>;
  205. cachePredicate: (arg0: ResolveRequest) => boolean;
  206. cacheWithContext: boolean;
  207. /**
  208. * A list of exports field condition names.
  209. */
  210. conditionNames: Set<string>;
  211. descriptionFiles: string[];
  212. enforceExtension: boolean;
  213. exportsFields: Set<string | string[]>;
  214. importsFields: Set<string | string[]>;
  215. extensions: Set<string>;
  216. fileSystem: FileSystem;
  217. unsafeCache: false | object;
  218. symlinks: boolean;
  219. resolver?: Resolver;
  220. modules: (string | string[])[];
  221. mainFields: { name: string[]; forceRelative: boolean }[];
  222. mainFiles: Set<string>;
  223. plugins: Plugin[];
  224. pnpApi: null | PnpApiImpl;
  225. roots: Set<string>;
  226. fullySpecified: boolean;
  227. resolveToContext: boolean;
  228. restrictions: Set<string | RegExp>;
  229. preferRelative: boolean;
  230. preferAbsolute: boolean;
  231. }
  232. type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>;
  233. declare abstract class Resolver {
  234. fileSystem: FileSystem;
  235. options: ResolveOptions;
  236. hooks: {
  237. resolveStep: SyncHook<
  238. [
  239. AsyncSeriesBailHook<
  240. [ResolveRequest, ResolveContext],
  241. null | ResolveRequest
  242. >,
  243. ResolveRequest
  244. ]
  245. >;
  246. noResolve: SyncHook<[ResolveRequest, Error]>;
  247. resolve: AsyncSeriesBailHook<
  248. [ResolveRequest, ResolveContext],
  249. null | ResolveRequest
  250. >;
  251. result: AsyncSeriesHook<[ResolveRequest, ResolveContext]>;
  252. };
  253. ensureHook(
  254. name:
  255. | string
  256. | AsyncSeriesBailHook<
  257. [ResolveRequest, ResolveContext],
  258. null | ResolveRequest
  259. >
  260. ): AsyncSeriesBailHook<
  261. [ResolveRequest, ResolveContext],
  262. null | ResolveRequest
  263. >;
  264. getHook(
  265. name:
  266. | string
  267. | AsyncSeriesBailHook<
  268. [ResolveRequest, ResolveContext],
  269. null | ResolveRequest
  270. >
  271. ): AsyncSeriesBailHook<
  272. [ResolveRequest, ResolveContext],
  273. null | ResolveRequest
  274. >;
  275. resolveSync(context: object, path: string, request: string): string | false;
  276. resolve(
  277. context: object,
  278. path: string,
  279. request: string,
  280. resolveContext: ResolveContext,
  281. callback: (
  282. arg0: null | Error,
  283. arg1?: string | false,
  284. arg2?: ResolveRequest
  285. ) => void
  286. ): void;
  287. doResolve(
  288. hook?: any,
  289. request?: any,
  290. message?: any,
  291. resolveContext?: any,
  292. callback?: any
  293. ): any;
  294. parse(identifier: string): ParsedIdentifier;
  295. isModule(path?: any): boolean;
  296. isPrivate(path?: any): boolean;
  297. isDirectory(path: string): boolean;
  298. join(path?: any, request?: any): string;
  299. normalize(path?: any): string;
  300. }
  301. declare interface UserResolveOptions {
  302. /**
  303. * A list of module alias configurations or an object which maps key to value
  304. */
  305. alias?: AliasOptions | AliasOption[];
  306. /**
  307. * A list of module alias configurations or an object which maps key to value, applied only after modules option
  308. */
  309. fallback?: AliasOptions | AliasOption[];
  310. /**
  311. * A list of alias fields in description files
  312. */
  313. aliasFields?: (string | string[])[];
  314. /**
  315. * A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties.
  316. */
  317. cachePredicate?: (arg0: ResolveRequest) => boolean;
  318. /**
  319. * Whether or not the unsafeCache should include request context as part of the cache key.
  320. */
  321. cacheWithContext?: boolean;
  322. /**
  323. * A list of description files to read from
  324. */
  325. descriptionFiles?: string[];
  326. /**
  327. * A list of exports field condition names.
  328. */
  329. conditionNames?: string[];
  330. /**
  331. * Enforce that a extension from extensions must be used
  332. */
  333. enforceExtension?: boolean;
  334. /**
  335. * A list of exports fields in description files
  336. */
  337. exportsFields?: (string | string[])[];
  338. /**
  339. * A list of imports fields in description files
  340. */
  341. importsFields?: (string | string[])[];
  342. /**
  343. * A list of extensions which should be tried for files
  344. */
  345. extensions?: string[];
  346. /**
  347. * The file system which should be used
  348. */
  349. fileSystem: FileSystem;
  350. /**
  351. * Use this cache object to unsafely cache the successful requests
  352. */
  353. unsafeCache?: boolean | object;
  354. /**
  355. * Resolve symlinks to their symlinked location
  356. */
  357. symlinks?: boolean;
  358. /**
  359. * A prepared Resolver to which the plugins are attached
  360. */
  361. resolver?: Resolver;
  362. /**
  363. * A list of directories to resolve modules from, can be absolute path or folder name
  364. */
  365. modules?: string | string[];
  366. /**
  367. * A list of main fields in description files
  368. */
  369. mainFields?: (
  370. | string
  371. | string[]
  372. | { name: string | string[]; forceRelative: boolean }
  373. )[];
  374. /**
  375. * A list of main files in directories
  376. */
  377. mainFiles?: string[];
  378. /**
  379. * A list of additional resolve plugins which should be applied
  380. */
  381. plugins?: Plugin[];
  382. /**
  383. * A PnP API that should be used - null is "never", undefined is "auto"
  384. */
  385. pnpApi?: null | PnpApiImpl;
  386. /**
  387. * A list of root paths
  388. */
  389. roots?: string[];
  390. /**
  391. * The request is already fully specified and no extensions or directories are resolved for it
  392. */
  393. fullySpecified?: boolean;
  394. /**
  395. * Resolve to a context instead of a file
  396. */
  397. resolveToContext?: boolean;
  398. /**
  399. * A list of resolve restrictions
  400. */
  401. restrictions?: (string | RegExp)[];
  402. /**
  403. * Use only the sync constiants of the file system calls
  404. */
  405. useSyncFileSystemCalls?: boolean;
  406. /**
  407. * Prefer to resolve module requests as relative requests before falling back to modules
  408. */
  409. preferRelative?: boolean;
  410. /**
  411. * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
  412. */
  413. preferAbsolute?: boolean;
  414. }
  415. declare interface WriteOnlySet<T> {
  416. add: (T?: any) => void;
  417. }
  418. declare function exports(
  419. context?: any,
  420. path?: any,
  421. request?: any,
  422. resolveContext?: any,
  423. callback?: any
  424. ): void;
  425. declare namespace exports {
  426. export const sync: (
  427. context?: any,
  428. path?: any,
  429. request?: any
  430. ) => string | false;
  431. export function create(
  432. options?: any
  433. ): (
  434. context?: any,
  435. path?: any,
  436. request?: any,
  437. resolveContext?: any,
  438. callback?: any
  439. ) => void;
  440. export namespace create {
  441. export const sync: (
  442. options?: any
  443. ) => (context?: any, path?: any, request?: any) => string | false;
  444. }
  445. export namespace ResolverFactory {
  446. export let createResolver: (options: UserResolveOptions) => Resolver;
  447. }
  448. export const forEachBail: (
  449. array?: any,
  450. iterator?: any,
  451. callback?: any
  452. ) => any;
  453. export {
  454. CachedInputFileSystem,
  455. CloneBasenamePlugin,
  456. LogInfoPlugin,
  457. PnpApiImpl as PnpApi,
  458. Resolver,
  459. FileSystem,
  460. ResolveContext,
  461. ResolveRequest,
  462. Plugin,
  463. UserResolveOptions as ResolveOptions
  464. };
  465. }
  466. export = exports;