@expo/metro-file-map 55.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/build/Watcher.d.ts +53 -0
- package/build/Watcher.js +249 -0
- package/build/cache/DiskCacheManager.d.ts +25 -0
- package/build/cache/DiskCacheManager.js +110 -0
- package/build/constants.d.ts +23 -0
- package/build/constants.js +27 -0
- package/build/crawlers/node/fallback.d.ts +20 -0
- package/build/crawlers/node/fallback.js +148 -0
- package/build/crawlers/node/index.d.ts +10 -0
- package/build/crawlers/node/index.js +152 -0
- package/build/crawlers/watchman/index.d.ts +8 -0
- package/build/crawlers/watchman/index.js +288 -0
- package/build/crawlers/watchman/planQuery.d.ts +31 -0
- package/build/crawlers/watchman/planQuery.js +99 -0
- package/build/index.d.ts +140 -0
- package/build/index.js +836 -0
- package/build/lib/FileProcessor.d.ts +42 -0
- package/build/lib/FileProcessor.js +180 -0
- package/build/lib/FileSystemChangeAggregator.d.ts +18 -0
- package/build/lib/FileSystemChangeAggregator.js +114 -0
- package/build/lib/RootPathUtils.d.ts +24 -0
- package/build/lib/RootPathUtils.js +311 -0
- package/build/lib/TreeFS.d.ts +161 -0
- package/build/lib/TreeFS.js +1006 -0
- package/build/lib/checkWatchmanCapabilities.d.ts +9 -0
- package/build/lib/checkWatchmanCapabilities.js +50 -0
- package/build/lib/normalizePathSeparatorsToPosix.d.ts +8 -0
- package/build/lib/normalizePathSeparatorsToPosix.js +20 -0
- package/build/lib/normalizePathSeparatorsToSystem.d.ts +8 -0
- package/build/lib/normalizePathSeparatorsToSystem.js +20 -0
- package/build/lib/removeOverlappingRoots.d.ts +10 -0
- package/build/lib/removeOverlappingRoots.js +37 -0
- package/build/lib/rootRelativeCacheKeys.d.ts +11 -0
- package/build/lib/rootRelativeCacheKeys.js +56 -0
- package/build/lib/sorting.d.ts +8 -0
- package/build/lib/sorting.js +31 -0
- package/build/plugins/DependencyPlugin.d.ts +23 -0
- package/build/plugins/DependencyPlugin.js +61 -0
- package/build/plugins/FileDataPlugin.d.ts +28 -0
- package/build/plugins/FileDataPlugin.js +46 -0
- package/build/plugins/HastePlugin.d.ts +32 -0
- package/build/plugins/HastePlugin.js +358 -0
- package/build/plugins/MockPlugin.d.ts +27 -0
- package/build/plugins/MockPlugin.js +157 -0
- package/build/plugins/dependencies/dependencyExtractor.d.ts +7 -0
- package/build/plugins/dependencies/dependencyExtractor.js +66 -0
- package/build/plugins/dependencies/worker.d.ts +18 -0
- package/build/plugins/dependencies/worker.js +30 -0
- package/build/plugins/haste/DuplicateHasteCandidatesError.d.ts +14 -0
- package/build/plugins/haste/DuplicateHasteCandidatesError.js +51 -0
- package/build/plugins/haste/HasteConflictsError.d.ts +12 -0
- package/build/plugins/haste/HasteConflictsError.js +49 -0
- package/build/plugins/haste/computeConflicts.d.ts +19 -0
- package/build/plugins/haste/computeConflicts.js +74 -0
- package/build/plugins/haste/getPlatformExtension.d.ts +7 -0
- package/build/plugins/haste/getPlatformExtension.js +19 -0
- package/build/plugins/haste/worker.d.ts +16 -0
- package/build/plugins/haste/worker.js +48 -0
- package/build/plugins/mocks/getMockName.d.ts +8 -0
- package/build/plugins/mocks/getMockName.js +17 -0
- package/build/ts-declarations/fb-watchman.d.ts +20 -0
- package/build/ts-declarations/fb-watchman.js +2 -0
- package/build/types.d.ts +404 -0
- package/build/types.js +8 -0
- package/build/watchers/AbstractWatcher.d.ts +30 -0
- package/build/watchers/AbstractWatcher.js +97 -0
- package/build/watchers/FallbackWatcher.d.ts +18 -0
- package/build/watchers/FallbackWatcher.js +411 -0
- package/build/watchers/NativeWatcher.d.ts +39 -0
- package/build/watchers/NativeWatcher.js +156 -0
- package/build/watchers/RecrawlWarning.d.ts +18 -0
- package/build/watchers/RecrawlWarning.js +59 -0
- package/build/watchers/WatchmanWatcher.d.ts +22 -0
- package/build/watchers/WatchmanWatcher.js +263 -0
- package/build/watchers/common.d.ts +39 -0
- package/build/watchers/common.js +60 -0
- package/build/worker.d.ts +24 -0
- package/build/worker.js +80 -0
- package/build/workerExclusionList.d.ts +8 -0
- package/build/workerExclusionList.js +57 -0
- package/package.json +54 -0
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export default function checkWatchmanCapabilities(requiredCapabilities: readonly string[]): Promise<{
|
|
8
|
+
version: string;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.default = checkWatchmanCapabilities;
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
async function checkWatchmanCapabilities(requiredCapabilities) {
|
|
13
|
+
const execFilePromise = (0, util_1.promisify)(child_process_1.execFile);
|
|
14
|
+
let rawResponse;
|
|
15
|
+
try {
|
|
16
|
+
const result = await execFilePromise('watchman', [
|
|
17
|
+
'list-capabilities',
|
|
18
|
+
'--output-encoding=json',
|
|
19
|
+
'--no-pretty',
|
|
20
|
+
'--no-spawn', // The client can answer this, so don't spawn a server
|
|
21
|
+
]);
|
|
22
|
+
rawResponse = result.stdout;
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (e?.code === 'ENOENT') {
|
|
26
|
+
throw new Error('Watchman is not installed or not available on PATH');
|
|
27
|
+
}
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
let parsedResponse;
|
|
31
|
+
try {
|
|
32
|
+
parsedResponse = JSON.parse(rawResponse);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
throw new Error('Failed to parse response from `watchman list-capabilities`');
|
|
36
|
+
}
|
|
37
|
+
if (parsedResponse == null ||
|
|
38
|
+
typeof parsedResponse !== 'object' ||
|
|
39
|
+
typeof parsedResponse.version !== 'string' ||
|
|
40
|
+
!Array.isArray(parsedResponse.capabilities)) {
|
|
41
|
+
throw new Error('Unexpected response from `watchman list-capabilities`');
|
|
42
|
+
}
|
|
43
|
+
const version = parsedResponse.version;
|
|
44
|
+
const capabilities = new Set(parsedResponse.capabilities);
|
|
45
|
+
const missingCapabilities = requiredCapabilities.filter((requiredCapability) => !capabilities.has(requiredCapability));
|
|
46
|
+
if (missingCapabilities.length > 0) {
|
|
47
|
+
throw new Error(`The installed version of Watchman (${version}) is missing required capabilities: ${missingCapabilities.join(', ')}`);
|
|
48
|
+
}
|
|
49
|
+
return { version };
|
|
50
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
declare let normalizePathSeparatorsToPosix: (filePath: string) => string;
|
|
8
|
+
export default normalizePathSeparatorsToPosix;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
let normalizePathSeparatorsToPosix;
|
|
14
|
+
if (path_1.default.sep === '/') {
|
|
15
|
+
normalizePathSeparatorsToPosix = (filePath) => filePath;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
normalizePathSeparatorsToPosix = (filePath) => filePath.replace(/\\/g, '/');
|
|
19
|
+
}
|
|
20
|
+
exports.default = normalizePathSeparatorsToPosix;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
declare let normalizePathSeparatorsToSystem: (filePath: string) => string;
|
|
8
|
+
export default normalizePathSeparatorsToSystem;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
let normalizePathSeparatorsToSystem;
|
|
14
|
+
if (path_1.default.sep === '/') {
|
|
15
|
+
normalizePathSeparatorsToSystem = (filePath) => filePath;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
normalizePathSeparatorsToSystem = (filePath) => filePath.replace(/\//g, path_1.default.sep);
|
|
19
|
+
}
|
|
20
|
+
exports.default = normalizePathSeparatorsToSystem;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
export default function removeOverlappingRoots(roots: readonly string[]): readonly string[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @flow strict
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = removeOverlappingRoots;
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
function removeOverlappingRoots(roots) {
|
|
18
|
+
const sorted = roots
|
|
19
|
+
.map((r) => path_1.default.resolve(r))
|
|
20
|
+
.sort((a, b) => {
|
|
21
|
+
const aRoot = a + path_1.default.sep;
|
|
22
|
+
const bRoot = b + path_1.default.sep;
|
|
23
|
+
return aRoot < bRoot ? -1 : aRoot > bRoot ? 1 : 0;
|
|
24
|
+
});
|
|
25
|
+
if (sorted.length === 0) {
|
|
26
|
+
return sorted;
|
|
27
|
+
}
|
|
28
|
+
const result = [sorted[0]];
|
|
29
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
30
|
+
const rootPath = sorted[i] + path_1.default.sep;
|
|
31
|
+
const prevPath = result[result.length - 1] + path_1.default.sep;
|
|
32
|
+
if (!rootPath.startsWith(prevPath)) {
|
|
33
|
+
result.push(sorted[i]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
import type { BuildParameters } from '../types';
|
|
8
|
+
export default function rootRelativeCacheKeys(buildParameters: BuildParameters): {
|
|
9
|
+
rootDirHash: string;
|
|
10
|
+
relativeConfigHash: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.default = rootRelativeCacheKeys;
|
|
13
|
+
const crypto_1 = require("crypto");
|
|
14
|
+
const RootPathUtils_1 = require("./RootPathUtils");
|
|
15
|
+
const normalizePathSeparatorsToPosix_1 = __importDefault(require("./normalizePathSeparatorsToPosix"));
|
|
16
|
+
function rootRelativeCacheKeys(buildParameters) {
|
|
17
|
+
const { rootDir, plugins, ...otherParameters } = buildParameters;
|
|
18
|
+
const rootDirHash = (0, crypto_1.createHash)('md5')
|
|
19
|
+
.update((0, normalizePathSeparatorsToPosix_1.default)(rootDir))
|
|
20
|
+
.digest('hex');
|
|
21
|
+
const pathUtils = new RootPathUtils_1.RootPathUtils(rootDir);
|
|
22
|
+
const cacheComponents = Object.keys(otherParameters)
|
|
23
|
+
.sort()
|
|
24
|
+
.map((key) => {
|
|
25
|
+
switch (key) {
|
|
26
|
+
case 'roots':
|
|
27
|
+
return buildParameters[key].map((root) => (0, normalizePathSeparatorsToPosix_1.default)(pathUtils.absoluteToNormal(root)));
|
|
28
|
+
case 'cacheBreaker':
|
|
29
|
+
case 'extensions':
|
|
30
|
+
case 'computeSha1':
|
|
31
|
+
case 'enableSymlinks':
|
|
32
|
+
case 'retainAllFiles':
|
|
33
|
+
return buildParameters[key] ?? null;
|
|
34
|
+
case 'ignorePattern':
|
|
35
|
+
return buildParameters[key].toString();
|
|
36
|
+
case 'forceNodeFilesystemAPI':
|
|
37
|
+
return null;
|
|
38
|
+
default:
|
|
39
|
+
key;
|
|
40
|
+
throw new Error('Unrecognised key in build parameters: ' + key);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
for (const plugin of plugins) {
|
|
44
|
+
cacheComponents.push(plugin.getCacheKey());
|
|
45
|
+
}
|
|
46
|
+
// JSON.stringify is stable here because we only deal in (nested) arrays of
|
|
47
|
+
// primitives. Use a different approach if this is expanded to include
|
|
48
|
+
// objects/Sets/Maps, etc.
|
|
49
|
+
const relativeConfigHash = (0, crypto_1.createHash)('md5')
|
|
50
|
+
.update(JSON.stringify(cacheComponents))
|
|
51
|
+
.digest('hex');
|
|
52
|
+
return {
|
|
53
|
+
rootDirHash,
|
|
54
|
+
relativeConfigHash,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export declare function compareStrings(a: null | string, b: null | string): number;
|
|
8
|
+
export declare function chainComparators<T>(...comparators: ((a: T, b: T) => number)[]): (a: T, b: T) => number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.compareStrings = compareStrings;
|
|
10
|
+
exports.chainComparators = chainComparators;
|
|
11
|
+
// Utilities for working with Array.prototype.sort
|
|
12
|
+
function compareStrings(a, b) {
|
|
13
|
+
if (a == null) {
|
|
14
|
+
return b == null ? 0 : -1;
|
|
15
|
+
}
|
|
16
|
+
if (b == null) {
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
return a.localeCompare(b);
|
|
20
|
+
}
|
|
21
|
+
function chainComparators(...comparators) {
|
|
22
|
+
return (a, b) => {
|
|
23
|
+
for (const comparator of comparators) {
|
|
24
|
+
const result = comparator(a, b);
|
|
25
|
+
if (result !== 0) {
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return 0;
|
|
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
|
+
import type { Path } from '../types';
|
|
8
|
+
import FileDataPlugin from './FileDataPlugin';
|
|
9
|
+
export interface DependencyPluginOptions {
|
|
10
|
+
/** Path to custom dependency extractor module */
|
|
11
|
+
readonly dependencyExtractor: string | null;
|
|
12
|
+
/** Whether to compute dependencies (performance optimization) */
|
|
13
|
+
readonly computeDependencies: boolean;
|
|
14
|
+
}
|
|
15
|
+
export default class DependencyPlugin extends FileDataPlugin<readonly string[] | null> {
|
|
16
|
+
constructor(options: DependencyPluginOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Get the list of dependencies for a given file.
|
|
19
|
+
* @param mixedPath Absolute or project-relative path to the file
|
|
20
|
+
* @returns Array of dependency module names, or null if the file doesn't exist
|
|
21
|
+
*/
|
|
22
|
+
getDependencies(mixedPath: Path): readonly string[] | null | undefined;
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const workerExclusionList_1 = __importDefault(require("../workerExclusionList"));
|
|
13
|
+
const FileDataPlugin_1 = __importDefault(require("./FileDataPlugin"));
|
|
14
|
+
class DependencyPlugin extends FileDataPlugin_1.default {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
const { dependencyExtractor, computeDependencies } = options;
|
|
17
|
+
let cacheKey;
|
|
18
|
+
if (dependencyExtractor != null) {
|
|
19
|
+
const mod = require(dependencyExtractor);
|
|
20
|
+
const getCacheKey = mod?.getCacheKey ??
|
|
21
|
+
(mod.__esModule === true && 'default' in mod ? mod.default : mod).getCacheKey;
|
|
22
|
+
cacheKey = getCacheKey?.() ?? dependencyExtractor;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
cacheKey = 'default-dependency-extractor';
|
|
26
|
+
}
|
|
27
|
+
super({
|
|
28
|
+
name: 'dependencies',
|
|
29
|
+
cacheKey,
|
|
30
|
+
worker: {
|
|
31
|
+
modulePath: require.resolve('./dependencies/worker'),
|
|
32
|
+
setupArgs: {
|
|
33
|
+
dependencyExtractor: dependencyExtractor ?? null,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
filter: ({ normalPath, isNodeModules }) => {
|
|
37
|
+
if (!computeDependencies) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (isNodeModules) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const ext = normalPath.substr(normalPath.lastIndexOf('.'));
|
|
44
|
+
return !workerExclusionList_1.default.has(ext);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get the list of dependencies for a given file.
|
|
50
|
+
* @param mixedPath Absolute or project-relative path to the file
|
|
51
|
+
* @returns Array of dependency module names, or null if the file doesn't exist
|
|
52
|
+
*/
|
|
53
|
+
getDependencies(mixedPath) {
|
|
54
|
+
const result = this.getFileSystem().lookup(mixedPath);
|
|
55
|
+
if (result.exists && result.type === 'f') {
|
|
56
|
+
return result.pluginData ?? [];
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = DependencyPlugin;
|
|
@@ -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
|
+
import type { FileMapPlugin, FileMapPluginInitOptions, FileMapPluginWorker, ReadonlyFileSystemChanges, V8Serializable } from '../types';
|
|
8
|
+
export interface FileDataPluginOptions extends FileMapPluginWorker {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly cacheKey: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Base class for FileMap plugins that store per-file data via a worker and
|
|
14
|
+
* have no separate serializable state. Provides default no-op implementations
|
|
15
|
+
* of lifecycle methods that subclasses can override as needed.
|
|
16
|
+
*/
|
|
17
|
+
export default class FileDataPlugin<PerFileData extends undefined | V8Serializable = undefined | V8Serializable> implements FileMapPlugin<null, PerFileData> {
|
|
18
|
+
#private;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
constructor({ name, worker, filter, cacheKey }: FileDataPluginOptions);
|
|
21
|
+
initialize(initOptions: FileMapPluginInitOptions<null, PerFileData>): Promise<void>;
|
|
22
|
+
getFileSystem(): FileMapPluginInitOptions<null, PerFileData>['files'];
|
|
23
|
+
onChanged(_changes: ReadonlyFileSystemChanges<PerFileData | undefined | null>): void;
|
|
24
|
+
assertValid(): void;
|
|
25
|
+
getSerializableSnapshot(): null;
|
|
26
|
+
getCacheKey(): string;
|
|
27
|
+
getWorker(): FileMapPluginWorker;
|
|
28
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
/**
|
|
10
|
+
* Base class for FileMap plugins that store per-file data via a worker and
|
|
11
|
+
* have no separate serializable state. Provides default no-op implementations
|
|
12
|
+
* of lifecycle methods that subclasses can override as needed.
|
|
13
|
+
*/
|
|
14
|
+
class FileDataPlugin {
|
|
15
|
+
name;
|
|
16
|
+
#worker;
|
|
17
|
+
#cacheKey;
|
|
18
|
+
#files;
|
|
19
|
+
constructor({ name, worker, filter, cacheKey }) {
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.#worker = { worker, filter };
|
|
22
|
+
this.#cacheKey = cacheKey;
|
|
23
|
+
}
|
|
24
|
+
async initialize(initOptions) {
|
|
25
|
+
this.#files = initOptions.files;
|
|
26
|
+
}
|
|
27
|
+
getFileSystem() {
|
|
28
|
+
const files = this.#files;
|
|
29
|
+
if (files == null) {
|
|
30
|
+
throw new Error(`${this.name} plugin has not been initialized`);
|
|
31
|
+
}
|
|
32
|
+
return files;
|
|
33
|
+
}
|
|
34
|
+
onChanged(_changes) { }
|
|
35
|
+
assertValid() { }
|
|
36
|
+
getSerializableSnapshot() {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
getCacheKey() {
|
|
40
|
+
return this.#cacheKey;
|
|
41
|
+
}
|
|
42
|
+
getWorker() {
|
|
43
|
+
return this.#worker;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = FileDataPlugin;
|
|
@@ -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
|
+
import type { Console, FileMapPlugin, FileMapPluginInitOptions, FileMapPluginWorker, HasteConflict, HasteMap, HasteMapItemMetadata, HTypeValue, Path, PerfLogger, ReadonlyFileSystemChanges } from '../types';
|
|
8
|
+
export interface HasteMapOptions {
|
|
9
|
+
readonly console?: Console | null;
|
|
10
|
+
readonly enableHastePackages: boolean;
|
|
11
|
+
readonly hasteImplModulePath: string | null;
|
|
12
|
+
readonly perfLogger?: PerfLogger | null;
|
|
13
|
+
readonly platforms: ReadonlySet<string>;
|
|
14
|
+
readonly rootDir: Path;
|
|
15
|
+
readonly failValidationOnConflicts: boolean;
|
|
16
|
+
}
|
|
17
|
+
export default class HastePlugin implements HasteMap, FileMapPlugin<null, string | null> {
|
|
18
|
+
#private;
|
|
19
|
+
readonly name: 'haste';
|
|
20
|
+
constructor(options: HasteMapOptions);
|
|
21
|
+
initialize({ files }: FileMapPluginInitOptions<null, string | null>): Promise<void>;
|
|
22
|
+
getSerializableSnapshot(): null;
|
|
23
|
+
getModule(name: string, platform?: string | undefined | null, supportsNativePlatform?: boolean | undefined | null, type?: HTypeValue | undefined | null): Path | undefined | null;
|
|
24
|
+
getModuleNameByPath(mixedPath: Path): string | undefined | null;
|
|
25
|
+
getPackage(name: string, platform: string | undefined | null, _supportsNativePlatform?: boolean | undefined | null): Path | undefined | null;
|
|
26
|
+
onChanged(delta: ReadonlyFileSystemChanges<string | null | undefined>): void;
|
|
27
|
+
setModule(id: string, module: HasteMapItemMetadata): void;
|
|
28
|
+
assertValid(): void;
|
|
29
|
+
computeConflicts(): HasteConflict[];
|
|
30
|
+
getCacheKey(): string;
|
|
31
|
+
getWorker(): FileMapPluginWorker;
|
|
32
|
+
}
|