UNPKG

2.05 kBTypeScriptView Raw
1export interface Host {
2 write(path: string, content: string): Promise<void>;
3 read(path: string): Promise<string>;
4}
5export declare const NodeHost: Host;
6export interface Change {
7 apply(host: Host): Promise<void>;
8 readonly path: string | null;
9 readonly order: number;
10 readonly description: string;
11}
12/**
13 * An operation that does nothing.
14 */
15export declare class NoopChange implements Change {
16 description: string;
17 order: number;
18 path: string;
19 apply(): Promise<void>;
20}
21/**
22 * An operation that mixes two or more changes, and merge them (in order).
23 * Can only apply to a single file. Use a ChangeManager to apply changes to multiple
24 * files.
25 */
26export declare class MultiChange implements Change {
27 private _path;
28 private _changes;
29 constructor(...changes: (Change[] | Change)[]);
30 appendChange(change: Change): void;
31 readonly description: string;
32 readonly order: number;
33 readonly path: string;
34 apply(host: Host): Promise<void>;
35}
36/**
37 * Will add text to the source code.
38 */
39export declare class InsertChange implements Change {
40 path: string;
41 private pos;
42 private toAdd;
43 order: number;
44 description: string;
45 constructor(path: string, pos: number, toAdd: string);
46 /**
47 * This method does not insert spaces if there is none in the original string.
48 */
49 apply(host: Host): Promise<any>;
50}
51/**
52 * Will remove text from the source code.
53 */
54export declare class RemoveChange implements Change {
55 path: string;
56 private pos;
57 private toRemove;
58 order: number;
59 description: string;
60 constructor(path: string, pos: number, toRemove: string);
61 apply(host: Host): Promise<any>;
62}
63/**
64 * Will replace text from the source code.
65 */
66export declare class ReplaceChange implements Change {
67 path: string;
68 private pos;
69 private oldText;
70 private newText;
71 order: number;
72 description: string;
73 constructor(path: string, pos: number, oldText: string, newText: string);
74 apply(host: Host): Promise<any>;
75}