types.d.ts 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*
  2. * This file was automatically generated.
  3. * DO NOT MODIFY BY HAND.
  4. * Run `yarn special-lint-fix` to update
  5. */
  6. import { Dirent } from "fs";
  7. import { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } from "tapable";
  8. type Alias = string | false | string[];
  9. declare interface AliasOption {
  10. alias: Alias;
  11. name: string;
  12. onlyModule?: boolean;
  13. }
  14. type AliasOptionNewRequest = string | false | string[];
  15. declare interface AliasOptions {
  16. [index: string]: AliasOptionNewRequest;
  17. }
  18. declare interface BaseResolveRequest {
  19. path: string | false;
  20. context?: object;
  21. descriptionFilePath?: string;
  22. descriptionFileRoot?: string;
  23. descriptionFileData?: JsonObject;
  24. relativePath?: string;
  25. ignoreSymlinks?: boolean;
  26. fullySpecified?: boolean;
  27. __innerRequest?: string;
  28. __innerRequest_request?: string;
  29. __innerRequest_relativePath?: string;
  30. }
  31. declare class CachedInputFileSystem {
  32. constructor(fileSystem: any, duration: number);
  33. fileSystem: any;
  34. lstat?: {
  35. (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
  36. (
  37. arg0: string,
  38. arg1: object,
  39. arg2: FileSystemCallback<string | Buffer>
  40. ): void;
  41. };
  42. lstatSync?: (arg0: string, arg1?: object) => FileSystemStats;
  43. stat: {
  44. (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
  45. (
  46. arg0: string,
  47. arg1: object,
  48. arg2: FileSystemCallback<string | Buffer>
  49. ): void;
  50. };
  51. statSync: (arg0: string, arg1?: object) => FileSystemStats;
  52. readdir: (
  53. arg0: string,
  54. arg1?:
  55. | null
  56. | ((
  57. arg0?: null | NodeJS.ErrnoException,
  58. arg1?: (string | Buffer)[] | Dirent[]
  59. ) => void)
  60. | ReaddirOptions
  61. | "ascii"
  62. | "utf8"
  63. | "utf-8"
  64. | "utf16le"
  65. | "ucs2"
  66. | "ucs-2"
  67. | "base64"
  68. | "base64url"
  69. | "latin1"
  70. | "binary"
  71. | "hex"
  72. | "buffer",
  73. arg2?: (
  74. arg0?: null | NodeJS.ErrnoException,
  75. arg1?: (string | Buffer)[] | Dirent[]
  76. ) => void
  77. ) => void;
  78. readdirSync: (
  79. arg0: string,
  80. arg1?: object
  81. ) => (string | Buffer)[] | FileSystemDirent[];
  82. readFile: {
  83. (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
  84. (
  85. arg0: string,
  86. arg1: object,
  87. arg2: FileSystemCallback<string | Buffer>
  88. ): void;
  89. };
  90. readFileSync: (arg0: string, arg1?: object) => string | Buffer;
  91. readJson?: {
  92. (arg0: string, arg1: FileSystemCallback<object>): void;
  93. (arg0: string, arg1: object, arg2: FileSystemCallback<object>): void;
  94. };
  95. readJsonSync?: (arg0: string, arg1?: object) => object;
  96. readlink: {
  97. (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
  98. (
  99. arg0: string,
  100. arg1: object,
  101. arg2: FileSystemCallback<string | Buffer>
  102. ): void;
  103. };
  104. readlinkSync: (arg0: string, arg1?: object) => string | Buffer;
  105. purge(what?: string | Set<string> | string[]): void;
  106. }
  107. declare class CloneBasenamePlugin {
  108. constructor(
  109. source:
  110. | string
  111. | AsyncSeriesBailHook<
  112. [ResolveRequest, ResolveContext],
  113. null | ResolveRequest
  114. >,
  115. target:
  116. | string
  117. | AsyncSeriesBailHook<
  118. [ResolveRequest, ResolveContext],
  119. null | ResolveRequest
  120. >
  121. );
  122. source:
  123. | string
  124. | AsyncSeriesBailHook<
  125. [ResolveRequest, ResolveContext],
  126. null | ResolveRequest
  127. >;
  128. target:
  129. | string
  130. | AsyncSeriesBailHook<
  131. [ResolveRequest, ResolveContext],
  132. null | ResolveRequest
  133. >;
  134. apply(resolver: Resolver): void;
  135. }
  136. type ErrorWithDetail = Error & { details?: string };
  137. declare interface ExtensionAliasOption {
  138. alias: string | string[];
  139. extension: string;
  140. }
  141. declare interface ExtensionAliasOptions {
  142. [index: string]: string | string[];
  143. }
  144. declare interface FileSystem {
  145. readFile: {
  146. (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
  147. (
  148. arg0: string,
  149. arg1: object,
  150. arg2: FileSystemCallback<string | Buffer>
  151. ): void;
  152. };
  153. readdir: (
  154. arg0: string,
  155. arg1?:
  156. | null
  157. | ((
  158. arg0?: null | NodeJS.ErrnoException,
  159. arg1?: (string | Buffer)[] | Dirent[]
  160. ) => void)
  161. | ReaddirOptions
  162. | "ascii"
  163. | "utf8"
  164. | "utf-8"
  165. | "utf16le"
  166. | "ucs2"
  167. | "ucs-2"
  168. | "base64"
  169. | "base64url"
  170. | "latin1"
  171. | "binary"
  172. | "hex"
  173. | "buffer",
  174. arg2?: (
  175. arg0?: null | NodeJS.ErrnoException,
  176. arg1?: (string | Buffer)[] | Dirent[]
  177. ) => void
  178. ) => void;
  179. readJson?: {
  180. (arg0: string, arg1: FileSystemCallback<object>): void;
  181. (arg0: string, arg1: object, arg2: FileSystemCallback<object>): void;
  182. };
  183. readlink: {
  184. (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
  185. (
  186. arg0: string,
  187. arg1: object,
  188. arg2: FileSystemCallback<string | Buffer>
  189. ): void;
  190. };
  191. lstat?: {
  192. (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
  193. (
  194. arg0: string,
  195. arg1: object,
  196. arg2: FileSystemCallback<string | Buffer>
  197. ): void;
  198. };
  199. stat: {
  200. (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
  201. (
  202. arg0: string,
  203. arg1: object,
  204. arg2: FileSystemCallback<string | Buffer>
  205. ): void;
  206. };
  207. }
  208. declare interface FileSystemCallback<T> {
  209. (err?: null | (PossibleFileSystemError & Error), result?: T): any;
  210. }
  211. declare interface FileSystemDirent {
  212. name: string | Buffer;
  213. isDirectory: () => boolean;
  214. isFile: () => boolean;
  215. }
  216. declare interface FileSystemStats {
  217. isDirectory: () => boolean;
  218. isFile: () => boolean;
  219. }
  220. declare interface Iterator<T, Z> {
  221. (
  222. item: T,
  223. callback: (err?: null | Error, result?: null | Z) => void,
  224. i: number
  225. ): void;
  226. }
  227. type JsonObject = { [index: string]: JsonValue } & {
  228. [index: string]:
  229. | undefined
  230. | null
  231. | string
  232. | number
  233. | boolean
  234. | JsonObject
  235. | JsonValue[];
  236. };
  237. type JsonValue = null | string | number | boolean | JsonObject | JsonValue[];
  238. declare interface KnownHooks {
  239. resolveStep: SyncHook<
  240. [
  241. AsyncSeriesBailHook<
  242. [ResolveRequest, ResolveContext],
  243. null | ResolveRequest
  244. >,
  245. ResolveRequest
  246. ]
  247. >;
  248. noResolve: SyncHook<[ResolveRequest, Error]>;
  249. resolve: AsyncSeriesBailHook<
  250. [ResolveRequest, ResolveContext],
  251. null | ResolveRequest
  252. >;
  253. result: AsyncSeriesHook<[ResolveRequest, ResolveContext]>;
  254. }
  255. declare class LogInfoPlugin {
  256. constructor(
  257. source:
  258. | string
  259. | AsyncSeriesBailHook<
  260. [ResolveRequest, ResolveContext],
  261. null | ResolveRequest
  262. >
  263. );
  264. source:
  265. | string
  266. | AsyncSeriesBailHook<
  267. [ResolveRequest, ResolveContext],
  268. null | ResolveRequest
  269. >;
  270. apply(resolver: Resolver): void;
  271. }
  272. declare interface ParsedIdentifier {
  273. request: string;
  274. query: string;
  275. fragment: string;
  276. directory: boolean;
  277. module: boolean;
  278. file: boolean;
  279. internal: boolean;
  280. }
  281. type Plugin =
  282. | undefined
  283. | null
  284. | false
  285. | ""
  286. | 0
  287. | { apply: (arg0: Resolver) => void }
  288. | ((this: Resolver, arg1: Resolver) => void);
  289. declare interface PnpApiImpl {
  290. resolveToUnqualified: (arg0: string, arg1: string, arg2: object) => string;
  291. }
  292. declare interface PossibleFileSystemError {
  293. code?: string;
  294. errno?: number;
  295. path?: string;
  296. syscall?: string;
  297. }
  298. declare interface ReaddirOptions {
  299. encoding?:
  300. | null
  301. | "ascii"
  302. | "utf8"
  303. | "utf-8"
  304. | "utf16le"
  305. | "ucs2"
  306. | "ucs-2"
  307. | "base64"
  308. | "base64url"
  309. | "latin1"
  310. | "binary"
  311. | "hex"
  312. | "buffer";
  313. withFileTypes?: boolean;
  314. }
  315. /**
  316. * Resolve context
  317. */
  318. declare interface ResolveContext {
  319. contextDependencies?: WriteOnlySet<string>;
  320. /**
  321. * files that was found on file system
  322. */
  323. fileDependencies?: WriteOnlySet<string>;
  324. /**
  325. * dependencies that was not found on file system
  326. */
  327. missingDependencies?: WriteOnlySet<string>;
  328. /**
  329. * set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`,
  330. */
  331. stack?: Set<string>;
  332. /**
  333. * log function
  334. */
  335. log?: (arg0: string) => void;
  336. /**
  337. * yield result, if provided plugins can return several results
  338. */
  339. yield?: (arg0: ResolveRequest) => void;
  340. }
  341. declare interface ResolveFunction {
  342. (context: object, path: string, request: string): string | false;
  343. (path: string, request: string): string | false;
  344. }
  345. declare interface ResolveFunctionAsync {
  346. (
  347. context: object,
  348. path: string,
  349. request: string,
  350. resolveContext: ResolveContext,
  351. callback: (
  352. err: null | ErrorWithDetail,
  353. res?: string | false,
  354. req?: ResolveRequest
  355. ) => void
  356. ): void;
  357. (
  358. context: object,
  359. path: string,
  360. request: string,
  361. callback: (
  362. err: null | ErrorWithDetail,
  363. res?: string | false,
  364. req?: ResolveRequest
  365. ) => void
  366. ): void;
  367. (
  368. path: string,
  369. request: string,
  370. resolveContext: ResolveContext,
  371. callback: (
  372. err: null | ErrorWithDetail,
  373. res?: string | false,
  374. req?: ResolveRequest
  375. ) => void
  376. ): void;
  377. (
  378. path: string,
  379. request: string,
  380. callback: (
  381. err: null | ErrorWithDetail,
  382. res?: string | false,
  383. req?: ResolveRequest
  384. ) => void
  385. ): void;
  386. }
  387. declare interface ResolveOptions {
  388. alias: AliasOption[];
  389. fallback: AliasOption[];
  390. aliasFields: Set<string | string[]>;
  391. extensionAlias: ExtensionAliasOption[];
  392. cachePredicate: (arg0: ResolveRequest) => boolean;
  393. cacheWithContext: boolean;
  394. /**
  395. * A list of exports field condition names.
  396. */
  397. conditionNames: Set<string>;
  398. descriptionFiles: string[];
  399. enforceExtension: boolean;
  400. exportsFields: Set<string | string[]>;
  401. importsFields: Set<string | string[]>;
  402. extensions: Set<string>;
  403. fileSystem: FileSystem;
  404. unsafeCache: false | object;
  405. symlinks: boolean;
  406. resolver?: Resolver;
  407. modules: (string | string[])[];
  408. mainFields: { name: string[]; forceRelative: boolean }[];
  409. mainFiles: Set<string>;
  410. plugins: Plugin[];
  411. pnpApi: null | PnpApiImpl;
  412. roots: Set<string>;
  413. fullySpecified: boolean;
  414. resolveToContext: boolean;
  415. restrictions: Set<string | RegExp>;
  416. preferRelative: boolean;
  417. preferAbsolute: boolean;
  418. }
  419. type ResolveOptionsOptionalFS = Omit<UserResolveOptions, "fileSystem"> &
  420. Partial<Pick<UserResolveOptions, "fileSystem">>;
  421. type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>;
  422. declare abstract class Resolver {
  423. fileSystem: FileSystem;
  424. options: ResolveOptions;
  425. hooks: KnownHooks;
  426. ensureHook(
  427. name:
  428. | string
  429. | AsyncSeriesBailHook<
  430. [ResolveRequest, ResolveContext],
  431. null | ResolveRequest
  432. >
  433. ): AsyncSeriesBailHook<
  434. [ResolveRequest, ResolveContext],
  435. null | ResolveRequest
  436. >;
  437. getHook(
  438. name:
  439. | string
  440. | AsyncSeriesBailHook<
  441. [ResolveRequest, ResolveContext],
  442. null | ResolveRequest
  443. >
  444. ): AsyncSeriesBailHook<
  445. [ResolveRequest, ResolveContext],
  446. null | ResolveRequest
  447. >;
  448. resolveSync(context: object, path: string, request: string): string | false;
  449. resolve(
  450. context: object,
  451. path: string,
  452. request: string,
  453. resolveContext: ResolveContext,
  454. callback: (
  455. err: null | ErrorWithDetail,
  456. res?: string | false,
  457. req?: ResolveRequest
  458. ) => void
  459. ): void;
  460. doResolve(
  461. hook: AsyncSeriesBailHook<
  462. [ResolveRequest, ResolveContext],
  463. null | ResolveRequest
  464. >,
  465. request: ResolveRequest,
  466. message: null | string,
  467. resolveContext: ResolveContext,
  468. callback: (err?: null | Error, result?: ResolveRequest) => void
  469. ): void;
  470. parse(identifier: string): ParsedIdentifier;
  471. isModule(path: string): boolean;
  472. isPrivate(path: string): boolean;
  473. isDirectory(path: string): boolean;
  474. join(path: string, request: string): string;
  475. normalize(path: string): string;
  476. }
  477. declare interface UserResolveOptions {
  478. /**
  479. * A list of module alias configurations or an object which maps key to value
  480. */
  481. alias?: AliasOptions | AliasOption[];
  482. /**
  483. * A list of module alias configurations or an object which maps key to value, applied only after modules option
  484. */
  485. fallback?: AliasOptions | AliasOption[];
  486. /**
  487. * An object which maps extension to extension aliases
  488. */
  489. extensionAlias?: ExtensionAliasOptions;
  490. /**
  491. * A list of alias fields in description files
  492. */
  493. aliasFields?: (string | string[])[];
  494. /**
  495. * A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties.
  496. */
  497. cachePredicate?: (arg0: ResolveRequest) => boolean;
  498. /**
  499. * Whether or not the unsafeCache should include request context as part of the cache key.
  500. */
  501. cacheWithContext?: boolean;
  502. /**
  503. * A list of description files to read from
  504. */
  505. descriptionFiles?: string[];
  506. /**
  507. * A list of exports field condition names.
  508. */
  509. conditionNames?: string[];
  510. /**
  511. * Enforce that a extension from extensions must be used
  512. */
  513. enforceExtension?: boolean;
  514. /**
  515. * A list of exports fields in description files
  516. */
  517. exportsFields?: (string | string[])[];
  518. /**
  519. * A list of imports fields in description files
  520. */
  521. importsFields?: (string | string[])[];
  522. /**
  523. * A list of extensions which should be tried for files
  524. */
  525. extensions?: string[];
  526. /**
  527. * The file system which should be used
  528. */
  529. fileSystem: FileSystem;
  530. /**
  531. * Use this cache object to unsafely cache the successful requests
  532. */
  533. unsafeCache?: boolean | object;
  534. /**
  535. * Resolve symlinks to their symlinked location
  536. */
  537. symlinks?: boolean;
  538. /**
  539. * A prepared Resolver to which the plugins are attached
  540. */
  541. resolver?: Resolver;
  542. /**
  543. * A list of directories to resolve modules from, can be absolute path or folder name
  544. */
  545. modules?: string | string[];
  546. /**
  547. * A list of main fields in description files
  548. */
  549. mainFields?: (
  550. | string
  551. | string[]
  552. | { name: string | string[]; forceRelative: boolean }
  553. )[];
  554. /**
  555. * A list of main files in directories
  556. */
  557. mainFiles?: string[];
  558. /**
  559. * A list of additional resolve plugins which should be applied
  560. */
  561. plugins?: Plugin[];
  562. /**
  563. * A PnP API that should be used - null is "never", undefined is "auto"
  564. */
  565. pnpApi?: null | PnpApiImpl;
  566. /**
  567. * A list of root paths
  568. */
  569. roots?: string[];
  570. /**
  571. * The request is already fully specified and no extensions or directories are resolved for it
  572. */
  573. fullySpecified?: boolean;
  574. /**
  575. * Resolve to a context instead of a file
  576. */
  577. resolveToContext?: boolean;
  578. /**
  579. * A list of resolve restrictions
  580. */
  581. restrictions?: (string | RegExp)[];
  582. /**
  583. * Use only the sync constraints of the file system calls
  584. */
  585. useSyncFileSystemCalls?: boolean;
  586. /**
  587. * Prefer to resolve module requests as relative requests before falling back to modules
  588. */
  589. preferRelative?: boolean;
  590. /**
  591. * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
  592. */
  593. preferAbsolute?: boolean;
  594. }
  595. declare interface WriteOnlySet<T> {
  596. add: (item: T) => void;
  597. }
  598. declare function exports(
  599. context: object,
  600. path: string,
  601. request: string,
  602. resolveContext: ResolveContext,
  603. callback: (
  604. err: null | ErrorWithDetail,
  605. res?: string | false,
  606. req?: ResolveRequest
  607. ) => void
  608. ): void;
  609. declare function exports(
  610. context: object,
  611. path: string,
  612. request: string,
  613. callback: (
  614. err: null | ErrorWithDetail,
  615. res?: string | false,
  616. req?: ResolveRequest
  617. ) => void
  618. ): void;
  619. declare function exports(
  620. path: string,
  621. request: string,
  622. resolveContext: ResolveContext,
  623. callback: (
  624. err: null | ErrorWithDetail,
  625. res?: string | false,
  626. req?: ResolveRequest
  627. ) => void
  628. ): void;
  629. declare function exports(
  630. path: string,
  631. request: string,
  632. callback: (
  633. err: null | ErrorWithDetail,
  634. res?: string | false,
  635. req?: ResolveRequest
  636. ) => void
  637. ): void;
  638. declare namespace exports {
  639. export const sync: ResolveFunction;
  640. export function create(
  641. options: ResolveOptionsOptionalFS
  642. ): ResolveFunctionAsync;
  643. export namespace create {
  644. export const sync: (options: ResolveOptionsOptionalFS) => ResolveFunction;
  645. }
  646. export namespace ResolverFactory {
  647. export let createResolver: (options: UserResolveOptions) => Resolver;
  648. }
  649. export const forEachBail: <T, Z>(
  650. array: T[],
  651. iterator: Iterator<T, Z>,
  652. callback: (err?: null | Error, result?: null | Z) => void
  653. ) => void;
  654. export type ResolveCallback = (
  655. err: null | ErrorWithDetail,
  656. res?: string | false,
  657. req?: ResolveRequest
  658. ) => void;
  659. export {
  660. CachedInputFileSystem,
  661. CloneBasenamePlugin,
  662. LogInfoPlugin,
  663. ResolveOptionsOptionalFS,
  664. PnpApiImpl as PnpApi,
  665. Resolver,
  666. FileSystem,
  667. ResolveContext,
  668. ResolveRequest,
  669. Plugin,
  670. UserResolveOptions as ResolveOptions,
  671. ResolveFunctionAsync,
  672. ResolveFunction
  673. };
  674. }
  675. export = exports;