metro-file-map 0.84.0 → 0.84.2
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 -1
- package/src/Watcher.d.ts +77 -0
- package/src/cache/DiskCacheManager.d.ts +49 -0
- package/src/constants.d.ts +22 -0
- package/src/crawlers/node/hasNativeFindSupport.d.ts +19 -0
- package/src/crawlers/node/index.d.ts +23 -0
- package/src/crawlers/watchman/index.d.ts +30 -0
- package/src/flow-types.d.ts +411 -0
- package/src/flow-types.js.flow +1 -1
- package/src/index.d.ts +182 -0
- package/src/index.js +10 -12
- package/src/index.js.flow +10 -15
- package/src/lib/FileProcessor.d.ts +60 -0
- package/src/lib/RootPathUtils.d.ts +30 -0
- package/src/lib/TreeFS.d.ts +166 -0
- package/src/lib/checkWatchmanCapabilities.d.ts +20 -0
- package/src/lib/normalizePathSeparatorsToPosix.d.ts +20 -0
- package/src/lib/normalizePathSeparatorsToSystem.d.ts +20 -0
- package/src/lib/rootRelativeCacheKeys.d.ts +24 -0
- package/src/lib/sorting.d.ts +23 -0
- package/src/plugins/DependencyPlugin.d.ts +63 -0
- package/src/plugins/DependencyPlugin.js +1 -1
- package/src/plugins/DependencyPlugin.js.flow +1 -1
- package/src/plugins/HastePlugin.d.ts +77 -0
- package/src/plugins/HastePlugin.js +1 -1
- package/src/plugins/HastePlugin.js.flow +1 -1
- package/src/plugins/MockPlugin.d.ts +50 -0
- package/src/plugins/MockPlugin.js +2 -2
- package/src/plugins/MockPlugin.js.flow +2 -2
- package/src/plugins/dependencies/dependencyExtractor.d.ts +1 -1
- package/src/plugins/haste/DuplicateHasteCandidatesError.d.ts +31 -0
- package/src/plugins/haste/HasteConflictsError.d.ts +23 -0
- package/src/plugins/haste/computeConflicts.d.ts +34 -0
- package/src/plugins/haste/getPlatformExtension.d.ts +21 -0
- package/src/plugins/mocks/getMockName.d.ts +20 -0
- package/src/watchers/AbstractWatcher.d.ts +41 -0
- package/src/watchers/FallbackWatcher.d.ts +28 -0
- package/src/watchers/NativeWatcher.d.ts +55 -0
- package/src/watchers/RecrawlWarning.d.ts +32 -0
- package/src/watchers/WatchmanWatcher.d.ts +34 -0
- package/src/watchers/common.d.ts +68 -0
|
@@ -64,7 +64,7 @@ export default class DependencyPlugin
|
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
bulkUpdate(delta: FileMapDelta<?ReadonlyArray<string>>): void {
|
|
68
68
|
// No-op: Worker already populated plugin data
|
|
69
69
|
// Plugin data is write-only from worker
|
|
70
70
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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<<c8bc637264c4155765c375a0f0971803>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/plugins/HastePlugin.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
|
+
Console,
|
|
20
|
+
FileMapDelta,
|
|
21
|
+
FileMapPlugin,
|
|
22
|
+
FileMapPluginInitOptions,
|
|
23
|
+
FileMapPluginWorker,
|
|
24
|
+
HasteConflict,
|
|
25
|
+
HasteMap,
|
|
26
|
+
HasteMapItemMetadata,
|
|
27
|
+
HTypeValue,
|
|
28
|
+
Path,
|
|
29
|
+
PerfLogger,
|
|
30
|
+
} from '../flow-types';
|
|
31
|
+
|
|
32
|
+
export type HasteMapOptions = Readonly<{
|
|
33
|
+
console?: null | undefined | Console;
|
|
34
|
+
enableHastePackages: boolean;
|
|
35
|
+
hasteImplModulePath: null | undefined | string;
|
|
36
|
+
perfLogger?: null | undefined | PerfLogger;
|
|
37
|
+
platforms: ReadonlySet<string>;
|
|
38
|
+
rootDir: Path;
|
|
39
|
+
failValidationOnConflicts: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
declare class HastePlugin
|
|
42
|
+
implements HasteMap, FileMapPlugin<null, string | null>
|
|
43
|
+
{
|
|
44
|
+
readonly name: 'haste';
|
|
45
|
+
constructor(options: HasteMapOptions);
|
|
46
|
+
initialize(
|
|
47
|
+
$$PARAM_0$$: FileMapPluginInitOptions<null, string | null>,
|
|
48
|
+
): Promise<void>;
|
|
49
|
+
getSerializableSnapshot(): null;
|
|
50
|
+
getModule(
|
|
51
|
+
name: string,
|
|
52
|
+
platform?: null | undefined | string,
|
|
53
|
+
supportsNativePlatform?: null | undefined | boolean,
|
|
54
|
+
type?: null | undefined | HTypeValue,
|
|
55
|
+
): null | undefined | Path;
|
|
56
|
+
getModuleNameByPath(mixedPath: Path): null | undefined | string;
|
|
57
|
+
getPackage(
|
|
58
|
+
name: string,
|
|
59
|
+
platform: null | undefined | string,
|
|
60
|
+
_supportsNativePlatform?: null | undefined | boolean,
|
|
61
|
+
): null | undefined | Path;
|
|
62
|
+
bulkUpdate(delta: FileMapDelta<null | undefined | string>): void;
|
|
63
|
+
onNewOrModifiedFile(
|
|
64
|
+
relativeFilePath: string,
|
|
65
|
+
id: null | undefined | string,
|
|
66
|
+
): void;
|
|
67
|
+
setModule(id: string, module: HasteMapItemMetadata): void;
|
|
68
|
+
onRemovedFile(
|
|
69
|
+
relativeFilePath: string,
|
|
70
|
+
moduleName: null | undefined | string,
|
|
71
|
+
): void;
|
|
72
|
+
assertValid(): void;
|
|
73
|
+
computeConflicts(): Array<HasteConflict>;
|
|
74
|
+
getCacheKey(): string;
|
|
75
|
+
getWorker(): FileMapPluginWorker;
|
|
76
|
+
}
|
|
77
|
+
export default HastePlugin;
|
|
@@ -237,7 +237,7 @@ export default class HastePlugin
|
|
|
237
237
|
);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
bulkUpdate(delta: FileMapDelta<?string>): void {
|
|
241
241
|
// Process removals first so that moves aren't treated as duplicates.
|
|
242
242
|
for (const [normalPath, maybeHasteId] of delta.removed) {
|
|
243
243
|
this.onRemovedFile(normalPath, maybeHasteId);
|
|
@@ -0,0 +1,50 @@
|
|
|
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<<81805d051693b746e75928fe6ed3dbca>>
|
|
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
|
+
FileMapDelta,
|
|
20
|
+
FileMapPlugin,
|
|
21
|
+
FileMapPluginInitOptions,
|
|
22
|
+
FileMapPluginWorker,
|
|
23
|
+
MockMap as IMockMap,
|
|
24
|
+
Path,
|
|
25
|
+
RawMockMap,
|
|
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
|
+
bulkUpdate(delta: FileMapDelta): void;
|
|
43
|
+
onNewOrModifiedFile(relativeFilePath: Path): void;
|
|
44
|
+
onRemovedFile(relativeFilePath: Path): void;
|
|
45
|
+
getSerializableSnapshot(): RawMockMap;
|
|
46
|
+
assertValid(): void;
|
|
47
|
+
getCacheKey(): string;
|
|
48
|
+
getWorker(): null | undefined | FileMapPluginWorker;
|
|
49
|
+
}
|
|
50
|
+
export default MockPlugin;
|
|
@@ -51,7 +51,7 @@ class MockPlugin {
|
|
|
51
51
|
if (pluginState != null && pluginState.version === this.#raw.version) {
|
|
52
52
|
this.#raw = pluginState;
|
|
53
53
|
} else {
|
|
54
|
-
|
|
54
|
+
this.bulkUpdate({
|
|
55
55
|
addedOrModified: [
|
|
56
56
|
...files.fileIterator({
|
|
57
57
|
includeNodeModules: false,
|
|
@@ -72,7 +72,7 @@ class MockPlugin {
|
|
|
72
72
|
(0, _normalizePathSeparatorsToSystem.default)(mockPosixRelativePath),
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
bulkUpdate(delta) {
|
|
76
76
|
for (const [relativeFilePath] of delta.removed) {
|
|
77
77
|
this.onRemovedFile(relativeFilePath);
|
|
78
78
|
}
|
|
@@ -79,7 +79,7 @@ export default class MockPlugin
|
|
|
79
79
|
this.#raw = pluginState;
|
|
80
80
|
} else {
|
|
81
81
|
// Otherwise, traverse all files to rebuild
|
|
82
|
-
|
|
82
|
+
this.bulkUpdate({
|
|
83
83
|
addedOrModified: [
|
|
84
84
|
...files.fileIterator({
|
|
85
85
|
includeNodeModules: false,
|
|
@@ -102,7 +102,7 @@ export default class MockPlugin
|
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
bulkUpdate(delta: FileMapDelta<>): void {
|
|
106
106
|
// Process removals first so that moves aren't treated as duplicates.
|
|
107
107
|
for (const [relativeFilePath] of delta.removed) {
|
|
108
108
|
this.onRemovedFile(relativeFilePath);
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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>;
|
|
@@ -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$$;
|
|
@@ -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
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,55 @@
|
|
|
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<<8239479487abff6df70ee54f9e05f352>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro-file-map/src/watchers/NativeWatcher.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {AbstractWatcher} from './AbstractWatcher';
|
|
18
|
+
/**
|
|
19
|
+
* NativeWatcher uses Node's native fs.watch API with recursive: true.
|
|
20
|
+
*
|
|
21
|
+
* Supported on macOS (and potentially Windows), because both natively have a
|
|
22
|
+
* concept of recurisve watching, via FSEvents and ReadDirectoryChangesW
|
|
23
|
+
* respectively. Notably Linux lacks this capability at the OS level.
|
|
24
|
+
*
|
|
25
|
+
* Node.js has at times supported the `recursive` option to fs.watch on Linux
|
|
26
|
+
* by walking the directory tree and creating a watcher on each directory, but
|
|
27
|
+
* this fits poorly with the synchronous `watch` API - either it must block for
|
|
28
|
+
* arbitrarily large IO, or it may drop changes after `watch` returns. See:
|
|
29
|
+
* https://github.com/nodejs/node/issues/48437
|
|
30
|
+
*
|
|
31
|
+
* Therefore, we retain a fallback to our own application-level recursive
|
|
32
|
+
* FallbackWatcher for Linux, which has async `startWatching`.
|
|
33
|
+
*
|
|
34
|
+
* On Windows, this watcher could be used in principle, but needs work around
|
|
35
|
+
* some Windows-specific edge cases handled in FallbackWatcher, like
|
|
36
|
+
* deduping file change events, ignoring directory changes, and handling EPERM.
|
|
37
|
+
*/
|
|
38
|
+
declare class NativeWatcher extends AbstractWatcher {
|
|
39
|
+
static isSupported(): boolean;
|
|
40
|
+
constructor(
|
|
41
|
+
dir: string,
|
|
42
|
+
opts: Readonly<{
|
|
43
|
+
ignored: null | undefined | RegExp;
|
|
44
|
+
globs: ReadonlyArray<string>;
|
|
45
|
+
dot: boolean;
|
|
46
|
+
}>,
|
|
47
|
+
);
|
|
48
|
+
startWatching(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* End watching.
|
|
51
|
+
*/
|
|
52
|
+
stopWatching(): Promise<void>;
|
|
53
|
+
_handleEvent(relativePath: string): void;
|
|
54
|
+
}
|
|
55
|
+
export default NativeWatcher;
|
|
@@ -0,0 +1,32 @@
|
|
|
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<<dc063c7e351d5c09a5ad65d09b5b6b2a>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/watchers/RecrawlWarning.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Originally vendored from
|
|
20
|
+
* https://github.com/amasad/sane/blob/64ff3a870c42e84f744086884bf55a4f9c22d376/src/utils/recrawl-warning-dedupe.js
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
declare class RecrawlWarning {
|
|
24
|
+
static RECRAWL_WARNINGS: Array<RecrawlWarning>;
|
|
25
|
+
static REGEXP: RegExp;
|
|
26
|
+
root: string;
|
|
27
|
+
count: number;
|
|
28
|
+
constructor(root: string, count: number);
|
|
29
|
+
static findByRoot(root: string): null | undefined | RecrawlWarning;
|
|
30
|
+
static isRecrawlWarningDupe(warningMessage: unknown): boolean;
|
|
31
|
+
}
|
|
32
|
+
export default RecrawlWarning;
|
|
@@ -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
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<b8358b8822835bcef505207f90b02c66>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/watchers/WatchmanWatcher.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 {WatcherOptions} from './common';
|
|
19
|
+
|
|
20
|
+
import {AbstractWatcher} from './AbstractWatcher';
|
|
21
|
+
/**
|
|
22
|
+
* Watches `dir`.
|
|
23
|
+
*/
|
|
24
|
+
declare class WatchmanWatcher extends AbstractWatcher {
|
|
25
|
+
readonly subscriptionName: string;
|
|
26
|
+
constructor(dir: string, opts: WatcherOptions);
|
|
27
|
+
startWatching(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Closes the watcher.
|
|
30
|
+
*/
|
|
31
|
+
stopWatching(): Promise<void>;
|
|
32
|
+
getPauseReason(): null | undefined | string;
|
|
33
|
+
}
|
|
34
|
+
export default WatchmanWatcher;
|
|
@@ -0,0 +1,68 @@
|
|
|
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<<4f8f87abcb055b965a90e994a55ed177>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro-file-map/src/watchers/common.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Originally vendored from
|
|
20
|
+
* https://github.com/amasad/sane/blob/64ff3a870c42e84f744086884bf55a4f9c22d376/src/common.js
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type {ChangeEventMetadata} from '../flow-types';
|
|
24
|
+
import type {Stats} from 'fs';
|
|
25
|
+
/**
|
|
26
|
+
* Constants
|
|
27
|
+
*/
|
|
28
|
+
export declare const DELETE_EVENT: 'delete';
|
|
29
|
+
export declare type DELETE_EVENT = typeof DELETE_EVENT;
|
|
30
|
+
export declare const TOUCH_EVENT: 'touch';
|
|
31
|
+
export declare type TOUCH_EVENT = typeof TOUCH_EVENT;
|
|
32
|
+
export declare const ALL_EVENT: 'all';
|
|
33
|
+
export declare type ALL_EVENT = typeof ALL_EVENT;
|
|
34
|
+
export type WatcherOptions = Readonly<{
|
|
35
|
+
globs: ReadonlyArray<string>;
|
|
36
|
+
dot: boolean;
|
|
37
|
+
ignored: null | undefined | RegExp;
|
|
38
|
+
watchmanDeferStates: ReadonlyArray<string>;
|
|
39
|
+
watchman?: unknown;
|
|
40
|
+
watchmanPath?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Checks a file relative path against the globs array.
|
|
44
|
+
*/
|
|
45
|
+
export declare function includedByGlob(
|
|
46
|
+
type: null | undefined | ('f' | 'l' | 'd'),
|
|
47
|
+
globs: ReadonlyArray<string>,
|
|
48
|
+
dot: boolean,
|
|
49
|
+
relativePath: string,
|
|
50
|
+
): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the given filePath matches the given RegExp, after converting
|
|
53
|
+
* (on Windows only) system separators to posix separators.
|
|
54
|
+
*
|
|
55
|
+
* Conversion to posix is for backwards compatibility with the previous
|
|
56
|
+
* anymatch matcher, which normlises all inputs[1]. This may not be consistent
|
|
57
|
+
* with other parts of metro-file-map.
|
|
58
|
+
*
|
|
59
|
+
* [1]: https://github.com/micromatch/anymatch/blob/3.1.1/index.js#L50
|
|
60
|
+
*/
|
|
61
|
+
export declare const posixPathMatchesPattern: (
|
|
62
|
+
pattern: RegExp,
|
|
63
|
+
filePath: string,
|
|
64
|
+
) => boolean;
|
|
65
|
+
export declare type posixPathMatchesPattern = typeof posixPathMatchesPattern;
|
|
66
|
+
export declare function typeFromStat(
|
|
67
|
+
stat: Stats,
|
|
68
|
+
): null | undefined | ChangeEventMetadata['type'];
|