types.d.ts 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658
  1. /*
  2. * This file was automatically generated.
  3. * DO NOT MODIFY BY HAND.
  4. * Run `yarn fix:special` to update
  5. */
  6. import { Buffer } from "buffer";
  7. import { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } from "tapable";
  8. import { URL as URL_Import } from "url";
  9. declare interface Abortable {
  10. /**
  11. * When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
  12. */
  13. signal?: AbortSignal;
  14. }
  15. type Alias = string | false | string[];
  16. declare interface AliasOption {
  17. alias: Alias;
  18. name: string;
  19. onlyModule?: boolean;
  20. }
  21. type AliasOptionNewRequest = string | false | string[];
  22. declare interface AliasOptions {
  23. [index: string]: AliasOptionNewRequest;
  24. }
  25. type BaseFileSystem = FileSystem & SyncFileSystem;
  26. declare interface BaseResolveRequest {
  27. /**
  28. * path
  29. */
  30. path: string | false;
  31. /**
  32. * content
  33. */
  34. context?: object;
  35. /**
  36. * description file path
  37. */
  38. descriptionFilePath?: string;
  39. /**
  40. * description file root
  41. */
  42. descriptionFileRoot?: string;
  43. /**
  44. * description file data
  45. */
  46. descriptionFileData?: JsonObject;
  47. /**
  48. * relative path
  49. */
  50. relativePath?: string;
  51. /**
  52. * true when need to ignore symlinks, otherwise false
  53. */
  54. ignoreSymlinks?: boolean;
  55. /**
  56. * true when full specified, otherwise false
  57. */
  58. fullySpecified?: boolean;
  59. /**
  60. * inner request for internal usage
  61. */
  62. __innerRequest?: string;
  63. /**
  64. * inner request for internal usage
  65. */
  66. __innerRequest_request?: string;
  67. /**
  68. * inner relative path for internal usage
  69. */
  70. __innerRequest_relativePath?: string;
  71. }
  72. type BufferEncoding =
  73. | "ascii"
  74. | "utf8"
  75. | "utf-8"
  76. | "utf16le"
  77. | "utf-16le"
  78. | "ucs2"
  79. | "ucs-2"
  80. | "base64"
  81. | "base64url"
  82. | "latin1"
  83. | "binary"
  84. | "hex";
  85. type BufferEncodingOption = "buffer" | { encoding: "buffer" };
  86. declare interface Cache {
  87. [index: string]: undefined | ResolveRequest | ResolveRequest[];
  88. }
  89. declare class CachedInputFileSystem {
  90. constructor(fileSystem: BaseFileSystem, duration: number);
  91. fileSystem: BaseFileSystem;
  92. lstat?: LStat;
  93. lstatSync?: LStatSync;
  94. stat: Stat;
  95. statSync: StatSync;
  96. readdir: Readdir;
  97. readdirSync: ReaddirSync;
  98. readFile: ReadFile;
  99. readFileSync: ReadFileSync;
  100. readJson?: (
  101. pathOrFileDescription: PathOrFileDescriptor,
  102. callback: (
  103. err: null | Error | NodeJS.ErrnoException,
  104. result?: JsonObject,
  105. ) => void,
  106. ) => void;
  107. readJsonSync?: (pathOrFileDescription: PathOrFileDescriptor) => JsonObject;
  108. readlink: Readlink;
  109. readlinkSync: ReadlinkSync;
  110. realpath?: RealPath;
  111. realpathSync?: RealPathSync;
  112. purge(
  113. what?:
  114. | string
  115. | number
  116. | Buffer
  117. | URL_url
  118. | (string | number | Buffer | URL_url)[]
  119. | Set<string | number | Buffer | URL_url>,
  120. ): void;
  121. }
  122. declare class CloneBasenamePlugin {
  123. constructor(
  124. source:
  125. | string
  126. | AsyncSeriesBailHook<
  127. [ResolveRequest, ResolveContext],
  128. null | ResolveRequest
  129. >,
  130. target:
  131. | string
  132. | AsyncSeriesBailHook<
  133. [ResolveRequest, ResolveContext],
  134. null | ResolveRequest
  135. >,
  136. );
  137. source:
  138. | string
  139. | AsyncSeriesBailHook<
  140. [ResolveRequest, ResolveContext],
  141. null | ResolveRequest
  142. >;
  143. target:
  144. | string
  145. | AsyncSeriesBailHook<
  146. [ResolveRequest, ResolveContext],
  147. null | ResolveRequest
  148. >;
  149. apply(resolver: Resolver): void;
  150. }
  151. declare interface Dirent<T extends string | Buffer = string> {
  152. /**
  153. * true when is file, otherwise false
  154. */
  155. isFile: () => boolean;
  156. /**
  157. * true when is directory, otherwise false
  158. */
  159. isDirectory: () => boolean;
  160. /**
  161. * true when is block device, otherwise false
  162. */
  163. isBlockDevice: () => boolean;
  164. /**
  165. * true when is character device, otherwise false
  166. */
  167. isCharacterDevice: () => boolean;
  168. /**
  169. * true when is symbolic link, otherwise false
  170. */
  171. isSymbolicLink: () => boolean;
  172. /**
  173. * true when is FIFO, otherwise false
  174. */
  175. isFIFO: () => boolean;
  176. /**
  177. * true when is socket, otherwise false
  178. */
  179. isSocket: () => boolean;
  180. /**
  181. * name
  182. */
  183. name: T;
  184. /**
  185. * path
  186. */
  187. parentPath: string;
  188. /**
  189. * path
  190. */
  191. path?: string;
  192. }
  193. type EncodingOption =
  194. | undefined
  195. | null
  196. | "ascii"
  197. | "utf8"
  198. | "utf-8"
  199. | "utf16le"
  200. | "utf-16le"
  201. | "ucs2"
  202. | "ucs-2"
  203. | "base64"
  204. | "base64url"
  205. | "latin1"
  206. | "binary"
  207. | "hex"
  208. | ObjectEncodingOptions;
  209. type ErrorWithDetail = Error & { details?: string };
  210. declare interface ExtensionAliasOption {
  211. alias: string | string[];
  212. extension: string;
  213. }
  214. declare interface ExtensionAliasOptions {
  215. [index: string]: string | string[];
  216. }
  217. declare interface FileSystem {
  218. /**
  219. * read file method
  220. */
  221. readFile: ReadFile;
  222. /**
  223. * readdir method
  224. */
  225. readdir: Readdir;
  226. /**
  227. * read json method
  228. */
  229. readJson?: (
  230. pathOrFileDescription: PathOrFileDescriptor,
  231. callback: (
  232. err: null | Error | NodeJS.ErrnoException,
  233. result?: JsonObject,
  234. ) => void,
  235. ) => void;
  236. /**
  237. * read link method
  238. */
  239. readlink: Readlink;
  240. /**
  241. * lstat method
  242. */
  243. lstat?: LStat;
  244. /**
  245. * stat method
  246. */
  247. stat: Stat;
  248. /**
  249. * realpath method
  250. */
  251. realpath?: RealPath;
  252. }
  253. type IBigIntStats = IStatsBase<bigint> & {
  254. atimeNs: bigint;
  255. mtimeNs: bigint;
  256. ctimeNs: bigint;
  257. birthtimeNs: bigint;
  258. };
  259. declare interface IStats {
  260. /**
  261. * is file
  262. */
  263. isFile: () => boolean;
  264. /**
  265. * is directory
  266. */
  267. isDirectory: () => boolean;
  268. /**
  269. * is block device
  270. */
  271. isBlockDevice: () => boolean;
  272. /**
  273. * is character device
  274. */
  275. isCharacterDevice: () => boolean;
  276. /**
  277. * is symbolic link
  278. */
  279. isSymbolicLink: () => boolean;
  280. /**
  281. * is FIFO
  282. */
  283. isFIFO: () => boolean;
  284. /**
  285. * is socket
  286. */
  287. isSocket: () => boolean;
  288. /**
  289. * dev
  290. */
  291. dev: number;
  292. /**
  293. * ino
  294. */
  295. ino: number;
  296. /**
  297. * mode
  298. */
  299. mode: number;
  300. /**
  301. * nlink
  302. */
  303. nlink: number;
  304. /**
  305. * uid
  306. */
  307. uid: number;
  308. /**
  309. * gid
  310. */
  311. gid: number;
  312. /**
  313. * rdev
  314. */
  315. rdev: number;
  316. /**
  317. * size
  318. */
  319. size: number;
  320. /**
  321. * blksize
  322. */
  323. blksize: number;
  324. /**
  325. * blocks
  326. */
  327. blocks: number;
  328. /**
  329. * atime ms
  330. */
  331. atimeMs: number;
  332. /**
  333. * mtime ms
  334. */
  335. mtimeMs: number;
  336. /**
  337. * ctime ms
  338. */
  339. ctimeMs: number;
  340. /**
  341. * birthtime ms
  342. */
  343. birthtimeMs: number;
  344. /**
  345. * atime
  346. */
  347. atime: Date;
  348. /**
  349. * mtime
  350. */
  351. mtime: Date;
  352. /**
  353. * ctime
  354. */
  355. ctime: Date;
  356. /**
  357. * birthtime
  358. */
  359. birthtime: Date;
  360. }
  361. declare interface IStatsBase<T> {
  362. /**
  363. * is file
  364. */
  365. isFile: () => boolean;
  366. /**
  367. * is directory
  368. */
  369. isDirectory: () => boolean;
  370. /**
  371. * is block device
  372. */
  373. isBlockDevice: () => boolean;
  374. /**
  375. * is character device
  376. */
  377. isCharacterDevice: () => boolean;
  378. /**
  379. * is symbolic link
  380. */
  381. isSymbolicLink: () => boolean;
  382. /**
  383. * is FIFO
  384. */
  385. isFIFO: () => boolean;
  386. /**
  387. * is socket
  388. */
  389. isSocket: () => boolean;
  390. /**
  391. * dev
  392. */
  393. dev: T;
  394. /**
  395. * ino
  396. */
  397. ino: T;
  398. /**
  399. * mode
  400. */
  401. mode: T;
  402. /**
  403. * nlink
  404. */
  405. nlink: T;
  406. /**
  407. * uid
  408. */
  409. uid: T;
  410. /**
  411. * gid
  412. */
  413. gid: T;
  414. /**
  415. * rdev
  416. */
  417. rdev: T;
  418. /**
  419. * size
  420. */
  421. size: T;
  422. /**
  423. * blksize
  424. */
  425. blksize: T;
  426. /**
  427. * blocks
  428. */
  429. blocks: T;
  430. /**
  431. * atime ms
  432. */
  433. atimeMs: T;
  434. /**
  435. * mtime ms
  436. */
  437. mtimeMs: T;
  438. /**
  439. * ctime ms
  440. */
  441. ctimeMs: T;
  442. /**
  443. * birthtime ms
  444. */
  445. birthtimeMs: T;
  446. /**
  447. * atime
  448. */
  449. atime: Date;
  450. /**
  451. * mtime
  452. */
  453. mtime: Date;
  454. /**
  455. * ctime
  456. */
  457. ctime: Date;
  458. /**
  459. * birthtime
  460. */
  461. birthtime: Date;
  462. }
  463. declare interface Iterator<T, Z> {
  464. (
  465. item: T,
  466. callback: (err?: null | Error, result?: null | Z) => void,
  467. i: number,
  468. ): void;
  469. }
  470. declare interface JsonObject {
  471. [index: string]:
  472. | undefined
  473. | null
  474. | string
  475. | number
  476. | boolean
  477. | JsonObject
  478. | JsonValue[];
  479. }
  480. type JsonValue = null | string | number | boolean | JsonObject | JsonValue[];
  481. declare interface KnownHooks {
  482. /**
  483. * resolve step hook
  484. */
  485. resolveStep: SyncHook<
  486. [
  487. AsyncSeriesBailHook<
  488. [ResolveRequest, ResolveContext],
  489. null | ResolveRequest
  490. >,
  491. ResolveRequest,
  492. ]
  493. >;
  494. /**
  495. * no resolve hook
  496. */
  497. noResolve: SyncHook<[ResolveRequest, Error]>;
  498. /**
  499. * resolve hook
  500. */
  501. resolve: AsyncSeriesBailHook<
  502. [ResolveRequest, ResolveContext],
  503. null | ResolveRequest
  504. >;
  505. /**
  506. * result hook
  507. */
  508. result: AsyncSeriesHook<[ResolveRequest, ResolveContext]>;
  509. }
  510. declare interface LStat {
  511. (
  512. path: PathLike,
  513. callback: (err: null | NodeJS.ErrnoException, result?: IStats) => void,
  514. ): void;
  515. (
  516. path: PathLike,
  517. options: undefined | (StatOptions & { bigint?: false }),
  518. callback: (err: null | NodeJS.ErrnoException, result?: IStats) => void,
  519. ): void;
  520. (
  521. path: PathLike,
  522. options: StatOptions & { bigint: true },
  523. callback: (
  524. err: null | NodeJS.ErrnoException,
  525. result?: IBigIntStats,
  526. ) => void,
  527. ): void;
  528. (
  529. path: PathLike,
  530. options: undefined | StatOptions,
  531. callback: (
  532. err: null | NodeJS.ErrnoException,
  533. result?: IStats | IBigIntStats,
  534. ) => void,
  535. ): void;
  536. }
  537. declare interface LStatSync {
  538. (path: PathLike, options?: undefined): IStats;
  539. (
  540. path: PathLike,
  541. options?: StatSyncOptions & { bigint?: false; throwIfNoEntry: false },
  542. ): undefined | IStats;
  543. (
  544. path: PathLike,
  545. options: StatSyncOptions & { bigint: true; throwIfNoEntry: false },
  546. ): undefined | IBigIntStats;
  547. (path: PathLike, options?: StatSyncOptions & { bigint?: false }): IStats;
  548. (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats;
  549. (
  550. path: PathLike,
  551. options: StatSyncOptions & { bigint: boolean; throwIfNoEntry?: false },
  552. ): IStats | IBigIntStats;
  553. (
  554. path: PathLike,
  555. options?: StatSyncOptions,
  556. ): undefined | IStats | IBigIntStats;
  557. }
  558. declare class LogInfoPlugin {
  559. constructor(
  560. source:
  561. | string
  562. | AsyncSeriesBailHook<
  563. [ResolveRequest, ResolveContext],
  564. null | ResolveRequest
  565. >,
  566. );
  567. source:
  568. | string
  569. | AsyncSeriesBailHook<
  570. [ResolveRequest, ResolveContext],
  571. null | ResolveRequest
  572. >;
  573. apply(resolver: Resolver): void;
  574. }
  575. declare interface ObjectEncodingOptions {
  576. /**
  577. * encoding
  578. */
  579. encoding?:
  580. | null
  581. | "ascii"
  582. | "utf8"
  583. | "utf-8"
  584. | "utf16le"
  585. | "utf-16le"
  586. | "ucs2"
  587. | "ucs-2"
  588. | "base64"
  589. | "base64url"
  590. | "latin1"
  591. | "binary"
  592. | "hex";
  593. }
  594. declare interface ParsedIdentifier {
  595. /**
  596. * request
  597. */
  598. request: string;
  599. /**
  600. * query
  601. */
  602. query: string;
  603. /**
  604. * fragment
  605. */
  606. fragment: string;
  607. /**
  608. * is directory
  609. */
  610. directory: boolean;
  611. /**
  612. * is module
  613. */
  614. module: boolean;
  615. /**
  616. * is file
  617. */
  618. file: boolean;
  619. /**
  620. * is internal
  621. */
  622. internal: boolean;
  623. }
  624. type PathLike = string | Buffer | URL_url;
  625. type PathOrFileDescriptor = string | number | Buffer | URL_url;
  626. type Plugin =
  627. | undefined
  628. | null
  629. | false
  630. | ""
  631. | 0
  632. | { apply: (this: Resolver, resolver: Resolver) => void }
  633. | ((this: Resolver, resolver: Resolver) => void);
  634. declare interface PnpApi {
  635. /**
  636. * resolve to unqualified
  637. */
  638. resolveToUnqualified: (
  639. packageName: string,
  640. issuer: string,
  641. options: { considerBuiltins: boolean },
  642. ) => null | string;
  643. }
  644. declare interface ReadFile {
  645. (
  646. path: PathOrFileDescriptor,
  647. options:
  648. | undefined
  649. | null
  650. | ({ encoding?: null; flag?: string } & Abortable),
  651. callback: (err: null | NodeJS.ErrnoException, result?: Buffer) => void,
  652. ): void;
  653. (
  654. path: PathOrFileDescriptor,
  655. options:
  656. | ({ encoding: BufferEncoding; flag?: string } & Abortable)
  657. | "ascii"
  658. | "utf8"
  659. | "utf-8"
  660. | "utf16le"
  661. | "utf-16le"
  662. | "ucs2"
  663. | "ucs-2"
  664. | "base64"
  665. | "base64url"
  666. | "latin1"
  667. | "binary"
  668. | "hex",
  669. callback: (err: null | NodeJS.ErrnoException, result?: string) => void,
  670. ): void;
  671. (
  672. path: PathOrFileDescriptor,
  673. options:
  674. | undefined
  675. | null
  676. | "ascii"
  677. | "utf8"
  678. | "utf-8"
  679. | "utf16le"
  680. | "utf-16le"
  681. | "ucs2"
  682. | "ucs-2"
  683. | "base64"
  684. | "base64url"
  685. | "latin1"
  686. | "binary"
  687. | "hex"
  688. | (ObjectEncodingOptions & { flag?: string } & Abortable),
  689. callback: (
  690. err: null | NodeJS.ErrnoException,
  691. result?: string | Buffer,
  692. ) => void,
  693. ): void;
  694. (
  695. path: PathOrFileDescriptor,
  696. callback: (err: null | NodeJS.ErrnoException, result?: Buffer) => void,
  697. ): void;
  698. }
  699. declare interface ReadFileSync {
  700. (
  701. path: PathOrFileDescriptor,
  702. options?: null | { encoding?: null; flag?: string },
  703. ): Buffer;
  704. (
  705. path: PathOrFileDescriptor,
  706. options:
  707. | "ascii"
  708. | "utf8"
  709. | "utf-8"
  710. | "utf16le"
  711. | "utf-16le"
  712. | "ucs2"
  713. | "ucs-2"
  714. | "base64"
  715. | "base64url"
  716. | "latin1"
  717. | "binary"
  718. | "hex"
  719. | { encoding: BufferEncoding; flag?: string },
  720. ): string;
  721. (
  722. path: PathOrFileDescriptor,
  723. options?:
  724. | null
  725. | "ascii"
  726. | "utf8"
  727. | "utf-8"
  728. | "utf16le"
  729. | "utf-16le"
  730. | "ucs2"
  731. | "ucs-2"
  732. | "base64"
  733. | "base64url"
  734. | "latin1"
  735. | "binary"
  736. | "hex"
  737. | (ObjectEncodingOptions & { flag?: string }),
  738. ): string | Buffer;
  739. }
  740. declare interface Readdir {
  741. (
  742. path: PathLike,
  743. options:
  744. | undefined
  745. | null
  746. | "ascii"
  747. | "utf8"
  748. | "utf-8"
  749. | "utf16le"
  750. | "utf-16le"
  751. | "ucs2"
  752. | "ucs-2"
  753. | "base64"
  754. | "base64url"
  755. | "latin1"
  756. | "binary"
  757. | "hex"
  758. | {
  759. encoding:
  760. | null
  761. | "ascii"
  762. | "utf8"
  763. | "utf-8"
  764. | "utf16le"
  765. | "utf-16le"
  766. | "ucs2"
  767. | "ucs-2"
  768. | "base64"
  769. | "base64url"
  770. | "latin1"
  771. | "binary"
  772. | "hex";
  773. withFileTypes?: false;
  774. recursive?: boolean;
  775. },
  776. callback: (err: null | NodeJS.ErrnoException, files?: string[]) => void,
  777. ): void;
  778. (
  779. path: PathLike,
  780. options:
  781. | { encoding: "buffer"; withFileTypes?: false; recursive?: boolean }
  782. | "buffer",
  783. callback: (err: null | NodeJS.ErrnoException, files?: Buffer[]) => void,
  784. ): void;
  785. (
  786. path: PathLike,
  787. options:
  788. | undefined
  789. | null
  790. | "ascii"
  791. | "utf8"
  792. | "utf-8"
  793. | "utf16le"
  794. | "utf-16le"
  795. | "ucs2"
  796. | "ucs-2"
  797. | "base64"
  798. | "base64url"
  799. | "latin1"
  800. | "binary"
  801. | "hex"
  802. | (ObjectEncodingOptions & {
  803. withFileTypes?: false;
  804. recursive?: boolean;
  805. }),
  806. callback: (
  807. err: null | NodeJS.ErrnoException,
  808. files?: string[] | Buffer[],
  809. ) => void,
  810. ): void;
  811. (
  812. path: PathLike,
  813. callback: (err: null | NodeJS.ErrnoException, files?: string[]) => void,
  814. ): void;
  815. (
  816. path: PathLike,
  817. options: ObjectEncodingOptions & {
  818. withFileTypes: true;
  819. recursive?: boolean;
  820. },
  821. callback: (
  822. err: null | NodeJS.ErrnoException,
  823. files?: Dirent<string>[],
  824. ) => void,
  825. ): void;
  826. (
  827. path: PathLike,
  828. options: { encoding: "buffer"; withFileTypes: true; recursive?: boolean },
  829. callback: (
  830. err: null | NodeJS.ErrnoException,
  831. files: Dirent<Buffer>[],
  832. ) => void,
  833. ): void;
  834. }
  835. declare interface ReaddirSync {
  836. (
  837. path: PathLike,
  838. options?:
  839. | null
  840. | "ascii"
  841. | "utf8"
  842. | "utf-8"
  843. | "utf16le"
  844. | "utf-16le"
  845. | "ucs2"
  846. | "ucs-2"
  847. | "base64"
  848. | "base64url"
  849. | "latin1"
  850. | "binary"
  851. | "hex"
  852. | {
  853. encoding:
  854. | null
  855. | "ascii"
  856. | "utf8"
  857. | "utf-8"
  858. | "utf16le"
  859. | "utf-16le"
  860. | "ucs2"
  861. | "ucs-2"
  862. | "base64"
  863. | "base64url"
  864. | "latin1"
  865. | "binary"
  866. | "hex";
  867. withFileTypes?: false;
  868. recursive?: boolean;
  869. },
  870. ): string[];
  871. (
  872. path: PathLike,
  873. options:
  874. | "buffer"
  875. | { encoding: "buffer"; withFileTypes?: false; recursive?: boolean },
  876. ): Buffer[];
  877. (
  878. path: PathLike,
  879. options?:
  880. | null
  881. | "ascii"
  882. | "utf8"
  883. | "utf-8"
  884. | "utf16le"
  885. | "utf-16le"
  886. | "ucs2"
  887. | "ucs-2"
  888. | "base64"
  889. | "base64url"
  890. | "latin1"
  891. | "binary"
  892. | "hex"
  893. | (ObjectEncodingOptions & {
  894. withFileTypes?: false;
  895. recursive?: boolean;
  896. }),
  897. ): string[] | Buffer[];
  898. (
  899. path: PathLike,
  900. options: ObjectEncodingOptions & {
  901. withFileTypes: true;
  902. recursive?: boolean;
  903. },
  904. ): Dirent<string>[];
  905. (
  906. path: PathLike,
  907. options: { encoding: "buffer"; withFileTypes: true; recursive?: boolean },
  908. ): Dirent<Buffer>[];
  909. }
  910. declare interface Readlink {
  911. (
  912. path: PathLike,
  913. options: EncodingOption,
  914. callback: (err: null | NodeJS.ErrnoException, result?: string) => void,
  915. ): void;
  916. (
  917. path: PathLike,
  918. options: BufferEncodingOption,
  919. callback: (err: null | NodeJS.ErrnoException, result?: Buffer) => void,
  920. ): void;
  921. (
  922. path: PathLike,
  923. options: EncodingOption,
  924. callback: (
  925. err: null | NodeJS.ErrnoException,
  926. result?: string | Buffer,
  927. ) => void,
  928. ): void;
  929. (
  930. path: PathLike,
  931. callback: (err: null | NodeJS.ErrnoException, result?: string) => void,
  932. ): void;
  933. }
  934. declare interface ReadlinkSync {
  935. (path: PathLike, options?: EncodingOption): string;
  936. (path: PathLike, options: BufferEncodingOption): Buffer;
  937. (path: PathLike, options?: EncodingOption): string | Buffer;
  938. }
  939. declare interface RealPath {
  940. (
  941. path: PathLike,
  942. options: EncodingOption,
  943. callback: (err: null | NodeJS.ErrnoException, result?: string) => void,
  944. ): void;
  945. (
  946. path: PathLike,
  947. options: BufferEncodingOption,
  948. callback: (err: null | NodeJS.ErrnoException, result?: Buffer) => void,
  949. ): void;
  950. (
  951. path: PathLike,
  952. options: EncodingOption,
  953. callback: (
  954. err: null | NodeJS.ErrnoException,
  955. result?: string | Buffer,
  956. ) => void,
  957. ): void;
  958. (
  959. path: PathLike,
  960. callback: (err: null | NodeJS.ErrnoException, result?: string) => void,
  961. ): void;
  962. }
  963. declare interface RealPathSync {
  964. (path: PathLike, options?: EncodingOption): string;
  965. (path: PathLike, options: BufferEncodingOption): Buffer;
  966. (path: PathLike, options?: EncodingOption): string | Buffer;
  967. }
  968. declare interface ResolveContext {
  969. /**
  970. * directories that was found on file system
  971. */
  972. contextDependencies?: WriteOnlySet<string>;
  973. /**
  974. * files that was found on file system
  975. */
  976. fileDependencies?: WriteOnlySet<string>;
  977. /**
  978. * dependencies that was not found on file system
  979. */
  980. missingDependencies?: WriteOnlySet<string>;
  981. /**
  982. * set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`,
  983. */
  984. stack?: Set<string>;
  985. /**
  986. * log function
  987. */
  988. log?: (str: string) => void;
  989. /**
  990. * yield result, if provided plugins can return several results
  991. */
  992. yield?: (request: ResolveRequest) => void;
  993. }
  994. declare interface ResolveFunction {
  995. (context: object, path: string, request: string): string | false;
  996. (path: string, request: string): string | false;
  997. }
  998. declare interface ResolveFunctionAsync {
  999. (
  1000. context: object,
  1001. path: string,
  1002. request: string,
  1003. resolveContext: ResolveContext,
  1004. callback: (
  1005. err: null | ErrorWithDetail,
  1006. res?: string | false,
  1007. req?: ResolveRequest,
  1008. ) => void,
  1009. ): void;
  1010. (
  1011. context: object,
  1012. path: string,
  1013. request: string,
  1014. callback: (
  1015. err: null | ErrorWithDetail,
  1016. res?: string | false,
  1017. req?: ResolveRequest,
  1018. ) => void,
  1019. ): void;
  1020. (
  1021. path: string,
  1022. request: string,
  1023. resolveContext: ResolveContext,
  1024. callback: (
  1025. err: null | ErrorWithDetail,
  1026. res?: string | false,
  1027. req?: ResolveRequest,
  1028. ) => void,
  1029. ): void;
  1030. (
  1031. path: string,
  1032. request: string,
  1033. callback: (
  1034. err: null | ErrorWithDetail,
  1035. res?: string | false,
  1036. req?: ResolveRequest,
  1037. ) => void,
  1038. ): void;
  1039. }
  1040. type ResolveOptionsOptionalFS = Omit<
  1041. ResolveOptionsResolverFactoryObject_2,
  1042. "fileSystem"
  1043. > &
  1044. Partial<Pick<ResolveOptionsResolverFactoryObject_2, "fileSystem">>;
  1045. declare interface ResolveOptionsResolverFactoryObject_1 {
  1046. /**
  1047. * alias
  1048. */
  1049. alias: AliasOption[];
  1050. /**
  1051. * fallback
  1052. */
  1053. fallback: AliasOption[];
  1054. /**
  1055. * alias fields
  1056. */
  1057. aliasFields: Set<string | string[]>;
  1058. /**
  1059. * extension alias
  1060. */
  1061. extensionAlias: ExtensionAliasOption[];
  1062. /**
  1063. * cache predicate
  1064. */
  1065. cachePredicate: (predicate: ResolveRequest) => boolean;
  1066. /**
  1067. * cache with context
  1068. */
  1069. cacheWithContext: boolean;
  1070. /**
  1071. * A list of exports field condition names.
  1072. */
  1073. conditionNames: Set<string>;
  1074. /**
  1075. * description files
  1076. */
  1077. descriptionFiles: string[];
  1078. /**
  1079. * enforce extension
  1080. */
  1081. enforceExtension: boolean;
  1082. /**
  1083. * exports fields
  1084. */
  1085. exportsFields: Set<string | string[]>;
  1086. /**
  1087. * imports fields
  1088. */
  1089. importsFields: Set<string | string[]>;
  1090. /**
  1091. * extensions
  1092. */
  1093. extensions: Set<string>;
  1094. /**
  1095. * fileSystem
  1096. */
  1097. fileSystem: FileSystem;
  1098. /**
  1099. * unsafe cache
  1100. */
  1101. unsafeCache: false | Cache;
  1102. /**
  1103. * symlinks
  1104. */
  1105. symlinks: boolean;
  1106. /**
  1107. * resolver
  1108. */
  1109. resolver?: Resolver;
  1110. /**
  1111. * modules
  1112. */
  1113. modules: (string | string[])[];
  1114. /**
  1115. * main fields
  1116. */
  1117. mainFields: { name: string[]; forceRelative: boolean }[];
  1118. /**
  1119. * main files
  1120. */
  1121. mainFiles: Set<string>;
  1122. /**
  1123. * plugins
  1124. */
  1125. plugins: Plugin[];
  1126. /**
  1127. * pnp API
  1128. */
  1129. pnpApi: null | PnpApi;
  1130. /**
  1131. * roots
  1132. */
  1133. roots: Set<string>;
  1134. /**
  1135. * fully specified
  1136. */
  1137. fullySpecified: boolean;
  1138. /**
  1139. * resolve to context
  1140. */
  1141. resolveToContext: boolean;
  1142. /**
  1143. * restrictions
  1144. */
  1145. restrictions: Set<string | RegExp>;
  1146. /**
  1147. * prefer relative
  1148. */
  1149. preferRelative: boolean;
  1150. /**
  1151. * prefer absolute
  1152. */
  1153. preferAbsolute: boolean;
  1154. }
  1155. declare interface ResolveOptionsResolverFactoryObject_2 {
  1156. /**
  1157. * A list of module alias configurations or an object which maps key to value
  1158. */
  1159. alias?: AliasOptions | AliasOption[];
  1160. /**
  1161. * A list of module alias configurations or an object which maps key to value, applied only after modules option
  1162. */
  1163. fallback?: AliasOptions | AliasOption[];
  1164. /**
  1165. * An object which maps extension to extension aliases
  1166. */
  1167. extensionAlias?: ExtensionAliasOptions;
  1168. /**
  1169. * A list of alias fields in description files
  1170. */
  1171. aliasFields?: (string | string[])[];
  1172. /**
  1173. * A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties.
  1174. */
  1175. cachePredicate?: (predicate: ResolveRequest) => boolean;
  1176. /**
  1177. * Whether or not the unsafeCache should include request context as part of the cache key.
  1178. */
  1179. cacheWithContext?: boolean;
  1180. /**
  1181. * A list of description files to read from
  1182. */
  1183. descriptionFiles?: string[];
  1184. /**
  1185. * A list of exports field condition names.
  1186. */
  1187. conditionNames?: string[];
  1188. /**
  1189. * Enforce that a extension from extensions must be used
  1190. */
  1191. enforceExtension?: boolean;
  1192. /**
  1193. * A list of exports fields in description files
  1194. */
  1195. exportsFields?: (string | string[])[];
  1196. /**
  1197. * A list of imports fields in description files
  1198. */
  1199. importsFields?: (string | string[])[];
  1200. /**
  1201. * A list of extensions which should be tried for files
  1202. */
  1203. extensions?: string[];
  1204. /**
  1205. * The file system which should be used
  1206. */
  1207. fileSystem: FileSystem;
  1208. /**
  1209. * Use this cache object to unsafely cache the successful requests
  1210. */
  1211. unsafeCache?: boolean | Cache;
  1212. /**
  1213. * Resolve symlinks to their symlinked location
  1214. */
  1215. symlinks?: boolean;
  1216. /**
  1217. * A prepared Resolver to which the plugins are attached
  1218. */
  1219. resolver?: Resolver;
  1220. /**
  1221. * A list of directories to resolve modules from, can be absolute path or folder name
  1222. */
  1223. modules?: string | string[];
  1224. /**
  1225. * A list of main fields in description files
  1226. */
  1227. mainFields?: (
  1228. | string
  1229. | string[]
  1230. | { name: string | string[]; forceRelative: boolean }
  1231. )[];
  1232. /**
  1233. * A list of main files in directories
  1234. */
  1235. mainFiles?: string[];
  1236. /**
  1237. * A list of additional resolve plugins which should be applied
  1238. */
  1239. plugins?: Plugin[];
  1240. /**
  1241. * A PnP API that should be used - null is "never", undefined is "auto"
  1242. */
  1243. pnpApi?: null | PnpApi;
  1244. /**
  1245. * A list of root paths
  1246. */
  1247. roots?: string[];
  1248. /**
  1249. * The request is already fully specified and no extensions or directories are resolved for it
  1250. */
  1251. fullySpecified?: boolean;
  1252. /**
  1253. * Resolve to a context instead of a file
  1254. */
  1255. resolveToContext?: boolean;
  1256. /**
  1257. * A list of resolve restrictions
  1258. */
  1259. restrictions?: (string | RegExp)[];
  1260. /**
  1261. * Use only the sync constraints of the file system calls
  1262. */
  1263. useSyncFileSystemCalls?: boolean;
  1264. /**
  1265. * Prefer to resolve module requests as relative requests before falling back to modules
  1266. */
  1267. preferRelative?: boolean;
  1268. /**
  1269. * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
  1270. */
  1271. preferAbsolute?: boolean;
  1272. }
  1273. type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>;
  1274. declare abstract class Resolver {
  1275. fileSystem: FileSystem;
  1276. options: ResolveOptionsResolverFactoryObject_1;
  1277. hooks: KnownHooks;
  1278. ensureHook(
  1279. name:
  1280. | string
  1281. | AsyncSeriesBailHook<
  1282. [ResolveRequest, ResolveContext],
  1283. null | ResolveRequest
  1284. >,
  1285. ): AsyncSeriesBailHook<
  1286. [ResolveRequest, ResolveContext],
  1287. null | ResolveRequest
  1288. >;
  1289. getHook(
  1290. name:
  1291. | string
  1292. | AsyncSeriesBailHook<
  1293. [ResolveRequest, ResolveContext],
  1294. null | ResolveRequest
  1295. >,
  1296. ): AsyncSeriesBailHook<
  1297. [ResolveRequest, ResolveContext],
  1298. null | ResolveRequest
  1299. >;
  1300. resolveSync(context: object, path: string, request: string): string | false;
  1301. resolve(
  1302. context: object,
  1303. path: string,
  1304. request: string,
  1305. resolveContext: ResolveContext,
  1306. callback: (
  1307. err: null | ErrorWithDetail,
  1308. res?: string | false,
  1309. req?: ResolveRequest,
  1310. ) => void,
  1311. ): void;
  1312. doResolve(
  1313. hook: AsyncSeriesBailHook<
  1314. [ResolveRequest, ResolveContext],
  1315. null | ResolveRequest
  1316. >,
  1317. request: ResolveRequest,
  1318. message: null | string,
  1319. resolveContext: ResolveContext,
  1320. callback: (err?: null | Error, result?: ResolveRequest) => void,
  1321. ): void;
  1322. parse(identifier: string): ParsedIdentifier;
  1323. isModule(path: string): boolean;
  1324. isPrivate(path: string): boolean;
  1325. isDirectory(path: string): boolean;
  1326. join(path: string, request: string): string;
  1327. normalize(path: string): string;
  1328. }
  1329. declare interface Stat {
  1330. (
  1331. path: PathLike,
  1332. callback: (err: null | NodeJS.ErrnoException, result?: IStats) => void,
  1333. ): void;
  1334. (
  1335. path: PathLike,
  1336. options: undefined | (StatOptions & { bigint?: false }),
  1337. callback: (err: null | NodeJS.ErrnoException, result?: IStats) => void,
  1338. ): void;
  1339. (
  1340. path: PathLike,
  1341. options: StatOptions & { bigint: true },
  1342. callback: (
  1343. err: null | NodeJS.ErrnoException,
  1344. result?: IBigIntStats,
  1345. ) => void,
  1346. ): void;
  1347. (
  1348. path: PathLike,
  1349. options: undefined | StatOptions,
  1350. callback: (
  1351. err: null | NodeJS.ErrnoException,
  1352. result?: IStats | IBigIntStats,
  1353. ) => void,
  1354. ): void;
  1355. }
  1356. declare interface StatOptions {
  1357. /**
  1358. * need bigint values
  1359. */
  1360. bigint?: boolean;
  1361. }
  1362. declare interface StatSync {
  1363. (path: PathLike, options?: undefined): IStats;
  1364. (
  1365. path: PathLike,
  1366. options?: StatSyncOptions & { bigint?: false; throwIfNoEntry: false },
  1367. ): undefined | IStats;
  1368. (
  1369. path: PathLike,
  1370. options: StatSyncOptions & { bigint: true; throwIfNoEntry: false },
  1371. ): undefined | IBigIntStats;
  1372. (path: PathLike, options?: StatSyncOptions & { bigint?: false }): IStats;
  1373. (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats;
  1374. (
  1375. path: PathLike,
  1376. options: StatSyncOptions & { bigint: boolean; throwIfNoEntry?: false },
  1377. ): IStats | IBigIntStats;
  1378. (
  1379. path: PathLike,
  1380. options?: StatSyncOptions,
  1381. ): undefined | IStats | IBigIntStats;
  1382. }
  1383. declare interface StatSyncOptions {
  1384. /**
  1385. * need bigint values
  1386. */
  1387. bigint?: boolean;
  1388. /**
  1389. * throw if no entry
  1390. */
  1391. throwIfNoEntry?: boolean;
  1392. }
  1393. declare interface SyncFileSystem {
  1394. /**
  1395. * read file sync method
  1396. */
  1397. readFileSync: ReadFileSync;
  1398. /**
  1399. * read dir sync method
  1400. */
  1401. readdirSync: ReaddirSync;
  1402. /**
  1403. * read json sync method
  1404. */
  1405. readJsonSync?: (pathOrFileDescription: PathOrFileDescriptor) => JsonObject;
  1406. /**
  1407. * read link sync method
  1408. */
  1409. readlinkSync: ReadlinkSync;
  1410. /**
  1411. * lstat sync method
  1412. */
  1413. lstatSync?: LStatSync;
  1414. /**
  1415. * stat sync method
  1416. */
  1417. statSync: StatSync;
  1418. /**
  1419. * real path sync method
  1420. */
  1421. realpathSync?: RealPathSync;
  1422. }
  1423. declare interface URL_url extends URL_Import {}
  1424. declare interface WriteOnlySet<T> {
  1425. add: (item: T) => void;
  1426. }
  1427. declare function exports(
  1428. context: object,
  1429. path: string,
  1430. request: string,
  1431. resolveContext: ResolveContext,
  1432. callback: (
  1433. err: null | ErrorWithDetail,
  1434. res?: string | false,
  1435. req?: ResolveRequest,
  1436. ) => void,
  1437. ): void;
  1438. declare function exports(
  1439. context: object,
  1440. path: string,
  1441. request: string,
  1442. callback: (
  1443. err: null | ErrorWithDetail,
  1444. res?: string | false,
  1445. req?: ResolveRequest,
  1446. ) => void,
  1447. ): void;
  1448. declare function exports(
  1449. path: string,
  1450. request: string,
  1451. resolveContext: ResolveContext,
  1452. callback: (
  1453. err: null | ErrorWithDetail,
  1454. res?: string | false,
  1455. req?: ResolveRequest,
  1456. ) => void,
  1457. ): void;
  1458. declare function exports(
  1459. path: string,
  1460. request: string,
  1461. callback: (
  1462. err: null | ErrorWithDetail,
  1463. res?: string | false,
  1464. req?: ResolveRequest,
  1465. ) => void,
  1466. ): void;
  1467. declare namespace exports {
  1468. export const sync: ResolveFunction;
  1469. export function create(
  1470. options: ResolveOptionsOptionalFS,
  1471. ): ResolveFunctionAsync;
  1472. export namespace create {
  1473. export const sync: (options: ResolveOptionsOptionalFS) => ResolveFunction;
  1474. }
  1475. export namespace ResolverFactory {
  1476. export let createResolver: (
  1477. options: ResolveOptionsResolverFactoryObject_2,
  1478. ) => Resolver;
  1479. }
  1480. export const forEachBail: <T, Z>(
  1481. array: T[],
  1482. iterator: Iterator<T, Z>,
  1483. callback: (err?: null | Error, result?: null | Z, i?: number) => void,
  1484. ) => void;
  1485. export type ResolveCallback = (
  1486. err: null | ErrorWithDetail,
  1487. res?: string | false,
  1488. req?: ResolveRequest,
  1489. ) => void;
  1490. export {
  1491. CachedInputFileSystem,
  1492. CloneBasenamePlugin,
  1493. LogInfoPlugin,
  1494. ResolveOptionsOptionalFS,
  1495. BaseFileSystem,
  1496. PnpApi,
  1497. Resolver,
  1498. FileSystem,
  1499. ResolveContext,
  1500. ResolveRequest,
  1501. SyncFileSystem,
  1502. Plugin,
  1503. ResolveOptionsResolverFactoryObject_2 as ResolveOptions,
  1504. ResolveFunctionAsync,
  1505. ResolveFunction,
  1506. };
  1507. }
  1508. export = exports;