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
@@ -40,19 +40,20 @@ const SUB_PREFIX = 'metro-file-map';
40
40
  * Watches `dir`.
41
41
  */
42
42
  export default class WatchmanWatcher extends AbstractWatcher {
43
- client: Client;
43
+ #client: Client;
44
44
  +subscriptionName: string;
45
- watchProjectInfo: ?$ReadOnly<{
45
+ #watchProjectInfo: ?Readonly<{
46
46
  relativePath: string,
47
47
  root: string,
48
48
  }>;
49
- +watchmanDeferStates: $ReadOnlyArray<string>;
49
+ +#watchmanDeferStates: ReadonlyArray<string>;
50
50
  #deferringStates: ?Set<string> = null;
51
51
 
52
- constructor(dir: string, {watchmanDeferStates, ...opts}: WatcherOptions) {
53
- super(dir, opts);
52
+ constructor(dir: string, opts: WatcherOptions) {
53
+ const {watchmanDeferStates, ...baseOpts} = opts;
54
+ super(dir, baseOpts);
54
55
 
55
- this.watchmanDeferStates = watchmanDeferStates;
56
+ this.#watchmanDeferStates = watchmanDeferStates;
56
57
 
57
58
  // Use a unique subscription name per process per watched directory
58
59
  const watchKey = createHash('md5').update(this.root).digest('hex');
@@ -62,40 +63,40 @@ export default class WatchmanWatcher extends AbstractWatcher {
62
63
  this.subscriptionName = `${SUB_PREFIX}-${process.pid}-${readablePath}-${watchKey}`;
63
64
  }
64
65
 
65
- async startWatching() {
66
- await new Promise((resolve, reject) => this._init(resolve, reject));
66
+ async startWatching(): Promise<void> {
67
+ await new Promise((resolve, reject) => this.#init(resolve, reject));
67
68
  }
68
69
 
69
70
  /**
70
71
  * Run the watchman `watch` command on the root and subscribe to changes.
71
72
  */
72
- _init(onReady: () => void, onError: (error: Error) => void) {
73
- if (this.client) {
74
- this.client.removeAllListeners();
73
+ #init(onReady: () => void, onError: (error: Error) => void) {
74
+ if (this.#client) {
75
+ this.#client.removeAllListeners();
75
76
  }
76
77
 
77
78
  const self = this;
78
- this.client = new watchman.Client();
79
- this.client.on('error', error => {
79
+ this.#client = new watchman.Client();
80
+ this.#client.on('error', error => {
80
81
  this.emitError(error);
81
82
  });
82
- this.client.on('subscription', changeEvent =>
83
- this._handleChangeEvent(changeEvent),
83
+ this.#client.on('subscription', changeEvent =>
84
+ this.#handleChangeEvent(changeEvent),
84
85
  );
85
- this.client.on('end', () => {
86
+ this.#client.on('end', () => {
86
87
  console.warn(
87
88
  '[metro-file-map] Warning: Lost connection to Watchman, reconnecting..',
88
89
  );
89
- self._init(
90
+ self.#init(
90
91
  () => {},
91
92
  error => self.emitError(error),
92
93
  );
93
94
  });
94
95
 
95
- this.watchProjectInfo = null;
96
+ this.#watchProjectInfo = null;
96
97
 
97
98
  function getWatchRoot() {
98
- return self.watchProjectInfo ? self.watchProjectInfo.root : self.root;
99
+ return self.#watchProjectInfo ? self.#watchProjectInfo.root : self.root;
99
100
  }
100
101
 
101
102
  function onWatchProject(error: ?Error, resp: WatchmanWatchResponse) {
@@ -109,14 +110,14 @@ export default class WatchmanWatcher extends AbstractWatcher {
109
110
 
110
111
  // NB: Watchman outputs posix-separated paths even on Windows, convert
111
112
  // them to system-native separators.
112
- self.watchProjectInfo = {
113
+ self.#watchProjectInfo = {
113
114
  relativePath: resp.relative_path
114
115
  ? normalizePathSeparatorsToSystem(resp.relative_path)
115
116
  : '',
116
117
  root: normalizePathSeparatorsToSystem(resp.watch),
117
118
  };
118
119
 
119
- self.client.command(['clock', getWatchRoot()], onClock);
120
+ self.#client.command(['clock', getWatchRoot()], onClock);
120
121
  }
121
122
 
122
123
  function onClock(error: ?Error, resp: WatchmanClockResponse) {
@@ -126,7 +127,7 @@ export default class WatchmanWatcher extends AbstractWatcher {
126
127
  }
127
128
 
128
129
  debug('Received clock response: %s', resp.clock);
129
- const watchProjectInfo = self.watchProjectInfo;
130
+ const watchProjectInfo = self.#watchProjectInfo;
130
131
 
131
132
  invariant(
132
133
  watchProjectInfo != null,
@@ -138,7 +139,7 @@ export default class WatchmanWatcher extends AbstractWatcher {
138
139
  const options: WatchmanQuery = {
139
140
  fields: ['name', 'exists', 'new', 'type', 'size', 'mtime_ms'],
140
141
  since: resp.clock,
141
- defer: self.watchmanDeferStates,
142
+ defer: self.#watchmanDeferStates,
142
143
  relative_root: watchProjectInfo.relativePath,
143
144
  };
144
145
 
@@ -154,7 +155,7 @@ export default class WatchmanWatcher extends AbstractWatcher {
154
155
  ];
155
156
  }
156
157
 
157
- self.client.command(
158
+ self.#client.command(
158
159
  ['subscribe', getWatchRoot(), self.subscriptionName, options],
159
160
  onSubscribe,
160
161
  );
@@ -176,13 +177,13 @@ export default class WatchmanWatcher extends AbstractWatcher {
176
177
  onReady();
177
178
  };
178
179
 
179
- self.client.command(['watch-project', getWatchRoot()], onWatchProject);
180
+ self.#client.command(['watch-project', getWatchRoot()], onWatchProject);
180
181
  }
181
182
 
182
183
  /**
183
184
  * Handles a change event coming from the subscription.
184
185
  */
185
- _handleChangeEvent(resp: WatchmanSubscriptionEvent) {
186
+ #handleChangeEvent(resp: WatchmanSubscriptionEvent) {
186
187
  debug(
187
188
  'Received subscription response: %s (fresh: %s, files: %s, enter: %s, leave: %s, clock: %s)',
188
189
  resp.subscription,
@@ -200,12 +201,12 @@ export default class WatchmanWatcher extends AbstractWatcher {
200
201
  );
201
202
 
202
203
  if (Array.isArray(resp.files)) {
203
- resp.files.forEach(change => this._handleFileChange(change, resp.clock));
204
+ resp.files.forEach(change => this.#handleFileChange(change, resp.clock));
204
205
  }
205
206
  const {'state-enter': stateEnter, 'state-leave': stateLeave} = resp;
206
207
  if (
207
208
  stateEnter != null &&
208
- (this.watchmanDeferStates ?? []).includes(stateEnter)
209
+ (this.#watchmanDeferStates ?? []).includes(stateEnter)
209
210
  ) {
210
211
  this.#deferringStates?.add(stateEnter);
211
212
  debug(
@@ -215,7 +216,7 @@ export default class WatchmanWatcher extends AbstractWatcher {
215
216
  }
216
217
  if (
217
218
  stateLeave != null &&
218
- (this.watchmanDeferStates ?? []).includes(stateLeave)
219
+ (this.#watchmanDeferStates ?? []).includes(stateLeave)
219
220
  ) {
220
221
  this.#deferringStates?.delete(stateLeave);
221
222
  debug(
@@ -228,12 +229,12 @@ export default class WatchmanWatcher extends AbstractWatcher {
228
229
  /**
229
230
  * Handles a single change event record.
230
231
  */
231
- _handleFileChange(
232
+ #handleFileChange(
232
233
  changeDescriptor: WatchmanFileChange,
233
234
  rawClock: WatchmanSubscriptionEvent['clock'],
234
235
  ) {
235
236
  const self = this;
236
- const watchProjectInfo = self.watchProjectInfo;
237
+ const watchProjectInfo = self.#watchProjectInfo;
237
238
 
238
239
  invariant(
239
240
  watchProjectInfo != null,
@@ -274,8 +275,8 @@ export default class WatchmanWatcher extends AbstractWatcher {
274
275
  }
275
276
 
276
277
  const clock =
277
- typeof rawClock === 'string' && this.watchProjectInfo != null
278
- ? ([this.watchProjectInfo.root, rawClock]: [string, string])
278
+ typeof rawClock === 'string' && this.#watchProjectInfo != null
279
+ ? ([this.#watchProjectInfo.root, rawClock] as [string, string])
279
280
  : undefined;
280
281
 
281
282
  if (!exists) {
@@ -313,11 +314,11 @@ export default class WatchmanWatcher extends AbstractWatcher {
313
314
  /**
314
315
  * Closes the watcher.
315
316
  */
316
- async stopWatching() {
317
+ async stopWatching(): Promise<void> {
317
318
  await super.stopWatching();
318
- if (this.client) {
319
- this.client.removeAllListeners();
320
- this.client.end();
319
+ if (this.#client) {
320
+ this.#client.removeAllListeners();
321
+ this.#client.end();
321
322
  }
322
323
  this.#deferringStates = null;
323
324
  }
@@ -340,7 +341,7 @@ export default class WatchmanWatcher extends AbstractWatcher {
340
341
  /**
341
342
  * Handles a warning in the watchman resp object.
342
343
  */
343
- function handleWarning(resp: $ReadOnly<{warning?: mixed, ...}>) {
344
+ function handleWarning(resp: Readonly<{warning?: unknown, ...}>) {
344
345
  if ('warning' in resp) {
345
346
  if (RecrawlWarning.isRecrawlWarningDupe(resp.warning)) {
346
347
  return true;
@@ -28,12 +28,12 @@ export const DELETE_EVENT = 'delete';
28
28
  export const TOUCH_EVENT = 'touch';
29
29
  export const ALL_EVENT = 'all';
30
30
 
31
- export type WatcherOptions = $ReadOnly<{
32
- globs: $ReadOnlyArray<string>,
31
+ export type WatcherOptions = Readonly<{
32
+ globs: ReadonlyArray<string>,
33
33
  dot: boolean,
34
34
  ignored: ?RegExp,
35
- watchmanDeferStates: $ReadOnlyArray<string>,
36
- watchman?: mixed,
35
+ watchmanDeferStates: ReadonlyArray<string>,
36
+ watchman?: unknown,
37
37
  watchmanPath?: string,
38
38
  }>;
39
39
 
@@ -42,7 +42,7 @@ export type WatcherOptions = $ReadOnly<{
42
42
  */
43
43
  export function includedByGlob(
44
44
  type: ?('f' | 'l' | 'd'),
45
- globs: $ReadOnlyArray<string>,
45
+ globs: ReadonlyArray<string>,
46
46
  dot: boolean,
47
47
  relativePath: string,
48
48
  ): boolean {
@@ -0,0 +1,36 @@
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
+ import type {
11
+ WorkerMessage,
12
+ WorkerMetadata,
13
+ WorkerSetupArgs,
14
+ } from './flow-types';
15
+
16
+ declare const worker: {
17
+ /**
18
+ * Called automatically by jest-worker before the first call to `worker` when
19
+ * this module is used as worker thread or child process.
20
+ */
21
+ setup: (args: WorkerSetupArgs) => void;
22
+ /**
23
+ * Called by jest-worker with each workload
24
+ */
25
+ processFile: (data: WorkerMessage) => WorkerMetadata;
26
+ /**
27
+ * Exposed for use outside a jest-worker context, ie when processing in-band.
28
+ */
29
+ Worker: {
30
+ new (setupArgs: WorkerSetupArgs): {
31
+ processFile(data: WorkerMessage): WorkerMetadata;
32
+ };
33
+ };
34
+ };
35
+
36
+ export = worker;
package/src/worker.js CHANGED
@@ -1,87 +1,45 @@
1
1
  "use strict";
2
2
 
3
- const defaultDependencyExtractor = require("./lib/dependencyExtractor");
4
- const excludedExtensions = require("./workerExclusionList");
5
3
  const { createHash } = require("crypto");
6
4
  const fs = require("graceful-fs");
7
- const path = require("path");
8
- const PACKAGE_JSON = path.sep + "package.json";
9
- let hasteImpl = null;
10
- let hasteImplModulePath = null;
11
- function getHasteImpl(requestedModulePath) {
12
- if (hasteImpl) {
13
- if (requestedModulePath !== hasteImplModulePath) {
14
- throw new Error("metro-file-map: hasteImplModulePath changed");
15
- }
16
- return hasteImpl;
17
- }
18
- hasteImplModulePath = requestedModulePath;
19
- hasteImpl = require(hasteImplModulePath);
20
- return hasteImpl;
21
- }
22
5
  function sha1hex(content) {
23
6
  return createHash("sha1").update(content).digest("hex");
24
7
  }
25
8
  class Worker {
26
- constructor(args) {}
9
+ #plugins;
10
+ constructor({ plugins = [] }) {
11
+ this.#plugins = plugins.map(({ modulePath, setupArgs }) => {
12
+ const PluginWorker = require(modulePath);
13
+ return new PluginWorker(setupArgs);
14
+ });
15
+ }
27
16
  processFile(data) {
28
17
  let content;
29
- let dependencies;
30
- let id;
31
18
  let sha1;
32
- const { computeDependencies, computeSha1, enableHastePackages, filePath } =
33
- data;
19
+ const { computeSha1, filePath, pluginsToRun } = data;
34
20
  const getContent = () => {
35
21
  if (content == null) {
36
22
  content = fs.readFileSync(filePath);
37
23
  }
38
24
  return content;
39
25
  };
40
- if (enableHastePackages && filePath.endsWith(PACKAGE_JSON)) {
41
- try {
42
- const fileData = JSON.parse(getContent().toString());
43
- if (fileData.name) {
44
- id = fileData.name;
45
- }
46
- } catch (err) {
47
- throw new Error(`Cannot parse ${filePath} as JSON: ${err.message}`);
48
- }
49
- } else if (
50
- (data.hasteImplModulePath != null || computeDependencies) &&
51
- !excludedExtensions.has(filePath.substr(filePath.lastIndexOf(".")))
52
- ) {
53
- if (data.hasteImplModulePath != null) {
54
- id = getHasteImpl(data.hasteImplModulePath).getHasteName(filePath);
55
- }
56
- if (computeDependencies) {
57
- const dependencyExtractor =
58
- data.dependencyExtractor != null
59
- ? require(data.dependencyExtractor)
60
- : null;
61
- dependencies = Array.from(
62
- dependencyExtractor != null
63
- ? dependencyExtractor.extract(
64
- getContent().toString(),
65
- filePath,
66
- defaultDependencyExtractor.extract,
67
- )
68
- : defaultDependencyExtractor.extract(getContent().toString()),
69
- );
70
- }
71
- }
26
+ const workerUtils = {
27
+ getContent,
28
+ };
29
+ const pluginData = pluginsToRun.map((pluginIdx) =>
30
+ this.#plugins[pluginIdx].processFile(data, workerUtils),
31
+ );
72
32
  if (computeSha1) {
73
33
  sha1 = sha1hex(getContent());
74
34
  }
75
35
  return content && data.maybeReturnContent
76
36
  ? {
77
37
  content,
78
- dependencies,
79
- id,
38
+ pluginData,
80
39
  sha1,
81
40
  }
82
41
  : {
83
- dependencies,
84
- id,
42
+ pluginData,
85
43
  sha1,
86
44
  };
87
45
  }
@@ -12,56 +12,40 @@
12
12
 
13
13
  /*::
14
14
  import type {
15
- DependencyExtractor,
15
+ FileMapPluginWorker,
16
+ MetadataWorker,
16
17
  WorkerMessage,
17
18
  WorkerMetadata,
18
19
  WorkerSetupArgs,
20
+ V8Serializable,
19
21
  } from './flow-types';
20
22
  */
21
23
 
22
24
  'use strict';
23
25
 
24
- const defaultDependencyExtractor = require('./lib/dependencyExtractor');
25
- const excludedExtensions = require('./workerExclusionList');
26
26
  const {createHash} = require('crypto');
27
27
  const fs = require('graceful-fs');
28
- const path = require('path');
29
-
30
- const PACKAGE_JSON = path.sep + 'package.json';
31
-
32
- let hasteImpl /*: ?{getHasteName: string => ?string} */ = null;
33
- let hasteImplModulePath /*: ?string */ = null;
34
-
35
- function getHasteImpl(
36
- requestedModulePath /*: string */,
37
- ) /*: {getHasteName: string => ?string} */ {
38
- if (hasteImpl) {
39
- if (requestedModulePath !== hasteImplModulePath) {
40
- throw new Error('metro-file-map: hasteImplModulePath changed');
41
- }
42
- return hasteImpl;
43
- }
44
- hasteImplModulePath = requestedModulePath;
45
- // $FlowFixMe[unsupported-syntax] - dynamic require
46
- hasteImpl = require(hasteImplModulePath);
47
- return hasteImpl;
48
- }
49
28
 
50
29
  function sha1hex(content /*: string | Buffer */) /*: string */ {
51
30
  return createHash('sha1').update(content).digest('hex');
52
31
  }
53
32
 
54
33
  class Worker {
55
- constructor(args /*: WorkerSetupArgs */) {}
34
+ #plugins /*: ReadonlyArray<MetadataWorker> */;
35
+
36
+ constructor({plugins = []} /*: WorkerSetupArgs */) {
37
+ this.#plugins = plugins.map(({modulePath, setupArgs}) => {
38
+ // $FlowFixMe[unsupported-syntax] - dynamic require
39
+ const PluginWorker = require(modulePath);
40
+ return new PluginWorker(setupArgs);
41
+ });
42
+ }
56
43
 
57
44
  processFile(data /*: WorkerMessage */) /*: WorkerMetadata */ {
58
45
  let content /*: ?Buffer */;
59
- let dependencies /*: WorkerMetadata['dependencies'] */;
60
- let id /*: WorkerMetadata['id'] */;
61
46
  let sha1 /*: WorkerMetadata['sha1'] */;
62
47
 
63
- const {computeDependencies, computeSha1, enableHastePackages, filePath} =
64
- data;
48
+ const {computeSha1, filePath, pluginsToRun} = data;
65
49
 
66
50
  const getContent = () /*: Buffer */ => {
67
51
  if (content == null) {
@@ -71,44 +55,10 @@ class Worker {
71
55
  return content;
72
56
  };
73
57
 
74
- if (enableHastePackages && filePath.endsWith(PACKAGE_JSON)) {
75
- // Process a package.json that is returned as a PACKAGE type with its name.
76
- try {
77
- const fileData = JSON.parse(getContent().toString());
78
-
79
- if (fileData.name) {
80
- id = fileData.name;
81
- }
82
- } catch (err) {
83
- throw new Error(`Cannot parse ${filePath} as JSON: ${err.message}`);
84
- }
85
- } else if (
86
- (data.hasteImplModulePath != null || computeDependencies) &&
87
- !excludedExtensions.has(filePath.substr(filePath.lastIndexOf('.')))
88
- ) {
89
- // Process a random file that is returned as a MODULE.
90
- if (data.hasteImplModulePath != null) {
91
- id = getHasteImpl(data.hasteImplModulePath).getHasteName(filePath);
92
- }
93
-
94
- if (computeDependencies) {
95
- const dependencyExtractor /*: ?DependencyExtractor */ =
96
- data.dependencyExtractor != null
97
- ? // $FlowFixMe[unsupported-syntax] - dynamic require
98
- require(data.dependencyExtractor)
99
- : null;
100
-
101
- dependencies = Array.from(
102
- dependencyExtractor != null
103
- ? dependencyExtractor.extract(
104
- getContent().toString(),
105
- filePath,
106
- defaultDependencyExtractor.extract,
107
- )
108
- : defaultDependencyExtractor.extract(getContent().toString()),
109
- );
110
- }
111
- }
58
+ const workerUtils = {getContent};
59
+ const pluginData = pluginsToRun.map(pluginIdx =>
60
+ this.#plugins[pluginIdx].processFile(data, workerUtils),
61
+ );
112
62
 
113
63
  // If a SHA-1 is requested on update, compute it.
114
64
  if (computeSha1) {
@@ -116,8 +66,8 @@ class Worker {
116
66
  }
117
67
 
118
68
  return content && data.maybeReturnContent
119
- ? {content, dependencies, id, sha1}
120
- : {dependencies, id, sha1};
69
+ ? {content, pluginData, sha1}
70
+ : {pluginData, sha1};
121
71
  }
122
72
  }
123
73
 
@@ -0,0 +1,12 @@
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
+ declare const exclusionList: ReadonlySet<string>;
11
+
12
+ export = exclusionList;
@@ -23,7 +23,7 @@
23
23
 
24
24
  'use strict';
25
25
 
26
- const extensions /*: $ReadOnlySet<string> */ = new Set([
26
+ const extensions /*: ReadonlySet<string> */ = new Set([
27
27
  // JSONs are never haste modules, except for "package.json", which is handled.
28
28
  '.json',
29
29
 
package/src/Watcher.d.ts DELETED
@@ -1,24 +0,0 @@
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
- * @oncall react_native
9
- */
10
-
11
- export type HealthCheckResult =
12
- | {type: 'error'; timeout: number; error: Error; watcher: string | null}
13
- | {
14
- type: 'success';
15
- timeout: number;
16
- timeElapsed: number;
17
- watcher: string | null;
18
- }
19
- | {
20
- type: 'timeout';
21
- timeout: number;
22
- watcher: string | null;
23
- pauseReason: string | null;
24
- };
@@ -1,38 +0,0 @@
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
- * @oncall react_native
9
- */
10
-
11
- import type {
12
- BuildParameters,
13
- CacheData,
14
- CacheManager,
15
- CacheManagerWriteOptions,
16
- } from '../flow-types';
17
-
18
- export interface DiskCacheConfig {
19
- buildParameters: BuildParameters;
20
- cacheFilePrefix?: string | null;
21
- cacheDirectory?: string | null;
22
- }
23
-
24
- export class DiskCacheManager implements CacheManager {
25
- constructor(options: DiskCacheConfig);
26
- static getCacheFilePath(
27
- buildParameters: BuildParameters,
28
- cacheFilePrefix?: string | null,
29
- cacheDirectory?: string | null,
30
- ): string;
31
- getCacheFilePath(): string;
32
- read(): Promise<CacheData | null>;
33
- write(
34
- getSnapshot: () => CacheData,
35
- opts: CacheManagerWriteOptions,
36
- ): Promise<void>;
37
- end(): Promise<void>;
38
- }