metro-file-map 0.83.3 → 0.84.0
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 +4 -3
- package/src/Watcher.js +59 -52
- package/src/Watcher.js.flow +39 -39
- package/src/cache/DiskCacheManager.js.flow +3 -3
- package/src/constants.js +9 -8
- package/src/constants.js.flow +6 -18
- package/src/crawlers/node/index.js +27 -25
- package/src/crawlers/node/index.js.flow +6 -8
- package/src/crawlers/watchman/index.js +26 -22
- package/src/crawlers/watchman/index.js.flow +3 -4
- package/src/crawlers/watchman/planQuery.d.ts +24 -0
- package/src/crawlers/watchman/planQuery.js.flow +4 -4
- package/src/flow-types.js.flow +125 -87
- package/src/index.js +267 -235
- package/src/index.js.flow +269 -275
- package/src/lib/FileProcessor.js +76 -54
- package/src/lib/FileProcessor.js.flow +93 -72
- package/src/lib/RootPathUtils.js +25 -21
- package/src/lib/RootPathUtils.js.flow +4 -4
- package/src/lib/TreeFS.js +72 -77
- package/src/lib/TreeFS.js.flow +104 -124
- package/src/lib/checkWatchmanCapabilities.js.flow +4 -4
- package/src/lib/dependencyExtractor.d.ts +14 -0
- package/src/lib/normalizePathSeparatorsToPosix.js +25 -21
- package/src/lib/normalizePathSeparatorsToPosix.js.flow +3 -3
- package/src/lib/normalizePathSeparatorsToSystem.js +25 -21
- package/src/lib/normalizePathSeparatorsToSystem.js.flow +3 -3
- package/src/lib/rootRelativeCacheKeys.js +0 -20
- package/src/lib/rootRelativeCacheKeys.js.flow +1 -23
- package/src/plugins/DependencyPlugin.js +75 -0
- package/src/plugins/DependencyPlugin.js.flow +144 -0
- package/src/plugins/HastePlugin.js +83 -38
- package/src/plugins/HastePlugin.js.flow +105 -51
- package/src/plugins/MockPlugin.js +7 -4
- package/src/plugins/MockPlugin.js.flow +24 -15
- package/src/plugins/dependencies/dependencyExtractor.d.ts +14 -0
- package/src/{lib → plugins/dependencies}/dependencyExtractor.js.flow +3 -6
- package/src/plugins/dependencies/worker.d.ts +24 -0
- package/src/plugins/dependencies/worker.js +24 -0
- package/src/plugins/dependencies/worker.js.flow +53 -0
- package/src/plugins/haste/HasteConflictsError.js.flow +2 -2
- package/src/plugins/haste/computeConflicts.js +2 -1
- package/src/plugins/haste/computeConflicts.js.flow +11 -12
- package/src/plugins/haste/getPlatformExtension.js.flow +2 -2
- package/src/plugins/haste/worker.d.ts +24 -0
- package/src/plugins/haste/worker.js +35 -0
- package/src/plugins/haste/worker.js.flow +64 -0
- package/src/plugins/mocks/getMockName.js +27 -23
- package/src/plugins/mocks/getMockName.js.flow +2 -4
- package/src/watchers/AbstractWatcher.js +27 -22
- package/src/watchers/AbstractWatcher.js.flow +6 -5
- package/src/watchers/FallbackWatcher.js +88 -84
- package/src/watchers/FallbackWatcher.js.flow +65 -65
- package/src/watchers/NativeWatcher.js +25 -21
- package/src/watchers/NativeWatcher.js.flow +3 -3
- package/src/watchers/RecrawlWarning.js.flow +1 -1
- package/src/watchers/WatchmanWatcher.js +61 -53
- package/src/watchers/WatchmanWatcher.js.flow +39 -38
- package/src/watchers/common.js.flow +5 -5
- package/src/worker.d.ts +36 -0
- package/src/worker.js +16 -58
- package/src/worker.js.flow +19 -69
- package/src/workerExclusionList.d.ts +12 -0
- package/src/workerExclusionList.js.flow +1 -1
- package/src/Watcher.d.ts +0 -24
- package/src/cache/DiskCacheManager.d.ts +0 -38
- package/src/flow-types.d.ts +0 -353
- package/src/index.d.ts +0 -97
- package/src/lib/DuplicateHasteCandidatesError.d.ts +0 -24
- /package/src/{lib → plugins/dependencies}/dependencyExtractor.js +0 -0
|
@@ -30,8 +30,8 @@ const debug = require('debug')('Metro:NodeCrawler');
|
|
|
30
30
|
type Callback = (result: FileData) => void;
|
|
31
31
|
|
|
32
32
|
function find(
|
|
33
|
-
roots:
|
|
34
|
-
extensions:
|
|
33
|
+
roots: ReadonlyArray<string>,
|
|
34
|
+
extensions: ReadonlyArray<string>,
|
|
35
35
|
ignore: IgnoreMatcher,
|
|
36
36
|
includeSymlinks: boolean,
|
|
37
37
|
rootDir: string,
|
|
@@ -79,10 +79,9 @@ function find(
|
|
|
79
79
|
stat.mtime.getTime(),
|
|
80
80
|
stat.size,
|
|
81
81
|
0,
|
|
82
|
-
'',
|
|
83
82
|
null,
|
|
84
83
|
stat.isSymbolicLink() ? 1 : 0,
|
|
85
|
-
|
|
84
|
+
null,
|
|
86
85
|
]);
|
|
87
86
|
}
|
|
88
87
|
}
|
|
@@ -108,8 +107,8 @@ function find(
|
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
function findNative(
|
|
111
|
-
roots:
|
|
112
|
-
extensions:
|
|
110
|
+
roots: ReadonlyArray<string>,
|
|
111
|
+
extensions: ReadonlyArray<string>,
|
|
113
112
|
ignore: IgnoreMatcher,
|
|
114
113
|
includeSymlinks: boolean,
|
|
115
114
|
rootDir: string,
|
|
@@ -157,10 +156,9 @@ function findNative(
|
|
|
157
156
|
stat.mtime.getTime(),
|
|
158
157
|
stat.size,
|
|
159
158
|
0,
|
|
160
|
-
'',
|
|
161
159
|
null,
|
|
162
160
|
stat.isSymbolicLink() ? 1 : 0,
|
|
163
|
-
|
|
161
|
+
null,
|
|
164
162
|
]);
|
|
165
163
|
}
|
|
166
164
|
if (--count === 0) {
|
|
@@ -16,28 +16,32 @@ var _fbWatchman = _interopRequireDefault(require("fb-watchman"));
|
|
|
16
16
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
17
17
|
var path = _interopRequireWildcard(require("path"));
|
|
18
18
|
var _perf_hooks = require("perf_hooks");
|
|
19
|
-
function
|
|
20
|
-
if ("function"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var n = { __proto__: null },
|
|
34
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
35
|
-
for (var u in e)
|
|
36
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
37
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
38
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
19
|
+
function _interopRequireWildcard(e, t) {
|
|
20
|
+
if ("function" == typeof WeakMap)
|
|
21
|
+
var r = new WeakMap(),
|
|
22
|
+
n = new WeakMap();
|
|
23
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
24
|
+
if (!t && e && e.__esModule) return e;
|
|
25
|
+
var o,
|
|
26
|
+
i,
|
|
27
|
+
f = { __proto__: null, default: e };
|
|
28
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
29
|
+
return f;
|
|
30
|
+
if ((o = t ? n : r)) {
|
|
31
|
+
if (o.has(e)) return o.get(e);
|
|
32
|
+
o.set(e, f);
|
|
39
33
|
}
|
|
40
|
-
|
|
34
|
+
for (const t in e)
|
|
35
|
+
"default" !== t &&
|
|
36
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
37
|
+
((i =
|
|
38
|
+
(o = Object.defineProperty) &&
|
|
39
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
40
|
+
(i.get || i.set)
|
|
41
|
+
? o(f, t, i)
|
|
42
|
+
: (f[t] = e[t]));
|
|
43
|
+
return f;
|
|
44
|
+
})(e, t);
|
|
41
45
|
}
|
|
42
46
|
function _interopRequireDefault(e) {
|
|
43
47
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -272,7 +276,7 @@ async function watchmanCrawl({
|
|
|
272
276
|
if (fileData.type === "l") {
|
|
273
277
|
symlinkInfo = fileData["symlink_target"] ?? 1;
|
|
274
278
|
}
|
|
275
|
-
const nextData = [mtime, size, 0,
|
|
279
|
+
const nextData = [mtime, size, 0, sha1hex ?? null, symlinkInfo, null];
|
|
276
280
|
if (isFresh) {
|
|
277
281
|
freshFileData.set(relativeFilePath, nextData);
|
|
278
282
|
} else {
|
|
@@ -31,7 +31,7 @@ import {performance} from 'perf_hooks';
|
|
|
31
31
|
|
|
32
32
|
type WatchmanRoots = Map<
|
|
33
33
|
string, // Posix-separated absolute path
|
|
34
|
-
|
|
34
|
+
Readonly<{directoryFilters: Array<string>, watcher: string}>,
|
|
35
35
|
>;
|
|
36
36
|
|
|
37
37
|
const WATCHMAN_WARNING_INITIAL_DELAY_MILLISECONDS = 10000;
|
|
@@ -132,7 +132,7 @@ export default async function watchmanCrawl({
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
async function getWatchmanRoots(
|
|
135
|
-
roots:
|
|
135
|
+
roots: ReadonlyArray<Path>,
|
|
136
136
|
): Promise<WatchmanRoots> {
|
|
137
137
|
perfLogger?.point('watchmanCrawl/getWatchmanRoots_start');
|
|
138
138
|
const watchmanRoots: WatchmanRoots = new Map();
|
|
@@ -336,10 +336,9 @@ export default async function watchmanCrawl({
|
|
|
336
336
|
mtime,
|
|
337
337
|
size,
|
|
338
338
|
0,
|
|
339
|
-
'',
|
|
340
339
|
sha1hex ?? null,
|
|
341
340
|
symlinkInfo,
|
|
342
|
-
|
|
341
|
+
null,
|
|
343
342
|
];
|
|
344
343
|
|
|
345
344
|
// If watchman is fresh, the removed files map starts with all files
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type WatchmanQuery = {[key: string]: unknown};
|
|
11
|
+
type WatchmanQuerySince = unknown;
|
|
12
|
+
|
|
13
|
+
export declare function planQuery(
|
|
14
|
+
args: Readonly<{
|
|
15
|
+
since: WatchmanQuerySince;
|
|
16
|
+
directoryFilters: ReadonlyArray<string>;
|
|
17
|
+
extensions: ReadonlyArray<string>;
|
|
18
|
+
includeSha1: boolean;
|
|
19
|
+
includeSymlinks: boolean;
|
|
20
|
+
}>,
|
|
21
|
+
): {
|
|
22
|
+
query: WatchmanQuery;
|
|
23
|
+
queryGenerator: string;
|
|
24
|
+
};
|
|
@@ -21,10 +21,10 @@ export function planQuery({
|
|
|
21
21
|
extensions,
|
|
22
22
|
includeSha1,
|
|
23
23
|
includeSymlinks,
|
|
24
|
-
}:
|
|
24
|
+
}: Readonly<{
|
|
25
25
|
since: ?WatchmanQuerySince,
|
|
26
|
-
directoryFilters:
|
|
27
|
-
extensions:
|
|
26
|
+
directoryFilters: ReadonlyArray<string>,
|
|
27
|
+
extensions: ReadonlyArray<string>,
|
|
28
28
|
includeSha1: boolean,
|
|
29
29
|
includeSymlinks: boolean,
|
|
30
30
|
}>): {
|
|
@@ -100,7 +100,7 @@ export function planQuery({
|
|
|
100
100
|
allOfTerms.push([
|
|
101
101
|
'anyof',
|
|
102
102
|
...directoryFilters.map(
|
|
103
|
-
dir =>
|
|
103
|
+
dir => ['dirname', dir] as WatchmanDirnameExpression,
|
|
104
104
|
),
|
|
105
105
|
]);
|
|
106
106
|
}
|
package/src/flow-types.js.flow
CHANGED
|
@@ -15,37 +15,28 @@ export type {PerfLoggerFactory, PerfLogger};
|
|
|
15
15
|
|
|
16
16
|
// These inputs affect the internal data collected for a given filesystem
|
|
17
17
|
// state, and changes may invalidate a cache.
|
|
18
|
-
export type BuildParameters =
|
|
19
|
-
computeDependencies: boolean,
|
|
18
|
+
export type BuildParameters = Readonly<{
|
|
20
19
|
computeSha1: boolean,
|
|
21
|
-
enableHastePackages: boolean,
|
|
22
20
|
enableSymlinks: boolean,
|
|
23
|
-
extensions:
|
|
21
|
+
extensions: ReadonlyArray<string>,
|
|
24
22
|
forceNodeFilesystemAPI: boolean,
|
|
25
23
|
ignorePattern: RegExp,
|
|
26
|
-
plugins:
|
|
24
|
+
plugins: ReadonlyArray<FileMapPlugin<>>,
|
|
27
25
|
retainAllFiles: boolean,
|
|
28
26
|
rootDir: string,
|
|
29
|
-
roots:
|
|
30
|
-
skipPackageJson: boolean,
|
|
31
|
-
|
|
32
|
-
// Module paths that should export a 'getCacheKey' method
|
|
33
|
-
dependencyExtractor: ?string,
|
|
34
|
-
hasteImplModulePath: ?string,
|
|
27
|
+
roots: ReadonlyArray<string>,
|
|
35
28
|
|
|
36
29
|
cacheBreaker: string,
|
|
37
30
|
}>;
|
|
38
31
|
|
|
39
32
|
export type BuildResult = {
|
|
40
33
|
fileSystem: FileSystem,
|
|
41
|
-
hasteMap: HasteMap,
|
|
42
|
-
mockMap: ?MockMap,
|
|
43
34
|
};
|
|
44
35
|
|
|
45
|
-
export type CacheData =
|
|
36
|
+
export type CacheData = Readonly<{
|
|
46
37
|
clocks: WatchmanClocks,
|
|
47
|
-
fileSystemData:
|
|
48
|
-
plugins:
|
|
38
|
+
fileSystemData: unknown,
|
|
39
|
+
plugins: ReadonlyMap<string, void | V8Serializable>,
|
|
49
40
|
}>;
|
|
50
41
|
|
|
51
42
|
export interface CacheManager {
|
|
@@ -83,14 +74,14 @@ export type CacheManagerFactory = (
|
|
|
83
74
|
options: CacheManagerFactoryOptions,
|
|
84
75
|
) => CacheManager;
|
|
85
76
|
|
|
86
|
-
export type CacheManagerFactoryOptions =
|
|
77
|
+
export type CacheManagerFactoryOptions = Readonly<{
|
|
87
78
|
buildParameters: BuildParameters,
|
|
88
79
|
}>;
|
|
89
80
|
|
|
90
|
-
export type CacheManagerWriteOptions =
|
|
81
|
+
export type CacheManagerWriteOptions = Readonly<{
|
|
91
82
|
changedSinceCacheRead: boolean,
|
|
92
83
|
eventSource: CacheManagerEventSource,
|
|
93
|
-
onWriteError: Error => void,
|
|
84
|
+
onWriteError: (error: Error) => void,
|
|
94
85
|
}>;
|
|
95
86
|
|
|
96
87
|
// A path that is
|
|
@@ -116,17 +107,17 @@ export type CrawlerOptions = {
|
|
|
116
107
|
abortSignal: ?AbortSignal,
|
|
117
108
|
computeSha1: boolean,
|
|
118
109
|
console: Console,
|
|
119
|
-
extensions:
|
|
110
|
+
extensions: ReadonlyArray<string>,
|
|
120
111
|
forceNodeFilesystemAPI: boolean,
|
|
121
112
|
ignore: IgnoreMatcher,
|
|
122
113
|
includeSymlinks: boolean,
|
|
123
114
|
perfLogger?: ?PerfLogger,
|
|
124
|
-
previousState:
|
|
125
|
-
clocks:
|
|
115
|
+
previousState: Readonly<{
|
|
116
|
+
clocks: ReadonlyMap<CanonicalPath, WatchmanClockSpec>,
|
|
126
117
|
fileSystem: FileSystem,
|
|
127
118
|
}>,
|
|
128
119
|
rootDir: string,
|
|
129
|
-
roots:
|
|
120
|
+
roots: ReadonlyArray<string>,
|
|
130
121
|
onStatus: (status: WatcherStatus) => void,
|
|
131
122
|
};
|
|
132
123
|
|
|
@@ -152,7 +143,7 @@ export type WatcherStatus =
|
|
|
152
143
|
}
|
|
153
144
|
| {
|
|
154
145
|
type: 'watchman_warning',
|
|
155
|
-
warning:
|
|
146
|
+
warning: unknown,
|
|
156
147
|
command: 'watch-project' | 'query',
|
|
157
148
|
};
|
|
158
149
|
|
|
@@ -165,65 +156,94 @@ export type EventsQueue = Array<{
|
|
|
165
156
|
type: string,
|
|
166
157
|
}>;
|
|
167
158
|
|
|
168
|
-
export type FileMapDelta =
|
|
169
|
-
removed: Iterable<[CanonicalPath,
|
|
170
|
-
addedOrModified: Iterable<[CanonicalPath,
|
|
159
|
+
export type FileMapDelta<T = null | void> = Readonly<{
|
|
160
|
+
removed: Iterable<[CanonicalPath, T]>,
|
|
161
|
+
addedOrModified: Iterable<[CanonicalPath, T]>,
|
|
171
162
|
}>;
|
|
172
163
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
164
|
+
export type FileMapPluginInitOptions<
|
|
165
|
+
SerializableState,
|
|
166
|
+
PerFileData = void,
|
|
167
|
+
> = Readonly<{
|
|
168
|
+
files: Readonly<{
|
|
169
|
+
fileIterator(
|
|
170
|
+
opts: Readonly<{
|
|
171
|
+
includeNodeModules: boolean,
|
|
172
|
+
includeSymlinks: boolean,
|
|
173
|
+
}>,
|
|
174
|
+
): Iterable<{
|
|
175
|
+
baseName: string,
|
|
176
|
+
canonicalPath: string,
|
|
177
|
+
pluginData: ?PerFileData,
|
|
178
178
|
}>,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export type FileMapPluginInitOptions<SerializableState> = $ReadOnly<{
|
|
187
|
-
files: FileSystemState,
|
|
179
|
+
lookup(
|
|
180
|
+
mixedPath: string,
|
|
181
|
+
):
|
|
182
|
+
| {exists: false}
|
|
183
|
+
| {exists: true, type: 'f', pluginData: PerFileData}
|
|
184
|
+
| {exists: true, type: 'd'},
|
|
185
|
+
}>,
|
|
188
186
|
pluginState: ?SerializableState,
|
|
189
187
|
}>;
|
|
190
188
|
|
|
191
|
-
type
|
|
189
|
+
export type FileMapPluginWorker = Readonly<{
|
|
190
|
+
worker: Readonly<{
|
|
191
|
+
modulePath: string,
|
|
192
|
+
setupArgs: JsonData,
|
|
193
|
+
}>,
|
|
194
|
+
filter: ({normalPath: string, isNodeModules: boolean}) => boolean,
|
|
195
|
+
}>;
|
|
192
196
|
|
|
193
|
-
export
|
|
197
|
+
export type V8Serializable =
|
|
198
|
+
| string
|
|
199
|
+
| number
|
|
200
|
+
| boolean
|
|
201
|
+
| null
|
|
202
|
+
| ReadonlyArray<V8Serializable>
|
|
203
|
+
| ReadonlySet<V8Serializable>
|
|
204
|
+
| ReadonlyMap<string, V8Serializable>
|
|
205
|
+
| Readonly<{[key: string]: V8Serializable}>;
|
|
206
|
+
|
|
207
|
+
export interface FileMapPlugin<
|
|
208
|
+
SerializableState: void | V8Serializable = void | V8Serializable,
|
|
209
|
+
PerFileData: void | V8Serializable = void | V8Serializable,
|
|
210
|
+
> {
|
|
194
211
|
+name: string;
|
|
195
212
|
initialize(
|
|
196
|
-
initOptions: FileMapPluginInitOptions<SerializableState>,
|
|
213
|
+
initOptions: FileMapPluginInitOptions<SerializableState, PerFileData>,
|
|
197
214
|
): Promise<void>;
|
|
198
215
|
assertValid(): void;
|
|
199
|
-
bulkUpdate(delta: FileMapDelta): Promise<void>;
|
|
216
|
+
bulkUpdate(delta: FileMapDelta<?PerFileData>): Promise<void>;
|
|
200
217
|
getSerializableSnapshot(): SerializableState;
|
|
201
|
-
onRemovedFile(relativeFilePath: string,
|
|
202
|
-
onNewOrModifiedFile(
|
|
203
|
-
relativeFilePath: string,
|
|
204
|
-
fileMetadata: FileMetadata,
|
|
205
|
-
): void;
|
|
218
|
+
onRemovedFile(relativeFilePath: string, pluginData: ?PerFileData): void;
|
|
219
|
+
onNewOrModifiedFile(relativeFilePath: string, pluginData: ?PerFileData): void;
|
|
206
220
|
getCacheKey(): string;
|
|
221
|
+
getWorker(): ?FileMapPluginWorker;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface MetadataWorker {
|
|
225
|
+
processFile(
|
|
226
|
+
WorkerMessage,
|
|
227
|
+
Readonly<{getContent: () => Buffer}>,
|
|
228
|
+
): V8Serializable;
|
|
207
229
|
}
|
|
208
230
|
|
|
209
231
|
export type HType = {
|
|
210
232
|
MTIME: 0,
|
|
211
233
|
SIZE: 1,
|
|
212
234
|
VISITED: 2,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
ID: 6,
|
|
235
|
+
SHA1: 3,
|
|
236
|
+
SYMLINK: 4,
|
|
237
|
+
PLUGINDATA: number,
|
|
217
238
|
PATH: 0,
|
|
218
239
|
TYPE: 1,
|
|
219
240
|
MODULE: 0,
|
|
220
241
|
PACKAGE: 1,
|
|
221
242
|
GENERIC_PLATFORM: 'g',
|
|
222
243
|
NATIVE_PLATFORM: 'native',
|
|
223
|
-
DEPENDENCY_DELIM: '\0',
|
|
224
244
|
};
|
|
225
245
|
|
|
226
|
-
export type HTypeValue =
|
|
246
|
+
export type HTypeValue = Values<HType>;
|
|
227
247
|
|
|
228
248
|
export type IgnoreMatcher = (item: string) => boolean;
|
|
229
249
|
|
|
@@ -233,13 +253,13 @@ export type FileMetadata = [
|
|
|
233
253
|
/* mtime */ ?number,
|
|
234
254
|
/* size */ number,
|
|
235
255
|
/* visited */ 0 | 1,
|
|
236
|
-
/* dependencies */ string,
|
|
237
256
|
/* sha1 */ ?string,
|
|
238
257
|
/* symlink */ 0 | 1 | string, // string specifies target, if known
|
|
239
|
-
/*
|
|
258
|
+
/* plugindata */
|
|
259
|
+
...
|
|
240
260
|
];
|
|
241
261
|
|
|
242
|
-
export type FileStats =
|
|
262
|
+
export type FileStats = Readonly<{
|
|
243
263
|
fileType: 'f' | 'l',
|
|
244
264
|
modifiedTime: ?number,
|
|
245
265
|
size: ?number,
|
|
@@ -248,12 +268,10 @@ export type FileStats = $ReadOnly<{
|
|
|
248
268
|
export interface FileSystem {
|
|
249
269
|
exists(file: Path): boolean;
|
|
250
270
|
getAllFiles(): Array<Path>;
|
|
251
|
-
getDependencies(file: Path): ?Array<string>;
|
|
252
271
|
getDifference(files: FileData): {
|
|
253
272
|
changedFiles: FileData,
|
|
254
273
|
removedFiles: Set<string>,
|
|
255
274
|
};
|
|
256
|
-
getModuleName(file: Path): ?string;
|
|
257
275
|
getSerializableSnapshot(): CacheData['fileSystemData'];
|
|
258
276
|
getSha1(file: Path): ?string;
|
|
259
277
|
getOrComputeSha1(file: Path): Promise<?{sha1: string, content?: Buffer}>;
|
|
@@ -324,6 +342,14 @@ export interface FileSystem {
|
|
|
324
342
|
|
|
325
343
|
export type Glob = string;
|
|
326
344
|
|
|
345
|
+
export type JsonData =
|
|
346
|
+
| string
|
|
347
|
+
| number
|
|
348
|
+
| boolean
|
|
349
|
+
| null
|
|
350
|
+
| Array<JsonData>
|
|
351
|
+
| {[key: string]: JsonData};
|
|
352
|
+
|
|
327
353
|
export type LookupResult =
|
|
328
354
|
| {
|
|
329
355
|
// The node is missing from the FileSystem implementation (note this
|
|
@@ -331,7 +357,7 @@ export type LookupResult =
|
|
|
331
357
|
// files).
|
|
332
358
|
exists: false,
|
|
333
359
|
// The real, normal, absolute paths of any symlinks traversed.
|
|
334
|
-
links:
|
|
360
|
+
links: ReadonlySet<string>,
|
|
335
361
|
// The real, normal, absolute path of the first path segment
|
|
336
362
|
// encountered that does not exist, or cannot be navigated through.
|
|
337
363
|
missing: string,
|
|
@@ -339,12 +365,24 @@ export type LookupResult =
|
|
|
339
365
|
| {
|
|
340
366
|
exists: true,
|
|
341
367
|
// The real, normal, absolute paths of any symlinks traversed.
|
|
342
|
-
links:
|
|
343
|
-
// The real, normal, absolute path of the
|
|
368
|
+
links: ReadonlySet<string>,
|
|
369
|
+
// The real, normal, absolute path of the directory.
|
|
370
|
+
realPath: string,
|
|
371
|
+
// Currently lookup always follows symlinks, so can only return
|
|
372
|
+
// directories or regular files, but this may be extended.
|
|
373
|
+
type: 'd',
|
|
374
|
+
}
|
|
375
|
+
| {
|
|
376
|
+
exists: true,
|
|
377
|
+
// The real, normal, absolute paths of any symlinks traversed.
|
|
378
|
+
links: ReadonlySet<string>,
|
|
379
|
+
// The real, normal, absolute path of the file.
|
|
344
380
|
realPath: string,
|
|
345
381
|
// Currently lookup always follows symlinks, so can only return
|
|
346
382
|
// directories or regular files, but this may be extended.
|
|
347
|
-
type: '
|
|
383
|
+
type: 'f',
|
|
384
|
+
// The file's metadata tuple. Must only be mutated via FileProcessor.
|
|
385
|
+
metadata: FileMetadata,
|
|
348
386
|
};
|
|
349
387
|
|
|
350
388
|
export interface MockMap {
|
|
@@ -366,6 +404,8 @@ export interface HasteMap {
|
|
|
366
404
|
type?: ?HTypeValue,
|
|
367
405
|
): ?Path;
|
|
368
406
|
|
|
407
|
+
getModuleNameByPath(file: Path): ?string;
|
|
408
|
+
|
|
369
409
|
getPackage(
|
|
370
410
|
name: string,
|
|
371
411
|
platform: ?string,
|
|
@@ -392,12 +432,12 @@ export interface MutableFileSystem extends FileSystem {
|
|
|
392
432
|
export type Path = string;
|
|
393
433
|
|
|
394
434
|
export type ProcessFileFunction = (
|
|
395
|
-
|
|
435
|
+
normalPath: string,
|
|
396
436
|
metadata: FileMetadata,
|
|
397
|
-
request:
|
|
437
|
+
request: Readonly<{computeSha1: boolean}>,
|
|
398
438
|
) => ?Buffer;
|
|
399
439
|
|
|
400
|
-
export type RawMockMap =
|
|
440
|
+
export type RawMockMap = Readonly<{
|
|
401
441
|
duplicates: Map<
|
|
402
442
|
string, // posix-separated mock name
|
|
403
443
|
Set<string>, // posix-separated, project-relative paths
|
|
@@ -409,16 +449,16 @@ export type RawMockMap = $ReadOnly<{
|
|
|
409
449
|
version: number,
|
|
410
450
|
}>;
|
|
411
451
|
|
|
412
|
-
export type ReadOnlyRawMockMap =
|
|
413
|
-
duplicates:
|
|
414
|
-
mocks:
|
|
452
|
+
export type ReadOnlyRawMockMap = Readonly<{
|
|
453
|
+
duplicates: ReadonlyMap<string, ReadonlySet<string>>,
|
|
454
|
+
mocks: ReadonlyMap<string, Path>,
|
|
415
455
|
version: number,
|
|
416
456
|
}>;
|
|
417
457
|
|
|
418
458
|
export interface WatcherBackend {
|
|
419
459
|
getPauseReason(): ?string;
|
|
420
|
-
onError((error: Error) => void): () => void;
|
|
421
|
-
onFileEvent((event: WatcherBackendChangeEvent) => void): () => void;
|
|
460
|
+
onError(listener: (error: Error) => void): () => void;
|
|
461
|
+
onFileEvent(listener: (event: WatcherBackendChangeEvent) => void): () => void;
|
|
422
462
|
startWatching(): Promise<void>;
|
|
423
463
|
stopWatching(): Promise<void>;
|
|
424
464
|
}
|
|
@@ -429,14 +469,14 @@ export type ChangeEventClock = [
|
|
|
429
469
|
];
|
|
430
470
|
|
|
431
471
|
export type WatcherBackendChangeEvent =
|
|
432
|
-
|
|
|
472
|
+
| Readonly<{
|
|
433
473
|
event: 'touch',
|
|
434
474
|
clock?: ChangeEventClock,
|
|
435
475
|
relativePath: string,
|
|
436
476
|
root: string,
|
|
437
477
|
metadata: ChangeEventMetadata,
|
|
438
478
|
}>
|
|
439
|
-
|
|
|
479
|
+
| Readonly<{
|
|
440
480
|
event: 'delete',
|
|
441
481
|
clock?: ChangeEventClock,
|
|
442
482
|
relativePath: string,
|
|
@@ -444,33 +484,31 @@ export type WatcherBackendChangeEvent =
|
|
|
444
484
|
metadata?: void,
|
|
445
485
|
}>;
|
|
446
486
|
|
|
447
|
-
export type WatcherBackendOptions =
|
|
487
|
+
export type WatcherBackendOptions = Readonly<{
|
|
448
488
|
ignored: ?RegExp,
|
|
449
|
-
globs:
|
|
489
|
+
globs: ReadonlyArray<string>,
|
|
450
490
|
dot: boolean,
|
|
451
491
|
...
|
|
452
492
|
}>;
|
|
453
493
|
|
|
454
494
|
export type WatchmanClockSpec =
|
|
455
495
|
| string
|
|
456
|
-
|
|
|
496
|
+
| Readonly<{scm: Readonly<{'mergebase-with': string}>}>;
|
|
457
497
|
export type WatchmanClocks = Map<Path, WatchmanClockSpec>;
|
|
458
498
|
|
|
459
|
-
export type WorkerMessage =
|
|
460
|
-
computeDependencies: boolean,
|
|
499
|
+
export type WorkerMessage = Readonly<{
|
|
461
500
|
computeSha1: boolean,
|
|
462
|
-
dependencyExtractor?: ?string,
|
|
463
|
-
enableHastePackages: boolean,
|
|
464
501
|
filePath: string,
|
|
465
|
-
hasteImplModulePath?: ?string,
|
|
466
502
|
maybeReturnContent: boolean,
|
|
503
|
+
pluginsToRun: ReadonlyArray<number>,
|
|
467
504
|
}>;
|
|
468
505
|
|
|
469
|
-
export type WorkerMetadata =
|
|
470
|
-
dependencies?: ?$ReadOnlyArray<string>,
|
|
471
|
-
id?: ?string,
|
|
506
|
+
export type WorkerMetadata = Readonly<{
|
|
472
507
|
sha1?: ?string,
|
|
473
508
|
content?: ?Buffer,
|
|
509
|
+
pluginData?: ReadonlyArray<V8Serializable>,
|
|
474
510
|
}>;
|
|
475
511
|
|
|
476
|
-
export type WorkerSetupArgs =
|
|
512
|
+
export type WorkerSetupArgs = Readonly<{
|
|
513
|
+
plugins?: ReadonlyArray<FileMapPluginWorker['worker']>,
|
|
514
|
+
}>;
|