metro-file-map 0.83.5 → 0.83.6
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/package.json +1 -1
- package/src/Watcher.d.ts +13 -9
- package/src/Watcher.js +66 -39
- package/src/Watcher.js.flow +84 -51
- package/src/cache/DiskCacheManager.d.ts +8 -1
- package/src/constants.d.ts +8 -1
- package/src/crawlers/node/hasNativeFindSupport.d.ts +8 -1
- package/src/crawlers/node/index.d.ts +10 -5
- package/src/crawlers/node/index.js +4 -1
- package/src/crawlers/node/index.js.flow +8 -6
- package/src/crawlers/watchman/index.d.ts +12 -12
- package/src/crawlers/watchman/index.js.flow +2 -6
- package/src/flow-types.d.ts +88 -32
- package/src/flow-types.js.flow +89 -29
- package/src/index.d.ts +11 -4
- package/src/index.js +145 -120
- package/src/index.js.flow +199 -149
- package/src/lib/FileProcessor.d.ts +8 -1
- package/src/lib/FileSystemChangeAggregator.d.ts +40 -0
- package/src/lib/FileSystemChangeAggregator.js +89 -0
- package/src/lib/FileSystemChangeAggregator.js.flow +143 -0
- package/src/lib/RootPathUtils.d.ts +8 -1
- package/src/lib/TreeFS.d.ts +23 -8
- package/src/lib/TreeFS.js +67 -16
- package/src/lib/TreeFS.js.flow +89 -16
- package/src/lib/checkWatchmanCapabilities.d.ts +8 -1
- package/src/lib/normalizePathSeparatorsToPosix.d.ts +8 -1
- package/src/lib/normalizePathSeparatorsToSystem.d.ts +8 -1
- package/src/lib/rootRelativeCacheKeys.d.ts +8 -1
- package/src/lib/sorting.d.ts +8 -1
- package/src/plugins/DependencyPlugin.d.ts +9 -13
- package/src/plugins/DependencyPlugin.js +1 -3
- package/src/plugins/DependencyPlugin.js.flow +1 -16
- package/src/plugins/HastePlugin.d.ts +10 -11
- package/src/plugins/HastePlugin.js +11 -11
- package/src/plugins/HastePlugin.js.flow +12 -12
- package/src/plugins/MockPlugin.d.ts +10 -5
- package/src/plugins/MockPlugin.js +17 -20
- package/src/plugins/MockPlugin.js.flow +18 -22
- package/src/plugins/dependencies/dependencyExtractor.d.ts +1 -1
- package/src/plugins/haste/DuplicateHasteCandidatesError.d.ts +8 -1
- package/src/plugins/haste/HasteConflictsError.d.ts +8 -1
- package/src/plugins/haste/computeConflicts.d.ts +8 -1
- package/src/plugins/haste/getPlatformExtension.d.ts +8 -1
- package/src/plugins/mocks/getMockName.d.ts +8 -1
- package/src/watchers/AbstractWatcher.d.ts +8 -1
- package/src/watchers/FallbackWatcher.d.ts +8 -1
- package/src/watchers/FallbackWatcher.js +19 -3
- package/src/watchers/FallbackWatcher.js.flow +28 -5
- package/src/watchers/NativeWatcher.d.ts +9 -2
- package/src/watchers/NativeWatcher.js +27 -5
- package/src/watchers/NativeWatcher.js.flow +33 -6
- package/src/watchers/RecrawlWarning.d.ts +8 -1
- package/src/watchers/WatchmanWatcher.d.ts +8 -1
- package/src/watchers/common.d.ts +10 -1
- package/src/watchers/common.js +6 -1
- package/src/watchers/common.js.flow +1 -0
|
@@ -99,9 +99,19 @@ class FallbackWatcher extends _AbstractWatcher.AbstractWatcher {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
#unregisterDir(dirpath) {
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
const removedFiles = [];
|
|
103
|
+
for (const registeredDir of Object.keys(this.#dirRegistry)) {
|
|
104
|
+
if (
|
|
105
|
+
registeredDir === dirpath ||
|
|
106
|
+
registeredDir.startsWith(dirpath + _path.default.sep)
|
|
107
|
+
) {
|
|
108
|
+
for (const filename of Object.keys(this.#dirRegistry[registeredDir])) {
|
|
109
|
+
removedFiles.push(_path.default.join(registeredDir, filename));
|
|
110
|
+
}
|
|
111
|
+
delete this.#dirRegistry[registeredDir];
|
|
112
|
+
}
|
|
104
113
|
}
|
|
114
|
+
return removedFiles;
|
|
105
115
|
}
|
|
106
116
|
#registered(fullpath) {
|
|
107
117
|
const dir = _path.default.dirname(fullpath);
|
|
@@ -294,7 +304,13 @@ class FallbackWatcher extends _AbstractWatcher.AbstractWatcher {
|
|
|
294
304
|
return;
|
|
295
305
|
}
|
|
296
306
|
this.#unregister(fullPath);
|
|
297
|
-
this.#unregisterDir(fullPath);
|
|
307
|
+
const removedFiles = this.#unregisterDir(fullPath);
|
|
308
|
+
for (const removedFile of removedFiles) {
|
|
309
|
+
this.#emitEvent({
|
|
310
|
+
event: DELETE_EVENT,
|
|
311
|
+
relativePath: _path.default.relative(this.root, removedFile),
|
|
312
|
+
});
|
|
313
|
+
}
|
|
298
314
|
if (registered) {
|
|
299
315
|
this.#emitEvent({
|
|
300
316
|
event: DELETE_EVENT,
|
|
@@ -124,12 +124,27 @@ export default class FallbackWatcher extends AbstractWatcher {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* Removes a dir from the registry
|
|
127
|
+
* Removes a dir from the registry, returning all files that were registered
|
|
128
|
+
* under it (recursively).
|
|
128
129
|
*/
|
|
129
|
-
#unregisterDir(dirpath: string):
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
#unregisterDir(dirpath: string): Array<string> {
|
|
131
|
+
const removedFiles: Array<string> = [];
|
|
132
|
+
|
|
133
|
+
// Find and remove all entries under this directory
|
|
134
|
+
for (const registeredDir of Object.keys(this.#dirRegistry)) {
|
|
135
|
+
if (
|
|
136
|
+
registeredDir === dirpath ||
|
|
137
|
+
registeredDir.startsWith(dirpath + path.sep)
|
|
138
|
+
) {
|
|
139
|
+
// Collect all files in this directory
|
|
140
|
+
for (const filename of Object.keys(this.#dirRegistry[registeredDir])) {
|
|
141
|
+
removedFiles.push(path.join(registeredDir, filename));
|
|
142
|
+
}
|
|
143
|
+
delete this.#dirRegistry[registeredDir];
|
|
144
|
+
}
|
|
132
145
|
}
|
|
146
|
+
|
|
147
|
+
return removedFiles;
|
|
133
148
|
}
|
|
134
149
|
|
|
135
150
|
/**
|
|
@@ -350,7 +365,15 @@ export default class FallbackWatcher extends AbstractWatcher {
|
|
|
350
365
|
return;
|
|
351
366
|
}
|
|
352
367
|
this.#unregister(fullPath);
|
|
353
|
-
|
|
368
|
+
// When a directory is deleted, emit delete events for all files we
|
|
369
|
+
// knew about under that directory
|
|
370
|
+
const removedFiles = this.#unregisterDir(fullPath);
|
|
371
|
+
for (const removedFile of removedFiles) {
|
|
372
|
+
this.#emitEvent({
|
|
373
|
+
event: DELETE_EVENT,
|
|
374
|
+
relativePath: path.relative(this.root, removedFile),
|
|
375
|
+
});
|
|
376
|
+
}
|
|
354
377
|
if (registered) {
|
|
355
378
|
this.#emitEvent({event: DELETE_EVENT, relativePath});
|
|
356
379
|
}
|
|
@@ -4,7 +4,14 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
|
+
* @generated SignedSource<<b68c5620efd3f5bec83279059d0d1b4e>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro-file-map/src/watchers/NativeWatcher.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
8
15
|
*/
|
|
9
16
|
|
|
10
17
|
import {AbstractWatcher} from './AbstractWatcher';
|
|
@@ -43,6 +50,6 @@ declare class NativeWatcher extends AbstractWatcher {
|
|
|
43
50
|
* End watching.
|
|
44
51
|
*/
|
|
45
52
|
stopWatching(): Promise<void>;
|
|
46
|
-
_handleEvent(relativePath: string): void;
|
|
53
|
+
_handleEvent(event: string, relativePath: string): void;
|
|
47
54
|
}
|
|
48
55
|
export default NativeWatcher;
|
|
@@ -39,6 +39,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
39
39
|
const debug = require("debug")("Metro:NativeWatcher");
|
|
40
40
|
const TOUCH_EVENT = "touch";
|
|
41
41
|
const DELETE_EVENT = "delete";
|
|
42
|
+
const RECRAWL_EVENT = "recrawl";
|
|
42
43
|
class NativeWatcher extends _AbstractWatcher.AbstractWatcher {
|
|
43
44
|
#fsWatcher;
|
|
44
45
|
static isSupported() {
|
|
@@ -57,8 +58,8 @@ class NativeWatcher extends _AbstractWatcher.AbstractWatcher {
|
|
|
57
58
|
persistent: false,
|
|
58
59
|
recursive: true,
|
|
59
60
|
},
|
|
60
|
-
(
|
|
61
|
-
this._handleEvent(relativePath).catch((error) => {
|
|
61
|
+
(event, relativePath) => {
|
|
62
|
+
this._handleEvent(event, relativePath).catch((error) => {
|
|
62
63
|
this.emitError(error);
|
|
63
64
|
});
|
|
64
65
|
},
|
|
@@ -71,13 +72,23 @@ class NativeWatcher extends _AbstractWatcher.AbstractWatcher {
|
|
|
71
72
|
this.#fsWatcher.close();
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
async _handleEvent(relativePath) {
|
|
75
|
+
async _handleEvent(event, relativePath) {
|
|
75
76
|
const absolutePath = path.resolve(this.root, relativePath);
|
|
76
77
|
if (this.doIgnore(relativePath)) {
|
|
77
|
-
debug(
|
|
78
|
+
debug(
|
|
79
|
+
'Ignoring event "%s" on %s (root: %s)',
|
|
80
|
+
event,
|
|
81
|
+
relativePath,
|
|
82
|
+
this.root,
|
|
83
|
+
);
|
|
78
84
|
return;
|
|
79
85
|
}
|
|
80
|
-
debug(
|
|
86
|
+
debug(
|
|
87
|
+
'Handling event "%s" on %s (root: %s)',
|
|
88
|
+
event,
|
|
89
|
+
relativePath,
|
|
90
|
+
this.root,
|
|
91
|
+
);
|
|
81
92
|
try {
|
|
82
93
|
const stat = await _fs.promises.lstat(absolutePath);
|
|
83
94
|
const type = (0, _common.typeFromStat)(stat);
|
|
@@ -89,6 +100,17 @@ class NativeWatcher extends _AbstractWatcher.AbstractWatcher {
|
|
|
89
100
|
) {
|
|
90
101
|
return;
|
|
91
102
|
}
|
|
103
|
+
if (type === "d" && event === "rename") {
|
|
104
|
+
debug(
|
|
105
|
+
"Directory rename detected on %s, requesting recrawl",
|
|
106
|
+
relativePath,
|
|
107
|
+
);
|
|
108
|
+
this.emitFileEvent({
|
|
109
|
+
event: RECRAWL_EVENT,
|
|
110
|
+
relativePath,
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
92
114
|
this.emitFileEvent({
|
|
93
115
|
event: TOUCH_EVENT,
|
|
94
116
|
relativePath,
|
|
@@ -21,6 +21,7 @@ const debug = require('debug')('Metro:NativeWatcher');
|
|
|
21
21
|
|
|
22
22
|
const TOUCH_EVENT = 'touch';
|
|
23
23
|
const DELETE_EVENT = 'delete';
|
|
24
|
+
const RECRAWL_EVENT = 'recrawl';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* NativeWatcher uses Node's native fs.watch API with recursive: true.
|
|
@@ -74,9 +75,8 @@ export default class NativeWatcher extends AbstractWatcher {
|
|
|
74
75
|
// ~instant on macOS or Windows.
|
|
75
76
|
recursive: true,
|
|
76
77
|
},
|
|
77
|
-
(
|
|
78
|
-
|
|
79
|
-
this._handleEvent(relativePath).catch(error => {
|
|
78
|
+
(event, relativePath) => {
|
|
79
|
+
this._handleEvent(event, relativePath).catch(error => {
|
|
80
80
|
this.emitError(error);
|
|
81
81
|
});
|
|
82
82
|
},
|
|
@@ -95,13 +95,23 @@ export default class NativeWatcher extends AbstractWatcher {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
async _handleEvent(relativePath: string) {
|
|
98
|
+
async _handleEvent(event: string, relativePath: string) {
|
|
99
99
|
const absolutePath = path.resolve(this.root, relativePath);
|
|
100
100
|
if (this.doIgnore(relativePath)) {
|
|
101
|
-
debug(
|
|
101
|
+
debug(
|
|
102
|
+
'Ignoring event "%s" on %s (root: %s)',
|
|
103
|
+
event,
|
|
104
|
+
relativePath,
|
|
105
|
+
this.root,
|
|
106
|
+
);
|
|
102
107
|
return;
|
|
103
108
|
}
|
|
104
|
-
debug(
|
|
109
|
+
debug(
|
|
110
|
+
'Handling event "%s" on %s (root: %s)',
|
|
111
|
+
event,
|
|
112
|
+
relativePath,
|
|
113
|
+
this.root,
|
|
114
|
+
);
|
|
105
115
|
|
|
106
116
|
try {
|
|
107
117
|
const stat = await fsPromises.lstat(absolutePath);
|
|
@@ -116,6 +126,23 @@ export default class NativeWatcher extends AbstractWatcher {
|
|
|
116
126
|
return;
|
|
117
127
|
}
|
|
118
128
|
|
|
129
|
+
// For directory "rename" events, notify that we need a recrawl since we
|
|
130
|
+
// wont' receive events for unmodified files underneath a moved (or
|
|
131
|
+
// cloned) directory. Renames are fired by the OS on moves, clones, and
|
|
132
|
+
// creations. We ignore "change" events because they indiciate a change
|
|
133
|
+
// to directory metadata, rather than its path or existence.
|
|
134
|
+
if (type === 'd' && event === 'rename') {
|
|
135
|
+
debug(
|
|
136
|
+
'Directory rename detected on %s, requesting recrawl',
|
|
137
|
+
relativePath,
|
|
138
|
+
);
|
|
139
|
+
this.emitFileEvent({
|
|
140
|
+
event: RECRAWL_EVENT,
|
|
141
|
+
relativePath,
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
119
146
|
this.emitFileEvent({
|
|
120
147
|
event: TOUCH_EVENT,
|
|
121
148
|
relativePath,
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<dc063c7e351d5c09a5ad65d09b5b6b2a>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/watchers/RecrawlWarning.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
/**
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<b8358b8822835bcef505207f90b02c66>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/watchers/WatchmanWatcher.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
import type {WatcherOptions} from './common';
|
package/src/watchers/common.d.ts
CHANGED
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<ebebfbca9d43e034fde8489e1d9f2dbb>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/watchers/common.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
9
16
|
*/
|
|
10
17
|
|
|
11
18
|
/**
|
|
@@ -22,6 +29,8 @@ export declare const DELETE_EVENT: 'delete';
|
|
|
22
29
|
export declare type DELETE_EVENT = typeof DELETE_EVENT;
|
|
23
30
|
export declare const TOUCH_EVENT: 'touch';
|
|
24
31
|
export declare type TOUCH_EVENT = typeof TOUCH_EVENT;
|
|
32
|
+
export declare const RECRAWL_EVENT: 'recrawl';
|
|
33
|
+
export declare type RECRAWL_EVENT = typeof RECRAWL_EVENT;
|
|
25
34
|
export declare const ALL_EVENT: 'all';
|
|
26
35
|
export declare type ALL_EVENT = typeof ALL_EVENT;
|
|
27
36
|
export type WatcherOptions = Readonly<{
|
package/src/watchers/common.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
|
-
exports.TOUCH_EVENT =
|
|
6
|
+
exports.TOUCH_EVENT =
|
|
7
|
+
exports.RECRAWL_EVENT =
|
|
8
|
+
exports.DELETE_EVENT =
|
|
9
|
+
exports.ALL_EVENT =
|
|
10
|
+
void 0;
|
|
7
11
|
exports.includedByGlob = includedByGlob;
|
|
8
12
|
exports.posixPathMatchesPattern = void 0;
|
|
9
13
|
exports.typeFromStat = typeFromStat;
|
|
@@ -14,6 +18,7 @@ function _interopRequireDefault(e) {
|
|
|
14
18
|
}
|
|
15
19
|
const DELETE_EVENT = (exports.DELETE_EVENT = "delete");
|
|
16
20
|
const TOUCH_EVENT = (exports.TOUCH_EVENT = "touch");
|
|
21
|
+
const RECRAWL_EVENT = (exports.RECRAWL_EVENT = "recrawl");
|
|
17
22
|
const ALL_EVENT = (exports.ALL_EVENT = "all");
|
|
18
23
|
function includedByGlob(type, globs, dot, relativePath) {
|
|
19
24
|
if (globs.length === 0 || type !== "f") {
|