UNPKG

4.26 kBTypeScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
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/// <reference types="node" />
8import type { Stats } from 'graceful-fs';
9import type { Config } from '@jest/types';
10import type HasteFS from './HasteFS';
11import type ModuleMap from './ModuleMap';
12declare type ValueType<T> = T extends Map<string, infer V> ? V : never;
13export declare type SerializableModuleMap = {
14 duplicates: ReadonlyArray<[string, [string, [string, [string, number]]]]>;
15 map: ReadonlyArray<[string, ValueType<ModuleMapData>]>;
16 mocks: ReadonlyArray<[string, ValueType<MockData>]>;
17 rootDir: Config.Path;
18};
19export interface IModuleMap<S = SerializableModuleMap> {
20 getModule(name: string, platform?: string | null, supportsNativePlatform?: boolean | null, type?: HTypeValue | null): Config.Path | null;
21 getPackage(name: string, platform: string | null | undefined, _supportsNativePlatform: boolean | null): Config.Path | null;
22 getMockModule(name: string): Config.Path | undefined;
23 getRawModuleMap(): RawModuleMap;
24 toJSON(): S;
25}
26export declare type HasteMapStatic<S = SerializableModuleMap> = {
27 getCacheFilePath(tmpdir: Config.Path, name: string, ...extra: Array<string>): string;
28 getModuleMapFromJSON(json: S): IModuleMap<S>;
29};
30export declare type IgnoreMatcher = (item: string) => boolean;
31export declare type WorkerMessage = {
32 computeDependencies: boolean;
33 computeSha1: boolean;
34 dependencyExtractor?: string | null;
35 rootDir: string;
36 filePath: string;
37 hasteImplModulePath?: string;
38};
39export declare type WorkerMetadata = {
40 dependencies: Array<string> | undefined | null;
41 id: string | undefined | null;
42 module: ModuleMetaData | undefined | null;
43 sha1: string | undefined | null;
44};
45export declare type CrawlerOptions = {
46 computeSha1: boolean;
47 enableSymlinks: boolean;
48 data: InternalHasteMap;
49 extensions: Array<string>;
50 forceNodeFilesystemAPI: boolean;
51 ignore: IgnoreMatcher;
52 rootDir: string;
53 roots: Array<string>;
54};
55export declare type HasteImpl = {
56 getHasteName(filePath: Config.Path): string | undefined;
57};
58export declare type FileData = Map<Config.Path, FileMetaData>;
59export declare type FileMetaData = [
60 string,
61 number,
62 number,
63 0 | 1,
64 string,
65 string | null | undefined
66];
67export declare type MockData = Map<string, Config.Path>;
68export declare type ModuleMapData = Map<string, ModuleMapItem>;
69export declare type WatchmanClockSpec = string | {
70 scm: {
71 'mergebase-with': string;
72 };
73};
74export declare type WatchmanClocks = Map<Config.Path, WatchmanClockSpec>;
75export declare type HasteRegExp = RegExp | ((str: string) => boolean);
76export declare type DuplicatesSet = Map<string, /* type */ number>;
77export declare type DuplicatesIndex = Map<string, Map<string, DuplicatesSet>>;
78export declare type InternalHasteMap = {
79 clocks: WatchmanClocks;
80 duplicates: DuplicatesIndex;
81 files: FileData;
82 map: ModuleMapData;
83 mocks: MockData;
84};
85export declare type IHasteMap = {
86 hasteFS: HasteFS;
87 moduleMap: IModuleMap;
88 __hasteMapForTest?: InternalHasteMap | null;
89};
90export declare type HasteMap = {
91 hasteFS: HasteFS;
92 moduleMap: ModuleMap;
93 __hasteMapForTest?: InternalHasteMap | null;
94};
95export declare type RawModuleMap = {
96 rootDir: Config.Path;
97 duplicates: DuplicatesIndex;
98 map: ModuleMapData;
99 mocks: MockData;
100};
101declare type ModuleMapItem = {
102 [platform: string]: ModuleMetaData;
103};
104export declare type ModuleMetaData = [Config.Path, /* type */ number];
105export declare type HType = {
106 ID: 0;
107 MTIME: 1;
108 SIZE: 2;
109 VISITED: 3;
110 DEPENDENCIES: 4;
111 SHA1: 5;
112 PATH: 0;
113 TYPE: 1;
114 MODULE: 0;
115 PACKAGE: 1;
116 GENERIC_PLATFORM: 'g';
117 NATIVE_PLATFORM: 'native';
118 DEPENDENCY_DELIM: '\0';
119};
120export declare type HTypeValue = HType[keyof HType];
121export declare type EventsQueue = Array<{
122 filePath: Config.Path;
123 stat: Stats | undefined;
124 type: string;
125}>;
126export declare type ChangeEvent = {
127 eventsQueue: EventsQueue;
128 hasteFS: HasteFS;
129 moduleMap: ModuleMap;
130};
131export {};
132
\No newline at end of file