@rspack/core 0.6.4 → 0.6.5-canary-73c31ab-20240510004618
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/browserslist/index.d.ts +1 -0
- package/compiled/browserslist/index.js +2028 -0
- package/compiled/browserslist/license +20 -0
- package/compiled/browserslist/package.json +1 -0
- package/compiled/graceful-fs/index.d.ts +13 -0
- package/compiled/graceful-fs/index.js +1063 -0
- package/compiled/graceful-fs/license +15 -0
- package/compiled/graceful-fs/package.json +1 -0
- package/compiled/json-parse-even-better-errors/index.d.ts +1 -0
- package/compiled/json-parse-even-better-errors/index.js +193 -0
- package/compiled/json-parse-even-better-errors/package.json +1 -0
- package/compiled/neo-async/index.d.ts +685 -0
- package/compiled/neo-async/index.js +9207 -0
- package/compiled/neo-async/license +22 -0
- package/compiled/neo-async/package.json +1 -0
- package/compiled/watchpack/index.d.ts +216 -0
- package/compiled/watchpack/index.js +2075 -0
- package/compiled/watchpack/license +20 -0
- package/compiled/watchpack/package.json +1 -0
- package/compiled/zod/index.d.ts +1647 -0
- package/compiled/zod/index.js +4208 -0
- package/compiled/zod/license +21 -0
- package/compiled/zod/package.json +1 -0
- package/compiled/zod-validation-error/index.d.ts +188 -0
- package/compiled/zod-validation-error/index.js +4367 -0
- package/compiled/zod-validation-error/license +9 -0
- package/compiled/zod-validation-error/package.json +1 -0
- package/dist/ChunkGroup.d.ts +2 -0
- package/dist/ChunkGroup.js +4 -0
- package/dist/Compiler.d.ts +2 -2
- package/dist/MultiCompiler.js +1 -1
- package/dist/MultiWatching.js +1 -1
- package/dist/builtin-plugin/BannerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/BannerPlugin.js +1 -1
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/HtmlRspackPlugin.js +1 -1
- package/dist/builtin-plugin/IgnorePlugin.js +1 -1
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +15 -0
- package/dist/builtin-plugin/SizeLimitsPlugin.js +9 -0
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/builtin-plugin/index.js +1 -0
- package/dist/config/browserslistTargetHandler.js +1 -1
- package/dist/config/defaults.js +15 -0
- package/dist/config/normalization.d.ts +2 -1
- package/dist/config/normalization.js +1 -0
- package/dist/config/zod.d.ts +60 -6
- package/dist/config/zod.js +16 -2
- package/dist/exports.d.ts +2 -0
- package/dist/exports.js +15 -10
- package/dist/lib/CacheFacade.js +1 -1
- package/dist/loader-runner/index.js +1 -1
- package/dist/node/NodeEnvironmentPlugin.js +1 -1
- package/dist/node/NodeWatchFileSystem.d.ts +3 -3
- package/dist/node/NodeWatchFileSystem.js +1 -1
- package/dist/rspackOptionsApply.js +4 -1
- package/dist/util/validate.d.ts +1 -1
- package/dist/util/validate.js +1 -1
- package/package.json +21 -14
|
@@ -0,0 +1,2075 @@
|
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
/******/ var __webpack_modules__ = ({
|
|
3
|
+
|
|
4
|
+
/***/ 140:
|
|
5
|
+
/***/ ((module) => {
|
|
6
|
+
|
|
7
|
+
module.exports = function (glob, opts) {
|
|
8
|
+
if (typeof glob !== 'string') {
|
|
9
|
+
throw new TypeError('Expected a string');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var str = String(glob);
|
|
13
|
+
|
|
14
|
+
// The regexp we are building, as a string.
|
|
15
|
+
var reStr = "";
|
|
16
|
+
|
|
17
|
+
// Whether we are matching so called "extended" globs (like bash) and should
|
|
18
|
+
// support single character matching, matching ranges of characters, group
|
|
19
|
+
// matching, etc.
|
|
20
|
+
var extended = opts ? !!opts.extended : false;
|
|
21
|
+
|
|
22
|
+
// When globstar is _false_ (default), '/foo/*' is translated a regexp like
|
|
23
|
+
// '^\/foo\/.*$' which will match any string beginning with '/foo/'
|
|
24
|
+
// When globstar is _true_, '/foo/*' is translated to regexp like
|
|
25
|
+
// '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' BUT
|
|
26
|
+
// which does not have a '/' to the right of it.
|
|
27
|
+
// E.g. with '/foo/*' these will match: '/foo/bar', '/foo/bar.txt' but
|
|
28
|
+
// these will not '/foo/bar/baz', '/foo/bar/baz.txt'
|
|
29
|
+
// Lastely, when globstar is _true_, '/foo/**' is equivelant to '/foo/*' when
|
|
30
|
+
// globstar is _false_
|
|
31
|
+
var globstar = opts ? !!opts.globstar : false;
|
|
32
|
+
|
|
33
|
+
// If we are doing extended matching, this boolean is true when we are inside
|
|
34
|
+
// a group (eg {*.html,*.js}), and false otherwise.
|
|
35
|
+
var inGroup = false;
|
|
36
|
+
|
|
37
|
+
// RegExp flags (eg "i" ) to pass in to RegExp constructor.
|
|
38
|
+
var flags = opts && typeof( opts.flags ) === "string" ? opts.flags : "";
|
|
39
|
+
|
|
40
|
+
var c;
|
|
41
|
+
for (var i = 0, len = str.length; i < len; i++) {
|
|
42
|
+
c = str[i];
|
|
43
|
+
|
|
44
|
+
switch (c) {
|
|
45
|
+
case "/":
|
|
46
|
+
case "$":
|
|
47
|
+
case "^":
|
|
48
|
+
case "+":
|
|
49
|
+
case ".":
|
|
50
|
+
case "(":
|
|
51
|
+
case ")":
|
|
52
|
+
case "=":
|
|
53
|
+
case "!":
|
|
54
|
+
case "|":
|
|
55
|
+
reStr += "\\" + c;
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case "?":
|
|
59
|
+
if (extended) {
|
|
60
|
+
reStr += ".";
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
case "[":
|
|
65
|
+
case "]":
|
|
66
|
+
if (extended) {
|
|
67
|
+
reStr += c;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
case "{":
|
|
72
|
+
if (extended) {
|
|
73
|
+
inGroup = true;
|
|
74
|
+
reStr += "(";
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
case "}":
|
|
79
|
+
if (extended) {
|
|
80
|
+
inGroup = false;
|
|
81
|
+
reStr += ")";
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
case ",":
|
|
86
|
+
if (inGroup) {
|
|
87
|
+
reStr += "|";
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
reStr += "\\" + c;
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
case "*":
|
|
94
|
+
// Move over all consecutive "*"'s.
|
|
95
|
+
// Also store the previous and next characters
|
|
96
|
+
var prevChar = str[i - 1];
|
|
97
|
+
var starCount = 1;
|
|
98
|
+
while(str[i + 1] === "*") {
|
|
99
|
+
starCount++;
|
|
100
|
+
i++;
|
|
101
|
+
}
|
|
102
|
+
var nextChar = str[i + 1];
|
|
103
|
+
|
|
104
|
+
if (!globstar) {
|
|
105
|
+
// globstar is disabled, so treat any number of "*" as one
|
|
106
|
+
reStr += ".*";
|
|
107
|
+
} else {
|
|
108
|
+
// globstar is enabled, so determine if this is a globstar segment
|
|
109
|
+
var isGlobstar = starCount > 1 // multiple "*"'s
|
|
110
|
+
&& (prevChar === "/" || prevChar === undefined) // from the start of the segment
|
|
111
|
+
&& (nextChar === "/" || nextChar === undefined) // to the end of the segment
|
|
112
|
+
|
|
113
|
+
if (isGlobstar) {
|
|
114
|
+
// it's a globstar, so match zero or more path segments
|
|
115
|
+
reStr += "((?:[^/]*(?:\/|$))*)";
|
|
116
|
+
i++; // move over the "/"
|
|
117
|
+
} else {
|
|
118
|
+
// it's not a globstar, so only match one path segment
|
|
119
|
+
reStr += "([^/]*)";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
|
|
124
|
+
default:
|
|
125
|
+
reStr += c;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// When regexp 'g' flag is specified don't
|
|
130
|
+
// constrain the regular expression with ^ & $
|
|
131
|
+
if (!flags || !~flags.indexOf('g')) {
|
|
132
|
+
reStr = "^" + reStr + "$";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return new RegExp(reStr, flags);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
/***/ }),
|
|
140
|
+
|
|
141
|
+
/***/ 238:
|
|
142
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
143
|
+
|
|
144
|
+
"use strict";
|
|
145
|
+
/*
|
|
146
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
147
|
+
Author Tobias Koppers @sokra
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
const EventEmitter = (__nccwpck_require__(361).EventEmitter);
|
|
152
|
+
const fs = __nccwpck_require__(453);
|
|
153
|
+
const path = __nccwpck_require__(17);
|
|
154
|
+
|
|
155
|
+
const watchEventSource = __nccwpck_require__(344);
|
|
156
|
+
|
|
157
|
+
const EXISTANCE_ONLY_TIME_ENTRY = Object.freeze({});
|
|
158
|
+
|
|
159
|
+
let FS_ACCURACY = 2000;
|
|
160
|
+
|
|
161
|
+
const IS_OSX = (__nccwpck_require__(37).platform)() === "darwin";
|
|
162
|
+
const WATCHPACK_POLLING = process.env.WATCHPACK_POLLING;
|
|
163
|
+
const FORCE_POLLING =
|
|
164
|
+
`${+WATCHPACK_POLLING}` === WATCHPACK_POLLING
|
|
165
|
+
? +WATCHPACK_POLLING
|
|
166
|
+
: !!WATCHPACK_POLLING && WATCHPACK_POLLING !== "false";
|
|
167
|
+
|
|
168
|
+
function withoutCase(str) {
|
|
169
|
+
return str.toLowerCase();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function needCalls(times, callback) {
|
|
173
|
+
return function() {
|
|
174
|
+
if (--times === 0) {
|
|
175
|
+
return callback();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
class Watcher extends EventEmitter {
|
|
181
|
+
constructor(directoryWatcher, filePath, startTime) {
|
|
182
|
+
super();
|
|
183
|
+
this.directoryWatcher = directoryWatcher;
|
|
184
|
+
this.path = filePath;
|
|
185
|
+
this.startTime = startTime && +startTime;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
checkStartTime(mtime, initial) {
|
|
189
|
+
const startTime = this.startTime;
|
|
190
|
+
if (typeof startTime !== "number") return !initial;
|
|
191
|
+
return startTime <= mtime;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
close() {
|
|
195
|
+
this.emit("closed");
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
class DirectoryWatcher extends EventEmitter {
|
|
200
|
+
constructor(watcherManager, directoryPath, options) {
|
|
201
|
+
super();
|
|
202
|
+
if (FORCE_POLLING) {
|
|
203
|
+
options.poll = FORCE_POLLING;
|
|
204
|
+
}
|
|
205
|
+
this.watcherManager = watcherManager;
|
|
206
|
+
this.options = options;
|
|
207
|
+
this.path = directoryPath;
|
|
208
|
+
// safeTime is the point in time after which reading is safe to be unchanged
|
|
209
|
+
// timestamp is a value that should be compared with another timestamp (mtime)
|
|
210
|
+
/** @type {Map<string, { safeTime: number, timestamp: number }} */
|
|
211
|
+
this.files = new Map();
|
|
212
|
+
/** @type {Map<string, number>} */
|
|
213
|
+
this.filesWithoutCase = new Map();
|
|
214
|
+
this.directories = new Map();
|
|
215
|
+
this.lastWatchEvent = 0;
|
|
216
|
+
this.initialScan = true;
|
|
217
|
+
this.ignored = options.ignored || (() => false);
|
|
218
|
+
this.nestedWatching = false;
|
|
219
|
+
this.polledWatching =
|
|
220
|
+
typeof options.poll === "number"
|
|
221
|
+
? options.poll
|
|
222
|
+
: options.poll
|
|
223
|
+
? 5007
|
|
224
|
+
: false;
|
|
225
|
+
this.timeout = undefined;
|
|
226
|
+
this.initialScanRemoved = new Set();
|
|
227
|
+
this.initialScanFinished = undefined;
|
|
228
|
+
/** @type {Map<string, Set<Watcher>>} */
|
|
229
|
+
this.watchers = new Map();
|
|
230
|
+
this.parentWatcher = null;
|
|
231
|
+
this.refs = 0;
|
|
232
|
+
this._activeEvents = new Map();
|
|
233
|
+
this.closed = false;
|
|
234
|
+
this.scanning = false;
|
|
235
|
+
this.scanAgain = false;
|
|
236
|
+
this.scanAgainInitial = false;
|
|
237
|
+
|
|
238
|
+
this.createWatcher();
|
|
239
|
+
this.doScan(true);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
createWatcher() {
|
|
243
|
+
try {
|
|
244
|
+
if (this.polledWatching) {
|
|
245
|
+
this.watcher = {
|
|
246
|
+
close: () => {
|
|
247
|
+
if (this.timeout) {
|
|
248
|
+
clearTimeout(this.timeout);
|
|
249
|
+
this.timeout = undefined;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
} else {
|
|
254
|
+
if (IS_OSX) {
|
|
255
|
+
this.watchInParentDirectory();
|
|
256
|
+
}
|
|
257
|
+
this.watcher = watchEventSource.watch(this.path);
|
|
258
|
+
this.watcher.on("change", this.onWatchEvent.bind(this));
|
|
259
|
+
this.watcher.on("error", this.onWatcherError.bind(this));
|
|
260
|
+
}
|
|
261
|
+
} catch (err) {
|
|
262
|
+
this.onWatcherError(err);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
forEachWatcher(path, fn) {
|
|
267
|
+
const watchers = this.watchers.get(withoutCase(path));
|
|
268
|
+
if (watchers !== undefined) {
|
|
269
|
+
for (const w of watchers) {
|
|
270
|
+
fn(w);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
setMissing(itemPath, initial, type) {
|
|
276
|
+
if (this.initialScan) {
|
|
277
|
+
this.initialScanRemoved.add(itemPath);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const oldDirectory = this.directories.get(itemPath);
|
|
281
|
+
if (oldDirectory) {
|
|
282
|
+
if (this.nestedWatching) oldDirectory.close();
|
|
283
|
+
this.directories.delete(itemPath);
|
|
284
|
+
|
|
285
|
+
this.forEachWatcher(itemPath, w => w.emit("remove", type));
|
|
286
|
+
if (!initial) {
|
|
287
|
+
this.forEachWatcher(this.path, w =>
|
|
288
|
+
w.emit("change", itemPath, null, type, initial)
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const oldFile = this.files.get(itemPath);
|
|
294
|
+
if (oldFile) {
|
|
295
|
+
this.files.delete(itemPath);
|
|
296
|
+
const key = withoutCase(itemPath);
|
|
297
|
+
const count = this.filesWithoutCase.get(key) - 1;
|
|
298
|
+
if (count <= 0) {
|
|
299
|
+
this.filesWithoutCase.delete(key);
|
|
300
|
+
this.forEachWatcher(itemPath, w => w.emit("remove", type));
|
|
301
|
+
} else {
|
|
302
|
+
this.filesWithoutCase.set(key, count);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (!initial) {
|
|
306
|
+
this.forEachWatcher(this.path, w =>
|
|
307
|
+
w.emit("change", itemPath, null, type, initial)
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
setFileTime(filePath, mtime, initial, ignoreWhenEqual, type) {
|
|
314
|
+
const now = Date.now();
|
|
315
|
+
|
|
316
|
+
if (this.ignored(filePath)) return;
|
|
317
|
+
|
|
318
|
+
const old = this.files.get(filePath);
|
|
319
|
+
|
|
320
|
+
let safeTime, accuracy;
|
|
321
|
+
if (initial) {
|
|
322
|
+
safeTime = Math.min(now, mtime) + FS_ACCURACY;
|
|
323
|
+
accuracy = FS_ACCURACY;
|
|
324
|
+
} else {
|
|
325
|
+
safeTime = now;
|
|
326
|
+
accuracy = 0;
|
|
327
|
+
|
|
328
|
+
if (old && old.timestamp === mtime && mtime + FS_ACCURACY < now) {
|
|
329
|
+
// We are sure that mtime is untouched
|
|
330
|
+
// This can be caused by some file attribute change
|
|
331
|
+
// e. g. when access time has been changed
|
|
332
|
+
// but the file content is untouched
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (ignoreWhenEqual && old && old.timestamp === mtime) return;
|
|
338
|
+
|
|
339
|
+
this.files.set(filePath, {
|
|
340
|
+
safeTime,
|
|
341
|
+
accuracy,
|
|
342
|
+
timestamp: mtime
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
if (!old) {
|
|
346
|
+
const key = withoutCase(filePath);
|
|
347
|
+
const count = this.filesWithoutCase.get(key);
|
|
348
|
+
this.filesWithoutCase.set(key, (count || 0) + 1);
|
|
349
|
+
if (count !== undefined) {
|
|
350
|
+
// There is already a file with case-insensitive-equal name
|
|
351
|
+
// On a case-insensitive filesystem we may miss the renaming
|
|
352
|
+
// when only casing is changed.
|
|
353
|
+
// To be sure that our information is correct
|
|
354
|
+
// we trigger a rescan here
|
|
355
|
+
this.doScan(false);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
this.forEachWatcher(filePath, w => {
|
|
359
|
+
if (!initial || w.checkStartTime(safeTime, initial)) {
|
|
360
|
+
w.emit("change", mtime, type);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
} else if (!initial) {
|
|
364
|
+
this.forEachWatcher(filePath, w => w.emit("change", mtime, type));
|
|
365
|
+
}
|
|
366
|
+
this.forEachWatcher(this.path, w => {
|
|
367
|
+
if (!initial || w.checkStartTime(safeTime, initial)) {
|
|
368
|
+
w.emit("change", filePath, safeTime, type, initial);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
setDirectory(directoryPath, birthtime, initial, type) {
|
|
374
|
+
if (this.ignored(directoryPath)) return;
|
|
375
|
+
if (directoryPath === this.path) {
|
|
376
|
+
if (!initial) {
|
|
377
|
+
this.forEachWatcher(this.path, w =>
|
|
378
|
+
w.emit("change", directoryPath, birthtime, type, initial)
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
} else {
|
|
382
|
+
const old = this.directories.get(directoryPath);
|
|
383
|
+
if (!old) {
|
|
384
|
+
const now = Date.now();
|
|
385
|
+
|
|
386
|
+
if (this.nestedWatching) {
|
|
387
|
+
this.createNestedWatcher(directoryPath);
|
|
388
|
+
} else {
|
|
389
|
+
this.directories.set(directoryPath, true);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
let safeTime;
|
|
393
|
+
if (initial) {
|
|
394
|
+
safeTime = Math.min(now, birthtime) + FS_ACCURACY;
|
|
395
|
+
} else {
|
|
396
|
+
safeTime = now;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
this.forEachWatcher(directoryPath, w => {
|
|
400
|
+
if (!initial || w.checkStartTime(safeTime, false)) {
|
|
401
|
+
w.emit("change", birthtime, type);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
this.forEachWatcher(this.path, w => {
|
|
405
|
+
if (!initial || w.checkStartTime(safeTime, initial)) {
|
|
406
|
+
w.emit("change", directoryPath, safeTime, type, initial);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
createNestedWatcher(directoryPath) {
|
|
414
|
+
const watcher = this.watcherManager.watchDirectory(directoryPath, 1);
|
|
415
|
+
watcher.on("change", (filePath, mtime, type, initial) => {
|
|
416
|
+
this.forEachWatcher(this.path, w => {
|
|
417
|
+
if (!initial || w.checkStartTime(mtime, initial)) {
|
|
418
|
+
w.emit("change", filePath, mtime, type, initial);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
this.directories.set(directoryPath, watcher);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
setNestedWatching(flag) {
|
|
426
|
+
if (this.nestedWatching !== !!flag) {
|
|
427
|
+
this.nestedWatching = !!flag;
|
|
428
|
+
if (this.nestedWatching) {
|
|
429
|
+
for (const directory of this.directories.keys()) {
|
|
430
|
+
this.createNestedWatcher(directory);
|
|
431
|
+
}
|
|
432
|
+
} else {
|
|
433
|
+
for (const [directory, watcher] of this.directories) {
|
|
434
|
+
watcher.close();
|
|
435
|
+
this.directories.set(directory, true);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
watch(filePath, startTime) {
|
|
442
|
+
const key = withoutCase(filePath);
|
|
443
|
+
let watchers = this.watchers.get(key);
|
|
444
|
+
if (watchers === undefined) {
|
|
445
|
+
watchers = new Set();
|
|
446
|
+
this.watchers.set(key, watchers);
|
|
447
|
+
}
|
|
448
|
+
this.refs++;
|
|
449
|
+
const watcher = new Watcher(this, filePath, startTime);
|
|
450
|
+
watcher.on("closed", () => {
|
|
451
|
+
if (--this.refs <= 0) {
|
|
452
|
+
this.close();
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
watchers.delete(watcher);
|
|
456
|
+
if (watchers.size === 0) {
|
|
457
|
+
this.watchers.delete(key);
|
|
458
|
+
if (this.path === filePath) this.setNestedWatching(false);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
watchers.add(watcher);
|
|
462
|
+
let safeTime;
|
|
463
|
+
if (filePath === this.path) {
|
|
464
|
+
this.setNestedWatching(true);
|
|
465
|
+
safeTime = this.lastWatchEvent;
|
|
466
|
+
for (const entry of this.files.values()) {
|
|
467
|
+
fixupEntryAccuracy(entry);
|
|
468
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
469
|
+
}
|
|
470
|
+
} else {
|
|
471
|
+
const entry = this.files.get(filePath);
|
|
472
|
+
if (entry) {
|
|
473
|
+
fixupEntryAccuracy(entry);
|
|
474
|
+
safeTime = entry.safeTime;
|
|
475
|
+
} else {
|
|
476
|
+
safeTime = 0;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (safeTime) {
|
|
480
|
+
if (safeTime >= startTime) {
|
|
481
|
+
process.nextTick(() => {
|
|
482
|
+
if (this.closed) return;
|
|
483
|
+
if (filePath === this.path) {
|
|
484
|
+
watcher.emit(
|
|
485
|
+
"change",
|
|
486
|
+
filePath,
|
|
487
|
+
safeTime,
|
|
488
|
+
"watch (outdated on attach)",
|
|
489
|
+
true
|
|
490
|
+
);
|
|
491
|
+
} else {
|
|
492
|
+
watcher.emit(
|
|
493
|
+
"change",
|
|
494
|
+
safeTime,
|
|
495
|
+
"watch (outdated on attach)",
|
|
496
|
+
true
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
} else if (this.initialScan) {
|
|
502
|
+
if (this.initialScanRemoved.has(filePath)) {
|
|
503
|
+
process.nextTick(() => {
|
|
504
|
+
if (this.closed) return;
|
|
505
|
+
watcher.emit("remove");
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
} else if (
|
|
509
|
+
filePath !== this.path &&
|
|
510
|
+
!this.directories.has(filePath) &&
|
|
511
|
+
watcher.checkStartTime(this.initialScanFinished, false)
|
|
512
|
+
) {
|
|
513
|
+
process.nextTick(() => {
|
|
514
|
+
if (this.closed) return;
|
|
515
|
+
watcher.emit("initial-missing", "watch (missing on attach)");
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
return watcher;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
onWatchEvent(eventType, filename) {
|
|
522
|
+
if (this.closed) return;
|
|
523
|
+
if (!filename) {
|
|
524
|
+
// In some cases no filename is provided
|
|
525
|
+
// This seem to happen on windows
|
|
526
|
+
// So some event happened but we don't know which file is affected
|
|
527
|
+
// We have to do a full scan of the directory
|
|
528
|
+
this.doScan(false);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const filePath = path.join(this.path, filename);
|
|
533
|
+
if (this.ignored(filePath)) return;
|
|
534
|
+
|
|
535
|
+
if (this._activeEvents.get(filename) === undefined) {
|
|
536
|
+
this._activeEvents.set(filename, false);
|
|
537
|
+
const checkStats = () => {
|
|
538
|
+
if (this.closed) return;
|
|
539
|
+
this._activeEvents.set(filename, false);
|
|
540
|
+
fs.lstat(filePath, (err, stats) => {
|
|
541
|
+
if (this.closed) return;
|
|
542
|
+
if (this._activeEvents.get(filename) === true) {
|
|
543
|
+
process.nextTick(checkStats);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
this._activeEvents.delete(filename);
|
|
547
|
+
// ENOENT happens when the file/directory doesn't exist
|
|
548
|
+
// EPERM happens when the containing directory doesn't exist
|
|
549
|
+
if (err) {
|
|
550
|
+
if (
|
|
551
|
+
err.code !== "ENOENT" &&
|
|
552
|
+
err.code !== "EPERM" &&
|
|
553
|
+
err.code !== "EBUSY"
|
|
554
|
+
) {
|
|
555
|
+
this.onStatsError(err);
|
|
556
|
+
} else {
|
|
557
|
+
if (filename === path.basename(this.path)) {
|
|
558
|
+
// This may indicate that the directory itself was removed
|
|
559
|
+
if (!fs.existsSync(this.path)) {
|
|
560
|
+
this.onDirectoryRemoved("stat failed");
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
this.lastWatchEvent = Date.now();
|
|
566
|
+
if (!stats) {
|
|
567
|
+
this.setMissing(filePath, false, eventType);
|
|
568
|
+
} else if (stats.isDirectory()) {
|
|
569
|
+
this.setDirectory(
|
|
570
|
+
filePath,
|
|
571
|
+
+stats.birthtime || 1,
|
|
572
|
+
false,
|
|
573
|
+
eventType
|
|
574
|
+
);
|
|
575
|
+
} else if (stats.isFile() || stats.isSymbolicLink()) {
|
|
576
|
+
if (stats.mtime) {
|
|
577
|
+
ensureFsAccuracy(stats.mtime);
|
|
578
|
+
}
|
|
579
|
+
this.setFileTime(
|
|
580
|
+
filePath,
|
|
581
|
+
+stats.mtime || +stats.ctime || 1,
|
|
582
|
+
false,
|
|
583
|
+
false,
|
|
584
|
+
eventType
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
process.nextTick(checkStats);
|
|
590
|
+
} else {
|
|
591
|
+
this._activeEvents.set(filename, true);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
onWatcherError(err) {
|
|
596
|
+
if (this.closed) return;
|
|
597
|
+
if (err) {
|
|
598
|
+
if (err.code !== "EPERM" && err.code !== "ENOENT") {
|
|
599
|
+
console.error("Watchpack Error (watcher): " + err);
|
|
600
|
+
}
|
|
601
|
+
this.onDirectoryRemoved("watch error");
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
onStatsError(err) {
|
|
606
|
+
if (err) {
|
|
607
|
+
console.error("Watchpack Error (stats): " + err);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
onScanError(err) {
|
|
612
|
+
if (err) {
|
|
613
|
+
console.error("Watchpack Error (initial scan): " + err);
|
|
614
|
+
}
|
|
615
|
+
this.onScanFinished();
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
onScanFinished() {
|
|
619
|
+
if (this.polledWatching) {
|
|
620
|
+
this.timeout = setTimeout(() => {
|
|
621
|
+
if (this.closed) return;
|
|
622
|
+
this.doScan(false);
|
|
623
|
+
}, this.polledWatching);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
onDirectoryRemoved(reason) {
|
|
628
|
+
if (this.watcher) {
|
|
629
|
+
this.watcher.close();
|
|
630
|
+
this.watcher = null;
|
|
631
|
+
}
|
|
632
|
+
this.watchInParentDirectory();
|
|
633
|
+
const type = `directory-removed (${reason})`;
|
|
634
|
+
for (const directory of this.directories.keys()) {
|
|
635
|
+
this.setMissing(directory, null, type);
|
|
636
|
+
}
|
|
637
|
+
for (const file of this.files.keys()) {
|
|
638
|
+
this.setMissing(file, null, type);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
watchInParentDirectory() {
|
|
643
|
+
if (!this.parentWatcher) {
|
|
644
|
+
const parentDir = path.dirname(this.path);
|
|
645
|
+
// avoid watching in the root directory
|
|
646
|
+
// removing directories in the root directory is not supported
|
|
647
|
+
if (path.dirname(parentDir) === parentDir) return;
|
|
648
|
+
|
|
649
|
+
this.parentWatcher = this.watcherManager.watchFile(this.path, 1);
|
|
650
|
+
this.parentWatcher.on("change", (mtime, type) => {
|
|
651
|
+
if (this.closed) return;
|
|
652
|
+
|
|
653
|
+
// On non-osx platforms we don't need this watcher to detect
|
|
654
|
+
// directory removal, as an EPERM error indicates that
|
|
655
|
+
if ((!IS_OSX || this.polledWatching) && this.parentWatcher) {
|
|
656
|
+
this.parentWatcher.close();
|
|
657
|
+
this.parentWatcher = null;
|
|
658
|
+
}
|
|
659
|
+
// Try to create the watcher when parent directory is found
|
|
660
|
+
if (!this.watcher) {
|
|
661
|
+
this.createWatcher();
|
|
662
|
+
this.doScan(false);
|
|
663
|
+
|
|
664
|
+
// directory was created so we emit an event
|
|
665
|
+
this.forEachWatcher(this.path, w =>
|
|
666
|
+
w.emit("change", this.path, mtime, type, false)
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
this.parentWatcher.on("remove", () => {
|
|
671
|
+
this.onDirectoryRemoved("parent directory removed");
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
doScan(initial) {
|
|
677
|
+
if (this.scanning) {
|
|
678
|
+
if (this.scanAgain) {
|
|
679
|
+
if (!initial) this.scanAgainInitial = false;
|
|
680
|
+
} else {
|
|
681
|
+
this.scanAgain = true;
|
|
682
|
+
this.scanAgainInitial = initial;
|
|
683
|
+
}
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
this.scanning = true;
|
|
687
|
+
if (this.timeout) {
|
|
688
|
+
clearTimeout(this.timeout);
|
|
689
|
+
this.timeout = undefined;
|
|
690
|
+
}
|
|
691
|
+
process.nextTick(() => {
|
|
692
|
+
if (this.closed) return;
|
|
693
|
+
fs.readdir(this.path, (err, items) => {
|
|
694
|
+
if (this.closed) return;
|
|
695
|
+
if (err) {
|
|
696
|
+
if (err.code === "ENOENT" || err.code === "EPERM") {
|
|
697
|
+
this.onDirectoryRemoved("scan readdir failed");
|
|
698
|
+
} else {
|
|
699
|
+
this.onScanError(err);
|
|
700
|
+
}
|
|
701
|
+
this.initialScan = false;
|
|
702
|
+
this.initialScanFinished = Date.now();
|
|
703
|
+
if (initial) {
|
|
704
|
+
for (const watchers of this.watchers.values()) {
|
|
705
|
+
for (const watcher of watchers) {
|
|
706
|
+
if (watcher.checkStartTime(this.initialScanFinished, false)) {
|
|
707
|
+
watcher.emit(
|
|
708
|
+
"initial-missing",
|
|
709
|
+
"scan (parent directory missing in initial scan)"
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (this.scanAgain) {
|
|
716
|
+
this.scanAgain = false;
|
|
717
|
+
this.doScan(this.scanAgainInitial);
|
|
718
|
+
} else {
|
|
719
|
+
this.scanning = false;
|
|
720
|
+
}
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
const itemPaths = new Set(
|
|
724
|
+
items.map(item => path.join(this.path, item.normalize("NFC")))
|
|
725
|
+
);
|
|
726
|
+
for (const file of this.files.keys()) {
|
|
727
|
+
if (!itemPaths.has(file)) {
|
|
728
|
+
this.setMissing(file, initial, "scan (missing)");
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
for (const directory of this.directories.keys()) {
|
|
732
|
+
if (!itemPaths.has(directory)) {
|
|
733
|
+
this.setMissing(directory, initial, "scan (missing)");
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (this.scanAgain) {
|
|
737
|
+
// Early repeat of scan
|
|
738
|
+
this.scanAgain = false;
|
|
739
|
+
this.doScan(initial);
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
const itemFinished = needCalls(itemPaths.size + 1, () => {
|
|
743
|
+
if (this.closed) return;
|
|
744
|
+
this.initialScan = false;
|
|
745
|
+
this.initialScanRemoved = null;
|
|
746
|
+
this.initialScanFinished = Date.now();
|
|
747
|
+
if (initial) {
|
|
748
|
+
const missingWatchers = new Map(this.watchers);
|
|
749
|
+
missingWatchers.delete(withoutCase(this.path));
|
|
750
|
+
for (const item of itemPaths) {
|
|
751
|
+
missingWatchers.delete(withoutCase(item));
|
|
752
|
+
}
|
|
753
|
+
for (const watchers of missingWatchers.values()) {
|
|
754
|
+
for (const watcher of watchers) {
|
|
755
|
+
if (watcher.checkStartTime(this.initialScanFinished, false)) {
|
|
756
|
+
watcher.emit(
|
|
757
|
+
"initial-missing",
|
|
758
|
+
"scan (missing in initial scan)"
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (this.scanAgain) {
|
|
765
|
+
this.scanAgain = false;
|
|
766
|
+
this.doScan(this.scanAgainInitial);
|
|
767
|
+
} else {
|
|
768
|
+
this.scanning = false;
|
|
769
|
+
this.onScanFinished();
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
for (const itemPath of itemPaths) {
|
|
773
|
+
fs.lstat(itemPath, (err2, stats) => {
|
|
774
|
+
if (this.closed) return;
|
|
775
|
+
if (err2) {
|
|
776
|
+
if (
|
|
777
|
+
err2.code === "ENOENT" ||
|
|
778
|
+
err2.code === "EPERM" ||
|
|
779
|
+
err2.code === "EACCES" ||
|
|
780
|
+
err2.code === "EBUSY"
|
|
781
|
+
) {
|
|
782
|
+
this.setMissing(itemPath, initial, "scan (" + err2.code + ")");
|
|
783
|
+
} else {
|
|
784
|
+
this.onScanError(err2);
|
|
785
|
+
}
|
|
786
|
+
itemFinished();
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
if (stats.isFile() || stats.isSymbolicLink()) {
|
|
790
|
+
if (stats.mtime) {
|
|
791
|
+
ensureFsAccuracy(stats.mtime);
|
|
792
|
+
}
|
|
793
|
+
this.setFileTime(
|
|
794
|
+
itemPath,
|
|
795
|
+
+stats.mtime || +stats.ctime || 1,
|
|
796
|
+
initial,
|
|
797
|
+
true,
|
|
798
|
+
"scan (file)"
|
|
799
|
+
);
|
|
800
|
+
} else if (stats.isDirectory()) {
|
|
801
|
+
if (!initial || !this.directories.has(itemPath))
|
|
802
|
+
this.setDirectory(
|
|
803
|
+
itemPath,
|
|
804
|
+
+stats.birthtime || 1,
|
|
805
|
+
initial,
|
|
806
|
+
"scan (dir)"
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
itemFinished();
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
itemFinished();
|
|
813
|
+
});
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
getTimes() {
|
|
818
|
+
const obj = Object.create(null);
|
|
819
|
+
let safeTime = this.lastWatchEvent;
|
|
820
|
+
for (const [file, entry] of this.files) {
|
|
821
|
+
fixupEntryAccuracy(entry);
|
|
822
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
823
|
+
obj[file] = Math.max(entry.safeTime, entry.timestamp);
|
|
824
|
+
}
|
|
825
|
+
if (this.nestedWatching) {
|
|
826
|
+
for (const w of this.directories.values()) {
|
|
827
|
+
const times = w.directoryWatcher.getTimes();
|
|
828
|
+
for (const file of Object.keys(times)) {
|
|
829
|
+
const time = times[file];
|
|
830
|
+
safeTime = Math.max(safeTime, time);
|
|
831
|
+
obj[file] = time;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
obj[this.path] = safeTime;
|
|
835
|
+
}
|
|
836
|
+
if (!this.initialScan) {
|
|
837
|
+
for (const watchers of this.watchers.values()) {
|
|
838
|
+
for (const watcher of watchers) {
|
|
839
|
+
const path = watcher.path;
|
|
840
|
+
if (!Object.prototype.hasOwnProperty.call(obj, path)) {
|
|
841
|
+
obj[path] = null;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return obj;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
collectTimeInfoEntries(fileTimestamps, directoryTimestamps) {
|
|
850
|
+
let safeTime = this.lastWatchEvent;
|
|
851
|
+
for (const [file, entry] of this.files) {
|
|
852
|
+
fixupEntryAccuracy(entry);
|
|
853
|
+
safeTime = Math.max(safeTime, entry.safeTime);
|
|
854
|
+
fileTimestamps.set(file, entry);
|
|
855
|
+
}
|
|
856
|
+
if (this.nestedWatching) {
|
|
857
|
+
for (const w of this.directories.values()) {
|
|
858
|
+
safeTime = Math.max(
|
|
859
|
+
safeTime,
|
|
860
|
+
w.directoryWatcher.collectTimeInfoEntries(
|
|
861
|
+
fileTimestamps,
|
|
862
|
+
directoryTimestamps
|
|
863
|
+
)
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
fileTimestamps.set(this.path, EXISTANCE_ONLY_TIME_ENTRY);
|
|
867
|
+
directoryTimestamps.set(this.path, {
|
|
868
|
+
safeTime
|
|
869
|
+
});
|
|
870
|
+
} else {
|
|
871
|
+
for (const dir of this.directories.keys()) {
|
|
872
|
+
// No additional info about this directory
|
|
873
|
+
// but maybe another DirectoryWatcher has info
|
|
874
|
+
fileTimestamps.set(dir, EXISTANCE_ONLY_TIME_ENTRY);
|
|
875
|
+
if (!directoryTimestamps.has(dir))
|
|
876
|
+
directoryTimestamps.set(dir, EXISTANCE_ONLY_TIME_ENTRY);
|
|
877
|
+
}
|
|
878
|
+
fileTimestamps.set(this.path, EXISTANCE_ONLY_TIME_ENTRY);
|
|
879
|
+
directoryTimestamps.set(this.path, EXISTANCE_ONLY_TIME_ENTRY);
|
|
880
|
+
}
|
|
881
|
+
if (!this.initialScan) {
|
|
882
|
+
for (const watchers of this.watchers.values()) {
|
|
883
|
+
for (const watcher of watchers) {
|
|
884
|
+
const path = watcher.path;
|
|
885
|
+
if (!fileTimestamps.has(path)) {
|
|
886
|
+
fileTimestamps.set(path, null);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
return safeTime;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
close() {
|
|
895
|
+
this.closed = true;
|
|
896
|
+
this.initialScan = false;
|
|
897
|
+
if (this.watcher) {
|
|
898
|
+
this.watcher.close();
|
|
899
|
+
this.watcher = null;
|
|
900
|
+
}
|
|
901
|
+
if (this.nestedWatching) {
|
|
902
|
+
for (const w of this.directories.values()) {
|
|
903
|
+
w.close();
|
|
904
|
+
}
|
|
905
|
+
this.directories.clear();
|
|
906
|
+
}
|
|
907
|
+
if (this.parentWatcher) {
|
|
908
|
+
this.parentWatcher.close();
|
|
909
|
+
this.parentWatcher = null;
|
|
910
|
+
}
|
|
911
|
+
this.emit("closed");
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
module.exports = DirectoryWatcher;
|
|
916
|
+
module.exports.EXISTANCE_ONLY_TIME_ENTRY = EXISTANCE_ONLY_TIME_ENTRY;
|
|
917
|
+
|
|
918
|
+
function fixupEntryAccuracy(entry) {
|
|
919
|
+
if (entry.accuracy > FS_ACCURACY) {
|
|
920
|
+
entry.safeTime = entry.safeTime - entry.accuracy + FS_ACCURACY;
|
|
921
|
+
entry.accuracy = FS_ACCURACY;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
function ensureFsAccuracy(mtime) {
|
|
926
|
+
if (!mtime) return;
|
|
927
|
+
if (FS_ACCURACY > 1 && mtime % 1 !== 0) FS_ACCURACY = 1;
|
|
928
|
+
else if (FS_ACCURACY > 10 && mtime % 10 !== 0) FS_ACCURACY = 10;
|
|
929
|
+
else if (FS_ACCURACY > 100 && mtime % 100 !== 0) FS_ACCURACY = 100;
|
|
930
|
+
else if (FS_ACCURACY > 1000 && mtime % 1000 !== 0) FS_ACCURACY = 1000;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
/***/ }),
|
|
935
|
+
|
|
936
|
+
/***/ 669:
|
|
937
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
938
|
+
|
|
939
|
+
"use strict";
|
|
940
|
+
/*
|
|
941
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
942
|
+
Author Tobias Koppers @sokra
|
|
943
|
+
*/
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
const fs = __nccwpck_require__(147);
|
|
947
|
+
const path = __nccwpck_require__(17);
|
|
948
|
+
|
|
949
|
+
// macOS, Linux, and Windows all rely on these errors
|
|
950
|
+
const EXPECTED_ERRORS = new Set(["EINVAL", "ENOENT"]);
|
|
951
|
+
|
|
952
|
+
// On Windows there is also this error in some cases
|
|
953
|
+
if (process.platform === "win32") EXPECTED_ERRORS.add("UNKNOWN");
|
|
954
|
+
|
|
955
|
+
class LinkResolver {
|
|
956
|
+
constructor() {
|
|
957
|
+
this.cache = new Map();
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* @param {string} file path to file or directory
|
|
962
|
+
* @returns {string[]} array of file and all symlinks contributed in the resolving process (first item is the resolved file)
|
|
963
|
+
*/
|
|
964
|
+
resolve(file) {
|
|
965
|
+
const cacheEntry = this.cache.get(file);
|
|
966
|
+
if (cacheEntry !== undefined) {
|
|
967
|
+
return cacheEntry;
|
|
968
|
+
}
|
|
969
|
+
const parent = path.dirname(file);
|
|
970
|
+
if (parent === file) {
|
|
971
|
+
// At root of filesystem there can't be a link
|
|
972
|
+
const result = Object.freeze([file]);
|
|
973
|
+
this.cache.set(file, result);
|
|
974
|
+
return result;
|
|
975
|
+
}
|
|
976
|
+
// resolve the parent directory to find links there and get the real path
|
|
977
|
+
const parentResolved = this.resolve(parent);
|
|
978
|
+
let realFile = file;
|
|
979
|
+
|
|
980
|
+
// is the parent directory really somewhere else?
|
|
981
|
+
if (parentResolved[0] !== parent) {
|
|
982
|
+
// get the real location of file
|
|
983
|
+
const basename = path.basename(file);
|
|
984
|
+
realFile = path.resolve(parentResolved[0], basename);
|
|
985
|
+
}
|
|
986
|
+
// try to read the link content
|
|
987
|
+
try {
|
|
988
|
+
const linkContent = fs.readlinkSync(realFile);
|
|
989
|
+
|
|
990
|
+
// resolve the link content relative to the parent directory
|
|
991
|
+
const resolvedLink = path.resolve(parentResolved[0], linkContent);
|
|
992
|
+
|
|
993
|
+
// recursive resolve the link content for more links in the structure
|
|
994
|
+
const linkResolved = this.resolve(resolvedLink);
|
|
995
|
+
|
|
996
|
+
// merge parent and link resolve results
|
|
997
|
+
let result;
|
|
998
|
+
if (linkResolved.length > 1 && parentResolved.length > 1) {
|
|
999
|
+
// when both contain links we need to duplicate them with a Set
|
|
1000
|
+
const resultSet = new Set(linkResolved);
|
|
1001
|
+
// add the link
|
|
1002
|
+
resultSet.add(realFile);
|
|
1003
|
+
// add all symlinks of the parent
|
|
1004
|
+
for (let i = 1; i < parentResolved.length; i++) {
|
|
1005
|
+
resultSet.add(parentResolved[i]);
|
|
1006
|
+
}
|
|
1007
|
+
result = Object.freeze(Array.from(resultSet));
|
|
1008
|
+
} else if (parentResolved.length > 1) {
|
|
1009
|
+
// we have links in the parent but not for the link content location
|
|
1010
|
+
result = parentResolved.slice();
|
|
1011
|
+
result[0] = linkResolved[0];
|
|
1012
|
+
// add the link
|
|
1013
|
+
result.push(realFile);
|
|
1014
|
+
Object.freeze(result);
|
|
1015
|
+
} else if (linkResolved.length > 1) {
|
|
1016
|
+
// we can return the link content location result
|
|
1017
|
+
result = linkResolved.slice();
|
|
1018
|
+
// add the link
|
|
1019
|
+
result.push(realFile);
|
|
1020
|
+
Object.freeze(result);
|
|
1021
|
+
} else {
|
|
1022
|
+
// neither link content location nor parent have links
|
|
1023
|
+
// this link is the only link here
|
|
1024
|
+
result = Object.freeze([
|
|
1025
|
+
// the resolve real location
|
|
1026
|
+
linkResolved[0],
|
|
1027
|
+
// add the link
|
|
1028
|
+
realFile
|
|
1029
|
+
]);
|
|
1030
|
+
}
|
|
1031
|
+
this.cache.set(file, result);
|
|
1032
|
+
return result;
|
|
1033
|
+
} catch (e) {
|
|
1034
|
+
if (!EXPECTED_ERRORS.has(e.code)) {
|
|
1035
|
+
throw e;
|
|
1036
|
+
}
|
|
1037
|
+
// no link
|
|
1038
|
+
const result = parentResolved.slice();
|
|
1039
|
+
result[0] = realFile;
|
|
1040
|
+
Object.freeze(result);
|
|
1041
|
+
this.cache.set(file, result);
|
|
1042
|
+
return result;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
module.exports = LinkResolver;
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
/***/ }),
|
|
1050
|
+
|
|
1051
|
+
/***/ 399:
|
|
1052
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1053
|
+
|
|
1054
|
+
"use strict";
|
|
1055
|
+
/*
|
|
1056
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1057
|
+
Author Tobias Koppers @sokra
|
|
1058
|
+
*/
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
const path = __nccwpck_require__(17);
|
|
1062
|
+
const DirectoryWatcher = __nccwpck_require__(238);
|
|
1063
|
+
|
|
1064
|
+
class WatcherManager {
|
|
1065
|
+
constructor(options) {
|
|
1066
|
+
this.options = options;
|
|
1067
|
+
this.directoryWatchers = new Map();
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
getDirectoryWatcher(directory) {
|
|
1071
|
+
const watcher = this.directoryWatchers.get(directory);
|
|
1072
|
+
if (watcher === undefined) {
|
|
1073
|
+
const newWatcher = new DirectoryWatcher(this, directory, this.options);
|
|
1074
|
+
this.directoryWatchers.set(directory, newWatcher);
|
|
1075
|
+
newWatcher.on("closed", () => {
|
|
1076
|
+
this.directoryWatchers.delete(directory);
|
|
1077
|
+
});
|
|
1078
|
+
return newWatcher;
|
|
1079
|
+
}
|
|
1080
|
+
return watcher;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
watchFile(p, startTime) {
|
|
1084
|
+
const directory = path.dirname(p);
|
|
1085
|
+
if (directory === p) return null;
|
|
1086
|
+
return this.getDirectoryWatcher(directory).watch(p, startTime);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
watchDirectory(directory, startTime) {
|
|
1090
|
+
return this.getDirectoryWatcher(directory).watch(directory, startTime);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
const watcherManagers = new WeakMap();
|
|
1095
|
+
/**
|
|
1096
|
+
* @param {object} options options
|
|
1097
|
+
* @returns {WatcherManager} the watcher manager
|
|
1098
|
+
*/
|
|
1099
|
+
module.exports = options => {
|
|
1100
|
+
const watcherManager = watcherManagers.get(options);
|
|
1101
|
+
if (watcherManager !== undefined) return watcherManager;
|
|
1102
|
+
const newWatcherManager = new WatcherManager(options);
|
|
1103
|
+
watcherManagers.set(options, newWatcherManager);
|
|
1104
|
+
return newWatcherManager;
|
|
1105
|
+
};
|
|
1106
|
+
module.exports.WatcherManager = WatcherManager;
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
/***/ }),
|
|
1110
|
+
|
|
1111
|
+
/***/ 385:
|
|
1112
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1113
|
+
|
|
1114
|
+
"use strict";
|
|
1115
|
+
/*
|
|
1116
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1117
|
+
Author Tobias Koppers @sokra
|
|
1118
|
+
*/
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
const path = __nccwpck_require__(17);
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* @template T
|
|
1125
|
+
* @typedef {Object} TreeNode
|
|
1126
|
+
* @property {string} filePath
|
|
1127
|
+
* @property {TreeNode} parent
|
|
1128
|
+
* @property {TreeNode[]} children
|
|
1129
|
+
* @property {number} entries
|
|
1130
|
+
* @property {boolean} active
|
|
1131
|
+
* @property {T[] | T | undefined} value
|
|
1132
|
+
*/
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* @template T
|
|
1136
|
+
* @param {Map<string, T[] | T} plan
|
|
1137
|
+
* @param {number} limit
|
|
1138
|
+
* @returns {Map<string, Map<T, string>>} the new plan
|
|
1139
|
+
*/
|
|
1140
|
+
module.exports = (plan, limit) => {
|
|
1141
|
+
const treeMap = new Map();
|
|
1142
|
+
// Convert to tree
|
|
1143
|
+
for (const [filePath, value] of plan) {
|
|
1144
|
+
treeMap.set(filePath, {
|
|
1145
|
+
filePath,
|
|
1146
|
+
parent: undefined,
|
|
1147
|
+
children: undefined,
|
|
1148
|
+
entries: 1,
|
|
1149
|
+
active: true,
|
|
1150
|
+
value
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
let currentCount = treeMap.size;
|
|
1154
|
+
// Create parents and calculate sum of entries
|
|
1155
|
+
for (const node of treeMap.values()) {
|
|
1156
|
+
const parentPath = path.dirname(node.filePath);
|
|
1157
|
+
if (parentPath !== node.filePath) {
|
|
1158
|
+
let parent = treeMap.get(parentPath);
|
|
1159
|
+
if (parent === undefined) {
|
|
1160
|
+
parent = {
|
|
1161
|
+
filePath: parentPath,
|
|
1162
|
+
parent: undefined,
|
|
1163
|
+
children: [node],
|
|
1164
|
+
entries: node.entries,
|
|
1165
|
+
active: false,
|
|
1166
|
+
value: undefined
|
|
1167
|
+
};
|
|
1168
|
+
treeMap.set(parentPath, parent);
|
|
1169
|
+
node.parent = parent;
|
|
1170
|
+
} else {
|
|
1171
|
+
node.parent = parent;
|
|
1172
|
+
if (parent.children === undefined) {
|
|
1173
|
+
parent.children = [node];
|
|
1174
|
+
} else {
|
|
1175
|
+
parent.children.push(node);
|
|
1176
|
+
}
|
|
1177
|
+
do {
|
|
1178
|
+
parent.entries += node.entries;
|
|
1179
|
+
parent = parent.parent;
|
|
1180
|
+
} while (parent);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
// Reduce until limit reached
|
|
1185
|
+
while (currentCount > limit) {
|
|
1186
|
+
// Select node that helps reaching the limit most effectively without overmerging
|
|
1187
|
+
const overLimit = currentCount - limit;
|
|
1188
|
+
let bestNode = undefined;
|
|
1189
|
+
let bestCost = Infinity;
|
|
1190
|
+
for (const node of treeMap.values()) {
|
|
1191
|
+
if (node.entries <= 1 || !node.children || !node.parent) continue;
|
|
1192
|
+
if (node.children.length === 0) continue;
|
|
1193
|
+
if (node.children.length === 1 && !node.value) continue;
|
|
1194
|
+
// Try to select the node with has just a bit more entries than we need to reduce
|
|
1195
|
+
// When just a bit more is over 30% over the limit,
|
|
1196
|
+
// also consider just a bit less entries then we need to reduce
|
|
1197
|
+
const cost =
|
|
1198
|
+
node.entries - 1 >= overLimit
|
|
1199
|
+
? node.entries - 1 - overLimit
|
|
1200
|
+
: overLimit - node.entries + 1 + limit * 0.3;
|
|
1201
|
+
if (cost < bestCost) {
|
|
1202
|
+
bestNode = node;
|
|
1203
|
+
bestCost = cost;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
if (!bestNode) break;
|
|
1207
|
+
// Merge all children
|
|
1208
|
+
const reduction = bestNode.entries - 1;
|
|
1209
|
+
bestNode.active = true;
|
|
1210
|
+
bestNode.entries = 1;
|
|
1211
|
+
currentCount -= reduction;
|
|
1212
|
+
let parent = bestNode.parent;
|
|
1213
|
+
while (parent) {
|
|
1214
|
+
parent.entries -= reduction;
|
|
1215
|
+
parent = parent.parent;
|
|
1216
|
+
}
|
|
1217
|
+
const queue = new Set(bestNode.children);
|
|
1218
|
+
for (const node of queue) {
|
|
1219
|
+
node.active = false;
|
|
1220
|
+
node.entries = 0;
|
|
1221
|
+
if (node.children) {
|
|
1222
|
+
for (const child of node.children) queue.add(child);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
// Write down new plan
|
|
1227
|
+
const newPlan = new Map();
|
|
1228
|
+
for (const rootNode of treeMap.values()) {
|
|
1229
|
+
if (!rootNode.active) continue;
|
|
1230
|
+
const map = new Map();
|
|
1231
|
+
const queue = new Set([rootNode]);
|
|
1232
|
+
for (const node of queue) {
|
|
1233
|
+
if (node.active && node !== rootNode) continue;
|
|
1234
|
+
if (node.value) {
|
|
1235
|
+
if (Array.isArray(node.value)) {
|
|
1236
|
+
for (const item of node.value) {
|
|
1237
|
+
map.set(item, node.filePath);
|
|
1238
|
+
}
|
|
1239
|
+
} else {
|
|
1240
|
+
map.set(node.value, node.filePath);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
if (node.children) {
|
|
1244
|
+
for (const child of node.children) {
|
|
1245
|
+
queue.add(child);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
newPlan.set(rootNode.filePath, map);
|
|
1250
|
+
}
|
|
1251
|
+
return newPlan;
|
|
1252
|
+
};
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
/***/ }),
|
|
1256
|
+
|
|
1257
|
+
/***/ 344:
|
|
1258
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
1259
|
+
|
|
1260
|
+
"use strict";
|
|
1261
|
+
/*
|
|
1262
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1263
|
+
Author Tobias Koppers @sokra
|
|
1264
|
+
*/
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
const fs = __nccwpck_require__(147);
|
|
1268
|
+
const path = __nccwpck_require__(17);
|
|
1269
|
+
const { EventEmitter } = __nccwpck_require__(361);
|
|
1270
|
+
const reducePlan = __nccwpck_require__(385);
|
|
1271
|
+
|
|
1272
|
+
const IS_OSX = (__nccwpck_require__(37).platform)() === "darwin";
|
|
1273
|
+
const IS_WIN = (__nccwpck_require__(37).platform)() === "win32";
|
|
1274
|
+
const SUPPORTS_RECURSIVE_WATCHING = IS_OSX || IS_WIN;
|
|
1275
|
+
|
|
1276
|
+
const watcherLimit =
|
|
1277
|
+
+process.env.WATCHPACK_WATCHER_LIMIT || (IS_OSX ? 2000 : 10000);
|
|
1278
|
+
|
|
1279
|
+
const recursiveWatcherLogging = !!process.env
|
|
1280
|
+
.WATCHPACK_RECURSIVE_WATCHER_LOGGING;
|
|
1281
|
+
|
|
1282
|
+
let isBatch = false;
|
|
1283
|
+
let watcherCount = 0;
|
|
1284
|
+
|
|
1285
|
+
/** @type {Map<Watcher, string>} */
|
|
1286
|
+
const pendingWatchers = new Map();
|
|
1287
|
+
|
|
1288
|
+
/** @type {Map<string, RecursiveWatcher>} */
|
|
1289
|
+
const recursiveWatchers = new Map();
|
|
1290
|
+
|
|
1291
|
+
/** @type {Map<string, DirectWatcher>} */
|
|
1292
|
+
const directWatchers = new Map();
|
|
1293
|
+
|
|
1294
|
+
/** @type {Map<Watcher, RecursiveWatcher | DirectWatcher>} */
|
|
1295
|
+
const underlyingWatcher = new Map();
|
|
1296
|
+
|
|
1297
|
+
class DirectWatcher {
|
|
1298
|
+
constructor(filePath) {
|
|
1299
|
+
this.filePath = filePath;
|
|
1300
|
+
this.watchers = new Set();
|
|
1301
|
+
this.watcher = undefined;
|
|
1302
|
+
try {
|
|
1303
|
+
const watcher = fs.watch(filePath);
|
|
1304
|
+
this.watcher = watcher;
|
|
1305
|
+
watcher.on("change", (type, filename) => {
|
|
1306
|
+
for (const w of this.watchers) {
|
|
1307
|
+
w.emit("change", type, filename);
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
watcher.on("error", error => {
|
|
1311
|
+
for (const w of this.watchers) {
|
|
1312
|
+
w.emit("error", error);
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
} catch (err) {
|
|
1316
|
+
process.nextTick(() => {
|
|
1317
|
+
for (const w of this.watchers) {
|
|
1318
|
+
w.emit("error", err);
|
|
1319
|
+
}
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
watcherCount++;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
add(watcher) {
|
|
1326
|
+
underlyingWatcher.set(watcher, this);
|
|
1327
|
+
this.watchers.add(watcher);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
remove(watcher) {
|
|
1331
|
+
this.watchers.delete(watcher);
|
|
1332
|
+
if (this.watchers.size === 0) {
|
|
1333
|
+
directWatchers.delete(this.filePath);
|
|
1334
|
+
watcherCount--;
|
|
1335
|
+
if (this.watcher) this.watcher.close();
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
getWatchers() {
|
|
1340
|
+
return this.watchers;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
class RecursiveWatcher {
|
|
1345
|
+
constructor(rootPath) {
|
|
1346
|
+
this.rootPath = rootPath;
|
|
1347
|
+
/** @type {Map<Watcher, string>} */
|
|
1348
|
+
this.mapWatcherToPath = new Map();
|
|
1349
|
+
/** @type {Map<string, Set<Watcher>>} */
|
|
1350
|
+
this.mapPathToWatchers = new Map();
|
|
1351
|
+
this.watcher = undefined;
|
|
1352
|
+
try {
|
|
1353
|
+
const watcher = fs.watch(rootPath, {
|
|
1354
|
+
recursive: true
|
|
1355
|
+
});
|
|
1356
|
+
this.watcher = watcher;
|
|
1357
|
+
watcher.on("change", (type, filename) => {
|
|
1358
|
+
if (!filename) {
|
|
1359
|
+
if (recursiveWatcherLogging) {
|
|
1360
|
+
process.stderr.write(
|
|
1361
|
+
`[watchpack] dispatch ${type} event in recursive watcher (${this.rootPath}) to all watchers\n`
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
for (const w of this.mapWatcherToPath.keys()) {
|
|
1365
|
+
w.emit("change", type);
|
|
1366
|
+
}
|
|
1367
|
+
} else {
|
|
1368
|
+
const dir = path.dirname(filename);
|
|
1369
|
+
const watchers = this.mapPathToWatchers.get(dir);
|
|
1370
|
+
if (recursiveWatcherLogging) {
|
|
1371
|
+
process.stderr.write(
|
|
1372
|
+
`[watchpack] dispatch ${type} event in recursive watcher (${
|
|
1373
|
+
this.rootPath
|
|
1374
|
+
}) for '${filename}' to ${
|
|
1375
|
+
watchers ? watchers.size : 0
|
|
1376
|
+
} watchers\n`
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
if (watchers === undefined) return;
|
|
1380
|
+
for (const w of watchers) {
|
|
1381
|
+
w.emit("change", type, path.basename(filename));
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
watcher.on("error", error => {
|
|
1386
|
+
for (const w of this.mapWatcherToPath.keys()) {
|
|
1387
|
+
w.emit("error", error);
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
} catch (err) {
|
|
1391
|
+
process.nextTick(() => {
|
|
1392
|
+
for (const w of this.mapWatcherToPath.keys()) {
|
|
1393
|
+
w.emit("error", err);
|
|
1394
|
+
}
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
watcherCount++;
|
|
1398
|
+
if (recursiveWatcherLogging) {
|
|
1399
|
+
process.stderr.write(
|
|
1400
|
+
`[watchpack] created recursive watcher at ${rootPath}\n`
|
|
1401
|
+
);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
add(filePath, watcher) {
|
|
1406
|
+
underlyingWatcher.set(watcher, this);
|
|
1407
|
+
const subpath = filePath.slice(this.rootPath.length + 1) || ".";
|
|
1408
|
+
this.mapWatcherToPath.set(watcher, subpath);
|
|
1409
|
+
const set = this.mapPathToWatchers.get(subpath);
|
|
1410
|
+
if (set === undefined) {
|
|
1411
|
+
const newSet = new Set();
|
|
1412
|
+
newSet.add(watcher);
|
|
1413
|
+
this.mapPathToWatchers.set(subpath, newSet);
|
|
1414
|
+
} else {
|
|
1415
|
+
set.add(watcher);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
remove(watcher) {
|
|
1420
|
+
const subpath = this.mapWatcherToPath.get(watcher);
|
|
1421
|
+
if (!subpath) return;
|
|
1422
|
+
this.mapWatcherToPath.delete(watcher);
|
|
1423
|
+
const set = this.mapPathToWatchers.get(subpath);
|
|
1424
|
+
set.delete(watcher);
|
|
1425
|
+
if (set.size === 0) {
|
|
1426
|
+
this.mapPathToWatchers.delete(subpath);
|
|
1427
|
+
}
|
|
1428
|
+
if (this.mapWatcherToPath.size === 0) {
|
|
1429
|
+
recursiveWatchers.delete(this.rootPath);
|
|
1430
|
+
watcherCount--;
|
|
1431
|
+
if (this.watcher) this.watcher.close();
|
|
1432
|
+
if (recursiveWatcherLogging) {
|
|
1433
|
+
process.stderr.write(
|
|
1434
|
+
`[watchpack] closed recursive watcher at ${this.rootPath}\n`
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
getWatchers() {
|
|
1441
|
+
return this.mapWatcherToPath;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
class Watcher extends EventEmitter {
|
|
1446
|
+
close() {
|
|
1447
|
+
if (pendingWatchers.has(this)) {
|
|
1448
|
+
pendingWatchers.delete(this);
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
const watcher = underlyingWatcher.get(this);
|
|
1452
|
+
watcher.remove(this);
|
|
1453
|
+
underlyingWatcher.delete(this);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
const createDirectWatcher = filePath => {
|
|
1458
|
+
const existing = directWatchers.get(filePath);
|
|
1459
|
+
if (existing !== undefined) return existing;
|
|
1460
|
+
const w = new DirectWatcher(filePath);
|
|
1461
|
+
directWatchers.set(filePath, w);
|
|
1462
|
+
return w;
|
|
1463
|
+
};
|
|
1464
|
+
|
|
1465
|
+
const createRecursiveWatcher = rootPath => {
|
|
1466
|
+
const existing = recursiveWatchers.get(rootPath);
|
|
1467
|
+
if (existing !== undefined) return existing;
|
|
1468
|
+
const w = new RecursiveWatcher(rootPath);
|
|
1469
|
+
recursiveWatchers.set(rootPath, w);
|
|
1470
|
+
return w;
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1473
|
+
const execute = () => {
|
|
1474
|
+
/** @type {Map<string, Watcher[] | Watcher>} */
|
|
1475
|
+
const map = new Map();
|
|
1476
|
+
const addWatcher = (watcher, filePath) => {
|
|
1477
|
+
const entry = map.get(filePath);
|
|
1478
|
+
if (entry === undefined) {
|
|
1479
|
+
map.set(filePath, watcher);
|
|
1480
|
+
} else if (Array.isArray(entry)) {
|
|
1481
|
+
entry.push(watcher);
|
|
1482
|
+
} else {
|
|
1483
|
+
map.set(filePath, [entry, watcher]);
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
for (const [watcher, filePath] of pendingWatchers) {
|
|
1487
|
+
addWatcher(watcher, filePath);
|
|
1488
|
+
}
|
|
1489
|
+
pendingWatchers.clear();
|
|
1490
|
+
|
|
1491
|
+
// Fast case when we are not reaching the limit
|
|
1492
|
+
if (!SUPPORTS_RECURSIVE_WATCHING || watcherLimit - watcherCount >= map.size) {
|
|
1493
|
+
// Create watchers for all entries in the map
|
|
1494
|
+
for (const [filePath, entry] of map) {
|
|
1495
|
+
const w = createDirectWatcher(filePath);
|
|
1496
|
+
if (Array.isArray(entry)) {
|
|
1497
|
+
for (const item of entry) w.add(item);
|
|
1498
|
+
} else {
|
|
1499
|
+
w.add(entry);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// Reconsider existing watchers to improving watch plan
|
|
1506
|
+
for (const watcher of recursiveWatchers.values()) {
|
|
1507
|
+
for (const [w, subpath] of watcher.getWatchers()) {
|
|
1508
|
+
addWatcher(w, path.join(watcher.rootPath, subpath));
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
for (const watcher of directWatchers.values()) {
|
|
1512
|
+
for (const w of watcher.getWatchers()) {
|
|
1513
|
+
addWatcher(w, watcher.filePath);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
// Merge map entries to keep watcher limit
|
|
1518
|
+
// Create a 10% buffer to be able to enter fast case more often
|
|
1519
|
+
const plan = reducePlan(map, watcherLimit * 0.9);
|
|
1520
|
+
|
|
1521
|
+
// Update watchers for all entries in the map
|
|
1522
|
+
for (const [filePath, entry] of plan) {
|
|
1523
|
+
if (entry.size === 1) {
|
|
1524
|
+
for (const [watcher, filePath] of entry) {
|
|
1525
|
+
const w = createDirectWatcher(filePath);
|
|
1526
|
+
const old = underlyingWatcher.get(watcher);
|
|
1527
|
+
if (old === w) continue;
|
|
1528
|
+
w.add(watcher);
|
|
1529
|
+
if (old !== undefined) old.remove(watcher);
|
|
1530
|
+
}
|
|
1531
|
+
} else {
|
|
1532
|
+
const filePaths = new Set(entry.values());
|
|
1533
|
+
if (filePaths.size > 1) {
|
|
1534
|
+
const w = createRecursiveWatcher(filePath);
|
|
1535
|
+
for (const [watcher, watcherPath] of entry) {
|
|
1536
|
+
const old = underlyingWatcher.get(watcher);
|
|
1537
|
+
if (old === w) continue;
|
|
1538
|
+
w.add(watcherPath, watcher);
|
|
1539
|
+
if (old !== undefined) old.remove(watcher);
|
|
1540
|
+
}
|
|
1541
|
+
} else {
|
|
1542
|
+
for (const filePath of filePaths) {
|
|
1543
|
+
const w = createDirectWatcher(filePath);
|
|
1544
|
+
for (const watcher of entry.keys()) {
|
|
1545
|
+
const old = underlyingWatcher.get(watcher);
|
|
1546
|
+
if (old === w) continue;
|
|
1547
|
+
w.add(watcher);
|
|
1548
|
+
if (old !== undefined) old.remove(watcher);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
exports.watch = filePath => {
|
|
1557
|
+
const watcher = new Watcher();
|
|
1558
|
+
// Find an existing watcher
|
|
1559
|
+
const directWatcher = directWatchers.get(filePath);
|
|
1560
|
+
if (directWatcher !== undefined) {
|
|
1561
|
+
directWatcher.add(watcher);
|
|
1562
|
+
return watcher;
|
|
1563
|
+
}
|
|
1564
|
+
let current = filePath;
|
|
1565
|
+
for (;;) {
|
|
1566
|
+
const recursiveWatcher = recursiveWatchers.get(current);
|
|
1567
|
+
if (recursiveWatcher !== undefined) {
|
|
1568
|
+
recursiveWatcher.add(filePath, watcher);
|
|
1569
|
+
return watcher;
|
|
1570
|
+
}
|
|
1571
|
+
const parent = path.dirname(current);
|
|
1572
|
+
if (parent === current) break;
|
|
1573
|
+
current = parent;
|
|
1574
|
+
}
|
|
1575
|
+
// Queue up watcher for creation
|
|
1576
|
+
pendingWatchers.set(watcher, filePath);
|
|
1577
|
+
if (!isBatch) execute();
|
|
1578
|
+
return watcher;
|
|
1579
|
+
};
|
|
1580
|
+
|
|
1581
|
+
exports.batch = fn => {
|
|
1582
|
+
isBatch = true;
|
|
1583
|
+
try {
|
|
1584
|
+
fn();
|
|
1585
|
+
} finally {
|
|
1586
|
+
isBatch = false;
|
|
1587
|
+
execute();
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
|
|
1591
|
+
exports.getNumberOfWatchers = () => {
|
|
1592
|
+
return watcherCount;
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
|
|
1596
|
+
/***/ }),
|
|
1597
|
+
|
|
1598
|
+
/***/ 375:
|
|
1599
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1600
|
+
|
|
1601
|
+
"use strict";
|
|
1602
|
+
/*
|
|
1603
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
1604
|
+
Author Tobias Koppers @sokra
|
|
1605
|
+
*/
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
const getWatcherManager = __nccwpck_require__(399);
|
|
1609
|
+
const LinkResolver = __nccwpck_require__(669);
|
|
1610
|
+
const EventEmitter = (__nccwpck_require__(361).EventEmitter);
|
|
1611
|
+
const globToRegExp = __nccwpck_require__(140);
|
|
1612
|
+
const watchEventSource = __nccwpck_require__(344);
|
|
1613
|
+
|
|
1614
|
+
const EMPTY_ARRAY = [];
|
|
1615
|
+
const EMPTY_OPTIONS = {};
|
|
1616
|
+
|
|
1617
|
+
function addWatchersToSet(watchers, set) {
|
|
1618
|
+
for (const ww of watchers) {
|
|
1619
|
+
const w = ww.watcher;
|
|
1620
|
+
if (!set.has(w.directoryWatcher)) {
|
|
1621
|
+
set.add(w.directoryWatcher);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
const stringToRegexp = ignored => {
|
|
1627
|
+
const source = globToRegExp(ignored, { globstar: true, extended: true })
|
|
1628
|
+
.source;
|
|
1629
|
+
const matchingStart = source.slice(0, source.length - 1) + "(?:$|\\/)";
|
|
1630
|
+
return matchingStart;
|
|
1631
|
+
};
|
|
1632
|
+
|
|
1633
|
+
const ignoredToFunction = ignored => {
|
|
1634
|
+
if (Array.isArray(ignored)) {
|
|
1635
|
+
const regexp = new RegExp(ignored.map(i => stringToRegexp(i)).join("|"));
|
|
1636
|
+
return x => regexp.test(x.replace(/\\/g, "/"));
|
|
1637
|
+
} else if (typeof ignored === "string") {
|
|
1638
|
+
const regexp = new RegExp(stringToRegexp(ignored));
|
|
1639
|
+
return x => regexp.test(x.replace(/\\/g, "/"));
|
|
1640
|
+
} else if (ignored instanceof RegExp) {
|
|
1641
|
+
return x => ignored.test(x.replace(/\\/g, "/"));
|
|
1642
|
+
} else if (ignored instanceof Function) {
|
|
1643
|
+
return ignored;
|
|
1644
|
+
} else if (ignored) {
|
|
1645
|
+
throw new Error(`Invalid option for 'ignored': ${ignored}`);
|
|
1646
|
+
} else {
|
|
1647
|
+
return () => false;
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
|
|
1651
|
+
const normalizeOptions = options => {
|
|
1652
|
+
return {
|
|
1653
|
+
followSymlinks: !!options.followSymlinks,
|
|
1654
|
+
ignored: ignoredToFunction(options.ignored),
|
|
1655
|
+
poll: options.poll
|
|
1656
|
+
};
|
|
1657
|
+
};
|
|
1658
|
+
|
|
1659
|
+
const normalizeCache = new WeakMap();
|
|
1660
|
+
const cachedNormalizeOptions = options => {
|
|
1661
|
+
const cacheEntry = normalizeCache.get(options);
|
|
1662
|
+
if (cacheEntry !== undefined) return cacheEntry;
|
|
1663
|
+
const normalized = normalizeOptions(options);
|
|
1664
|
+
normalizeCache.set(options, normalized);
|
|
1665
|
+
return normalized;
|
|
1666
|
+
};
|
|
1667
|
+
|
|
1668
|
+
class WatchpackFileWatcher {
|
|
1669
|
+
constructor(watchpack, watcher, files) {
|
|
1670
|
+
this.files = Array.isArray(files) ? files : [files];
|
|
1671
|
+
this.watcher = watcher;
|
|
1672
|
+
watcher.on("initial-missing", type => {
|
|
1673
|
+
for (const file of this.files) {
|
|
1674
|
+
if (!watchpack._missing.has(file))
|
|
1675
|
+
watchpack._onRemove(file, file, type);
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
watcher.on("change", (mtime, type) => {
|
|
1679
|
+
for (const file of this.files) {
|
|
1680
|
+
watchpack._onChange(file, mtime, file, type);
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
watcher.on("remove", type => {
|
|
1684
|
+
for (const file of this.files) {
|
|
1685
|
+
watchpack._onRemove(file, file, type);
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
update(files) {
|
|
1691
|
+
if (!Array.isArray(files)) {
|
|
1692
|
+
if (this.files.length !== 1) {
|
|
1693
|
+
this.files = [files];
|
|
1694
|
+
} else if (this.files[0] !== files) {
|
|
1695
|
+
this.files[0] = files;
|
|
1696
|
+
}
|
|
1697
|
+
} else {
|
|
1698
|
+
this.files = files;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
close() {
|
|
1703
|
+
this.watcher.close();
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
class WatchpackDirectoryWatcher {
|
|
1708
|
+
constructor(watchpack, watcher, directories) {
|
|
1709
|
+
this.directories = Array.isArray(directories) ? directories : [directories];
|
|
1710
|
+
this.watcher = watcher;
|
|
1711
|
+
watcher.on("initial-missing", type => {
|
|
1712
|
+
for (const item of this.directories) {
|
|
1713
|
+
watchpack._onRemove(item, item, type);
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
watcher.on("change", (file, mtime, type) => {
|
|
1717
|
+
for (const item of this.directories) {
|
|
1718
|
+
watchpack._onChange(item, mtime, file, type);
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
watcher.on("remove", type => {
|
|
1722
|
+
for (const item of this.directories) {
|
|
1723
|
+
watchpack._onRemove(item, item, type);
|
|
1724
|
+
}
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
update(directories) {
|
|
1729
|
+
if (!Array.isArray(directories)) {
|
|
1730
|
+
if (this.directories.length !== 1) {
|
|
1731
|
+
this.directories = [directories];
|
|
1732
|
+
} else if (this.directories[0] !== directories) {
|
|
1733
|
+
this.directories[0] = directories;
|
|
1734
|
+
}
|
|
1735
|
+
} else {
|
|
1736
|
+
this.directories = directories;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
close() {
|
|
1741
|
+
this.watcher.close();
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
class Watchpack extends EventEmitter {
|
|
1746
|
+
constructor(options) {
|
|
1747
|
+
super();
|
|
1748
|
+
if (!options) options = EMPTY_OPTIONS;
|
|
1749
|
+
this.options = options;
|
|
1750
|
+
this.aggregateTimeout =
|
|
1751
|
+
typeof options.aggregateTimeout === "number"
|
|
1752
|
+
? options.aggregateTimeout
|
|
1753
|
+
: 200;
|
|
1754
|
+
this.watcherOptions = cachedNormalizeOptions(options);
|
|
1755
|
+
this.watcherManager = getWatcherManager(this.watcherOptions);
|
|
1756
|
+
this.fileWatchers = new Map();
|
|
1757
|
+
this.directoryWatchers = new Map();
|
|
1758
|
+
this._missing = new Set();
|
|
1759
|
+
this.startTime = undefined;
|
|
1760
|
+
this.paused = false;
|
|
1761
|
+
this.aggregatedChanges = new Set();
|
|
1762
|
+
this.aggregatedRemovals = new Set();
|
|
1763
|
+
this.aggregateTimer = undefined;
|
|
1764
|
+
this._onTimeout = this._onTimeout.bind(this);
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
watch(arg1, arg2, arg3) {
|
|
1768
|
+
let files, directories, missing, startTime;
|
|
1769
|
+
if (!arg2) {
|
|
1770
|
+
({
|
|
1771
|
+
files = EMPTY_ARRAY,
|
|
1772
|
+
directories = EMPTY_ARRAY,
|
|
1773
|
+
missing = EMPTY_ARRAY,
|
|
1774
|
+
startTime
|
|
1775
|
+
} = arg1);
|
|
1776
|
+
} else {
|
|
1777
|
+
files = arg1;
|
|
1778
|
+
directories = arg2;
|
|
1779
|
+
missing = EMPTY_ARRAY;
|
|
1780
|
+
startTime = arg3;
|
|
1781
|
+
}
|
|
1782
|
+
this.paused = false;
|
|
1783
|
+
const fileWatchers = this.fileWatchers;
|
|
1784
|
+
const directoryWatchers = this.directoryWatchers;
|
|
1785
|
+
const ignored = this.watcherOptions.ignored;
|
|
1786
|
+
const filter = path => !ignored(path);
|
|
1787
|
+
const addToMap = (map, key, item) => {
|
|
1788
|
+
const list = map.get(key);
|
|
1789
|
+
if (list === undefined) {
|
|
1790
|
+
map.set(key, item);
|
|
1791
|
+
} else if (Array.isArray(list)) {
|
|
1792
|
+
list.push(item);
|
|
1793
|
+
} else {
|
|
1794
|
+
map.set(key, [list, item]);
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
const fileWatchersNeeded = new Map();
|
|
1798
|
+
const directoryWatchersNeeded = new Map();
|
|
1799
|
+
const missingFiles = new Set();
|
|
1800
|
+
if (this.watcherOptions.followSymlinks) {
|
|
1801
|
+
const resolver = new LinkResolver();
|
|
1802
|
+
for (const file of files) {
|
|
1803
|
+
if (filter(file)) {
|
|
1804
|
+
for (const innerFile of resolver.resolve(file)) {
|
|
1805
|
+
if (file === innerFile || filter(innerFile)) {
|
|
1806
|
+
addToMap(fileWatchersNeeded, innerFile, file);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
for (const file of missing) {
|
|
1812
|
+
if (filter(file)) {
|
|
1813
|
+
for (const innerFile of resolver.resolve(file)) {
|
|
1814
|
+
if (file === innerFile || filter(innerFile)) {
|
|
1815
|
+
missingFiles.add(file);
|
|
1816
|
+
addToMap(fileWatchersNeeded, innerFile, file);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
for (const dir of directories) {
|
|
1822
|
+
if (filter(dir)) {
|
|
1823
|
+
let first = true;
|
|
1824
|
+
for (const innerItem of resolver.resolve(dir)) {
|
|
1825
|
+
if (filter(innerItem)) {
|
|
1826
|
+
addToMap(
|
|
1827
|
+
first ? directoryWatchersNeeded : fileWatchersNeeded,
|
|
1828
|
+
innerItem,
|
|
1829
|
+
dir
|
|
1830
|
+
);
|
|
1831
|
+
}
|
|
1832
|
+
first = false;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
} else {
|
|
1837
|
+
for (const file of files) {
|
|
1838
|
+
if (filter(file)) {
|
|
1839
|
+
addToMap(fileWatchersNeeded, file, file);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
for (const file of missing) {
|
|
1843
|
+
if (filter(file)) {
|
|
1844
|
+
missingFiles.add(file);
|
|
1845
|
+
addToMap(fileWatchersNeeded, file, file);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
for (const dir of directories) {
|
|
1849
|
+
if (filter(dir)) {
|
|
1850
|
+
addToMap(directoryWatchersNeeded, dir, dir);
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
// Close unneeded old watchers
|
|
1855
|
+
// and update existing watchers
|
|
1856
|
+
for (const [key, w] of fileWatchers) {
|
|
1857
|
+
const needed = fileWatchersNeeded.get(key);
|
|
1858
|
+
if (needed === undefined) {
|
|
1859
|
+
w.close();
|
|
1860
|
+
fileWatchers.delete(key);
|
|
1861
|
+
} else {
|
|
1862
|
+
w.update(needed);
|
|
1863
|
+
fileWatchersNeeded.delete(key);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
for (const [key, w] of directoryWatchers) {
|
|
1867
|
+
const needed = directoryWatchersNeeded.get(key);
|
|
1868
|
+
if (needed === undefined) {
|
|
1869
|
+
w.close();
|
|
1870
|
+
directoryWatchers.delete(key);
|
|
1871
|
+
} else {
|
|
1872
|
+
w.update(needed);
|
|
1873
|
+
directoryWatchersNeeded.delete(key);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
// Create new watchers and install handlers on these watchers
|
|
1877
|
+
watchEventSource.batch(() => {
|
|
1878
|
+
for (const [key, files] of fileWatchersNeeded) {
|
|
1879
|
+
const watcher = this.watcherManager.watchFile(key, startTime);
|
|
1880
|
+
if (watcher) {
|
|
1881
|
+
fileWatchers.set(key, new WatchpackFileWatcher(this, watcher, files));
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
for (const [key, directories] of directoryWatchersNeeded) {
|
|
1885
|
+
const watcher = this.watcherManager.watchDirectory(key, startTime);
|
|
1886
|
+
if (watcher) {
|
|
1887
|
+
directoryWatchers.set(
|
|
1888
|
+
key,
|
|
1889
|
+
new WatchpackDirectoryWatcher(this, watcher, directories)
|
|
1890
|
+
);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
this._missing = missingFiles;
|
|
1895
|
+
this.startTime = startTime;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
close() {
|
|
1899
|
+
this.paused = true;
|
|
1900
|
+
if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
|
|
1901
|
+
for (const w of this.fileWatchers.values()) w.close();
|
|
1902
|
+
for (const w of this.directoryWatchers.values()) w.close();
|
|
1903
|
+
this.fileWatchers.clear();
|
|
1904
|
+
this.directoryWatchers.clear();
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
pause() {
|
|
1908
|
+
this.paused = true;
|
|
1909
|
+
if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
getTimes() {
|
|
1913
|
+
const directoryWatchers = new Set();
|
|
1914
|
+
addWatchersToSet(this.fileWatchers.values(), directoryWatchers);
|
|
1915
|
+
addWatchersToSet(this.directoryWatchers.values(), directoryWatchers);
|
|
1916
|
+
const obj = Object.create(null);
|
|
1917
|
+
for (const w of directoryWatchers) {
|
|
1918
|
+
const times = w.getTimes();
|
|
1919
|
+
for (const file of Object.keys(times)) obj[file] = times[file];
|
|
1920
|
+
}
|
|
1921
|
+
return obj;
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
getTimeInfoEntries() {
|
|
1925
|
+
const map = new Map();
|
|
1926
|
+
this.collectTimeInfoEntries(map, map);
|
|
1927
|
+
return map;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
collectTimeInfoEntries(fileTimestamps, directoryTimestamps) {
|
|
1931
|
+
const allWatchers = new Set();
|
|
1932
|
+
addWatchersToSet(this.fileWatchers.values(), allWatchers);
|
|
1933
|
+
addWatchersToSet(this.directoryWatchers.values(), allWatchers);
|
|
1934
|
+
const safeTime = { value: 0 };
|
|
1935
|
+
for (const w of allWatchers) {
|
|
1936
|
+
w.collectTimeInfoEntries(fileTimestamps, directoryTimestamps, safeTime);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
getAggregated() {
|
|
1941
|
+
if (this.aggregateTimer) {
|
|
1942
|
+
clearTimeout(this.aggregateTimer);
|
|
1943
|
+
this.aggregateTimer = undefined;
|
|
1944
|
+
}
|
|
1945
|
+
const changes = this.aggregatedChanges;
|
|
1946
|
+
const removals = this.aggregatedRemovals;
|
|
1947
|
+
this.aggregatedChanges = new Set();
|
|
1948
|
+
this.aggregatedRemovals = new Set();
|
|
1949
|
+
return { changes, removals };
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
_onChange(item, mtime, file, type) {
|
|
1953
|
+
file = file || item;
|
|
1954
|
+
if (!this.paused) {
|
|
1955
|
+
this.emit("change", file, mtime, type);
|
|
1956
|
+
if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
|
|
1957
|
+
this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout);
|
|
1958
|
+
}
|
|
1959
|
+
this.aggregatedRemovals.delete(item);
|
|
1960
|
+
this.aggregatedChanges.add(item);
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
_onRemove(item, file, type) {
|
|
1964
|
+
file = file || item;
|
|
1965
|
+
if (!this.paused) {
|
|
1966
|
+
this.emit("remove", file, type);
|
|
1967
|
+
if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
|
|
1968
|
+
this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout);
|
|
1969
|
+
}
|
|
1970
|
+
this.aggregatedChanges.delete(item);
|
|
1971
|
+
this.aggregatedRemovals.add(item);
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
_onTimeout() {
|
|
1975
|
+
this.aggregateTimer = undefined;
|
|
1976
|
+
const changes = this.aggregatedChanges;
|
|
1977
|
+
const removals = this.aggregatedRemovals;
|
|
1978
|
+
this.aggregatedChanges = new Set();
|
|
1979
|
+
this.aggregatedRemovals = new Set();
|
|
1980
|
+
this.emit("aggregated", changes, removals);
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
module.exports = Watchpack;
|
|
1985
|
+
|
|
1986
|
+
|
|
1987
|
+
/***/ }),
|
|
1988
|
+
|
|
1989
|
+
/***/ 453:
|
|
1990
|
+
/***/ ((module) => {
|
|
1991
|
+
|
|
1992
|
+
"use strict";
|
|
1993
|
+
module.exports = require("../graceful-fs");
|
|
1994
|
+
|
|
1995
|
+
/***/ }),
|
|
1996
|
+
|
|
1997
|
+
/***/ 361:
|
|
1998
|
+
/***/ ((module) => {
|
|
1999
|
+
|
|
2000
|
+
"use strict";
|
|
2001
|
+
module.exports = require("events");
|
|
2002
|
+
|
|
2003
|
+
/***/ }),
|
|
2004
|
+
|
|
2005
|
+
/***/ 147:
|
|
2006
|
+
/***/ ((module) => {
|
|
2007
|
+
|
|
2008
|
+
"use strict";
|
|
2009
|
+
module.exports = require("fs");
|
|
2010
|
+
|
|
2011
|
+
/***/ }),
|
|
2012
|
+
|
|
2013
|
+
/***/ 37:
|
|
2014
|
+
/***/ ((module) => {
|
|
2015
|
+
|
|
2016
|
+
"use strict";
|
|
2017
|
+
module.exports = require("os");
|
|
2018
|
+
|
|
2019
|
+
/***/ }),
|
|
2020
|
+
|
|
2021
|
+
/***/ 17:
|
|
2022
|
+
/***/ ((module) => {
|
|
2023
|
+
|
|
2024
|
+
"use strict";
|
|
2025
|
+
module.exports = require("path");
|
|
2026
|
+
|
|
2027
|
+
/***/ })
|
|
2028
|
+
|
|
2029
|
+
/******/ });
|
|
2030
|
+
/************************************************************************/
|
|
2031
|
+
/******/ // The module cache
|
|
2032
|
+
/******/ var __webpack_module_cache__ = {};
|
|
2033
|
+
/******/
|
|
2034
|
+
/******/ // The require function
|
|
2035
|
+
/******/ function __nccwpck_require__(moduleId) {
|
|
2036
|
+
/******/ // Check if module is in cache
|
|
2037
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
2038
|
+
/******/ if (cachedModule !== undefined) {
|
|
2039
|
+
/******/ return cachedModule.exports;
|
|
2040
|
+
/******/ }
|
|
2041
|
+
/******/ // Create a new module (and put it into the cache)
|
|
2042
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
2043
|
+
/******/ // no module.id needed
|
|
2044
|
+
/******/ // no module.loaded needed
|
|
2045
|
+
/******/ exports: {}
|
|
2046
|
+
/******/ };
|
|
2047
|
+
/******/
|
|
2048
|
+
/******/ // Execute the module function
|
|
2049
|
+
/******/ var threw = true;
|
|
2050
|
+
/******/ try {
|
|
2051
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
|
|
2052
|
+
/******/ threw = false;
|
|
2053
|
+
/******/ } finally {
|
|
2054
|
+
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
|
2055
|
+
/******/ }
|
|
2056
|
+
/******/
|
|
2057
|
+
/******/ // Return the exports of the module
|
|
2058
|
+
/******/ return module.exports;
|
|
2059
|
+
/******/ }
|
|
2060
|
+
/******/
|
|
2061
|
+
/************************************************************************/
|
|
2062
|
+
/******/ /* webpack/runtime/compat */
|
|
2063
|
+
/******/
|
|
2064
|
+
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|
|
2065
|
+
/******/
|
|
2066
|
+
/************************************************************************/
|
|
2067
|
+
/******/
|
|
2068
|
+
/******/ // startup
|
|
2069
|
+
/******/ // Load entry module and return exports
|
|
2070
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
2071
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(375);
|
|
2072
|
+
/******/ module.exports = __webpack_exports__;
|
|
2073
|
+
/******/
|
|
2074
|
+
/******/ })()
|
|
2075
|
+
;
|