1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import { BaseException } from '@angular-devkit/core';
|
10 | import MagicString from 'magic-string';
|
11 | import { LinkedList } from './linked-list';
|
12 | export declare class IndexOutOfBoundException extends BaseException {
|
13 | constructor(index: number, min: number, max?: number);
|
14 | }
|
15 | /** @deprecated Since v13.0 */
|
16 | export declare class ContentCannotBeRemovedException extends BaseException {
|
17 | constructor();
|
18 | }
|
19 | /**
|
20 | * A Chunk description, including left/right content that has been inserted.
|
21 | * If _left/_right is null, this means that content was deleted. If the _content is null,
|
22 | * it means the content itself was deleted.
|
23 | *
|
24 | * @see UpdateBuffer
|
25 | * @deprecated Since v13.0
|
26 | */
|
27 | export declare class Chunk {
|
28 | start: number;
|
29 | end: number;
|
30 | originalContent: Buffer;
|
31 | private _content;
|
32 | private _left;
|
33 | private _right;
|
34 | private _assertLeft;
|
35 | private _assertRight;
|
36 | next: Chunk | null;
|
37 | constructor(start: number, end: number, originalContent: Buffer);
|
38 | get length(): number;
|
39 | toString(encoding?: BufferEncoding): string;
|
40 | slice(start: number): Chunk;
|
41 | append(buffer: Buffer, essential: boolean): void;
|
42 | prepend(buffer: Buffer, essential: boolean): void;
|
43 | assert(left: boolean, _content: boolean, right: boolean): void;
|
44 | remove(left: boolean, content: boolean, right: boolean): void;
|
45 | copy(target: Buffer, start: number): number;
|
46 | }
|
47 | /**
|
48 | * Base class for an update buffer implementation that allows buffers to be inserted to the _right
|
49 | * or _left, or deleted, while keeping indices to the original buffer.
|
50 | */
|
51 | export declare abstract class UpdateBufferBase {
|
52 | protected _originalContent: Buffer;
|
53 | constructor(_originalContent: Buffer);
|
54 | abstract get length(): number;
|
55 | abstract get original(): Buffer;
|
56 | abstract toString(encoding?: string): string;
|
57 | abstract generate(): Buffer;
|
58 | abstract insertLeft(index: number, content: Buffer, assert?: boolean): void;
|
59 | abstract insertRight(index: number, content: Buffer, assert?: boolean): void;
|
60 | abstract remove(index: number, length: number): void;
|
61 | /**
|
62 | * Creates an UpdateBufferBase instance. Depending on the NG_UPDATE_BUFFER_V2
|
63 | * environment variable, will either create an UpdateBuffer or an UpdateBuffer2
|
64 | * instance.
|
65 | *
|
66 | * See: https://github.com/angular/angular-cli/issues/21110
|
67 | *
|
68 | * @param originalContent The original content of the update buffer instance.
|
69 | * @returns An UpdateBufferBase instance.
|
70 | */
|
71 | static create(originalContent: Buffer): UpdateBufferBase;
|
72 | }
|
73 | /**
|
74 | * An utility class that allows buffers to be inserted to the _right or _left, or deleted, while
|
75 | * keeping indices to the original buffer.
|
76 | *
|
77 | * The constructor takes an original buffer, and keeps it into a linked list of chunks, smaller
|
78 | * buffers that keep track of _content inserted to the _right or _left of it.
|
79 | *
|
80 | * Since the Node Buffer structure is non-destructive when slicing, we try to use slicing to create
|
81 | * new chunks, and always keep chunks pointing to the original content.
|
82 | *
|
83 | * @deprecated Since v13.0
|
84 | */
|
85 | export declare class UpdateBuffer extends UpdateBufferBase {
|
86 | protected _linkedList: LinkedList<Chunk>;
|
87 | constructor(originalContent: Buffer);
|
88 | protected _assertIndex(index: number): void;
|
89 | protected _slice(start: number): [Chunk, Chunk];
|
90 | /**
|
91 | * Gets the position in the content based on the position in the string.
|
92 | * Some characters might be wider than one byte, thus we have to determine the position using
|
93 | * string functions.
|
94 | */
|
95 | protected _getTextPosition(index: number): number;
|
96 | get length(): number;
|
97 | get original(): Buffer;
|
98 | toString(encoding?: BufferEncoding): string;
|
99 | generate(): Buffer;
|
100 | insertLeft(index: number, content: Buffer, assert?: boolean): void;
|
101 | insertRight(index: number, content: Buffer, assert?: boolean): void;
|
102 | remove(index: number, length: number): void;
|
103 | }
|
104 | /**
|
105 | * An utility class that allows buffers to be inserted to the _right or _left, or deleted, while
|
106 | * keeping indices to the original buffer.
|
107 | */
|
108 | export declare class UpdateBuffer2 extends UpdateBufferBase {
|
109 | protected _mutatableContent: MagicString;
|
110 | protected _assertIndex(index: number): void;
|
111 | get length(): number;
|
112 | get original(): Buffer;
|
113 | toString(): string;
|
114 | generate(): Buffer;
|
115 | insertLeft(index: number, content: Buffer): void;
|
116 | insertRight(index: number, content: Buffer): void;
|
117 | remove(index: number, length: number): void;
|
118 | }
|