metro-file-map 0.81.0 → 0.81.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -6
- package/src/Watcher.js +35 -34
- package/src/Watcher.js.flow +41 -62
- package/src/flow-types.d.ts +14 -21
- package/src/flow-types.js.flow +39 -20
- package/src/index.d.ts +5 -1
- package/src/index.js +95 -172
- package/src/index.js.flow +115 -191
- package/src/lib/HasteConflictsError.js +56 -0
- package/src/lib/HasteConflictsError.js.flow +62 -0
- package/src/lib/MockMap.js +110 -4
- package/src/lib/MockMap.js.flow +122 -4
- package/src/lib/MutableHasteMap.js +106 -44
- package/src/lib/MutableHasteMap.js.flow +141 -59
- package/src/lib/TreeFS.js.flow +7 -5
- package/src/lib/computeConflicts.js +73 -0
- package/src/lib/computeConflicts.js.flow +105 -0
- package/src/lib/sorting.js +27 -0
- package/src/lib/sorting.js.flow +35 -0
- package/src/watchers/AbstractWatcher.js +76 -0
- package/src/watchers/AbstractWatcher.js.flow +92 -0
- package/src/watchers/{NodeWatcher.js → FallbackWatcher.js} +112 -71
- package/src/watchers/{NodeWatcher.js.flow → FallbackWatcher.js.flow} +125 -99
- package/src/watchers/NativeWatcher.js +109 -0
- package/src/watchers/NativeWatcher.js.flow +136 -0
- package/src/watchers/WatchmanWatcher.js +57 -59
- package/src/watchers/WatchmanWatcher.js.flow +54 -76
- package/src/watchers/common.js +9 -61
- package/src/watchers/common.js.flow +19 -90
- package/src/worker.js +0 -7
- package/src/worker.js.flow +1 -8
- package/src/lib/DuplicateError.js +0 -14
- package/src/lib/DuplicateError.js.flow +0 -22
- package/src/watchers/FSEventsWatcher.js +0 -179
- package/src/watchers/FSEventsWatcher.js.flow +0 -231
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-file-map",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.1",
|
|
4
4
|
"description": "[Experimental] - 🚇 File crawling, watching and mapping for Metro",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"anymatch": "^3.0.3",
|
|
17
16
|
"debug": "^2.2.0",
|
|
18
17
|
"fb-watchman": "^2.0.0",
|
|
19
18
|
"flow-enums-runtime": "^0.0.6",
|
|
@@ -21,16 +20,12 @@
|
|
|
21
20
|
"invariant": "^2.2.4",
|
|
22
21
|
"jest-worker": "^29.6.3",
|
|
23
22
|
"micromatch": "^4.0.4",
|
|
24
|
-
"node-abort-controller": "^3.1.1",
|
|
25
23
|
"nullthrows": "^1.1.1",
|
|
26
24
|
"walker": "^1.0.7"
|
|
27
25
|
},
|
|
28
26
|
"devDependencies": {
|
|
29
27
|
"slash": "^3.0.0"
|
|
30
28
|
},
|
|
31
|
-
"optionalDependencies": {
|
|
32
|
-
"fsevents": "^2.3.2"
|
|
33
|
-
},
|
|
34
29
|
"engines": {
|
|
35
30
|
"node": ">=18.18"
|
|
36
31
|
}
|
package/src/Watcher.js
CHANGED
|
@@ -7,10 +7,12 @@ exports.Watcher = void 0;
|
|
|
7
7
|
var _node = _interopRequireDefault(require("./crawlers/node"));
|
|
8
8
|
var _watchman = _interopRequireDefault(require("./crawlers/watchman"));
|
|
9
9
|
var _common = require("./watchers/common");
|
|
10
|
-
var
|
|
11
|
-
require("./watchers/
|
|
10
|
+
var _FallbackWatcher = _interopRequireDefault(
|
|
11
|
+
require("./watchers/FallbackWatcher")
|
|
12
|
+
);
|
|
13
|
+
var _NativeWatcher = _interopRequireDefault(
|
|
14
|
+
require("./watchers/NativeWatcher")
|
|
12
15
|
);
|
|
13
|
-
var _NodeWatcher = _interopRequireDefault(require("./watchers/NodeWatcher"));
|
|
14
16
|
var _WatchmanWatcher = _interopRequireDefault(
|
|
15
17
|
require("./watchers/WatchmanWatcher")
|
|
16
18
|
);
|
|
@@ -60,8 +62,8 @@ class Watcher extends _events.default {
|
|
|
60
62
|
async crawl() {
|
|
61
63
|
this._options.perfLogger?.point("crawl_start");
|
|
62
64
|
const options = this._options;
|
|
63
|
-
const
|
|
64
|
-
options.
|
|
65
|
+
const ignoreForCrawl = (filePath) =>
|
|
66
|
+
options.ignoreForCrawl(filePath) ||
|
|
65
67
|
path.basename(filePath).startsWith(this._options.healthCheckFilePrefix);
|
|
66
68
|
const crawl = options.useWatchman ? _watchman.default : _node.default;
|
|
67
69
|
let crawler = crawl === _watchman.default ? "watchman" : "node";
|
|
@@ -73,7 +75,7 @@ class Watcher extends _events.default {
|
|
|
73
75
|
includeSymlinks: options.enableSymlinks,
|
|
74
76
|
extensions: options.extensions,
|
|
75
77
|
forceNodeFilesystemAPI: options.forceNodeFilesystemAPI,
|
|
76
|
-
ignore,
|
|
78
|
+
ignore: ignoreForCrawl,
|
|
77
79
|
onStatus: (status) => {
|
|
78
80
|
this.emit("status", status);
|
|
79
81
|
},
|
|
@@ -123,17 +125,17 @@ class Watcher extends _events.default {
|
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
async watch(onChange) {
|
|
126
|
-
const { extensions,
|
|
128
|
+
const { extensions, ignorePatternForWatch, useWatchman } = this._options;
|
|
127
129
|
const WatcherImpl = useWatchman
|
|
128
130
|
? _WatchmanWatcher.default
|
|
129
|
-
:
|
|
130
|
-
?
|
|
131
|
-
:
|
|
132
|
-
let watcher = "
|
|
131
|
+
: _NativeWatcher.default.isSupported()
|
|
132
|
+
? _NativeWatcher.default
|
|
133
|
+
: _FallbackWatcher.default;
|
|
134
|
+
let watcher = "fallback";
|
|
133
135
|
if (WatcherImpl === _WatchmanWatcher.default) {
|
|
134
136
|
watcher = "watchman";
|
|
135
|
-
} else if (WatcherImpl ===
|
|
136
|
-
watcher = "
|
|
137
|
+
} else if (WatcherImpl === _NativeWatcher.default) {
|
|
138
|
+
watcher = "native";
|
|
137
139
|
}
|
|
138
140
|
debug(`Using watcher: ${watcher}`);
|
|
139
141
|
this._options.perfLogger?.annotate({
|
|
@@ -145,39 +147,38 @@ class Watcher extends _events.default {
|
|
|
145
147
|
const createWatcherBackend = (root) => {
|
|
146
148
|
const watcherOptions = {
|
|
147
149
|
dot: true,
|
|
148
|
-
|
|
150
|
+
globs: [
|
|
149
151
|
"**/package.json",
|
|
150
152
|
"**/" + this._options.healthCheckFilePrefix + "*",
|
|
151
153
|
...extensions.map((extension) => "**/*." + extension),
|
|
152
154
|
],
|
|
153
|
-
ignored:
|
|
155
|
+
ignored: ignorePatternForWatch,
|
|
154
156
|
watchmanDeferStates: this._options.watchmanDeferStates,
|
|
155
157
|
};
|
|
156
158
|
const watcher = new WatcherImpl(root, watcherOptions);
|
|
157
|
-
return new Promise((resolve, reject) => {
|
|
159
|
+
return new Promise(async (resolve, reject) => {
|
|
158
160
|
const rejectTimeout = setTimeout(
|
|
159
161
|
() => reject(new Error("Failed to start watch mode.")),
|
|
160
162
|
MAX_WAIT_TIME
|
|
161
163
|
);
|
|
162
|
-
watcher.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
);
|
|
173
|
-
this._handleHealthCheckObservation(basename);
|
|
174
|
-
}
|
|
175
|
-
return;
|
|
164
|
+
watcher.onFileEvent((change) => {
|
|
165
|
+
const basename = path.basename(change.relativePath);
|
|
166
|
+
if (basename.startsWith(this._options.healthCheckFilePrefix)) {
|
|
167
|
+
if (change.event === _common.TOUCH_EVENT) {
|
|
168
|
+
debug(
|
|
169
|
+
"Observed possible health check cookie: %s in %s",
|
|
170
|
+
change.relativePath,
|
|
171
|
+
root
|
|
172
|
+
);
|
|
173
|
+
this._handleHealthCheckObservation(basename);
|
|
176
174
|
}
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
onChange(change);
|
|
180
178
|
});
|
|
179
|
+
await watcher.startWatching();
|
|
180
|
+
clearTimeout(rejectTimeout);
|
|
181
|
+
resolve(watcher);
|
|
181
182
|
});
|
|
182
183
|
};
|
|
183
184
|
this._backends = await Promise.all(
|
|
@@ -192,7 +193,7 @@ class Watcher extends _events.default {
|
|
|
192
193
|
resolveHealthCheck();
|
|
193
194
|
}
|
|
194
195
|
async close() {
|
|
195
|
-
await Promise.all(this._backends.map((watcher) => watcher.
|
|
196
|
+
await Promise.all(this._backends.map((watcher) => watcher.stopWatching()));
|
|
196
197
|
this._activeWatcher = null;
|
|
197
198
|
}
|
|
198
199
|
async checkHealth(timeout) {
|
package/src/Watcher.js.flow
CHANGED
|
@@ -9,22 +9,22 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type {
|
|
12
|
-
ChangeEventMetadata,
|
|
13
12
|
Console,
|
|
14
13
|
CrawlerOptions,
|
|
15
14
|
FileData,
|
|
16
15
|
Path,
|
|
17
16
|
PerfLogger,
|
|
17
|
+
WatcherBackend,
|
|
18
|
+
WatcherBackendChangeEvent,
|
|
18
19
|
WatchmanClocks,
|
|
19
20
|
} from './flow-types';
|
|
20
21
|
import type {WatcherOptions as WatcherBackendOptions} from './watchers/common';
|
|
21
|
-
import type {AbortSignal} from 'node-abort-controller';
|
|
22
22
|
|
|
23
23
|
import nodeCrawl from './crawlers/node';
|
|
24
24
|
import watchmanCrawl from './crawlers/watchman';
|
|
25
|
-
import {
|
|
26
|
-
import
|
|
27
|
-
import
|
|
25
|
+
import {TOUCH_EVENT} from './watchers/common';
|
|
26
|
+
import FallbackWatcher from './watchers/FallbackWatcher';
|
|
27
|
+
import NativeWatcher from './watchers/NativeWatcher';
|
|
28
28
|
import WatchmanWatcher from './watchers/WatchmanWatcher';
|
|
29
29
|
import EventEmitter from 'events';
|
|
30
30
|
import * as fs from 'fs';
|
|
@@ -50,8 +50,8 @@ type WatcherOptions = {
|
|
|
50
50
|
extensions: $ReadOnlyArray<string>,
|
|
51
51
|
forceNodeFilesystemAPI: boolean,
|
|
52
52
|
healthCheckFilePrefix: string,
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
ignoreForCrawl: string => boolean,
|
|
54
|
+
ignorePatternForWatch: RegExp,
|
|
55
55
|
previousState: CrawlerOptions['previousState'],
|
|
56
56
|
perfLogger: ?PerfLogger,
|
|
57
57
|
roots: $ReadOnlyArray<string>,
|
|
@@ -61,11 +61,6 @@ type WatcherOptions = {
|
|
|
61
61
|
watchmanDeferStates: $ReadOnlyArray<string>,
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
interface WatcherBackend {
|
|
65
|
-
getPauseReason(): ?string;
|
|
66
|
-
close(): Promise<void>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
64
|
let nextInstanceId = 0;
|
|
70
65
|
|
|
71
66
|
export type HealthCheckResult =
|
|
@@ -92,8 +87,8 @@ export class Watcher extends EventEmitter {
|
|
|
92
87
|
this._options.perfLogger?.point('crawl_start');
|
|
93
88
|
|
|
94
89
|
const options = this._options;
|
|
95
|
-
const
|
|
96
|
-
options.
|
|
90
|
+
const ignoreForCrawl = (filePath: string) =>
|
|
91
|
+
options.ignoreForCrawl(filePath) ||
|
|
97
92
|
path.basename(filePath).startsWith(this._options.healthCheckFilePrefix);
|
|
98
93
|
const crawl = options.useWatchman ? watchmanCrawl : nodeCrawl;
|
|
99
94
|
let crawler = crawl === watchmanCrawl ? 'watchman' : 'node';
|
|
@@ -107,7 +102,7 @@ export class Watcher extends EventEmitter {
|
|
|
107
102
|
includeSymlinks: options.enableSymlinks,
|
|
108
103
|
extensions: options.extensions,
|
|
109
104
|
forceNodeFilesystemAPI: options.forceNodeFilesystemAPI,
|
|
110
|
-
ignore,
|
|
105
|
+
ignore: ignoreForCrawl,
|
|
111
106
|
onStatus: status => {
|
|
112
107
|
this.emit('status', status);
|
|
113
108
|
},
|
|
@@ -163,28 +158,21 @@ export class Watcher extends EventEmitter {
|
|
|
163
158
|
}
|
|
164
159
|
}
|
|
165
160
|
|
|
166
|
-
async watch(
|
|
167
|
-
|
|
168
|
-
type: string,
|
|
169
|
-
filePath: string,
|
|
170
|
-
root: string,
|
|
171
|
-
metadata: ChangeEventMetadata,
|
|
172
|
-
) => void,
|
|
173
|
-
) {
|
|
174
|
-
const {extensions, ignorePattern, useWatchman} = this._options;
|
|
161
|
+
async watch(onChange: (change: WatcherBackendChangeEvent) => void) {
|
|
162
|
+
const {extensions, ignorePatternForWatch, useWatchman} = this._options;
|
|
175
163
|
|
|
176
|
-
// WatchmanWatcher >
|
|
164
|
+
// WatchmanWatcher > NativeWatcher > FallbackWatcher
|
|
177
165
|
const WatcherImpl = useWatchman
|
|
178
166
|
? WatchmanWatcher
|
|
179
|
-
:
|
|
180
|
-
?
|
|
181
|
-
:
|
|
167
|
+
: NativeWatcher.isSupported()
|
|
168
|
+
? NativeWatcher
|
|
169
|
+
: FallbackWatcher;
|
|
182
170
|
|
|
183
|
-
let watcher = '
|
|
171
|
+
let watcher = 'fallback';
|
|
184
172
|
if (WatcherImpl === WatchmanWatcher) {
|
|
185
173
|
watcher = 'watchman';
|
|
186
|
-
} else if (WatcherImpl ===
|
|
187
|
-
watcher = '
|
|
174
|
+
} else if (WatcherImpl === NativeWatcher) {
|
|
175
|
+
watcher = 'native';
|
|
188
176
|
}
|
|
189
177
|
debug(`Using watcher: ${watcher}`);
|
|
190
178
|
this._options.perfLogger?.annotate({string: {watcher}});
|
|
@@ -193,7 +181,7 @@ export class Watcher extends EventEmitter {
|
|
|
193
181
|
const createWatcherBackend = (root: Path): Promise<WatcherBackend> => {
|
|
194
182
|
const watcherOptions: WatcherBackendOptions = {
|
|
195
183
|
dot: true,
|
|
196
|
-
|
|
184
|
+
globs: [
|
|
197
185
|
// Ensure we always include package.json files, which are crucial for
|
|
198
186
|
/// module resolution.
|
|
199
187
|
'**/package.json',
|
|
@@ -201,44 +189,35 @@ export class Watcher extends EventEmitter {
|
|
|
201
189
|
'**/' + this._options.healthCheckFilePrefix + '*',
|
|
202
190
|
...extensions.map(extension => '**/*.' + extension),
|
|
203
191
|
],
|
|
204
|
-
ignored:
|
|
192
|
+
ignored: ignorePatternForWatch,
|
|
205
193
|
watchmanDeferStates: this._options.watchmanDeferStates,
|
|
206
194
|
};
|
|
207
|
-
const watcher = new WatcherImpl(root, watcherOptions);
|
|
195
|
+
const watcher: WatcherBackend = new WatcherImpl(root, watcherOptions);
|
|
208
196
|
|
|
209
|
-
return new Promise((resolve, reject) => {
|
|
197
|
+
return new Promise(async (resolve, reject) => {
|
|
210
198
|
const rejectTimeout = setTimeout(
|
|
211
199
|
() => reject(new Error('Failed to start watch mode.')),
|
|
212
200
|
MAX_WAIT_TIME,
|
|
213
201
|
);
|
|
214
202
|
|
|
215
|
-
watcher.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
'Observed possible health check cookie: %s in %s',
|
|
230
|
-
filePath,
|
|
231
|
-
root,
|
|
232
|
-
);
|
|
233
|
-
this._handleHealthCheckObservation(basename);
|
|
234
|
-
}
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
onChange(type, filePath, root, metadata);
|
|
238
|
-
},
|
|
239
|
-
);
|
|
240
|
-
resolve(watcher);
|
|
203
|
+
watcher.onFileEvent(change => {
|
|
204
|
+
const basename = path.basename(change.relativePath);
|
|
205
|
+
if (basename.startsWith(this._options.healthCheckFilePrefix)) {
|
|
206
|
+
if (change.event === TOUCH_EVENT) {
|
|
207
|
+
debug(
|
|
208
|
+
'Observed possible health check cookie: %s in %s',
|
|
209
|
+
change.relativePath,
|
|
210
|
+
root,
|
|
211
|
+
);
|
|
212
|
+
this._handleHealthCheckObservation(basename);
|
|
213
|
+
}
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
onChange(change);
|
|
241
217
|
});
|
|
218
|
+
await watcher.startWatching();
|
|
219
|
+
clearTimeout(rejectTimeout);
|
|
220
|
+
resolve(watcher);
|
|
242
221
|
});
|
|
243
222
|
};
|
|
244
223
|
|
|
@@ -256,7 +235,7 @@ export class Watcher extends EventEmitter {
|
|
|
256
235
|
}
|
|
257
236
|
|
|
258
237
|
async close() {
|
|
259
|
-
await Promise.all(this._backends.map(watcher => watcher.
|
|
238
|
+
await Promise.all(this._backends.map(watcher => watcher.stopWatching()));
|
|
260
239
|
this._activeWatcher = null;
|
|
261
240
|
}
|
|
262
241
|
|
package/src/flow-types.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type {PerfLogger, PerfLoggerFactory, RootPerfLogger} from 'metro-config';
|
|
12
|
-
import type {AbortSignal} from 'node-abort-controller';
|
|
13
12
|
|
|
14
13
|
export type {PerfLoggerFactory, PerfLogger};
|
|
15
14
|
|
|
@@ -43,7 +42,7 @@ export interface BuildResult {
|
|
|
43
42
|
|
|
44
43
|
export interface CacheData {
|
|
45
44
|
readonly clocks: WatchmanClocks;
|
|
46
|
-
readonly mocks:
|
|
45
|
+
readonly mocks: RawMockMap;
|
|
47
46
|
readonly files: FileData;
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -254,6 +253,13 @@ export type LookupResult =
|
|
|
254
253
|
type: 'd' | 'f';
|
|
255
254
|
};
|
|
256
255
|
|
|
256
|
+
export type HasteConflict = {
|
|
257
|
+
id: string;
|
|
258
|
+
platform: string | null;
|
|
259
|
+
absolutePaths: Array<string>;
|
|
260
|
+
type: 'duplicate' | 'shadowing';
|
|
261
|
+
};
|
|
262
|
+
|
|
257
263
|
export interface HasteMap {
|
|
258
264
|
getModule(
|
|
259
265
|
name: string,
|
|
@@ -268,10 +274,14 @@ export interface HasteMap {
|
|
|
268
274
|
_supportsNativePlatform: boolean | null,
|
|
269
275
|
): Path | null;
|
|
270
276
|
|
|
271
|
-
|
|
277
|
+
computeConflicts(): Array<HasteConflict>;
|
|
272
278
|
}
|
|
273
279
|
|
|
274
|
-
export type
|
|
280
|
+
export type RawMockMap = {
|
|
281
|
+
readonly mocks: Map<string, string>;
|
|
282
|
+
readonly duplicates: Map<string, Set<string>>;
|
|
283
|
+
};
|
|
284
|
+
|
|
275
285
|
export type HasteMapData = Map<string, HasteMapItem>;
|
|
276
286
|
|
|
277
287
|
export interface HasteMapItem {
|
|
@@ -287,21 +297,6 @@ export interface MutableFileSystem extends FileSystem {
|
|
|
287
297
|
|
|
288
298
|
export type Path = string;
|
|
289
299
|
|
|
290
|
-
export interface RawHasteMap {
|
|
291
|
-
rootDir: Path;
|
|
292
|
-
duplicates: DuplicatesIndex;
|
|
293
|
-
map: HasteMapData;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export type ReadOnlyRawHasteMap = Readonly<{
|
|
297
|
-
rootDir: Path;
|
|
298
|
-
duplicates: ReadonlyMap<
|
|
299
|
-
string,
|
|
300
|
-
ReadonlyMap<string, ReadonlyMap<string, number>>
|
|
301
|
-
>;
|
|
302
|
-
map: ReadonlyMap<string, HasteMapItem>;
|
|
303
|
-
}>;
|
|
304
|
-
|
|
305
300
|
export type WatchmanClockSpec =
|
|
306
301
|
| string
|
|
307
302
|
| Readonly<{scm: Readonly<{'mergebase-with': string}>}>;
|
|
@@ -312,7 +307,6 @@ export type WorkerMessage = Readonly<{
|
|
|
312
307
|
computeSha1: boolean;
|
|
313
308
|
dependencyExtractor?: string | null;
|
|
314
309
|
enableHastePackages: boolean;
|
|
315
|
-
readLink: boolean;
|
|
316
310
|
rootDir: string;
|
|
317
311
|
filePath: string;
|
|
318
312
|
hasteImplModulePath?: string | null;
|
|
@@ -323,5 +317,4 @@ export type WorkerMetadata = Readonly<{
|
|
|
323
317
|
id?: string | null;
|
|
324
318
|
module?: HasteMapItemMetaData | null;
|
|
325
319
|
sha1?: string | null;
|
|
326
|
-
symlinkTarget?: string | null;
|
|
327
320
|
}>;
|
package/src/flow-types.js.flow
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
import type {PerfLogger, PerfLoggerFactory, RootPerfLogger} from 'metro-config';
|
|
15
|
-
import type {AbortSignal} from 'node-abort-controller';
|
|
16
15
|
|
|
17
16
|
export type {PerfLoggerFactory, PerfLogger};
|
|
18
17
|
|
|
@@ -43,12 +42,12 @@ export type BuildParameters = $ReadOnly<{
|
|
|
43
42
|
export type BuildResult = {
|
|
44
43
|
fileSystem: FileSystem,
|
|
45
44
|
hasteMap: HasteMap,
|
|
46
|
-
mockMap: MockMap,
|
|
45
|
+
mockMap: ?MockMap,
|
|
47
46
|
};
|
|
48
47
|
|
|
49
48
|
export type CacheData = $ReadOnly<{
|
|
50
49
|
clocks: WatchmanClocks,
|
|
51
|
-
mocks: RawMockMap,
|
|
50
|
+
mocks: ?RawMockMap,
|
|
52
51
|
fileSystemData: mixed,
|
|
53
52
|
}>;
|
|
54
53
|
|
|
@@ -125,7 +124,7 @@ export type DuplicatesIndex = Map<string, Map<string, DuplicatesSet>>;
|
|
|
125
124
|
|
|
126
125
|
export type EventsQueue = Array<{
|
|
127
126
|
filePath: Path,
|
|
128
|
-
metadata
|
|
127
|
+
metadata: ChangeEventMetadata,
|
|
129
128
|
type: string,
|
|
130
129
|
}>;
|
|
131
130
|
|
|
@@ -272,6 +271,13 @@ export interface MockMap {
|
|
|
272
271
|
getMockModule(name: string): ?Path;
|
|
273
272
|
}
|
|
274
273
|
|
|
274
|
+
export type HasteConflict = {
|
|
275
|
+
id: string,
|
|
276
|
+
platform: string | null,
|
|
277
|
+
absolutePaths: Array<string>,
|
|
278
|
+
type: 'duplicate' | 'shadowing',
|
|
279
|
+
};
|
|
280
|
+
|
|
275
281
|
export interface HasteMap {
|
|
276
282
|
getModule(
|
|
277
283
|
name: string,
|
|
@@ -286,7 +292,7 @@ export interface HasteMap {
|
|
|
286
292
|
_supportsNativePlatform: ?boolean,
|
|
287
293
|
): ?Path;
|
|
288
294
|
|
|
289
|
-
|
|
295
|
+
computeConflicts(): Array<HasteConflict>;
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
export type HasteMapData = Map<string, HasteMapItem>;
|
|
@@ -305,22 +311,37 @@ export interface MutableFileSystem extends FileSystem {
|
|
|
305
311
|
|
|
306
312
|
export type Path = string;
|
|
307
313
|
|
|
308
|
-
export type RawMockMap =
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
map: HasteMapData,
|
|
313
|
-
};
|
|
314
|
+
export type RawMockMap = $ReadOnly<{
|
|
315
|
+
duplicates: Map<string, Set<string>>,
|
|
316
|
+
mocks: Map<string, Path>,
|
|
317
|
+
}>;
|
|
314
318
|
|
|
315
|
-
export type
|
|
316
|
-
duplicates: $ReadOnlyMap<
|
|
317
|
-
|
|
318
|
-
$ReadOnlyMap<string, $ReadOnlyMap<string, number>>,
|
|
319
|
-
>,
|
|
320
|
-
map: $ReadOnlyMap<string, HasteMapItem>,
|
|
319
|
+
export type ReadOnlyRawMockMap = $ReadOnly<{
|
|
320
|
+
duplicates: $ReadOnlyMap<string, $ReadOnlySet<string>>,
|
|
321
|
+
mocks: $ReadOnlyMap<string, Path>,
|
|
321
322
|
}>;
|
|
322
323
|
|
|
323
|
-
export
|
|
324
|
+
export interface WatcherBackend {
|
|
325
|
+
getPauseReason(): ?string;
|
|
326
|
+
onError((error: Error) => void): () => void;
|
|
327
|
+
onFileEvent((event: WatcherBackendChangeEvent) => void): () => void;
|
|
328
|
+
startWatching(): Promise<void>;
|
|
329
|
+
stopWatching(): Promise<void>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export type WatcherBackendChangeEvent =
|
|
333
|
+
| $ReadOnly<{
|
|
334
|
+
event: 'touch',
|
|
335
|
+
relativePath: string,
|
|
336
|
+
root: string,
|
|
337
|
+
metadata: ChangeEventMetadata,
|
|
338
|
+
}>
|
|
339
|
+
| $ReadOnly<{
|
|
340
|
+
event: 'delete',
|
|
341
|
+
relativePath: string,
|
|
342
|
+
root: string,
|
|
343
|
+
metadata?: void,
|
|
344
|
+
}>;
|
|
324
345
|
|
|
325
346
|
export type WatchmanClockSpec =
|
|
326
347
|
| string
|
|
@@ -332,7 +353,6 @@ export type WorkerMessage = $ReadOnly<{
|
|
|
332
353
|
computeSha1: boolean,
|
|
333
354
|
dependencyExtractor?: ?string,
|
|
334
355
|
enableHastePackages: boolean,
|
|
335
|
-
readLink: boolean,
|
|
336
356
|
rootDir: string,
|
|
337
357
|
filePath: string,
|
|
338
358
|
hasteImplModulePath?: ?string,
|
|
@@ -343,5 +363,4 @@ export type WorkerMetadata = $ReadOnly<{
|
|
|
343
363
|
id?: ?string,
|
|
344
364
|
module?: ?HasteMapItemMetaData,
|
|
345
365
|
sha1?: ?string,
|
|
346
|
-
symlinkTarget?: ?string,
|
|
347
366
|
}>;
|
package/src/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
Console,
|
|
18
18
|
FileData,
|
|
19
19
|
FileSystem,
|
|
20
|
+
HasteConflict,
|
|
20
21
|
HasteMapData,
|
|
21
22
|
HasteMapItem,
|
|
22
23
|
PerfLoggerFactory,
|
|
@@ -90,4 +91,7 @@ export default class FileMap extends EventEmitter {
|
|
|
90
91
|
read(): Promise<CacheData | null>;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
export class
|
|
94
|
+
export class HasteConflictsError extends Error {
|
|
95
|
+
constructor(conflicts: ReadonlyArray<HasteConflict>);
|
|
96
|
+
getDetailedMessage(pathsRelativeToRoot?: string): string;
|
|
97
|
+
}
|