metro-file-map 0.83.4 → 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.
Files changed (70) hide show
  1. package/package.json +3 -2
  2. package/src/Watcher.d.ts +74 -0
  3. package/src/Watcher.js +68 -48
  4. package/src/Watcher.js.flow +84 -51
  5. package/src/cache/DiskCacheManager.d.ts +49 -0
  6. package/src/cache/DiskCacheManager.js +1 -5
  7. package/src/constants.d.ts +22 -0
  8. package/src/crawlers/node/hasNativeFindSupport.d.ts +19 -0
  9. package/src/crawlers/node/index.d.ts +21 -0
  10. package/src/crawlers/node/index.js +6 -10
  11. package/src/crawlers/node/index.js.flow +8 -6
  12. package/src/crawlers/watchman/index.d.ts +23 -0
  13. package/src/crawlers/watchman/index.js +2 -9
  14. package/src/crawlers/watchman/index.js.flow +2 -6
  15. package/src/flow-types.d.ts +460 -0
  16. package/src/flow-types.js.flow +89 -29
  17. package/src/index.d.ts +182 -0
  18. package/src/index.js +148 -132
  19. package/src/index.js.flow +200 -155
  20. package/src/lib/FileProcessor.d.ts +60 -0
  21. package/src/lib/FileProcessor.js +1 -5
  22. package/src/lib/FileSystemChangeAggregator.d.ts +40 -0
  23. package/src/lib/FileSystemChangeAggregator.js +89 -0
  24. package/src/lib/FileSystemChangeAggregator.js.flow +143 -0
  25. package/src/lib/RootPathUtils.d.ts +30 -0
  26. package/src/lib/RootPathUtils.js +2 -9
  27. package/src/lib/TreeFS.d.ts +174 -0
  28. package/src/lib/TreeFS.js +68 -21
  29. package/src/lib/TreeFS.js.flow +89 -16
  30. package/src/lib/checkWatchmanCapabilities.d.ts +20 -0
  31. package/src/lib/normalizePathSeparatorsToPosix.d.ts +20 -0
  32. package/src/lib/normalizePathSeparatorsToPosix.js +1 -4
  33. package/src/lib/normalizePathSeparatorsToSystem.d.ts +20 -0
  34. package/src/lib/normalizePathSeparatorsToSystem.js +1 -4
  35. package/src/lib/rootRelativeCacheKeys.d.ts +24 -0
  36. package/src/lib/rootRelativeCacheKeys.js +1 -5
  37. package/src/lib/sorting.d.ts +23 -0
  38. package/src/plugins/DependencyPlugin.d.ts +52 -0
  39. package/src/plugins/DependencyPlugin.js +1 -3
  40. package/src/plugins/DependencyPlugin.js.flow +1 -16
  41. package/src/plugins/HastePlugin.d.ts +69 -0
  42. package/src/plugins/HastePlugin.js +12 -16
  43. package/src/plugins/HastePlugin.js.flow +12 -12
  44. package/src/plugins/MockPlugin.d.ts +48 -0
  45. package/src/plugins/MockPlugin.js +18 -25
  46. package/src/plugins/MockPlugin.js.flow +18 -22
  47. package/src/plugins/dependencies/dependencyExtractor.d.ts +1 -1
  48. package/src/plugins/haste/DuplicateHasteCandidatesError.d.ts +31 -0
  49. package/src/plugins/haste/DuplicateHasteCandidatesError.js +1 -5
  50. package/src/plugins/haste/HasteConflictsError.d.ts +23 -0
  51. package/src/plugins/haste/HasteConflictsError.js +1 -5
  52. package/src/plugins/haste/computeConflicts.d.ts +34 -0
  53. package/src/plugins/haste/computeConflicts.js +1 -5
  54. package/src/plugins/haste/getPlatformExtension.d.ts +21 -0
  55. package/src/plugins/mocks/getMockName.d.ts +20 -0
  56. package/src/plugins/mocks/getMockName.js +1 -4
  57. package/src/watchers/AbstractWatcher.d.ts +41 -0
  58. package/src/watchers/AbstractWatcher.js +2 -9
  59. package/src/watchers/FallbackWatcher.d.ts +28 -0
  60. package/src/watchers/FallbackWatcher.js +21 -12
  61. package/src/watchers/FallbackWatcher.js.flow +28 -5
  62. package/src/watchers/NativeWatcher.d.ts +55 -0
  63. package/src/watchers/NativeWatcher.js +28 -9
  64. package/src/watchers/NativeWatcher.js.flow +33 -6
  65. package/src/watchers/RecrawlWarning.d.ts +32 -0
  66. package/src/watchers/WatchmanWatcher.d.ts +34 -0
  67. package/src/watchers/WatchmanWatcher.js +2 -9
  68. package/src/watchers/common.d.ts +70 -0
  69. package/src/watchers/common.js +7 -6
  70. package/src/watchers/common.js.flow +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro-file-map",
