@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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-present Devon Govett
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/lib/Cache.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { Readable } from "stream";
2
+ export interface Cache {
3
+ ensure(): Promise<void>;
4
+ has(key: string): Promise<boolean>;
5
+ get<T>(key: string): Promise<T | null | undefined>;
6
+ set(key: string, value: unknown): Promise<void>;
7
+ getStream(key: string): Readable;
8
+ setStream(key: string, stream: Readable): Promise<void>;
9
+ getBlob(key: string): Promise<Buffer>;
10
+ setBlob(key: string, contents: Buffer | string): Promise<void>;
11
+ hasLargeBlob(key: string): Promise<boolean>;
12
+ getLargeBlob(key: string): Promise<Buffer>;
13
+ setLargeBlob(key: string, contents: Buffer | string, options?: {
14
+ signal?: AbortSignal;
15
+ }): Promise<void>;
16
+ getBuffer(key: string): Promise<Buffer | null | undefined>;
17
+
18
+ /**
19
+ * In a multi-threaded environment, where there are potentially multiple Cache
20
+ * instances writing to the cache, ensure that this instance has the latest view
21
+ * of the changes that may have been written to the cache in other threads.
22
+ */
23
+ refresh(): void;
24
+ }
@@ -0,0 +1,2 @@
1
+ /** See Dependency */
2
+ export type DependencySpecifier = string;
@@ -0,0 +1,13 @@
1
+ import type { Glob } from "./Glob";
2
+ import type { FilePath } from "./FilePath";
3
+ export type GlobInvalidation = {
4
+ glob: Glob;
5
+ };
6
+ export type FileInvalidation = {
7
+ filePath: FilePath;
8
+ };
9
+ export type FileAboveInvalidation = {
10
+ fileName: string;
11
+ aboveFilePath: FilePath;
12
+ };
13
+ export type FileCreateInvalidation = FileInvalidation | GlobInvalidation | FileAboveInvalidation;
@@ -0,0 +1 @@
1
+ export type FilePath = string;
@@ -0,0 +1,91 @@
1
+ import type { FilePath } from "./FilePath";
2
+ import type { Readable, Writable } from "stream";
3
+ import type { Event, Options as WatcherOptions, AsyncSubscription } from "@parcel/watcher";
4
+ export type FileOptions = {
5
+ mode?: number;
6
+ };
7
+ export type ReaddirOptions = {
8
+ withFileTypes?: false;
9
+ } | {
10
+ withFileTypes: true;
11
+ };
12
+ export interface Stats {
13
+ dev: number;
14
+ ino: number;
15
+ mode: number;
16
+ nlink: number;
17
+ uid: number;
18
+ gid: number;
19
+ rdev: number;
20
+ size: number;
21
+ blksize: number;
22
+ blocks: number;
23
+ atimeMs: number;
24
+ mtimeMs: number;
25
+ ctimeMs: number;
26
+ birthtimeMs: number;
27
+ atime: Date;
28
+ mtime: Date;
29
+ ctime: Date;
30
+ birthtime: Date;
31
+ isFile(): boolean;
32
+ isDirectory(): boolean;
33
+ isBlockDevice(): boolean;
34
+ isCharacterDevice(): boolean;
35
+ isSymbolicLink(): boolean;
36
+ isFIFO(): boolean;
37
+ isSocket(): boolean;
38
+ }
39
+ export type Encoding = "hex" | "utf8" | "utf-8" | "ascii" | "binary" | "base64" | "ucs2" | "ucs-2" | "utf16le" | "latin1";
40
+ export interface FileSystem {
41
+ readFile(filePath: FilePath): Promise<Buffer>;
42
+ readFile(filePath: FilePath, encoding: Encoding): Promise<string>;
43
+ readFileSync(filePath: FilePath): Buffer;
44
+ readFileSync(filePath: FilePath, encoding: Encoding): string;
45
+ writeFile(filePath: FilePath, contents: Buffer | string, options: FileOptions | null | undefined): Promise<void>;
46
+ copyFile(source: FilePath, destination: FilePath, flags?: number): Promise<void>;
47
+ stat(filePath: FilePath): Promise<Stats>;
48
+ statSync(filePath: FilePath): Stats;
49
+ readdir(path: FilePath, opts?: {
50
+ withFileTypes?: false;
51
+ }): Promise<FilePath[]>;
52
+ readdir(path: FilePath, opts: {
53
+ withFileTypes: true;
54
+ }): Promise<Dirent[]>;
55
+ readdirSync(path: FilePath, opts?: {
56
+ withFileTypes?: false;
57
+ }): FilePath[];
58
+ readdirSync(path: FilePath, opts: {
59
+ withFileTypes: true;
60
+ }): Dirent[];
61
+ symlink(target: FilePath, path: FilePath): Promise<void>;
62
+ unlink(path: FilePath): Promise<void>;
63
+ realpath(path: FilePath): Promise<FilePath>;
64
+ realpathSync(path: FilePath): FilePath;
65
+ exists(path: FilePath): Promise<boolean>;
66
+ existsSync(path: FilePath): boolean;
67
+ mkdirp(path: FilePath): Promise<void>;
68
+ rimraf(path: FilePath): Promise<void>;
69
+ ncp(source: FilePath, destination: FilePath): Promise<void>;
70
+ createReadStream(path: FilePath, options?: FileOptions | null | undefined): Readable;
71
+ createWriteStream(path: FilePath, options?: FileOptions | null | undefined): Writable;
72
+ cwd(): FilePath;
73
+ chdir(dir: FilePath): void;
74
+ watch(dir: FilePath, fn: (err: Error | null | undefined, events: Array<Event>) => unknown, opts: WatcherOptions): Promise<AsyncSubscription>;
75
+ getEventsSince(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<Array<Event>>;
76
+ writeSnapshot(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<void>;
77
+ findAncestorFile(fileNames: Array<string>, fromDir: FilePath, root: FilePath): FilePath | null | undefined;
78
+ findNodeModule(moduleName: string, fromDir: FilePath): FilePath | null | undefined;
79
+ findFirstFile(filePaths: Array<FilePath>): FilePath | null | undefined;
80
+ }
81
+ // https://nodejs.org/api/fs.html#fs_class_fs_dirent
82
+ export interface Dirent {
83
+ readonly name: string;
84
+ isBlockDevice(): boolean;
85
+ isCharacterDevice(): boolean;
86
+ isDirectory(): boolean;
87
+ isFIFO(): boolean;
88
+ isFile(): boolean;
89
+ isSocket(): boolean;
90
+ isSymbolicLink(): boolean;
91
+ }
package/lib/Glob.d.ts ADDED
@@ -0,0 +1 @@
1
+ export type Glob = string;
@@ -0,0 +1,50 @@
1
+ import type { FileCreateInvalidation, PackageJSON } from "./index";
2
+ import type { SemverRange } from "./SemverRange";
3
+ import type { DependencySpecifier } from "./DependencySpecifier";
4
+ import type { FileSystem } from "./FileSystem";
5
+ import type { FilePath } from "./FilePath";
6
+ export type PackageManagerResolveResult = {
7
+ resolved: FilePath | DependencySpecifier;
8
+ pkg?: PackageJSON | null | undefined;
9
+ invalidateOnFileCreate: Array<FileCreateInvalidation>;
10
+ invalidateOnFileChange: Set<FilePath>;
11
+ type: number;
12
+ };
13
+ export type InstallOptions = {
14
+ installPeers?: boolean;
15
+ saveDev?: boolean;
16
+ packageInstaller?: PackageInstaller | null | undefined;
17
+ };
18
+ export type InstallerOptions = {
19
+ modules: Array<ModuleRequest>;
20
+ fs: FileSystem;
21
+ cwd: FilePath;
22
+ packagePath?: FilePath | null | undefined;
23
+ saveDev?: boolean;
24
+ };
25
+ export interface PackageInstaller {
26
+ install(opts: InstallerOptions): Promise<void>;
27
+ }
28
+ export type Invalidations = {
29
+ invalidateOnFileCreate: Array<FileCreateInvalidation>;
30
+ invalidateOnFileChange: Set<FilePath>;
31
+ invalidateOnStartup: boolean;
32
+ };
33
+ export interface PackageManager {
34
+ require(id: DependencySpecifier, from: FilePath, arg2: {
35
+ range?: SemverRange | null | undefined;
36
+ shouldAutoInstall?: boolean;
37
+ saveDev?: boolean;
38
+ } | null | undefined): Promise<any>;
39
+ resolve(id: DependencySpecifier, from: FilePath, arg2: {
40
+ range?: SemverRange | null | undefined;
41
+ shouldAutoInstall?: boolean;
42
+ saveDev?: boolean;
43
+ } | null | undefined): Promise<PackageManagerResolveResult>;
44
+ getInvalidations(id: DependencySpecifier, from: FilePath): Invalidations;
45
+ invalidate(id: DependencySpecifier, from: FilePath): void;
46
+ }
47
+ export type ModuleRequest = {
48
+ readonly name: string;
49
+ readonly range: SemverRange | null | undefined;
50
+ };
@@ -0,0 +1 @@
1
+ export type PackageName = string;
@@ -0,0 +1 @@
1
+ export type SemverRange = string;