UNPKG

1.75 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Observable } from 'rxjs';
9import { Path, PathFragment } from '../path';
10export type FileBuffer = ArrayBuffer;
11export type FileBufferLike = ArrayBufferLike;
12export interface HostWatchOptions {
13 readonly persistent?: boolean;
14 readonly recursive?: boolean;
15}
16export declare const enum HostWatchEventType {
17 Changed = 0,
18 Created = 1,
19 Deleted = 2,
20 Renamed = 3
21}
22export type Stats<T extends object = {}> = T & {
23 isFile(): boolean;
24 isDirectory(): boolean;
25 readonly size: number;
26 readonly atime: Date;
27 readonly mtime: Date;
28 readonly ctime: Date;
29 readonly birthtime: Date;
30};
31export interface HostWatchEvent {
32 readonly time: Date;
33 readonly type: HostWatchEventType;
34 readonly path: Path;
35}
36export interface HostCapabilities {
37 synchronous: boolean;
38}
39export interface ReadonlyHost<StatsT extends object = {}> {
40 readonly capabilities: HostCapabilities;
41 read(path: Path): Observable<FileBuffer>;
42 list(path: Path): Observable<PathFragment[]>;
43 exists(path: Path): Observable<boolean>;
44 isDirectory(path: Path): Observable<boolean>;
45 isFile(path: Path): Observable<boolean>;
46 stat(path: Path): Observable<Stats<StatsT> | null> | null;
47}
48export interface Host<StatsT extends object = {}> extends ReadonlyHost<StatsT> {
49 write(path: Path, content: FileBufferLike): Observable<void>;
50 delete(path: Path): Observable<void>;
51 rename(from: Path, to: Path): Observable<void>;
52 watch(path: Path, options?: HostWatchOptions): Observable<HostWatchEvent> | null;
53}