3
- "version": "0.83.4",
3
+ "version": "0.83.6",
4
4
  "description": "[Experimental] - 🚇 File crawling, watching and mapping for Metro",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -10,7 +10,8 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git@github.com:facebook/metro.git"
13
+ "url": "git+https://github.com/facebook/metro.git",
14
+ "directory": "packages/metro-file-map"
14
15
  },
15
16
  "scripts": {
16
17
  "prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src",
@@ -0,0 +1,74 @@
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
+ * @noformat
8
+ * @generated SignedSource<<25fee66c7d26ad53cdd5bbab454fe50b>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro-file-map/src/Watcher.js
12
+ * To regenerate, run:
13
+ * js1 build metro-ts-defs (internal) OR
14
+ * yarn run build-ts-defs (OSS)
15
+ */
16
+
17
+ import type {
18
+ Console,
19
+ CrawlerOptions,
20
+ CrawlResult,
21
+ PerfLogger,
22
+ WatcherBackendChangeEvent,
23
+ } from './flow-types';
24
+
25
+ import EventEmitter from 'events';
26
+
27
+ type WatcherOptions = {
28
+ abortSignal: AbortSignal;
29
+ computeSha1: boolean;
30
+ console: Console;
31
+ enableSymlinks: boolean;
32
+ extensions: ReadonlyArray<string>;
33
+ forceNodeFilesystemAPI: boolean;
34
+ healthCheckFilePrefix: string;
35
+ ignoreForCrawl: (filePath: string) => boolean;
36
+ ignorePatternForWatch: RegExp;
37
+ previousState: CrawlerOptions['previousState'];
38
+ perfLogger: null | undefined | PerfLogger;
39
+ roots: ReadonlyArray<string>;
40
+ rootDir: string;
41
+ useWatchman: boolean;
42
+ watch: boolean;
43
+ watchmanDeferStates: ReadonlyArray<string>;
44
+ };
45
+ export type HealthCheckResult =
46
+ | {
47
+ type: 'error';
48
+ timeout: number;
49
+ error: Error;
50
+ watcher: null | undefined | string;
51
+ }
52
+ | {
53
+ type: 'success';
54
+ timeout: number;
55
+ timeElapsed: number;
56
+ watcher: null | undefined | string;
57
+ }
58
+ | {
59
+ type: 'timeout';
60
+ timeout: number;
61
+ watcher: null | undefined | string;
62
+ pauseReason: null | undefined | string;
63
+ };
64
+ export declare class Watcher extends EventEmitter {
65
+ constructor(options: WatcherOptions);
66
+ crawl(): Promise<CrawlResult>;
67
+ recrawl(
68
+ subpath: string,
69
+ currentFileSystem: CrawlerOptions['previousState']['fileSystem'],
70
+ ): Promise<CrawlResult>;
71
+ watch(onChange: (change: WatcherBackendChangeEvent) => void): void;
72
+ close(): void;
73
+ checkHealth(timeout: number): Promise<HealthCheckResult>;
74
+ }
package/src/Watcher.js CHANGED
@@ -29,10 +29,7 @@ function _interopRequireWildcard(e, t) {
29
29
  if (!t && e && e.__esModule) return e;
30
30
  var o,
31
31
  i,
32
- f = {
33
- __proto__: null,
34
- default: e,
35
- };
32
+ f = { __proto__: null, default: e };
36
33
  if (null === e || ("object" != typeof e && "function" != typeof e))
37
34
  return f;
38
35
  if ((o = t ? n : r)) {
@@ -52,11 +49,7 @@ function _interopRequireWildcard(e, t) {
52
49
  })(e, t);
53
50
  }
54
51
  function _interopRequireDefault(e) {
55
- return e && e.__esModule
56
- ? e
57
- : {
58
- default: e,
59
- };
52
+ return e && e.__esModule ? e : { default: e };
60
53
  }
61
54
  const debug = require("debug")("Metro:Watcher");
62
55
  const MAX_WAIT_TIME = 240000;
@@ -76,10 +69,32 @@ class Watcher extends _events.default {
76
69
  async crawl() {
77
70
  this.#options.perfLogger?.point("crawl_start");
78
71
  const options = this.#options;
72
+ const result = await this.#crawl({
73
+ previousState: options.previousState,
74
+ roots: options.roots,
75
+ useWatchman: options.useWatchman,
76
+ });
77
+ this.#options.perfLogger?.point("crawl_end");
78
+ return result;
79
+ }
80
+ async recrawl(subpath, currentFileSystem) {
81
+ return this.#crawl({
82
+ previousState: {
83
+ clocks: new Map(),
84
+ fileSystem: currentFileSystem,
85
+ },
86
+ roots: [path.join(this.#options.rootDir, subpath)],
87
+ subpath,
88
+ useWatchman: false,
89
+ });
90
+ }
91
+ async #crawl(crawlOptions) {
92
+ const options = this.#options;
93
+ const { useWatchman, subpath } = crawlOptions;
79
94
  const ignoreForCrawl = (filePath) =>
