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.
- package/package.json +3 -2
- package/src/Watcher.d.ts +74 -0
- package/src/Watcher.js +68 -48
- package/src/Watcher.js.flow +84 -51
- package/src/cache/DiskCacheManager.d.ts +49 -0
- package/src/cache/DiskCacheManager.js +1 -5
- package/src/constants.d.ts +22 -0
- package/src/crawlers/node/hasNativeFindSupport.d.ts +19 -0
- package/src/crawlers/node/index.d.ts +21 -0
- package/src/crawlers/node/index.js +6 -10
- package/src/crawlers/node/index.js.flow +8 -6
- package/src/crawlers/watchman/index.d.ts +23 -0
- package/src/crawlers/watchman/index.js +2 -9
- package/src/crawlers/watchman/index.js.flow +2 -6
- package/src/flow-types.d.ts +460 -0
- package/src/flow-types.js.flow +89 -29
- package/src/index.d.ts +182 -0
- package/src/index.js +148 -132
- package/src/index.js.flow +200 -155
- package/src/lib/FileProcessor.d.ts +60 -0
- package/src/lib/FileProcessor.js +1 -5
- package/src/lib/FileSystemChangeAggregator.d.ts +40 -0
- package/src/lib/FileSystemChangeAggregator.js +89 -0
- package/src/lib/FileSystemChangeAggregator.js.flow +143 -0
- package/src/lib/RootPathUtils.d.ts +30 -0
- package/src/lib/RootPathUtils.js +2 -9
- package/src/lib/TreeFS.d.ts +174 -0
- package/src/lib/TreeFS.js +68 -21
- package/src/lib/TreeFS.js.flow +89 -16
- package/src/lib/checkWatchmanCapabilities.d.ts +20 -0
- package/src/lib/normalizePathSeparatorsToPosix.d.ts +20 -0
- package/src/lib/normalizePathSeparatorsToPosix.js +1 -4
- package/src/lib/normalizePathSeparatorsToSystem.d.ts +20 -0
- package/src/lib/normalizePathSeparatorsToSystem.js +1 -4
- package/src/lib/rootRelativeCacheKeys.d.ts +24 -0
- package/src/lib/rootRelativeCacheKeys.js +1 -5
- package/src/lib/sorting.d.ts +23 -0
- package/src/plugins/DependencyPlugin.d.ts +52 -0
- package/src/plugins/DependencyPlugin.js +1 -3
- package/src/plugins/DependencyPlugin.js.flow +1 -16
- package/src/plugins/HastePlugin.d.ts +69 -0
- package/src/plugins/HastePlugin.js +12 -16
- package/src/plugins/HastePlugin.js.flow +12 -12
- package/src/plugins/MockPlugin.d.ts +48 -0
- package/src/plugins/MockPlugin.js +18 -25
- package/src/plugins/MockPlugin.js.flow +18 -22
- package/src/plugins/dependencies/dependencyExtractor.d.ts +1 -1
- package/src/plugins/haste/DuplicateHasteCandidatesError.d.ts +31 -0
- package/src/plugins/haste/DuplicateHasteCandidatesError.js +1 -5
- package/src/plugins/haste/HasteConflictsError.d.ts +23 -0
- package/src/plugins/haste/HasteConflictsError.js +1 -5
- package/src/plugins/haste/computeConflicts.d.ts +34 -0
- package/src/plugins/haste/computeConflicts.js +1 -5
- package/src/plugins/haste/getPlatformExtension.d.ts +21 -0
- package/src/plugins/mocks/getMockName.d.ts +20 -0
- package/src/plugins/mocks/getMockName.js +1 -4
- package/src/watchers/AbstractWatcher.d.ts +41 -0
- package/src/watchers/AbstractWatcher.js +2 -9
- package/src/watchers/FallbackWatcher.d.ts +28 -0
- package/src/watchers/FallbackWatcher.js +21 -12
- package/src/watchers/FallbackWatcher.js.flow +28 -5
- package/src/watchers/NativeWatcher.d.ts +55 -0
- package/src/watchers/NativeWatcher.js +28 -9
- package/src/watchers/NativeWatcher.js.flow +33 -6
- package/src/watchers/RecrawlWarning.d.ts +32 -0
- package/src/watchers/WatchmanWatcher.d.ts +34 -0
- package/src/watchers/WatchmanWatcher.js +2 -9
- package/src/watchers/common.d.ts +70 -0
- package/src/watchers/common.js +7 -6
- package/src/watchers/common.js.flow +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
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<<d9402d4670982b1e675e1edd9201cf75>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/plugins/MockPlugin.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
|
+
FileMapPlugin,
|
|
20
|
+
FileMapPluginInitOptions,
|
|
21
|
+
FileMapPluginWorker,
|
|
22
|
+
MockMap as IMockMap,
|
|
23
|
+
Path,
|
|
24
|
+
RawMockMap,
|
|
25
|
+
ReadonlyFileSystemChanges,
|
|
26
|
+
} from '../flow-types';
|
|
27
|
+
|
|
28
|
+
export declare const CACHE_VERSION: 2;
|
|
29
|
+
export declare type CACHE_VERSION = typeof CACHE_VERSION;
|
|
30
|
+
export type MockMapOptions = Readonly<{
|
|
31
|
+
console: typeof console;
|
|
32
|
+
mocksPattern: RegExp;
|
|
33
|
+
rawMockMap?: RawMockMap;
|
|
34
|
+
rootDir: Path;
|
|
35
|
+
throwOnModuleCollision: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
declare class MockPlugin implements FileMapPlugin<RawMockMap, void>, IMockMap {
|
|
38
|
+
readonly name: 'mocks';
|
|
39
|
+
constructor($$PARAM_0$$: MockMapOptions);
|
|
40
|
+
initialize($$PARAM_0$$: FileMapPluginInitOptions<RawMockMap>): Promise<void>;
|
|
41
|
+
getMockModule(name: string): null | undefined | Path;
|
|
42
|
+
onChanged(delta: ReadonlyFileSystemChanges<null | undefined | void>): void;
|
|
43
|
+
getSerializableSnapshot(): RawMockMap;
|
|
44
|
+
assertValid(): void;
|
|
45
|
+
getCacheKey(): string;
|
|
46
|
+
getWorker(): null | undefined | FileMapPluginWorker;
|
|
47
|
+
}
|
|
48
|
+
export default MockPlugin;
|
|
@@ -15,11 +15,7 @@ var _getMockName = _interopRequireDefault(require("./mocks/getMockName"));
|
|
|
15
15
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
16
16
|
var _path = _interopRequireDefault(require("path"));
|
|
17
17
|
function _interopRequireDefault(e) {
|
|
18
|
-
return e && e.__esModule
|
|
19
|
-
? e
|
|
20
|
-
: {
|
|
21
|
-
default: e,
|
|
22
|
-
};
|
|
18
|
+
return e && e.__esModule ? e : { default: e };
|
|
23
19
|
}
|
|
24
20
|
const CACHE_VERSION = (exports.CACHE_VERSION = 2);
|
|
25
21
|
class MockPlugin {
|
|
@@ -55,15 +51,12 @@ class MockPlugin {
|
|
|
55
51
|
if (pluginState != null && pluginState.version === this.#raw.version) {
|
|
56
52
|
this.#raw = pluginState;
|
|
57
53
|
} else {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
].map(({ canonicalPath }) => [canonicalPath, null]),
|
|
65
|
-
removed: [],
|
|
66
|
-
});
|
|
54
|
+
for (const { canonicalPath } of files.fileIterator({
|
|
55
|
+
includeNodeModules: false,
|
|
56
|
+
includeSymlinks: false,
|
|
57
|
+
})) {
|
|
58
|
+
this.#onFileAdded(canonicalPath);
|
|
59
|
+
}
|
|
67
60
|
}
|
|
68
61
|
}
|
|
69
62
|
getMockModule(name) {
|
|
@@ -76,22 +69,22 @@ class MockPlugin {
|
|
|
76
69
|
(0, _normalizePathSeparatorsToSystem.default)(mockPosixRelativePath),
|
|
77
70
|
);
|
|
78
71
|
}
|
|
79
|
-
|
|
80
|
-
for (const [
|
|
81
|
-
this
|
|
72
|
+
onChanged(delta) {
|
|
73
|
+
for (const [canonicalPath] of delta.removedFiles) {
|
|
74
|
+
this.#onFileRemoved(canonicalPath);
|
|
82
75
|
}
|
|
83
|
-
for (const [
|
|
84
|
-
this
|
|
76
|
+
for (const [canonicalPath] of delta.addedFiles) {
|
|
77
|
+
this.#onFileAdded(canonicalPath);
|
|
85
78
|
}
|
|
86
79
|
}
|
|
87
|
-
|
|
88
|
-
const absoluteFilePath = this.#pathUtils.normalToAbsolute(
|
|
80
|
+
#onFileAdded(canonicalPath) {
|
|
81
|
+
const absoluteFilePath = this.#pathUtils.normalToAbsolute(canonicalPath);
|
|
89
82
|
if (!this.#mocksPattern.test(absoluteFilePath)) {
|
|
90
83
|
return;
|
|
91
84
|
}
|
|
92
85
|
const mockName = (0, _getMockName.default)(absoluteFilePath);
|
|
93
86
|
const posixRelativePath = (0, _normalizePathSeparatorsToPosix.default)(
|
|
94
|
-
|
|
87
|
+
canonicalPath,
|
|
95
88
|
);
|
|
96
89
|
const existingMockPosixPath = this.#raw.mocks.get(mockName);
|
|
97
90
|
if (existingMockPosixPath != null) {
|
|
@@ -108,8 +101,8 @@ class MockPlugin {
|
|
|
108
101
|
}
|
|
109
102
|
this.#raw.mocks.set(mockName, posixRelativePath);
|
|
110
103
|
}
|
|
111
|
-
|
|
112
|
-
const absoluteFilePath = this.#pathUtils.normalToAbsolute(
|
|
104
|
+
#onFileRemoved(canonicalPath) {
|
|
105
|
+
const absoluteFilePath = this.#pathUtils.normalToAbsolute(canonicalPath);
|
|
113
106
|
if (!this.#mocksPattern.test(absoluteFilePath)) {
|
|
114
107
|
return;
|
|
115
108
|
}
|
|
@@ -117,7 +110,7 @@ class MockPlugin {
|
|
|
117
110
|
const duplicates = this.#raw.duplicates.get(mockName);
|
|
118
111
|
if (duplicates != null) {
|
|
119
112
|
const posixRelativePath = (0, _normalizePathSeparatorsToPosix.default)(
|
|
120
|
-
|
|
113
|
+
canonicalPath,
|
|
121
114
|
);
|
|
122
115
|
duplicates.delete(posixRelativePath);
|
|
123
116
|
if (duplicates.size === 1) {
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type {
|
|
13
|
-
FileMapDelta,
|
|
14
13
|
FileMapPlugin,
|
|
15
14
|
FileMapPluginInitOptions,
|
|
16
15
|
FileMapPluginWorker,
|
|
17
16
|
MockMap as IMockMap,
|
|
18
17
|
Path,
|
|
19
18
|
RawMockMap,
|
|
19
|
+
ReadonlyFileSystemChanges,
|
|
20
20
|
} from '../flow-types';
|
|
21
21
|
|
|
22
22
|
import normalizePathSeparatorsToPosix from '../lib/normalizePathSeparatorsToPosix';
|
|
@@ -79,15 +79,12 @@ export default class MockPlugin
|
|
|
79
79
|
this.#raw = pluginState;
|
|
80
80
|
} else {
|
|
81
81
|
// Otherwise, traverse all files to rebuild
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
].map(({canonicalPath}) => [canonicalPath, null]),
|
|
89
|
-
removed: [],
|
|
90
|
-
});
|
|
82
|
+
for (const {canonicalPath} of files.fileIterator({
|
|
83
|
+
includeNodeModules: false,
|
|
84
|
+
includeSymlinks: false,
|
|
85
|
+
})) {
|
|
86
|
+
this.#onFileAdded(canonicalPath);
|
|
87
|
+
}
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
90
|
|
|
@@ -102,24 +99,24 @@ export default class MockPlugin
|
|
|
102
99
|
);
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
|
|
102
|
+
onChanged(delta: ReadonlyFileSystemChanges<?void>): void {
|
|
106
103
|
// Process removals first so that moves aren't treated as duplicates.
|
|
107
|
-
for (const [
|
|
108
|
-
this
|
|
104
|
+
for (const [canonicalPath] of delta.removedFiles) {
|
|
105
|
+
this.#onFileRemoved(canonicalPath);
|
|
109
106
|
}
|
|
110
|
-
for (const [
|
|
111
|
-
this
|
|
107
|
+
for (const [canonicalPath] of delta.addedFiles) {
|
|
108
|
+
this.#onFileAdded(canonicalPath);
|
|
112
109
|
}
|
|
113
110
|
}
|
|
114
111
|
|
|
115
|
-
|
|
116
|
-
const absoluteFilePath = this.#pathUtils.normalToAbsolute(
|
|
112
|
+
#onFileAdded(canonicalPath: Path): void {
|
|
113
|
+
const absoluteFilePath = this.#pathUtils.normalToAbsolute(canonicalPath);
|
|
117
114
|
if (!this.#mocksPattern.test(absoluteFilePath)) {
|
|
118
115
|
return;
|
|
119
116
|
}
|
|
120
117
|
|
|
121
118
|
const mockName = getMockName(absoluteFilePath);
|
|
122
|
-
const posixRelativePath = normalizePathSeparatorsToPosix(
|
|
119
|
+
const posixRelativePath = normalizePathSeparatorsToPosix(canonicalPath);
|
|
123
120
|
|
|
124
121
|
const existingMockPosixPath = this.#raw.mocks.get(mockName);
|
|
125
122
|
if (existingMockPosixPath != null) {
|
|
@@ -141,16 +138,15 @@ export default class MockPlugin
|
|
|
141
138
|
this.#raw.mocks.set(mockName, posixRelativePath);
|
|
142
139
|
}
|
|
143
140
|
|
|
144
|
-
|
|
145
|
-
const absoluteFilePath = this.#pathUtils.normalToAbsolute(
|
|
141
|
+
#onFileRemoved(canonicalPath: Path): void {
|
|
142
|
+
const absoluteFilePath = this.#pathUtils.normalToAbsolute(canonicalPath);
|
|
146
143
|
if (!this.#mocksPattern.test(absoluteFilePath)) {
|
|
147
144
|
return;
|
|
148
145
|
}
|
|
149
146
|
const mockName = getMockName(absoluteFilePath);
|
|
150
147
|
const duplicates = this.#raw.duplicates.get(mockName);
|
|
151
148
|
if (duplicates != null) {
|
|
152
|
-
const posixRelativePath =
|
|
153
|
-
normalizePathSeparatorsToPosix(relativeFilePath);
|
|
149
|
+
const posixRelativePath = normalizePathSeparatorsToPosix(canonicalPath);
|
|
154
150
|
duplicates.delete(posixRelativePath);
|
|
155
151
|
if (duplicates.size === 1) {
|
|
156
152
|
this.#raw.duplicates.delete(mockName);
|
|
@@ -0,0 +1,31 @@
|
|
|
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<<2c991103bc4a71a81ef04de0884de576>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/plugins/haste/DuplicateHasteCandidatesError.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 {DuplicatesSet} from '../../flow-types';
|
|
19
|
+
|
|
20
|
+
export declare class DuplicateHasteCandidatesError extends Error {
|
|
21
|
+
hasteName: string;
|
|
22
|
+
platform: string | null;
|
|
23
|
+
supportsNativePlatform: boolean;
|
|
24
|
+
duplicatesSet: DuplicatesSet;
|
|
25
|
+
constructor(
|
|
26
|
+
name: string,
|
|
27
|
+
platform: string,
|
|
28
|
+
supportsNativePlatform: boolean,
|
|
29
|
+
duplicatesSet: DuplicatesSet,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -6,11 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.DuplicateHasteCandidatesError = void 0;
|
|
7
7
|
var _constants = _interopRequireDefault(require("../../constants"));
|
|
8
8
|
function _interopRequireDefault(e) {
|
|
9
|
-
return e && e.__esModule
|
|
10
|
-
? e
|
|
11
|
-
: {
|
|
12
|
-
default: e,
|
|
13
|
-
};
|
|
9
|
+
return e && e.__esModule ? e : { default: e };
|
|
14
10
|
}
|
|
15
11
|
class DuplicateHasteCandidatesError extends Error {
|
|
16
12
|
constructor(name, platform, supportsNativePlatform, duplicatesSet) {
|
|
@@ -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<<53c103ffe2115282c4d72593f47018aa>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/plugins/haste/HasteConflictsError.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 {HasteConflict} from '../../flow-types';
|
|
19
|
+
|
|
20
|
+
export declare class HasteConflictsError extends Error {
|
|
21
|
+
constructor(conflicts: ReadonlyArray<HasteConflict>);
|
|
22
|
+
getDetailedMessage(pathsRelativeToRoot: null | undefined | string): string;
|
|
23
|
+
}
|
|
@@ -6,11 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.HasteConflictsError = void 0;
|
|
7
7
|
var _path = _interopRequireDefault(require("path"));
|
|
8
8
|
function _interopRequireDefault(e) {
|
|
9
|
-
return e && e.__esModule
|
|
10
|
-
? e
|
|
11
|
-
: {
|
|
12
|
-
default: e,
|
|
13
|
-
};
|
|
9
|
+
return e && e.__esModule ? e : { default: e };
|
|
14
10
|
}
|
|
15
11
|
class HasteConflictsError extends Error {
|
|
16
12
|
#conflicts;
|
|
@@ -0,0 +1,34 @@
|
|
|
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<<f56c9fdb2fc1c692fa880c61a14ba1e3>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro-file-map/src/plugins/haste/computeConflicts.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 {HasteMapItem} from '../../flow-types';
|
|
18
|
+
|
|
19
|
+
type Conflict = {
|
|
20
|
+
id: string;
|
|
21
|
+
platform: string | null;
|
|
22
|
+
absolutePaths: Array<string>;
|
|
23
|
+
type: 'duplicate' | 'shadowing';
|
|
24
|
+
};
|
|
25
|
+
export declare function computeHasteConflicts(
|
|
26
|
+
options: Readonly<{
|
|
27
|
+
duplicates: ReadonlyMap<
|
|
28
|
+
string,
|
|
29
|
+
ReadonlyMap<string, ReadonlyMap<string, number>>
|
|
30
|
+
>;
|
|
31
|
+
map: ReadonlyMap<string, HasteMapItem>;
|
|
32
|
+
rootDir: string;
|
|
33
|
+
}>,
|
|
34
|
+
): Array<Conflict>;
|
|
@@ -8,11 +8,7 @@ var _constants = _interopRequireDefault(require("../../constants"));
|
|
|
8
8
|
var _sorting = require("../../lib/sorting");
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
function _interopRequireDefault(e) {
|
|
11
|
-
return e && e.__esModule
|
|
12
|
-
? e
|
|
13
|
-
: {
|
|
14
|
-
default: e,
|
|
15
|
-
};
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
16
12
|
}
|
|
17
13
|
function computeHasteConflicts(options) {
|
|
18
14
|
const { duplicates, map, rootDir } = options;
|
|
@@ -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
|
+
* @generated SignedSource<<3d628d7c2b6149348fcdc5782fc24bb7>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro-file-map/src/plugins/haste/getPlatformExtension.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
declare function getPlatformExtension(
|
|
18
|
+
file: string,
|
|
19
|
+
platforms: ReadonlySet<string>,
|
|
20
|
+
): null | undefined | string;
|
|
21
|
+
export default getPlatformExtension;
|
|
@@ -0,0 +1,20 @@
|
|
|
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<<1c1794b89fa69eff13b6cd80bf0ab42d>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro-file-map/src/plugins/mocks/getMockName.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: (filePath: string) => string;
|
|
18
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
19
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
20
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
|
@@ -13,10 +13,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
13
13
|
if (!t && e && e.__esModule) return e;
|
|
14
14
|
var o,
|
|
15
15
|
i,
|
|
16
|
-
f = {
|
|
17
|
-
__proto__: null,
|
|
18
|
-
default: e,
|
|
19
|
-
};
|
|
16
|
+
f = { __proto__: null, default: e };
|
|
20
17
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
21
18
|
return f;
|
|
22
19
|
if ((o = t ? n : r)) {
|
|
@@ -0,0 +1,41 @@
|
|
|
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<<ba8a5de14ca08c751a87bea6b356a670>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro-file-map/src/watchers/AbstractWatcher.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
|
+
WatcherBackend,
|
|
19
|
+
WatcherBackendChangeEvent,
|
|
20
|
+
WatcherBackendOptions,
|
|
21
|
+
} from '../flow-types';
|
|
22
|
+
|
|
23
|
+
export type Listeners = Readonly<{
|
|
24
|
+
onFileEvent: (event: WatcherBackendChangeEvent) => void;
|
|
25
|
+
onError: (error: Error) => void;
|
|
26
|
+
}>;
|
|
27
|
+
export declare class AbstractWatcher implements WatcherBackend {
|
|
28
|
+
readonly root: string;
|
|
29
|
+
readonly ignored: null | undefined | RegExp;
|
|
30
|
+
readonly globs: ReadonlyArray<string>;
|
|
31
|
+
readonly dot: boolean;
|
|
32
|
+
readonly doIgnore: (path: string) => boolean;
|
|
33
|
+
constructor(dir: string, opts: WatcherBackendOptions);
|
|
34
|
+
onFileEvent(listener: (event: WatcherBackendChangeEvent) => void): () => void;
|
|
35
|
+
onError(listener: (error: Error) => void): () => void;
|
|
36
|
+
startWatching(): Promise<void>;
|
|
37
|
+
stopWatching(): Promise<void>;
|
|
38
|
+
emitFileEvent(event: Omit<WatcherBackendChangeEvent, 'root'>): void;
|
|
39
|
+
emitError(error: Error): void;
|
|
40
|
+
getPauseReason(): null | undefined | string;
|
|
41
|
+
}
|
|
@@ -15,10 +15,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
15
15
|
if (!t && e && e.__esModule) return e;
|
|
16
16
|
var o,
|
|
17
17
|
i,
|
|
18
|
-
f = {
|
|
19
|
-
__proto__: null,
|
|
20
|
-
default: e,
|
|
21
|
-
};
|
|
18
|
+
f = { __proto__: null, default: e };
|
|
22
19
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
23
20
|
return f;
|
|
24
21
|
if ((o = t ? n : r)) {
|
|
@@ -38,11 +35,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
38
35
|
})(e, t);
|
|
39
36
|
}
|
|
40
37
|
function _interopRequireDefault(e) {
|
|
41
|
-
return e && e.__esModule
|
|
42
|
-
? e
|
|
43
|
-
: {
|
|
44
|
-
default: e,
|
|
45
|
-
};
|
|
38
|
+
return e && e.__esModule ? e : { default: e };
|
|
46
39
|
}
|
|
47
40
|
class AbstractWatcher {
|
|
48
41
|
#emitter = new _events.default();
|
|
@@ -0,0 +1,28 @@
|
|
|
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<<5152d1919d3373e4df611e0fca805e1c>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/watchers/FallbackWatcher.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {AbstractWatcher} from './AbstractWatcher';
|
|
19
|
+
|
|
20
|
+
declare class FallbackWatcher extends AbstractWatcher {
|
|
21
|
+
startWatching(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* End watching.
|
|
24
|
+
*/
|
|
25
|
+
stopWatching(): Promise<void>;
|
|
26
|
+
getPauseReason(): null | undefined | string;
|
|
27
|
+
}
|
|
28
|
+
export default FallbackWatcher;
|
|
@@ -11,11 +11,7 @@ var _os = _interopRequireDefault(require("os"));
|
|
|
11
11
|
var _path = _interopRequireDefault(require("path"));
|
|
12
12
|
var _walker = _interopRequireDefault(require("walker"));
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
|
-
return e && e.__esModule
|
|
15
|
-
? e
|
|
16
|
-
: {
|
|
17
|
-
default: e,
|
|
18
|
-
};
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
19
15
|
}
|
|
20
16
|
function _interopRequireWildcard(e, t) {
|
|
21
17
|
if ("function" == typeof WeakMap)
|
|
@@ -25,10 +21,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
25
21
|
if (!t && e && e.__esModule) return e;
|
|
26
22
|
var o,
|
|
27
23
|
i,
|
|
28
|
-
f = {
|
|
29
|
-
__proto__: null,
|
|
30
|
-
default: e,
|
|
31
|
-
};
|
|
24
|
+
f = { __proto__: null, default: e };
|
|
32
25
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
33
26
|
return f;
|
|
34
27
|
if ((o = t ? n : r)) {
|
|
@@ -106,9 +99,19 @@ class FallbackWatcher extends _AbstractWatcher.AbstractWatcher {
|
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
101
|
#unregisterDir(dirpath) {
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
const removedFiles = [];
|
|
103
|
+
for (const registeredDir of Object.keys(this.#dirRegistry)) {
|
|
104
|
+
if (
|
|
105
|
+
registeredDir === dirpath ||
|
|
106
|
+
registeredDir.startsWith(dirpath + _path.default.sep)
|
|
107
|
+
) {
|
|
108
|
+
for (const filename of Object.keys(this.#dirRegistry[registeredDir])) {
|
|
109
|
+
removedFiles.push(_path.default.join(registeredDir, filename));
|
|
110
|
+
}
|
|
111
|
+
delete this.#dirRegistry[registeredDir];
|
|
112
|
+
}
|
|
111
113
|
}
|
|
114
|
+
return removedFiles;
|
|
112
115
|
}
|
|
113
116
|
#registered(fullpath) {
|
|
114
117
|
const dir = _path.default.dirname(fullpath);
|
|
@@ -301,7 +304,13 @@ class FallbackWatcher extends _AbstractWatcher.AbstractWatcher {
|
|
|
301
304
|
return;
|
|
302
305
|
}
|
|
303
306
|
this.#unregister(fullPath);
|
|
304
|
-
this.#unregisterDir(fullPath);
|
|
307
|
+
const removedFiles = this.#unregisterDir(fullPath);
|
|
308
|
+
for (const removedFile of removedFiles) {
|
|
309
|
+
this.#emitEvent({
|
|
310
|
+
event: DELETE_EVENT,
|
|
311
|
+
relativePath: _path.default.relative(this.root, removedFile),
|
|
312
|
+
});
|
|
313
|
+
}
|
|
305
314
|
if (registered) {
|
|
306
315
|
this.#emitEvent({
|
|
307
316
|
event: DELETE_EVENT,
|
|
@@ -124,12 +124,27 @@ export default class FallbackWatcher extends AbstractWatcher {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* Removes a dir from the registry
|
|
127
|
+
* Removes a dir from the registry, returning all files that were registered
|
|
128
|
+
* under it (recursively).
|
|
128
129
|
*/
|
|
129
|
-
#unregisterDir(dirpath: string):
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
#unregisterDir(dirpath: string): Array<string> {
|
|
131
|
+
const removedFiles: Array<string> = [];
|
|
132
|
+
|
|
133
|
+
// Find and remove all entries under this directory
|
|
134
|
+
for (const registeredDir of Object.keys(this.#dirRegistry)) {
|
|
135
|
+
if (
|
|
136
|
+
registeredDir === dirpath ||
|
|
137
|
+
registeredDir.startsWith(dirpath + path.sep)
|
|
138
|
+
) {
|
|
139
|
+
// Collect all files in this directory
|
|
140
|
+
for (const filename of Object.keys(this.#dirRegistry[registeredDir])) {
|
|
141
|
+
removedFiles.push(path.join(registeredDir, filename));
|
|
142
|
+
}
|
|
143
|
+
delete this.#dirRegistry[registeredDir];
|
|
144
|
+
}
|
|
132
145
|
}
|
|
146
|
+
|
|
147
|
+
return removedFiles;
|
|
133
148
|
}
|
|
134
149
|
|
|
135
150
|
/**
|
|
@@ -350,7 +365,15 @@ export default class FallbackWatcher extends AbstractWatcher {
|
|
|
350
365
|
return;
|
|
351
366
|
}
|
|
352
367
|
this.#unregister(fullPath);
|
|
353
|
-
|
|
368
|
+
// When a directory is deleted, emit delete events for all files we
|
|
369
|
+
// knew about under that directory
|
|
370
|
+
const removedFiles = this.#unregisterDir(fullPath);
|
|
371
|
+
for (const removedFile of removedFiles) {
|
|
372
|
+
this.#emitEvent({
|
|
373
|
+
event: DELETE_EVENT,
|
|
374
|
+
relativePath: path.relative(this.root, removedFile),
|
|
375
|
+
});
|
|
376
|
+
}
|
|
354
377
|
if (registered) {
|
|
355
378
|
this.#emitEvent({event: DELETE_EVENT, relativePath});
|
|
356
379
|
}
|