@parcel/types-internal 2.12.1-canary.3182
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/LICENSE +21 -0
- package/lib/Cache.d.ts +24 -0
- package/lib/DependencySpecifier.d.ts +2 -0
- package/lib/FileCreateInvalidation.d.ts +13 -0
- package/lib/FilePath.d.ts +1 -0
- package/lib/FileSystem.d.ts +91 -0
- package/lib/Glob.d.ts +1 -0
- package/lib/PackageManager.d.ts +50 -0
- package/lib/PackageName.d.ts +1 -0
- package/lib/SemverRange.d.ts +1 -0
- package/lib/index.d.ts +2086 -0
- package/lib/unsafe.d.ts +6 -0
- package/package.json +25 -0
- package/scripts/build-ts.js +15 -0
- package/scripts/build-ts.sh +11 -0
- package/src/Cache.js +28 -0
- package/src/DependencySpecifier.js +4 -0
- package/src/FileCreateInvalidation.js +22 -0
- package/src/FilePath.js +3 -0
- package/src/FileSystem.js +127 -0
- package/src/Glob.js +3 -0
- package/src/PackageManager.js +60 -0
- package/src/PackageName.js +3 -0
- package/src/SemverRange.js +3 -0
- package/src/index.js +2096 -0
- package/src/unsafe.js +9 -0
package/lib/unsafe.d.ts
ADDED
package/package.json
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"name": "@parcel/types-internal",
|
3
|
+
"version": "2.12.1-canary.3182+2df56ed28",
|
4
|
+
"license": "MIT",
|
5
|
+
"main": "src/index.js",
|
6
|
+
"types": "lib/index.d.ts",
|
7
|
+
"repository": {
|
8
|
+
"type": "git",
|
9
|
+
"url": "https://github.com/parcel-bundler/parcel.git"
|
10
|
+
},
|
11
|
+
"publishConfig": {
|
12
|
+
"access": "public"
|
13
|
+
},
|
14
|
+
"scripts": {
|
15
|
+
"build-ts": "./scripts/build-ts.sh",
|
16
|
+
"check-ts": "tsc --noEmit lib/index.d.ts"
|
17
|
+
},
|
18
|
+
"dependencies": {
|
19
|
+
"@parcel/diagnostic": "2.0.0-canary.1559+2df56ed28",
|
20
|
+
"@parcel/feature-flags": "2.12.1-canary.3182+2df56ed28",
|
21
|
+
"@parcel/source-map": "^2.1.1",
|
22
|
+
"utility-types": "^3.10.0"
|
23
|
+
},
|
24
|
+
"gitHead": "2df56ed286ae41610d5ed9d439c37d6cd02c8ead"
|
25
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const fs = require('fs');
|
2
|
+
const path = require('path');
|
3
|
+
|
4
|
+
const typesPath = path.join(__dirname, '../lib/index.d.ts');
|
5
|
+
|
6
|
+
let contents = fs.readFileSync(typesPath, 'utf8');
|
7
|
+
// Some fixups of flow-to-ts output
|
8
|
+
contents = contents.replace(
|
9
|
+
'Record<string, JSONValue>',
|
10
|
+
'{[key: string]: JSONValue}',
|
11
|
+
);
|
12
|
+
contents = contents.replace(/\$ReadOnlyMap/g, 'ReadonlyMap');
|
13
|
+
contents = contents.replace(/\$ReadOnlySet/g, 'ReadonlySet');
|
14
|
+
|
15
|
+
fs.writeFileSync(typesPath, contents);
|
package/src/Cache.js
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
// @flow strict-local
|
2
|
+
|
3
|
+
import type {Readable} from 'stream';
|
4
|
+
|
5
|
+
export interface Cache {
|
6
|
+
ensure(): Promise<void>;
|
7
|
+
has(key: string): Promise<boolean>;
|
8
|
+
get<T>(key: string): Promise<?T>;
|
9
|
+
set(key: string, value: mixed): Promise<void>;
|
10
|
+
getStream(key: string): Readable;
|
11
|
+
setStream(key: string, stream: Readable): Promise<void>;
|
12
|
+
getBlob(key: string): Promise<Buffer>;
|
13
|
+
setBlob(key: string, contents: Buffer | string): Promise<void>;
|
14
|
+
hasLargeBlob(key: string): Promise<boolean>;
|
15
|
+
getLargeBlob(key: string): Promise<Buffer>;
|
16
|
+
setLargeBlob(
|
17
|
+
key: string,
|
18
|
+
contents: Buffer | string,
|
19
|
+
options?: {|signal?: AbortSignal|},
|
20
|
+
): Promise<void>;
|
21
|
+
getBuffer(key: string): Promise<?Buffer>;
|
22
|
+
/**
|
23
|
+
* In a multi-threaded environment, where there are potentially multiple Cache
|
24
|
+
* instances writing to the cache, ensure that this instance has the latest view
|
25
|
+
* of the changes that may have been written to the cache in other threads.
|
26
|
+
*/
|
27
|
+
refresh(): void;
|
28
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// @flow
|
2
|
+
|
3
|
+
import type {Glob} from './Glob';
|
4
|
+
import type {FilePath} from './FilePath';
|
5
|
+
|
6
|
+
export type GlobInvalidation = {|
|
7
|
+
glob: Glob,
|
8
|
+
|};
|
9
|
+
|
10
|
+
export type FileInvalidation = {|
|
11
|
+
filePath: FilePath,
|
12
|
+
|};
|
13
|
+
|
14
|
+
export type FileAboveInvalidation = {|
|
15
|
+
fileName: string,
|
16
|
+
aboveFilePath: FilePath,
|
17
|
+
|};
|
18
|
+
|
19
|
+
export type FileCreateInvalidation =
|
20
|
+
| FileInvalidation
|
21
|
+
| GlobInvalidation
|
22
|
+
| FileAboveInvalidation;
|
package/src/FilePath.js
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
// @flow
|
2
|
+
import type {FilePath} from './FilePath';
|
3
|
+
import type {Readable, Writable} from 'stream';
|
4
|
+
import type {
|
5
|
+
Event,
|
6
|
+
Options as WatcherOptions,
|
7
|
+
AsyncSubscription,
|
8
|
+
} from '@parcel/watcher';
|
9
|
+
|
10
|
+
export type FileOptions = {mode?: number, ...};
|
11
|
+
export type ReaddirOptions =
|
12
|
+
| {withFileTypes?: false, ...}
|
13
|
+
| {withFileTypes: true, ...};
|
14
|
+
|
15
|
+
export interface Stats {
|
16
|
+
dev: number;
|
17
|
+
ino: number;
|
18
|
+
mode: number;
|
19
|
+
nlink: number;
|
20
|
+
uid: number;
|
21
|
+
gid: number;
|
22
|
+
rdev: number;
|
23
|
+
size: number;
|
24
|
+
blksize: number;
|
25
|
+
blocks: number;
|
26
|
+
atimeMs: number;
|
27
|
+
mtimeMs: number;
|
28
|
+
ctimeMs: number;
|
29
|
+
birthtimeMs: number;
|
30
|
+
atime: Date;
|
31
|
+
mtime: Date;
|
32
|
+
ctime: Date;
|
33
|
+
birthtime: Date;
|
34
|
+
|
35
|
+
isFile(): boolean;
|
36
|
+
isDirectory(): boolean;
|
37
|
+
isBlockDevice(): boolean;
|
38
|
+
isCharacterDevice(): boolean;
|
39
|
+
isSymbolicLink(): boolean;
|
40
|
+
isFIFO(): boolean;
|
41
|
+
isSocket(): boolean;
|
42
|
+
}
|
43
|
+
|
44
|
+
export type Encoding =
|
45
|
+
| 'hex'
|
46
|
+
| 'utf8'
|
47
|
+
| 'utf-8'
|
48
|
+
| 'ascii'
|
49
|
+
| 'binary'
|
50
|
+
| 'base64'
|
51
|
+
| 'ucs2'
|
52
|
+
| 'ucs-2'
|
53
|
+
| 'utf16le'
|
54
|
+
| 'latin1';
|
55
|
+
|
56
|
+
export interface FileSystem {
|
57
|
+
readFile(filePath: FilePath): Promise<Buffer>;
|
58
|
+
readFile(filePath: FilePath, encoding: Encoding): Promise<string>;
|
59
|
+
readFileSync(filePath: FilePath): Buffer;
|
60
|
+
readFileSync(filePath: FilePath, encoding: Encoding): string;
|
61
|
+
writeFile(
|
62
|
+
filePath: FilePath,
|
63
|
+
contents: Buffer | string,
|
64
|
+
options: ?FileOptions,
|
65
|
+
): Promise<void>;
|
66
|
+
copyFile(
|
67
|
+
source: FilePath,
|
68
|
+
destination: FilePath,
|
69
|
+
flags?: number,
|
70
|
+
): Promise<void>;
|
71
|
+
stat(filePath: FilePath): Promise<Stats>;
|
72
|
+
statSync(filePath: FilePath): Stats;
|
73
|
+
readdir(
|
74
|
+
path: FilePath,
|
75
|
+
opts?: {withFileTypes?: false, ...},
|
76
|
+
): Promise<FilePath[]>;
|
77
|
+
readdir(path: FilePath, opts: {withFileTypes: true, ...}): Promise<Dirent[]>;
|
78
|
+
readdirSync(path: FilePath, opts?: {withFileTypes?: false, ...}): FilePath[];
|
79
|
+
readdirSync(path: FilePath, opts: {withFileTypes: true, ...}): Dirent[];
|
80
|
+
symlink(target: FilePath, path: FilePath): Promise<void>;
|
81
|
+
unlink(path: FilePath): Promise<void>;
|
82
|
+
realpath(path: FilePath): Promise<FilePath>;
|
83
|
+
realpathSync(path: FilePath): FilePath;
|
84
|
+
exists(path: FilePath): Promise<boolean>;
|
85
|
+
existsSync(path: FilePath): boolean;
|
86
|
+
mkdirp(path: FilePath): Promise<void>;
|
87
|
+
rimraf(path: FilePath): Promise<void>;
|
88
|
+
ncp(source: FilePath, destination: FilePath): Promise<void>;
|
89
|
+
createReadStream(path: FilePath, options?: ?FileOptions): Readable;
|
90
|
+
createWriteStream(path: FilePath, options?: ?FileOptions): Writable;
|
91
|
+
cwd(): FilePath;
|
92
|
+
chdir(dir: FilePath): void;
|
93
|
+
watch(
|
94
|
+
dir: FilePath,
|
95
|
+
fn: (err: ?Error, events: Array<Event>) => mixed,
|
96
|
+
opts: WatcherOptions,
|
97
|
+
): Promise<AsyncSubscription>;
|
98
|
+
getEventsSince(
|
99
|
+
dir: FilePath,
|
100
|
+
snapshot: FilePath,
|
101
|
+
opts: WatcherOptions,
|
102
|
+
): Promise<Array<Event>>;
|
103
|
+
writeSnapshot(
|
104
|
+
dir: FilePath,
|
105
|
+
snapshot: FilePath,
|
106
|
+
opts: WatcherOptions,
|
107
|
+
): Promise<void>;
|
108
|
+
findAncestorFile(
|
109
|
+
fileNames: Array<string>,
|
110
|
+
fromDir: FilePath,
|
111
|
+
root: FilePath,
|
112
|
+
): ?FilePath;
|
113
|
+
findNodeModule(moduleName: string, fromDir: FilePath): ?FilePath;
|
114
|
+
findFirstFile(filePaths: Array<FilePath>): ?FilePath;
|
115
|
+
}
|
116
|
+
|
117
|
+
// https://nodejs.org/api/fs.html#fs_class_fs_dirent
|
118
|
+
export interface Dirent {
|
119
|
+
+name: string;
|
120
|
+
isBlockDevice(): boolean;
|
121
|
+
isCharacterDevice(): boolean;
|
122
|
+
isDirectory(): boolean;
|
123
|
+
isFIFO(): boolean;
|
124
|
+
isFile(): boolean;
|
125
|
+
isSocket(): boolean;
|
126
|
+
isSymbolicLink(): boolean;
|
127
|
+
}
|
package/src/Glob.js
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
// @flow
|
2
|
+
|
3
|
+
import type {FileCreateInvalidation, PackageJSON} from './index';
|
4
|
+
import type {SemverRange} from './SemverRange';
|
5
|
+
import type {DependencySpecifier} from './DependencySpecifier';
|
6
|
+
import type {FileSystem} from './FileSystem';
|
7
|
+
import type {FilePath} from './FilePath';
|
8
|
+
|
9
|
+
export type PackageManagerResolveResult = {|
|
10
|
+
resolved: FilePath | DependencySpecifier,
|
11
|
+
pkg?: ?PackageJSON,
|
12
|
+
invalidateOnFileCreate: Array<FileCreateInvalidation>,
|
13
|
+
invalidateOnFileChange: Set<FilePath>,
|
14
|
+
type: number,
|
15
|
+
|};
|
16
|
+
|
17
|
+
export type InstallOptions = {
|
18
|
+
installPeers?: boolean,
|
19
|
+
saveDev?: boolean,
|
20
|
+
packageInstaller?: ?PackageInstaller,
|
21
|
+
...
|
22
|
+
};
|
23
|
+
|
24
|
+
export type InstallerOptions = {|
|
25
|
+
modules: Array<ModuleRequest>,
|
26
|
+
fs: FileSystem,
|
27
|
+
cwd: FilePath,
|
28
|
+
packagePath?: ?FilePath,
|
29
|
+
saveDev?: boolean,
|
30
|
+
|};
|
31
|
+
|
32
|
+
export interface PackageInstaller {
|
33
|
+
install(opts: InstallerOptions): Promise<void>;
|
34
|
+
}
|
35
|
+
|
36
|
+
export type Invalidations = {|
|
37
|
+
invalidateOnFileCreate: Array<FileCreateInvalidation>,
|
38
|
+
invalidateOnFileChange: Set<FilePath>,
|
39
|
+
invalidateOnStartup: boolean,
|
40
|
+
|};
|
41
|
+
|
42
|
+
export interface PackageManager {
|
43
|
+
require(
|
44
|
+
id: DependencySpecifier,
|
45
|
+
from: FilePath,
|
46
|
+
?{|range?: ?SemverRange, shouldAutoInstall?: boolean, saveDev?: boolean|},
|
47
|
+
): Promise<any>;
|
48
|
+
resolve(
|
49
|
+
id: DependencySpecifier,
|
50
|
+
from: FilePath,
|
51
|
+
?{|range?: ?SemverRange, shouldAutoInstall?: boolean, saveDev?: boolean|},
|
52
|
+
): Promise<PackageManagerResolveResult>;
|
53
|
+
getInvalidations(id: DependencySpecifier, from: FilePath): Invalidations;
|
54
|
+
invalidate(id: DependencySpecifier, from: FilePath): void;
|
55
|
+
}
|
56
|
+
|
57
|
+
export type ModuleRequest = {|
|
58
|
+
+name: string,
|
59
|
+
+range: ?SemverRange,
|
60
|
+
|};
|