11/// <reference types="node" />
22
3- import { loader } from "webpack" ;
3+ import { LoaderContext } from "webpack" ;
44
55export type Readonly < T > = {
66 readonly [ P in keyof T ] : T [ P ] ;
77} ;
88
9+ export interface LoaderInterpolateOption {
10+ customInterpolateName ?: typeof interpolateName ;
11+ }
12+
913export interface InterpolateOption {
1014 context ?: string | undefined ;
1115 content ?: string | Buffer | undefined ;
@@ -16,36 +20,26 @@ export interface OptionObject {
1620 [ key : string ] : null | false | true | string ;
1721}
1822
19- export type HashType = "sha1" | "md4" | "md5" | "sha256" | "sha512" ;
20-
21- export type DigestType = "hex" | "base26" | "base32" | "base36" | "base49" | "base52" | "base58" | "base62" | "base64" ;
22-
23- /**
24- * Recommended way to retrieve the options of a loader invocation
25- * {@link https://github.com/webpack/loader-utils#getoptions}
26- */
27- export function getOptions ( loaderContext : loader . LoaderContext ) : Readonly < OptionObject > ;
28-
23+ export type InterpolateNameType = string | ( ( resourcePath : string , resourceQuery ?: string ) => string ) ;
24+
25+ export type HashType = "xxhash64" | "sha1" | "md4" | "native-md4" | "md5" | "sha256" | "sha512" ;
26+
27+ export type DigestType =
28+ | "hex"
29+ | "base26"
30+ | "base32"
31+ | "base36"
32+ | "base49"
33+ | "base52"
34+ | "base58"
35+ | "base62"
36+ | "base64"
37+ | "base64safe" ;
2938/**
30- * Parses a passed string (e.g. loaderContext.resourceQuery) as a query string, and returns an object.
31- * {@link https://github.com/webpack/loader-utils#parsequery}
39+ * {@link https://https://github.com/webpack/loader-utils#urltorequest }
3240 */
33- export function parseQuery ( optionString : string ) : OptionObject ;
34-
35- /**
36- * Turns a request into a string that can be used inside require() or import while avoiding absolute paths. Use it instead of JSON.stringify(...) if you're generating code inside a loader.
37- * {@link https://github.com/webpack/loader-utils#stringifyrequest}
38- */
39- export function stringifyRequest ( loaderContext : loader . LoaderContext , resource : string ) : string ;
40-
41- export function getRemainingRequest ( loaderContext : loader . LoaderContext ) : string ;
42-
43- export function getCurrentRequest ( loaderContext : loader . LoaderContext ) : string ;
44-
4541export function isUrlRequest ( url : string , root ?: string ) : boolean ;
4642
47- export function parseString ( str : string ) : string ;
48-
4943/**
5044 * Converts some resource URL to a webpack module request.
5145 * {@link https://github.com/webpack/loader-utils#urltorequest}
@@ -57,12 +51,17 @@ export function urlToRequest(url: string, root?: string): string;
5751 * The template and regular expression are set as query params called name and regExp on the current loader's context.
5852 * {@link https://github.com/webpack/loader-utils#interpolatename}
5953 */
60- export function interpolateName ( loaderContext : loader . LoaderContext , name : string , options ?: any ) : string ;
54+ export function interpolateName (
55+ loaderContext : LoaderContext < LoaderInterpolateOption > ,
56+ name : InterpolateNameType ,
57+ options ?: InterpolateOption ,
58+ ) : string ;
6159
6260/**
63- * @param buffer
64- * @param [hashType='md4']
65- * @param [digestType='hex']
66- * @param [maxLength=9999]
61+ * @param buffer the content that should be hashed
62+ * @param [hashType='xxhash64'] one of `xxhash64`, `sha1`, `md4`, `md5`, `sha256`, `sha512` or any other node.js supported hash type
63+ * @param [digestType='hex'] one of `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`, `base64safe`
64+ * @param [maxLength=9999] the maximum length in chars
65+ * {@link https://github.com/webpack/loader-utils#gethashdigest}
6766 */
68- export function getHashDigest ( buffer : Buffer , hashType : HashType , digestType : DigestType , maxLength : number ) : string ;
67+ export function getHashDigest ( buffer : Buffer , hashType ? : HashType , digestType ? : DigestType , maxLength ? : number ) : string ;
0 commit comments