types.d.ts 12 KB

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