1 | export = CopyPlugin;
|
2 | /** @typedef {import("schema-utils/declarations/validate").Schema} Schema */
|
3 | /** @typedef {import("webpack").Compiler} Compiler */
|
4 | /** @typedef {import("webpack").Compilation} Compilation */
|
5 | /** @typedef {import("webpack").WebpackError} WebpackError */
|
6 | /** @typedef {import("webpack").Asset} Asset */
|
7 | /** @typedef {import("globby").Options} GlobbyOptions */
|
8 | /** @typedef {import("globby").GlobEntry} GlobEntry */
|
9 | /** @typedef {ReturnType<Compilation["getLogger"]>} WebpackLogger */
|
10 | /** @typedef {ReturnType<Compilation["getCache"]>} CacheFacade */
|
11 | /** @typedef {ReturnType<ReturnType<Compilation["getCache"]>["getLazyHashedEtag"]>} Etag */
|
12 | /** @typedef {ReturnType<Compilation["fileSystemInfo"]["mergeSnapshots"]>} Snapshot */
|
13 | /**
|
14 | * @typedef {boolean} Force
|
15 | */
|
16 | /**
|
17 | * @typedef {Object} CopiedResult
|
18 | * @property {string} sourceFilename
|
19 | * @property {string} absoluteFilename
|
20 | * @property {string} filename
|
21 | * @property {Asset["source"]} source
|
22 | * @property {Force | undefined} force
|
23 | * @property {Record<string, any>} info
|
24 | */
|
25 | /**
|
26 | * @typedef {string} StringPattern
|
27 | */
|
28 | /**
|
29 | * @typedef {boolean} NoErrorOnMissing
|
30 | */
|
31 | /**
|
32 | * @typedef {string} Context
|
33 | */
|
34 | /**
|
35 | * @typedef {string} From
|
36 | */
|
37 | /**
|
38 | * @callback ToFunction
|
39 | * @param {{ context: string, absoluteFilename?: string }} pathData
|
40 | * @return {string | Promise<string>}
|
41 | */
|
42 | /**
|
43 | * @typedef {string | ToFunction} To
|
44 | */
|
45 | /**
|
46 | * @typedef {"dir" | "file" | "template"} ToType
|
47 | */
|
48 | /**
|
49 | * @callback TransformerFunction
|
50 | * @param {Buffer} input
|
51 | * @param {string} absoluteFilename
|
52 | * @returns {string | Buffer | Promise<string> | Promise<Buffer>}
|
53 | */
|
54 | /**
|
55 | * @typedef {{ keys: { [key: string]: any } } | { keys: ((defaultCacheKeys: { [key: string]: any }, absoluteFilename: string) => Promise<{ [key: string]: any }>) }} TransformerCacheObject
|
56 | */
|
57 | /**
|
58 | * @typedef {Object} TransformerObject
|
59 | * @property {TransformerFunction} transformer
|
60 | * @property {boolean | TransformerCacheObject} [cache]
|
61 | */
|
62 | /**
|
63 | * @typedef {TransformerFunction | TransformerObject} Transform
|
64 | */
|
65 | /**
|
66 | * @callback Filter
|
67 | * @param {string} filepath
|
68 | * @returns {boolean | Promise<boolean>}
|
69 | */
|
70 | /**
|
71 | * @callback TransformAllFunction
|
72 | * @param {{ data: Buffer, sourceFilename: string, absoluteFilename: string }[]} data
|
73 | * @returns {string | Buffer | Promise<string> | Promise<Buffer>}
|
74 | */
|
75 | /**
|
76 | * @typedef { Record<string, any> | ((item: { absoluteFilename: string, sourceFilename: string, filename: string, toType: ToType }) => Record<string, any>) } Info
|
77 | */
|
78 | /**
|
79 | * @typedef {Object} ObjectPattern
|
80 | * @property {From} from
|
81 | * @property {GlobbyOptions} [globOptions]
|
82 | * @property {Context} [context]
|
83 | * @property {To} [to]
|
84 | * @property {ToType} [toType]
|
85 | * @property {Info} [info]
|
86 | * @property {Filter} [filter]
|
87 | * @property {Transform} [transform]
|
88 | * @property {TransformAllFunction} [transformAll]
|
89 | * @property {Force} [force]
|
90 | * @property {number} [priority]
|
91 | * @property {NoErrorOnMissing} [noErrorOnMissing]
|
92 | */
|
93 | /**
|
94 | * @typedef {StringPattern | ObjectPattern} Pattern
|
95 | */
|
96 | /**
|
97 | * @typedef {Object} AdditionalOptions
|
98 | * @property {number} [concurrency]
|
99 | */
|
100 | /**
|
101 | * @typedef {Object} PluginOptions
|
102 | * @property {Pattern[]} patterns
|
103 | * @property {AdditionalOptions} [options]
|
104 | */
|
105 | declare class CopyPlugin {
|
106 | /**
|
107 | * @private
|
108 | * @param {Compilation} compilation
|
109 | * @param {number} startTime
|
110 | * @param {string} dependency
|
111 | * @returns {Promise<Snapshot | undefined>}
|
112 | */
|
113 | private static createSnapshot;
|
114 | /**
|
115 | * @private
|
116 | * @param {Compilation} compilation
|
117 | * @param {Snapshot} snapshot
|
118 | * @returns {Promise<boolean | undefined>}
|
119 | */
|
120 | private static checkSnapshotValid;
|
121 | /**
|
122 | * @private
|
123 | * @param {Compiler} compiler
|
124 | * @param {Compilation} compilation
|
125 | * @param {Buffer} source
|
126 | * @returns {string}
|
127 | */
|
128 | private static getContentHash;
|
129 | /**
|
130 | * @private
|
131 | * @param {typeof import("globby").globby} globby
|
132 | * @param {Compiler} compiler
|
133 | * @param {Compilation} compilation
|
134 | * @param {WebpackLogger} logger
|
135 | * @param {CacheFacade} cache
|
136 | * @param {ObjectPattern & { context: string }} inputPattern
|
137 | * @param {number} index
|
138 | * @returns {Promise<Array<CopiedResult | undefined> | undefined>}
|
139 | */
|
140 | private static runPattern;
|
141 | /**
|
142 | * @param {PluginOptions} [options]
|
143 | */
|
144 | constructor(options?: PluginOptions | undefined);
|
145 | /**
|
146 | * @private
|
147 | * @type {Pattern[]}
|
148 | */
|
149 | private patterns;
|
150 | /**
|
151 | * @private
|
152 | * @type {AdditionalOptions}
|
153 | */
|
154 | private options;
|
155 | /**
|
156 | * @param {Compiler} compiler
|
157 | */
|
158 | apply(compiler: Compiler): void;
|
159 | }
|
160 | declare namespace CopyPlugin {
|
161 | export {
|
162 | Schema,
|
163 | Compiler,
|
164 | Compilation,
|
165 | WebpackError,
|
166 | Asset,
|
167 | GlobbyOptions,
|
168 | GlobEntry,
|
169 | WebpackLogger,
|
170 | CacheFacade,
|
171 | Etag,
|
172 | Snapshot,
|
173 | Force,
|
174 | CopiedResult,
|
175 | StringPattern,
|
176 | NoErrorOnMissing,
|
177 | Context,
|
178 | From,
|
179 | ToFunction,
|
180 | To,
|
181 | ToType,
|
182 | TransformerFunction,
|
183 | TransformerCacheObject,
|
184 | TransformerObject,
|
185 | Transform,
|
186 | Filter,
|
187 | TransformAllFunction,
|
188 | Info,
|
189 | ObjectPattern,
|
190 | Pattern,
|
191 | AdditionalOptions,
|
192 | PluginOptions,
|
193 | };
|
194 | }
|
195 | type Schema = import("schema-utils/declarations/validate").Schema;
|
196 | type Compiler = import("webpack").Compiler;
|
197 | type Compilation = import("webpack").Compilation;
|
198 | type WebpackError = import("webpack").WebpackError;
|
199 | type Asset = import("webpack").Asset;
|
200 | type GlobbyOptions = import("globby").Options;
|
201 | type GlobEntry = import("globby").GlobEntry;
|
202 | type WebpackLogger = ReturnType<Compilation["getLogger"]>;
|
203 | type CacheFacade = ReturnType<Compilation["getCache"]>;
|
204 | type Etag = ReturnType<
|
205 | ReturnType<Compilation["getCache"]>["getLazyHashedEtag"]
|
206 | >;
|
207 | type Snapshot = ReturnType<Compilation["fileSystemInfo"]["mergeSnapshots"]>;
|
208 | type Force = boolean;
|
209 | type CopiedResult = {
|
210 | sourceFilename: string;
|
211 | absoluteFilename: string;
|
212 | filename: string;
|
213 | source: Asset["source"];
|
214 | force: Force | undefined;
|
215 | info: Record<string, any>;
|
216 | };
|
217 | type StringPattern = string;
|
218 | type NoErrorOnMissing = boolean;
|
219 | type Context = string;
|
220 | type From = string;
|
221 | type ToFunction = (pathData: {
|
222 | context: string;
|
223 | absoluteFilename?: string;
|
224 | }) => string | Promise<string>;
|
225 | type To = string | ToFunction;
|
226 | type ToType = "dir" | "file" | "template";
|
227 | type TransformerFunction = (
|
228 | input: Buffer,
|
229 | absoluteFilename: string,
|
230 | ) => string | Buffer | Promise<string> | Promise<Buffer>;
|
231 | type TransformerCacheObject =
|
232 | | {
|
233 | keys: {
|
234 | [key: string]: any;
|
235 | };
|
236 | }
|
237 | | {
|
238 | keys: (
|
239 | defaultCacheKeys: {
|
240 | [key: string]: any;
|
241 | },
|
242 | absoluteFilename: string,
|
243 | ) => Promise<{
|
244 | [key: string]: any;
|
245 | }>;
|
246 | };
|
247 | type TransformerObject = {
|
248 | transformer: TransformerFunction;
|
249 | cache?: boolean | TransformerCacheObject | undefined;
|
250 | };
|
251 | type Transform = TransformerFunction | TransformerObject;
|
252 | type Filter = (filepath: string) => boolean | Promise<boolean>;
|
253 | type TransformAllFunction = (
|
254 | data: {
|
255 | data: Buffer;
|
256 | sourceFilename: string;
|
257 | absoluteFilename: string;
|
258 | }[],
|
259 | ) => string | Buffer | Promise<string> | Promise<Buffer>;
|
260 | type Info =
|
261 | | Record<string, any>
|
262 | | ((item: {
|
263 | absoluteFilename: string;
|
264 | sourceFilename: string;
|
265 | filename: string;
|
266 | toType: ToType;
|
267 | }) => Record<string, any>);
|
268 | type ObjectPattern = {
|
269 | from: From;
|
270 | globOptions?: import("globby").Options | undefined;
|
271 | context?: string | undefined;
|
272 | to?: To | undefined;
|
273 | toType?: ToType | undefined;
|
274 | info?: Info | undefined;
|
275 | filter?: Filter | undefined;
|
276 | transform?: Transform | undefined;
|
277 | transformAll?: TransformAllFunction | undefined;
|
278 | force?: boolean | undefined;
|
279 | priority?: number | undefined;
|
280 | noErrorOnMissing?: boolean | undefined;
|
281 | };
|
282 | type Pattern = StringPattern | ObjectPattern;
|
283 | type AdditionalOptions = {
|
284 | concurrency?: number | undefined;
|
285 | };
|
286 | type PluginOptions = {
|
287 | patterns: Pattern[];
|
288 | options?: AdditionalOptions | undefined;
|
289 | };
|