80
95
  options.ignoreForCrawl(filePath) ||
81
96
  path.basename(filePath).startsWith(this.#options.healthCheckFilePrefix);
82
- const crawl = options.useWatchman ? _watchman.default : _node.default;
97
+ const crawl = useWatchman ? _watchman.default : _node.default;
83
98
  let crawler = crawl === _watchman.default ? "watchman" : "node";
84
99
  options.abortSignal.throwIfAborted();
85
100
  const crawlerOptions = {
@@ -94,49 +109,47 @@ class Watcher extends _events.default {
94
109
  this.emit("status", status);
95
110
  },
96
111
  perfLogger: options.perfLogger,
97
- previousState: options.previousState,
112
+ previousState: crawlOptions.previousState,
98
113
  rootDir: options.rootDir,
99
- roots: options.roots,
114
+ roots: crawlOptions.roots,
115
+ subpath,
100
116
  };
101
- const retry = (error) => {
102
- if (crawl === _watchman.default) {
103
- crawler = "node";
104
- options.console.warn(
105
- "metro-file-map: Watchman crawl failed. Retrying once with node " +
106
- "crawler.\n" +
107
- " Usually this happens when watchman isn't running. Create an " +
108
- "empty `.watchmanconfig` file in your project's root folder or " +
109
- "initialize a git or hg repository in your project.\n" +
110
- " " +
111
- error.toString(),
112
- );
113
- return (0, _node.default)(crawlerOptions).catch((e) => {
114
- throw new Error(
115
- "Crawler retry failed:\n" +
116
- ` Original error: ${error.message}\n` +
117
- ` Retry error: ${e.message}\n`,
118
- );
119
- });
117
+ debug("Crawling roots: %s with %s crawler.", crawlOptions.roots, crawler);
118
+ let delta;
119
+ try {
120
+ delta = await crawl(crawlerOptions);
121
+ } catch (firstError) {
122
+ if (crawl !== _watchman.default) {
123
+ throw firstError;
120
124
  }
121
- throw error;
122
- };
123
- const logEnd = (delta) => {
124
- debug(
125
- 'Crawler "%s" returned %d added/modified, %d removed, %d clock(s).',
126
- crawler,
127
- delta.changedFiles.size,
128
- delta.removedFiles.size,
129
- delta.clocks?.size ?? 0,
125
+ crawler = "node";
126
+ options.console.warn(
127
+ "metro-file-map: Watchman crawl failed. Retrying once with node " +
128
+ "crawler.\n" +
129
+ " Usually this happens when watchman isn't running. Create an " +
130
+ "empty `.watchmanconfig` file in your project's root folder or " +
131
+ "initialize a git or hg repository in your project.\n" +
132
+ " " +
133
+ firstError.toString(),
130
134
  );
131
- this.#options.perfLogger?.point("crawl_end");
132
- return delta;
133
- };
134
- debug('Beginning crawl with "%s".', crawler);
135
- try {
136
- return crawl(crawlerOptions).catch(retry).then(logEnd);
137
- } catch (error) {
138
- return retry(error).then(logEnd);
135
+ try {
136
+ delta = await (0, _node.default)(crawlerOptions);
137
+ } catch (retryError) {
138
+ throw new Error(
139
+ "Crawler retry failed:\n" +
140
+ ` Original error: ${firstError.message}\n` +
141
+ ` Retry error: ${retryError.message}\n`,
142
+ );
143
+ }
139
144
  }
145
+ debug(
146
+ 'Crawler "%s" returned %d added/modified, %d removed, %d clock(s).',
147
+ crawler,
148
+ delta.changedFiles.size,
149
+ delta.removedFiles.size,
150
+ delta.clocks?.size ?? 0,
151
+ );
152
+ return delta;
140
153
  }
141
154
  async watch(onChange) {
142
155
  const { extensions, ignorePatternForWatch, useWatchman } = this.#options;
@@ -188,6 +201,13 @@ class Watcher extends _events.default {
188
201
  }
189
202
  return;
190
203
  }
204
+ if (change.event === "recrawl" && useWatchman) {
205
+ this.#options.console.error(
206
+ "metro-file-map: Received unexpected recrawl event while using " +
207
+ "Watchman. Watchman recrawls are not implemented.",
208
+ );
209
+ return;
210
+ }
191
211
  onChange(change);
192
212
  });
