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.
Files changed (70) hide show
  1. package/package.json +4 -3
  2. package/src/Watcher.js +59 -52
  3. package/src/Watcher.js.flow +39 -39
  4. package/src/cache/DiskCacheManager.js.flow +3 -3
  5. package/src/constants.js +9 -8
  6. package/src/constants.js.flow +6 -18
  7. package/src/crawlers/node/index.js +27 -25
  8. package/src/crawlers/node/index.js.flow +6 -8
  9. package/src/crawlers/watchman/index.js +26 -22
  10. package/src/crawlers/watchman/index.js.flow +3 -4
  11. package/src/crawlers/watchman/planQuery.d.ts +24 -0
  12. package/src/crawlers/watchman/planQuery.js.flow +4 -4
  13. package/src/flow-types.js.flow +125 -87
  14. package/src/index.js +267 -235
  15. package/src/index.js.flow +269 -275
  16. package/src/lib/FileProcessor.js +76 -54
  17. package/src/lib/FileProcessor.js.flow +93 -72
  18. package/src/lib/RootPathUtils.js +25 -21
  19. package/src/lib/RootPathUtils.js.flow +4 -4
  20. package/src/lib/TreeFS.js +72 -77
  21. package/src/lib/TreeFS.js.flow +104 -124
  22. package/src/lib/checkWatchmanCapabilities.js.flow +4 -4
  23. package/src/lib/dependencyExtractor.d.ts +14 -0
  24. package/src/lib/normalizePathSeparatorsToPosix.js +25 -21
  25. package/src/lib/normalizePathSeparatorsToPosix.js.flow +3 -3
  26. package/src/lib/normalizePathSeparatorsToSystem.js +25 -21
  27. package/src/lib/normalizePathSeparatorsToSystem.js.flow +3 -3
  28. package/src/lib/rootRelativeCacheKeys.js +0 -20
  29. package/src/lib/rootRelativeCacheKeys.js.flow +1 -23
  30. package/src/plugins/DependencyPlugin.js +75 -0
  31. package/src/plugins/DependencyPlugin.js.flow +144 -0
  32. package/src/plugins/HastePlugin.js +83 -38
  33. package/src/plugins/HastePlugin.js.flow +105 -51
  34. package/src/plugins/MockPlugin.js +7 -4
  35. package/src/plugins/MockPlugin.js.flow +24 -15
  36. package/src/plugins/dependencies/dependencyExtractor.d.ts +14 -0
  37. package/src/{lib → plugins/dependencies}/dependencyExtractor.js.flow +3 -6
  38. package/src/plugins/dependencies/worker.d.ts +24 -0
  39. package/src/plugins/dependencies/worker.js +24 -0
  40. package/src/plugins/dependencies/worker.js.flow +53 -0
  41. package/src/plugins/haste/HasteConflictsError.js.flow +2 -2
  42. package/src/plugins/haste/computeConflicts.js +2 -1
  43. package/src/plugins/haste/computeConflicts.js.flow +11 -12
  44. package/src/plugins/haste/getPlatformExtension.js.flow +2 -2
  45. package/src/plugins/haste/worker.d.ts +24 -0
  46. package/src/plugins/haste/worker.js +35 -0
  47. package/src/plugins/haste/worker.js.flow +64 -0
  48. package/src/plugins/mocks/getMockName.js +27 -23
  49. package/src/plugins/mocks/getMockName.js.flow +2 -4
  50. package/src/watchers/AbstractWatcher.js +27 -22
  51. package/src/watchers/AbstractWatcher.js.flow +6 -5
  52. package/src/watchers/FallbackWatcher.js +88 -84
  53. package/src/watchers/FallbackWatcher.js.flow +65 -65
  54. package/src/watchers/NativeWatcher.js +25 -21
  55. package/src/watchers/NativeWatcher.js.flow +3 -3
  56. package/src/watchers/RecrawlWarning.js.flow +1 -1
  57. package/src/watchers/WatchmanWatcher.js +61 -53
  58. package/src/watchers/WatchmanWatcher.js.flow +39 -38
  59. package/src/watchers/common.js.flow +5 -5
  60. package/src/worker.d.ts +36 -0
  61. package/src/worker.js +16 -58
  62. package/src/worker.js.flow +19 -69
  63. package/src/workerExclusionList.d.ts +12 -0
  64. package/src/workerExclusionList.js.flow +1 -1
  65. package/src/Watcher.d.ts +0 -24
  66. package/src/cache/DiskCacheManager.d.ts +0 -38
  67. package/src/flow-types.d.ts +0 -353
  68. package/src/index.d.ts +0 -97
  69. package/src/lib/DuplicateHasteCandidatesError.d.ts +0 -24
  70. /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: $ReadOnlyArray<string>,
34
- extensions: $ReadOnlyArray<string>,
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: $ReadOnlyArray<string>,
112
- extensions: $ReadOnlyArray<string>,
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 _getRequireWildcardCache(e) {
20
- if ("function" != typeof WeakMap) return null;
21
- var r = new WeakMap(),
22
- t = new WeakMap();
23
- return (_getRequireWildcardCache = function (e) {
24
- return e ? t : r;
25
- })(e);
26
- }
27
- function _interopRequireWildcard(e, r) {
28
- if (!r && e && e.__esModule) return e;
29
- if (null === e || ("object" != typeof e && "function" != typeof e))
30
- return { default: e };
31
- var t = _getRequireWildcardCache(r);
32
- if (t && t.has(e)) return t.get(e);
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
- return ((n.default = e), t && t.set(e, n), n);
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, "", sha1hex ?? null, symlinkInfo, ""];
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
- $ReadOnly<{directoryFilters: Array<string>, watcher: string}>,
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: $ReadOnlyArray<Path>,
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
- }: $ReadOnly<{
24
+ }: Readonly<{
25
25
  since: ?WatchmanQuerySince,
26
- directoryFilters: $ReadOnlyArray<string>,
27
- extensions: $ReadOnlyArray<string>,
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 => (['dirname', dir]: WatchmanDirnameExpression),
103
+ dir => ['dirname', dir] as WatchmanDirnameExpression,
104
104
  ),
