types.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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. * yield result, if provided plugins can return several results
  202. */
  203. yield?: (arg0: ResolveRequest) => void;
  204. }
  205. declare interface ResolveOptions {
  206. alias: AliasOption[];
  207. fallback: AliasOption[];
  208. aliasFields: Set<string | string[]>;
  209. cachePredicate: (arg0: ResolveRequest) => boolean;
  210. cacheWithContext: boolean;
  211. /**
  212. * A list of exports field condition names.
  213. */
  214. conditionNames: Set<string>;
  215. descriptionFiles: string[];
  216. enforceExtension: boolean;
  217. exportsFields: Set<string | string[]>;
  218. importsFields: Set<string | string[]>;
  219. extensions: Set<string>;
  220. fileSystem: FileSystem;
  221. unsafeCache: false | object;
  222. symlinks: boolean;
  223. resolver?: Resolver;
  224. modules: (string | string[])[];
  225. mainFields: { name: string[]; forceRelative: boolean }[];
  226. mainFiles: Set<string>;
  227. plugins: Plugin[];
  228. pnpApi: null | PnpApiImpl;
  229. roots: Set<string>;
  230. fullySpecified: boolean;
  231. resolveToContext: boolean;
  232. restrictions: Set<string | RegExp>;
  233. preferRelative: boolean;
  234. preferAbsolute: boolean;
  235. }
  236. type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>;
  237. declare abstract class Resolver {
  238. fileSystem: FileSystem;
  239. options: ResolveOptions;
  240. hooks: {
  241. resolveStep: SyncHook<
  242. [
  243. AsyncSeriesBailHook<
  244. [ResolveRequest, ResolveContext],
  245. null | ResolveRequest
  246. >,
  247. ResolveRequest
  248. ]
  249. >;
  250. noResolve: SyncHook<[ResolveRequest, Error]>;
  251. resolve: AsyncSeriesBailHook<
  252. [ResolveRequest, ResolveContext],
  253. null | ResolveRequest
  254. >;
  255. result: AsyncSeriesHook<[ResolveRequest, ResolveContext]>;
  256. };
  257. ensureHook(
  258. name:
  259. | string
  260. | AsyncSeriesBailHook<
  261. [ResolveRequest, ResolveContext],
  262. null | ResolveRequest
  263. >
  264. ): AsyncSeriesBailHook<
  265. [ResolveRequest, ResolveContext],
  266. null | ResolveRequest
  267. >;
  268. getHook(
  269. name:
  270. | string
  271. | AsyncSeriesBailHook<
  272. [ResolveRequest, ResolveContext],
  273. null | ResolveRequest
  274. >
  275. ): AsyncSeriesBailHook<
  276. [ResolveRequest, ResolveContext],
  277. null | ResolveRequest
  278. >;
  279. resolveSync(context: object, path: string, request: string): string | false;
  280. resolve(
  281. context: object,
  282. path: string,
  283. request: string,
  284. resolveContext: ResolveContext,
  285. callback: (
  286. arg0: null | Error,
  287. arg1?: string | false,
  288. arg2?: ResolveRequest
  289. ) => void
  290. ): void;
  291. doResolve(
  292. hook?: any,
  293. request?: any,
  294. message?: any,
  295. resolveContext?: any,
  296. callback?: any
  297. ): any;
  298. parse(identifier: string): ParsedIdentifier;
  299. isModule(path?: any): boolean;
  300. isPrivate(path?: any): boolean;
  301. isDirectory(path: string): boolean;
  302. join(path?: any, request?: any): string;
  303. normalize(path?: any): string;
  304. }
  305. declare interface UserResolveOptions {
  306. /**
  307. * A list of module alias configurations or an object which maps key to value
  308. */
  309. alias?: AliasOptions | AliasOption[];
  310. /**
  311. * A list of module alias configurations or an object which maps key to value, applied only after modules option
  312. */
  313. fallback?: AliasOptions | AliasOption[];
  314. /**
  315. * A list of alias fields in description files
  316. */
  317. aliasFields?: (string | string[])[];
  318. /**
  319. * A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties.
  320. */
  321. cachePredicate?: (arg0: ResolveRequest) => boolean;
  322. /**
  323. * Whether or not the unsafeCache should include request context as part of the cache key.
  324. */
  325. cacheWithContext?: boolean;
  326. /**
  327. * A list of description files to read from
  328. */
  329. descriptionFiles?: string[];
  330. /**
  331. * A list of exports field condition names.
  332. */
  333. conditionNames?: string[];
  334. /**
  335. * Enforce that a extension from extensions must be used
  336. */
  337. enforceExtension?: boolean;
  338. /**
  339. * A list of exports fields in description files
  340. */
  341. exportsFields?: (string | string[])[];
  342. /**
  343. * A list of imports fields in description files
  344. */
  345. importsFields?: (string | string[])[];
  346. /**
  347. * A list of extensions which should be tried for files
  348. */
  349. extensions?: string[];
  350. /**
  351. * The file system which should be used
  352. */
  353. fileSystem: FileSystem;
  354. /**
  355. * Use this cache object to unsafely cache the successful requests
  356. */
  357. unsafeCache?: boolean | object;
  358. /**
  359. * Resolve symlinks to their symlinked location
  360. */
  361. symlinks?: boolean;
  362. /**
  363. * A prepared Resolver to which the plugins are attached
  364. */
  365. resolver?: Resolver;
  366. /**
  367. * A list of directories to resolve modules from, can be absolute path or folder name
  368. */
  369. modules?: string | string[];
  370. /**
  371. * A list of main fields in description files
  372. */
  373. mainFields?: (
  374. | string
  375. | string[]
  376. | { name: string | string[]; forceRelative: boolean }
  377. )[];
  378. /**
  379. * A list of main files in directories
  380. */
  381. mainFiles?: string[];
  382. /**
  383. * A list of additional resolve plugins which should be applied
  384. */
  385. plugins?: Plugin[];
  386. /**
  387. * A PnP API that should be used - null is "never", undefined is "auto"
  388. */
  389. pnpApi?: null | PnpApiImpl;
  390. /**
  391. * A list of root paths
  392. */
  393. roots?: string[];
  394. /**
  395. * The request is already fully specified and no extensions or directories are resolved for it
  396. */
  397. fullySpecified?: boolean;
  398. /**
  399. * Resolve to a context instead of a file
  400. */
  401. resolveToContext?: boolean;
  402. /**
  403. * A list of resolve restrictions
  404. */
  405. restrictions?: (string | RegExp)[];
  406. /**
  407. * Use only the sync constraints of the file system calls
  408. */
  409. useSyncFileSystemCalls?: boolean;
  410. /**
  411. * Prefer to resolve module requests as relative requests before falling back to modules
  412. */
  413. preferRelative?: boolean;
  414. /**
  415. * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
  416. */
  417. preferAbsolute?: boolean;
  418. }
  419. declare interface WriteOnlySet<T> {
  420. add: (T?: any) => void;
  421. }
  422. declare function exports(
  423. context?: any,
  424. path?: any,
  425. request?: any,
  426. resolveContext?: any,
  427. callback?: any
  428. ): void;
  429. declare namespace exports {
  430. export const sync: (
  431. context?: any,
  432. path?: any,
  433. request?: any
  434. ) => string | false;
  435. export function create(
  436. options?: any
  437. ): (
  438. context?: any,
  439. path?: any,
  440. request?: any,
  441. resolveContext?: any,
  442. callback?: any
  443. ) => void;
  444. export namespace create {
  445. export const sync: (
  446. options?: any
  447. ) => (context?: any, path?: any, request?: any) => string | false;
  448. }
  449. export namespace ResolverFactory {
  450. export let createResolver: (options: UserResolveOptions) => Resolver;
  451. }
  452. export const forEachBail: (
  453. array?: any,
  454. iterator?: any,
  455. callback?: any
  456. ) => any;
  457. export {
  458. CachedInputFileSystem,
  459. CloneBasenamePlugin,
  460. LogInfoPlugin,
  461. PnpApiImpl as PnpApi,
  462. Resolver,
  463. FileSystem,
  464. ResolveContext,
  465. ResolveRequest,
  466. Plugin,
  467. UserResolveOptions as ResolveOptions
  468. };
  469. }
  470. export = exports;