193
213
  await watcher.startWatching();
@@ -11,12 +11,11 @@
11
11
  import type {
12
12
  Console,
13
13
  CrawlerOptions,
14
- FileData,
14
+ CrawlResult,
15
15
  Path,
16
16
  PerfLogger,
17
17
  WatcherBackend,
18
18
  WatcherBackendChangeEvent,
19
- WatchmanClocks,
20
19
  } from './flow-types';
21
20
  import type {WatcherOptions as WatcherBackendOptions} from './watchers/common';
22
21
 
@@ -37,11 +36,12 @@ const debug = require('debug')('Metro:Watcher');
37
36
 
38
37
  const MAX_WAIT_TIME = 240000;
39
38
 
40
- type CrawlResult = {
41
- changedFiles: FileData,
42
- clocks?: WatchmanClocks,
43
- removedFiles: Set<Path>,
44
- };
39
+ type InternalCrawlOptions = Readonly<{
40
+ previousState: CrawlerOptions['previousState'],
41
+ roots: ReadonlyArray<string>,
42
+ subpath?: string,
43
+ useWatchman: boolean,
44
+ }>;
45
45
 
46
46
  type WatcherOptions = {
47
47
  abortSignal: AbortSignal,
@@ -86,12 +86,41 @@ export class Watcher extends EventEmitter {
86
86
 
87
87
  async crawl(): Promise<CrawlResult> {
88
88
  this.#options.perfLogger?.point('crawl_start');
89
+ const options = this.#options;
90
+
91
+ const result = await this.#crawl({
92
+ previousState: options.previousState,
93
+ roots: options.roots,
94
+ useWatchman: options.useWatchman,
95
+ });
89
96
 
97
+ this.#options.perfLogger?.point('crawl_end');
98
+ return result;
99
+ }
100
+
101
+ async recrawl(
102
+ subpath: string,
103
+ currentFileSystem: CrawlerOptions['previousState']['fileSystem'],
104
+ ): Promise<CrawlResult> {
105
+ return this.#crawl({
106
+ previousState: {
107
+ clocks: new Map(),
108
+ fileSystem: currentFileSystem,
109
+ },
110
+ roots: [path.join(this.#options.rootDir, subpath)],
111
+ subpath,
112
+ useWatchman: false,
113
+ });
114
+ }
115
+
116
+ async #crawl(crawlOptions: InternalCrawlOptions): Promise<CrawlResult> {
90
117
  const options = this.#options;
