|
1 | 1 | /// <reference types="node" /> |
2 | | -export default CompressionPlugin; |
3 | | -export type Schema = import("schema-utils/declarations/validate").Schema; |
4 | | -export type Compiler = import("webpack").Compiler; |
5 | | -export type WebpackPluginInstance = import("webpack").WebpackPluginInstance; |
6 | | -export type Compilation = import("webpack").Compilation; |
7 | | -export type Source = import("webpack").sources.Source; |
8 | | -export type Asset = import("webpack").Asset; |
9 | | -export type WebpackError = import("webpack").WebpackError; |
10 | | -export type WithImplicitCoercion<T> = |
11 | | - | T |
12 | | - | { |
13 | | - valueOf(): T; |
14 | | - }; |
15 | | -export type Rule = RegExp | string; |
16 | | -export type Rules = Rule[] | Rule; |
17 | | -export type CustomOptions = { |
18 | | - [key: string]: any; |
19 | | -}; |
20 | | -export type InferDefaultType<T> = T extends infer U ? U : CustomOptions; |
21 | | -export type CompressionOptions<T> = InferDefaultType<T>; |
22 | | -export type AlgorithmFunction<T> = ( |
23 | | - input: Buffer, |
24 | | - options: CompressionOptions<T>, |
25 | | - callback: ( |
26 | | - error: Error | null | undefined, |
27 | | - result: |
28 | | - | string |
29 | | - | ArrayBuffer |
30 | | - | SharedArrayBuffer |
31 | | - | Uint8Array |
32 | | - | readonly number[] |
33 | | - | { |
34 | | - valueOf(): ArrayBuffer | SharedArrayBuffer; |
35 | | - } |
36 | | - | { |
37 | | - valueOf(): string | Uint8Array | readonly number[]; |
38 | | - } |
39 | | - | { |
40 | | - valueOf(): string; |
41 | | - } |
42 | | - | { |
43 | | - [Symbol.toPrimitive](hint: "string"): string; |
44 | | - } |
45 | | - ) => void |
46 | | -) => any; |
47 | | -export type PathData = { |
48 | | - [key: string]: any; |
49 | | -}; |
50 | | -export type Filename = string | ((fileData: PathData) => string); |
51 | | -export type DeleteOriginalAssets = boolean | "keep-source-map"; |
52 | | -export type BasePluginOptions<T> = { |
53 | | - test?: Rules | undefined; |
54 | | - include?: Rules | undefined; |
55 | | - exclude?: Rules | undefined; |
56 | | - threshold?: number | undefined; |
57 | | - minRatio?: number | undefined; |
58 | | - deleteOriginalAssets?: DeleteOriginalAssets | undefined; |
59 | | - filename?: Filename | undefined; |
60 | | -}; |
61 | | -export type ZlibOptions = import("zlib").ZlibOptions; |
62 | | -export type DefinedDefaultAlgorithmAndOptions<T> = T extends ZlibOptions |
63 | | - ? { |
64 | | - algorithm?: string | AlgorithmFunction<T> | undefined; |
65 | | - compressionOptions?: CompressionOptions<T> | undefined; |
66 | | - } |
67 | | - : { |
68 | | - algorithm: string | AlgorithmFunction<T>; |
69 | | - compressionOptions?: CompressionOptions<T> | undefined; |
70 | | - }; |
71 | | -export type InternalPluginOptions<T> = BasePluginOptions<T> & { |
72 | | - algorithm: string | AlgorithmFunction<T>; |
73 | | - compressionOptions: CompressionOptions<T>; |
74 | | - threshold: number; |
75 | | - minRatio: number; |
76 | | - deleteOriginalAssets: DeleteOriginalAssets; |
77 | | - filename: Filename; |
78 | | -}; |
| 2 | +export = CompressionPlugin; |
79 | 3 | /** @typedef {import("schema-utils/declarations/validate").Schema} Schema */ |
80 | 4 | /** @typedef {import("webpack").Compiler} Compiler */ |
81 | 5 | /** @typedef {import("webpack").WebpackPluginInstance} WebpackPluginInstance */ |
@@ -183,3 +107,104 @@ declare class CompressionPlugin<T = import("zlib").ZlibOptions> |
183 | 107 | */ |
184 | 108 | apply(compiler: Compiler): void; |
185 | 109 | } |
| 110 | +declare namespace CompressionPlugin { |
| 111 | + export { |
| 112 | + Schema, |
| 113 | + Compiler, |
| 114 | + WebpackPluginInstance, |
| 115 | + Compilation, |
| 116 | + Source, |
| 117 | + Asset, |
| 118 | + WebpackError, |
| 119 | + WithImplicitCoercion, |
| 120 | + Rule, |
| 121 | + Rules, |
| 122 | + CustomOptions, |
| 123 | + InferDefaultType, |
| 124 | + CompressionOptions, |
| 125 | + AlgorithmFunction, |
| 126 | + PathData, |
| 127 | + Filename, |
| 128 | + DeleteOriginalAssets, |
| 129 | + BasePluginOptions, |
| 130 | + ZlibOptions, |
| 131 | + DefinedDefaultAlgorithmAndOptions, |
| 132 | + InternalPluginOptions, |
| 133 | + }; |
| 134 | +} |
| 135 | +type WebpackPluginInstance = import("webpack").WebpackPluginInstance; |
| 136 | +type Compiler = import("webpack").Compiler; |
| 137 | +type BasePluginOptions<T> = { |
| 138 | + test?: Rules | undefined; |
| 139 | + include?: Rules | undefined; |
| 140 | + exclude?: Rules | undefined; |
| 141 | + threshold?: number | undefined; |
| 142 | + minRatio?: number | undefined; |
| 143 | + deleteOriginalAssets?: DeleteOriginalAssets | undefined; |
| 144 | + filename?: Filename | undefined; |
| 145 | +}; |
| 146 | +type DefinedDefaultAlgorithmAndOptions<T> = T extends ZlibOptions |
| 147 | + ? { |
| 148 | + algorithm?: string | AlgorithmFunction<T> | undefined; |
| 149 | + compressionOptions?: CompressionOptions<T> | undefined; |
| 150 | + } |
| 151 | + : { |
| 152 | + algorithm: string | AlgorithmFunction<T>; |
| 153 | + compressionOptions?: CompressionOptions<T> | undefined; |
| 154 | + }; |
| 155 | +type Schema = import("schema-utils/declarations/validate").Schema; |
| 156 | +type Compilation = import("webpack").Compilation; |
| 157 | +type Source = import("webpack").sources.Source; |
| 158 | +type Asset = import("webpack").Asset; |
| 159 | +type WebpackError = import("webpack").WebpackError; |
| 160 | +type WithImplicitCoercion<T> = |
| 161 | + | T |
| 162 | + | { |
| 163 | + valueOf(): T; |
| 164 | + }; |
| 165 | +type Rule = RegExp | string; |
| 166 | +type Rules = Rule[] | Rule; |
| 167 | +type CustomOptions = { |
| 168 | + [key: string]: any; |
| 169 | +}; |
| 170 | +type InferDefaultType<T> = T extends infer U ? U : CustomOptions; |
| 171 | +type CompressionOptions<T> = InferDefaultType<T>; |
| 172 | +type AlgorithmFunction<T> = ( |
| 173 | + input: Buffer, |
| 174 | + options: CompressionOptions<T>, |
| 175 | + callback: ( |
| 176 | + error: Error | null | undefined, |
| 177 | + result: |
| 178 | + | string |
| 179 | + | ArrayBuffer |
| 180 | + | SharedArrayBuffer |
| 181 | + | Uint8Array |
| 182 | + | readonly number[] |
| 183 | + | { |
| 184 | + valueOf(): ArrayBuffer | SharedArrayBuffer; |
| 185 | + } |
| 186 | + | { |
| 187 | + valueOf(): string | Uint8Array | readonly number[]; |
| 188 | + } |
| 189 | + | { |
| 190 | + valueOf(): string; |
| 191 | + } |
| 192 | + | { |
| 193 | + [Symbol.toPrimitive](hint: "string"): string; |
| 194 | + } |
| 195 | + ) => void |
| 196 | +) => any; |
| 197 | +type PathData = { |
| 198 | + [key: string]: any; |
| 199 | +}; |
| 200 | +type Filename = string | ((fileData: PathData) => string); |
| 201 | +type DeleteOriginalAssets = boolean | "keep-source-map"; |
| 202 | +type ZlibOptions = import("zlib").ZlibOptions; |
| 203 | +type InternalPluginOptions<T> = BasePluginOptions<T> & { |
| 204 | + algorithm: string | AlgorithmFunction<T>; |
| 205 | + compressionOptions: CompressionOptions<T>; |
| 206 | + threshold: number; |
| 207 | + minRatio: number; |
| 208 | + deleteOriginalAssets: DeleteOriginalAssets; |
| 209 | + filename: Filename; |
| 210 | +}; |
0 commit comments