105
105
  ]);
106
106
  }
@@ -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 = $ReadOnly<{
19
- computeDependencies: boolean,
18
+ export type BuildParameters = Readonly<{
20
19
  computeSha1: boolean,
21
- enableHastePackages: boolean,
22
20
  enableSymlinks: boolean,
23
- extensions: $ReadOnlyArray<string>,
21
+ extensions: ReadonlyArray<string>,
24
22
  forceNodeFilesystemAPI: boolean,
25
23
  ignorePattern: RegExp,
26
- plugins: $ReadOnlyArray<FileMapPlugin<>>,
24
+ plugins: ReadonlyArray<FileMapPlugin<>>,
27
25
  retainAllFiles: boolean,
28
26
  rootDir: string,
29
- roots: $ReadOnlyArray<string>,
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 = $ReadOnly<{
36
+ export type CacheData = Readonly<{
46
37
  clocks: WatchmanClocks,
47
- fileSystemData: mixed,
48
- plugins: $ReadOnlyMap<string, V8Serializable>,
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 = $ReadOnly<{
77
+ export type CacheManagerFactoryOptions = Readonly<{
87
78
  buildParameters: BuildParameters,
88
79
  }>;
89
80
 
90
- export type CacheManagerWriteOptions = $ReadOnly<{
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: $ReadOnlyArray<string>,
110
+ extensions: ReadonlyArray<string>,
120
111
  forceNodeFilesystemAPI: boolean,
121
112
  ignore: IgnoreMatcher,
122
113
  includeSymlinks: boolean,
123
114
  perfLogger?: ?PerfLogger,
124
- previousState: $ReadOnly<{
125
- clocks: $ReadOnlyMap<CanonicalPath, WatchmanClockSpec>,
115
+ previousState: Readonly<{
116
+ clocks: ReadonlyMap<CanonicalPath, WatchmanClockSpec>,
126
117
  fileSystem: FileSystem,
127
118
  }>,
128
119
  rootDir: string,
129
- roots: $ReadOnlyArray<string>,
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: mixed,
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 = $ReadOnly<{
169
- removed: Iterable<[CanonicalPath, FileMetadata]>,
170
- addedOrModified: Iterable<[CanonicalPath, FileMetadata]>,
159
+ export type FileMapDelta<T = null | void> = Readonly<{
160
+ removed: Iterable<[CanonicalPath, T]>,
161
+ addedOrModified: Iterable<[CanonicalPath, T]>,
171
162
  }>;
172
163
 
173
- interface FileSystemState {
174
- metadataIterator(
175
- opts: $ReadOnly<{
176
- includeNodeModules: boolean,
177
- includeSymlinks: boolean,
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
- ): Iterable<{
180
- baseName: string,
181
- canonicalPath: string,
182
- metadata: FileMetadata,
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 V8Serializable = interface {};
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 interface FileMapPlugin<SerializableState = V8Serializable> {
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, fileMetadata: FileMetadata): void;
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
- DEPENDENCIES: 3,
214
- SHA1: 4,
215
- SYMLINK: 5,
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 = $Values<HType>;
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
- /* id */ string,
258
+ /* plugindata */
259
+ ...
240
260
  ];
241
261
 
242
- export type FileStats = $ReadOnly<{
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: $ReadOnlySet<string>,
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: $ReadOnlySet<string>,
343
- // The real, normal, absolute path of the file or directory.
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: 'd' | 'f',
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
- absolutePath: string,
435
+ normalPath: string,
396
436
  metadata: FileMetadata,
397
- request: $ReadOnly<{computeSha1: boolean}>,
437
+ request: Readonly<{computeSha1: boolean}>,
398
438
  ) => ?Buffer;
399
439
 
400
- export type RawMockMap = $ReadOnly<{
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 = $ReadOnly<{
413
- duplicates: $ReadOnlyMap<string, $ReadOnlySet<string>>,
414
- mocks: $ReadOnlyMap<string, Path>,
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
- | $ReadOnly<{
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
- | $ReadOnly<{
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 = $ReadOnly<{
487
+ export type WatcherBackendOptions = Readonly<{
448
488
  ignored: ?RegExp,
449
- globs: $ReadOnlyArray<string>,
489
+ globs: ReadonlyArray<string>,
450
490
  dot: boolean,
451
491
  ...
452
492
  }>;
453
493
 
454
494
  export type WatchmanClockSpec =
455
495
  | string
456
- | $ReadOnly<{scm: $ReadOnly<{'mergebase-with': string}>}>;
496
+ | Readonly<{scm: Readonly<{'mergebase-with': string}>}>;
457
497
  export type WatchmanClocks = Map<Path, WatchmanClockSpec>;
458
498
 
459
- export type WorkerMessage = $ReadOnly<{
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 = $ReadOnly<{
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 = $ReadOnly<{}>;
512
+ export type WorkerSetupArgs = Readonly<{
513
+ plugins?: ReadonlyArray<FileMapPluginWorker['worker']>,
514
+ }>;