118
+ const {useWatchman, subpath} = crawlOptions;
119
+
91
120
  const ignoreForCrawl = (filePath: string) =>
92
121
  options.ignoreForCrawl(filePath) ||
93
122
  path.basename(filePath).startsWith(this.#options.healthCheckFilePrefix);
94
- const crawl = options.useWatchman ? watchmanCrawl : nodeCrawl;
123
+ const crawl = useWatchman ? watchmanCrawl : nodeCrawl;
95
124
  let crawler = crawl === watchmanCrawl ? 'watchman' : 'node';
96
125
 
97
126
  options.abortSignal.throwIfAborted();
@@ -108,55 +137,50 @@ export class Watcher extends EventEmitter {
108
137
  this.emit('status', status);
109
138
  },
110
139
  perfLogger: options.perfLogger,
111
- previousState: options.previousState,
140
+ previousState: crawlOptions.previousState,
112
141
  rootDir: options.rootDir,
113
- roots: options.roots,
142
+ roots: crawlOptions.roots,
143
+ subpath,
114
144
  };
115
145
 
116
- const retry = (error: Error): Promise<CrawlResult> => {
117
- if (crawl === watchmanCrawl) {
118
- crawler = 'node';
119
- options.console.warn(
120
- 'metro-file-map: Watchman crawl failed. Retrying once with node ' +
121
- 'crawler.\n' +
122
- " Usually this happens when watchman isn't running. Create an " +
123
- "empty `.watchmanconfig` file in your project's root folder or " +
124
- 'initialize a git or hg repository in your project.\n' +
125
- ' ' +
126
- error.toString(),
127
- );
128
- // $FlowFixMe[incompatible-type] Found when updating Promise type definition
129
- return nodeCrawl(crawlerOptions).catch<CrawlResult>(e => {
130
- throw new Error(
131
- 'Crawler retry failed:\n' +
132
- ` Original error: ${error.message}\n` +
133
- ` Retry error: ${e.message}\n`,
134
- );
135
- });
136
- }
137
-
138
- throw error;
139
- };
140
-
141
- const logEnd = (delta: CrawlResult): CrawlResult => {
142
- debug(
143
- 'Crawler "%s" returned %d added/modified, %d removed, %d clock(s).',
144
- crawler,
145
- delta.changedFiles.size,
146
- delta.removedFiles.size,
147
- delta.clocks?.size ?? 0,
148
- );
149
- this.#options.perfLogger?.point('crawl_end');
150
- return delta;
151
- };
146
+ debug('Crawling roots: %s with %s crawler.', crawlOptions.roots, crawler);
152
147
 
153
- debug('Beginning crawl with "%s".', crawler);
148
+ let delta: CrawlResult;
154
149
  try {
155
- // $FlowFixMe[incompatible-type] Found when updating Promise type definition
156
- return crawl(crawlerOptions).catch<CrawlResult>(retry).then(logEnd);
157
- } catch (error) {
158
- return retry(error).then(logEnd);
150
+ delta = await crawl(crawlerOptions);
151
+ } catch (firstError) {
152
+ if (crawl !== watchmanCrawl) {
153
+ throw firstError;
154
+ }
155
+ crawler = 'node';
156
+ options.console.warn(
157
+ 'metro-file-map: Watchman crawl failed. Retrying once with node ' +
158
+ 'crawler.\n' +
159
+ " Usually this happens when watchman isn't running. Create an " +
160
+ "empty `.watchmanconfig` file in your project's root folder or " +
161
+ 'initialize a git or hg repository in your project.\n' +
162
+ ' ' +
163
+ firstError.toString(),
164
+ );
165
+ try {
166
+ delta = await nodeCrawl(crawlerOptions);
167
+ } catch (retryError) {
168
+ throw new Error(
169
+ 'Crawler retry failed:\n' +
170
+ ` Original error: ${firstError.message}\n` +
171
+ ` Retry error: ${retryError.message}\n`,
172
+ );
173
+ }
159
174
  }
175
+
176
+ debug(
177
+ 'Crawler "%s" returned %d added/modified, %d removed, %d clock(s).',
178
+ crawler,
179
+ delta.changedFiles.size,
180
+ delta.removedFiles.size,
181
+ delta.clocks?.size ?? 0,
182
+ );
183
+ return delta;
160
184
  }
161
185
 
162
186
  async watch(onChange: (change: WatcherBackendChangeEvent) => void) {
@@ -214,6 +238,15 @@ export class Watcher extends EventEmitter {
214
238
  }
215
239
  return;
216
240
  }
241
+ // Watchman handles recrawls internally - receiving a recrawl event
242
+ // when using Watchman would indicate a bug. Log an error and ignore.
243
+ if (change.event === 'recrawl' && useWatchman) {
244
+ this.#options.console.error(
245
+ 'metro-file-map: Received unexpected recrawl event while using ' +
246
+ 'Watchman. Watchman recrawls are not implemented.',
247
+ );
248
+ return;
249
+ }
217
250
  onChange(change);
218
251
  });
219
252
  await watcher.startWatching();
@@ -0,0 +1,49 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<9cdec2a3b7a46f0a893dd5dc392a5294>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro-file-map/src/cache/DiskCacheManager.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {
19
+ BuildParameters,
20
+ CacheData,
21
+ CacheManager,
22
+ CacheManagerFactoryOptions,
23
+ CacheManagerWriteOptions,
24
+ } from '../flow-types';
25
+
26
+ type AutoSaveOptions = Readonly<{debounceMs: number}>;
27
+ type DiskCacheConfig = Readonly<{
28
+ autoSave?: Partial<AutoSaveOptions> | boolean;
29
+ cacheFilePrefix?: null | undefined | string;
30
+ cacheDirectory?: null | undefined | string;
31
+ }>;
32
+ export declare class DiskCacheManager implements CacheManager {
33
+ constructor(
34
+ $$PARAM_0$$: CacheManagerFactoryOptions,
35
+ $$PARAM_1$$: DiskCacheConfig,
36
+ );
37
+ static getCacheFilePath(
38
+ buildParameters: BuildParameters,
39
+ cacheFilePrefix?: null | undefined | string,
40
+ cacheDirectory?: null | undefined | string,
41
+ ): string;
42
+ getCacheFilePath(): string;
43
+ read(): Promise<null | undefined | CacheData>;
44
+ write(
45
+ getSnapshot: () => CacheData,
46
+ $$PARAM_1$$: CacheManagerWriteOptions,
47
+ ): Promise<void>;
48
+ end(): Promise<void>;
49
+ }
@@ -13,11 +13,7 @@ var _path = _interopRequireDefault(require("path"));
13
13
  var _timers = require("timers");
14
14
  var _v = require("v8");
15
15
  function _interopRequireDefault(e) {
16
- return e && e.__esModule
17
- ? e
18
- : {
19
- default: e,
20
- };
16
+ return e && e.__esModule ? e : { default: e };
21
17
  }
22
18
  const debug = require("debug")("Metro:FileMapCache");
23
19
  const DEFAULT_PREFIX = "metro-file-map";
@@ -0,0 +1,22 @@
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
+ * @noformat
8
+ * @generated SignedSource<<733fae11203b79438dfb1ee2bbb6473d>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro-file-map/src/constants.js
12
+ * To regenerate, run:
13
+ * js1 build metro-ts-defs (internal) OR
14
+ * yarn run build-ts-defs (OSS)
15
+ */
16
+
17
+ import type {HType} from './flow-types';
18
+
19
+ declare const $$EXPORT_DEFAULT_DECLARATION$$: HType;
20
+ declare type $$EXPORT_DEFAULT_DECLARATION$$ =
21
+ typeof $$EXPORT_DEFAULT_DECLARATION$$;
22
+ export default $$EXPORT_DEFAULT_DECLARATION$$;
@@ -0,0 +1,19 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<8b6ff8a24f9156cd7991006c72edd296>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro-file-map/src/crawlers/node/hasNativeFindSupport.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ declare function hasNativeFindSupport(): Promise<boolean>;
19
+ export default hasNativeFindSupport;
@@ -0,0 +1,21 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<27109494e4956802ba89ac6fd22aa277>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro-file-map/src/crawlers/node/index.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {CrawlerOptions, CrawlResult} from '../../flow-types';
19
+
20
+ declare function nodeCrawl(options: CrawlerOptions): Promise<CrawlResult>;
21
+ export default nodeCrawl;
@@ -20,10 +20,7 @@ function _interopRequireWildcard(e, t) {
20
20
  if (!t && e && e.__esModule) return e;
21
21
  var o,
22
22
  i,
23
- f = {
24
- __proto__: null,
25
- default: e,
26
- };
23
+ f = { __proto__: null, default: e };
27
24
  if (null === e || ("object" != typeof e && "function" != typeof e))
28
25
  return f;
29
26
  if ((o = t ? n : r)) {
@@ -43,11 +40,7 @@ function _interopRequireWildcard(e, t) {
43
40
  })(e, t);
44
41
  }
45
42
  function _interopRequireDefault(e) {
46
- return e && e.__esModule
47
- ? e
48
- : {
49
- default: e,
50
- };
43
+ return e && e.__esModule ? e : { default: e };
51
44
  }
52
45
  const debug = require("debug")("Metro:NodeCrawler");
53
46
  function find(
@@ -190,6 +183,7 @@ async function nodeCrawl(options) {
190
183
  perfLogger,
191
184
  roots,
192
185
  abortSignal,
186
+ subpath,
193
187
  } = options;
194
188
  abortSignal?.throwIfAborted();
195
189
  perfLogger?.point("nodeCrawl_start");
@@ -200,7 +194,9 @@ async function nodeCrawl(options) {
200
194
  debug("Using system find: %s", useNativeFind);
201
195
  return new Promise((resolve, reject) => {
202
196
  const callback = (fileData) => {
203
- const difference = previousState.fileSystem.getDifference(fileData);
197
+ const difference = previousState.fileSystem.getDifference(fileData, {
198
+ subpath,
199
+ });
204
200
  perfLogger?.point("nodeCrawl_end");
205
201
  try {
206
202
  abortSignal?.throwIfAborted();
@@ -10,9 +10,9 @@
10
10
  */
11
11
 
12
12
  import type {
13
- CanonicalPath,
14
13
  Console,
15
14
  CrawlerOptions,
15
+ CrawlResult,
16
16
  FileData,
17
17
  IgnoreMatcher,
18
18
  } from '../../flow-types';
@@ -170,10 +170,9 @@ function findNative(
170
170
  });
171
171
  }
172
172
 
173
- export default async function nodeCrawl(options: CrawlerOptions): Promise<{
174
- removedFiles: Set<CanonicalPath>,
175
- changedFiles: FileData,
176
- }> {
173
+ export default async function nodeCrawl(
174
+ options: CrawlerOptions,
175
+ ): Promise<CrawlResult> {
177
176
  const {
178
177
  console,
179
178
  previousState,
@@ -185,6 +184,7 @@ export default async function nodeCrawl(options: CrawlerOptions): Promise<{
185
184
  perfLogger,
186
185
  roots,
187
186
  abortSignal,
187
+ subpath,
188
188
  } = options;
189
189
 
190
190
  abortSignal?.throwIfAborted();
@@ -199,7 +199,9 @@ export default async function nodeCrawl(options: CrawlerOptions): Promise<{
199
199
 
200
200
  return new Promise((resolve, reject) => {
201
201
  const callback: Callback = fileData => {
202
- const difference = previousState.fileSystem.getDifference(fileData);
202
+ const difference = previousState.fileSystem.getDifference(fileData, {
203
+ subpath,
204
+ });
203
205
 
204
206
  perfLogger?.point('nodeCrawl_end');
205
207
 
@@ -0,0 +1,23 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<bcfb58810773510450845bc00a93beae>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro-file-map/src/crawlers/watchman/index.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {CrawlerOptions, CrawlResult} from '../../flow-types';
19
+
20
+ declare function watchmanCrawl(
21
+ $$PARAM_0$$: CrawlerOptions,
22
+ ): Promise<CrawlResult>;
23
+ export default watchmanCrawl;