@noldova/diff 0.0.0-stage → 0.0.2
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/README.md +4 -2
- package/api/index.d.ts +232 -0
- package/api/index.js +13 -0
- package/api/index.js.map +1 -0
- package/enums/merge-region-kind.js +16 -0
- package/enums/merge-region-kind.js.map +1 -0
- package/models/diff-change.js +26 -0
- package/models/diff-change.js.map +1 -0
- package/models/diff-region.js +22 -0
- package/models/diff-region.js.map +1 -0
- package/models/diff-split.js +16 -0
- package/models/diff-split.js.map +1 -0
- package/models/merge-region.js +26 -0
- package/models/merge-region.js.map +1 -0
- package/models/side-change.js +16 -0
- package/models/side-change.js.map +1 -0
- package/package.json +25 -4
- package/services/merge3.js +75 -0
- package/services/merge3.js.map +1 -0
- package/services/sequence-diff.js +220 -0
- package/services/sequence-diff.js.map +1 -0
- package/services/string-ids.js +27 -0
- package/services/string-ids.js.map +1 -0
- package/services/text-diff.js +57 -0
- package/services/text-diff.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Noldova
|
|
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/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @noldova/diff
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Line and character diffs, and a 3-way merge of line sequences, with no framework and no DOM, shaped as a CONTEXT package so it can move there.
|
|
4
|
+
`TextDiff.lines` and `TextDiff.characters` give an edit that turns the original into the modified text, as `DiffChange` spans, the shortest unless a long text's anchors or words-first pass, or a cost cap, cut it short; `Merge3.lines` splits base, ours and theirs into unchanged, one-sided, same and conflicting regions.
|
|
5
|
+
[The repository's README](https://github.com/noldova-com/diff#readme) says how to install and use it.
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* What a region of a 3-way merge holds, compared with the base.
|
|
11
|
+
*/
|
|
12
|
+
export declare enum MergeRegionKind {
|
|
13
|
+
/**
|
|
14
|
+
* Neither side changed these lines.
|
|
15
|
+
*/
|
|
16
|
+
Unchanged = "Unchanged",
|
|
17
|
+
/**
|
|
18
|
+
* Only ours changed these lines.
|
|
19
|
+
*/
|
|
20
|
+
Ours = "Ours",
|
|
21
|
+
/**
|
|
22
|
+
* Only theirs changed these lines.
|
|
23
|
+
*/
|
|
24
|
+
Theirs = "Theirs",
|
|
25
|
+
/**
|
|
26
|
+
* Both sides made the same change.
|
|
27
|
+
*/
|
|
28
|
+
Both = "Both",
|
|
29
|
+
/**
|
|
30
|
+
* The sides changed these lines differently, or their changes touch.
|
|
31
|
+
*/
|
|
32
|
+
Conflict = "Conflict"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One change of a diff: the span `originalStart` to `originalEnd` of the original becomes the span
|
|
37
|
+
* `modifiedStart` to `modifiedEnd` of the modified sequence; either span may be empty.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { TextDiff } from "@noldova/diff";
|
|
42
|
+
*
|
|
43
|
+
* const [change] = TextDiff.lines(["a", "b"], ["a", "x"]);
|
|
44
|
+
* change.originalStart; // 1
|
|
45
|
+
* change.modifiedLength; // 1
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class DiffChange {
|
|
49
|
+
/**
|
|
50
|
+
* Where the change starts in the original sequence.
|
|
51
|
+
*/
|
|
52
|
+
public readonly originalStart: number;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Where the change ends in the original sequence, exclusive.
|
|
56
|
+
*/
|
|
57
|
+
public readonly originalEnd: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Where the change starts in the modified sequence.
|
|
61
|
+
*/
|
|
62
|
+
public readonly modifiedStart: number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Where the change ends in the modified sequence, exclusive.
|
|
66
|
+
*/
|
|
67
|
+
public readonly modifiedEnd: number;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Initializes the change from its two spans. The spans are taken as given, unchecked.
|
|
71
|
+
*
|
|
72
|
+
* @param originalStart Where the change starts in the original sequence, from 0.
|
|
73
|
+
* @param originalEnd Where the change ends in the original sequence, exclusive; equal to `originalStart` when the change only adds.
|
|
74
|
+
* @param modifiedStart Where the change starts in the modified sequence, from 0.
|
|
75
|
+
* @param modifiedEnd Where the change ends in the modified sequence, exclusive; equal to `modifiedStart` when the change only removes.
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { DiffChange } from "@noldova/diff";
|
|
79
|
+
*
|
|
80
|
+
* new DiffChange(1, 2, 1, 1).originalLength; // 1
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
public constructor(originalStart: number, originalEnd: number, modifiedStart: number, modifiedEnd: number);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* How many items of the original the change removes.
|
|
87
|
+
*/
|
|
88
|
+
public get originalLength(): number;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* How many items of the modified sequence the change adds.
|
|
92
|
+
*/
|
|
93
|
+
public get modifiedLength(): number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* One region of a 3-way merge, with its span in the base, ours and theirs; the regions together cover each sequence once, in order.
|
|
98
|
+
*/
|
|
99
|
+
export declare class MergeRegion {
|
|
100
|
+
/**
|
|
101
|
+
* What the region holds.
|
|
102
|
+
*/
|
|
103
|
+
public readonly kind: MergeRegionKind;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Where the region starts in the base.
|
|
107
|
+
*/
|
|
108
|
+
public readonly baseStart: number;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Where the region ends in the base, exclusive.
|
|
112
|
+
*/
|
|
113
|
+
public readonly baseEnd: number;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Where the region starts in ours.
|
|
117
|
+
*/
|
|
118
|
+
public readonly oursStart: number;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Where the region ends in ours, exclusive.
|
|
122
|
+
*/
|
|
123
|
+
public readonly oursEnd: number;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Where the region starts in theirs.
|
|
127
|
+
*/
|
|
128
|
+
public readonly theirsStart: number;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Where the region ends in theirs, exclusive.
|
|
132
|
+
*/
|
|
133
|
+
public readonly theirsEnd: number;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Initializes the region from its kind and its three spans. The spans are taken as given, unchecked.
|
|
137
|
+
*
|
|
138
|
+
* @param kind What the region holds.
|
|
139
|
+
* @param baseStart Where the region starts in the base, from 0.
|
|
140
|
+
* @param baseEnd Where the region ends in the base, exclusive; equal to `baseStart` when the region holds no base lines.
|
|
141
|
+
* @param oursStart Where the region starts in ours, from 0.
|
|
142
|
+
* @param oursEnd Where the region ends in ours, exclusive; equal to `oursStart` when the region holds none of our lines.
|
|
143
|
+
* @param theirsStart Where the region starts in theirs, from 0.
|
|
144
|
+
* @param theirsEnd Where the region ends in theirs, exclusive; equal to `theirsStart` when the region holds none of their lines.
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* import { MergeRegion, MergeRegionKind } from "@noldova/diff";
|
|
148
|
+
*
|
|
149
|
+
* new MergeRegion(MergeRegionKind.Ours, 0, 1, 0, 2, 0, 1).kind; // "Ours"
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
public constructor(kind: MergeRegionKind, baseStart: number, baseEnd: number, oursStart: number, oursEnd: number, theirsStart: number, theirsEnd: number);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A 3-way merge of line sequences.
|
|
157
|
+
*/
|
|
158
|
+
export declare class Merge3 {
|
|
159
|
+
/**
|
|
160
|
+
* Splits base, ours and theirs into unchanged, one-sided, same and conflicting regions.
|
|
161
|
+
*
|
|
162
|
+
* @param base The lines both sides started from.
|
|
163
|
+
* @param ours One side's lines.
|
|
164
|
+
* @param theirs The other side's lines.
|
|
165
|
+
* @returns The regions, in order; none for three empty sequences.
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* import { Merge3, MergeRegionKind } from "@noldova/diff";
|
|
169
|
+
*
|
|
170
|
+
* const regions = Merge3.lines(["a", "b"], ["a", "X"], ["a", "Y"]);
|
|
171
|
+
* regions[1]?.kind === MergeRegionKind.Conflict; // true
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
public static lines(base: readonly string[], ours: readonly string[], theirs: readonly string[]): readonly MergeRegion[];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Diffs of lines and of characters: each turns the original into the
|
|
179
|
+
* modified text, and is the shortest edit unless a limit below cuts it short.
|
|
180
|
+
*/
|
|
181
|
+
export declare class TextDiff {
|
|
182
|
+
/**
|
|
183
|
+
* Gives an edit from one line sequence to another: the shortest, unless a region of over 2,048 lines on both sides together is first split at
|
|
184
|
+
* the lines that occur once on each side, or a search that hasn't met its other half after 256 rounds splits where it reached furthest; the
|
|
185
|
+
* changes always turn the original into the modified lines.
|
|
186
|
+
*
|
|
187
|
+
* @param original The lines before.
|
|
188
|
+
* @param modified The lines after.
|
|
189
|
+
* @returns The changes, in order and apart; none for equal sequences.
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* import { TextDiff } from "@noldova/diff";
|
|
193
|
+
*
|
|
194
|
+
* TextDiff.lines(["a", "b"], ["a", "b"]).length; // 0
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
public static lines(original: readonly string[], modified: readonly string[]): readonly DiffChange[];
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Gives an edit from one string to another, by code point, as UTF-16 offsets that never split a surrogate pair: the shortest, unless texts over
|
|
201
|
+
* 2,048 characters together are diffed by words first, then by character inside the changed words, or a search that hasn't met its other half
|
|
202
|
+
* after 256 rounds splits where it reached furthest; the changes always turn the original into the modified text.
|
|
203
|
+
*
|
|
204
|
+
* @param original The text before.
|
|
205
|
+
* @param modified The text after.
|
|
206
|
+
* @returns The changes, in order and apart.
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import { TextDiff } from "@noldova/diff";
|
|
210
|
+
*
|
|
211
|
+
* TextDiff.characters("cat", "cut")[0]?.originalStart; // 1
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
public static characters(original: string, modified: string): readonly DiffChange[];
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Gives each value the number `ids` holds for it, adding the next number for a value it doesn't hold yet.
|
|
218
|
+
*
|
|
219
|
+
* @param values The values to number.
|
|
220
|
+
* @param ids The numbers given so far, which the call extends.
|
|
221
|
+
* @returns Each value's number, in order.
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* import { TextDiff } from "@noldova/diff";
|
|
225
|
+
*
|
|
226
|
+
* const ids = new Map<string, number>();
|
|
227
|
+
* TextDiff.encode(["a", "b", "a"], ids); // Int32Array [0, 1, 0]
|
|
228
|
+
* TextDiff.encode(["b", "c"], ids); // Int32Array [1, 2], extending the same numbers
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
public static encode(values: readonly string[], ids: Map<string, number>): Int32Array;
|
|
232
|
+
}
|
package/api/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export { MergeRegionKind } from "../enums/merge-region-kind.js";
|
|
9
|
+
export { DiffChange } from "../models/diff-change.js";
|
|
10
|
+
export { MergeRegion } from "../models/merge-region.js";
|
|
11
|
+
export { Merge3 } from "../services/merge3.js";
|
|
12
|
+
export { TextDiff } from "../services/text-diff.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export var MergeRegionKind;
|
|
9
|
+
(function (MergeRegionKind) {
|
|
10
|
+
MergeRegionKind["Unchanged"] = "Unchanged";
|
|
11
|
+
MergeRegionKind["Ours"] = "Ours";
|
|
12
|
+
MergeRegionKind["Theirs"] = "Theirs";
|
|
13
|
+
MergeRegionKind["Both"] = "Both";
|
|
14
|
+
MergeRegionKind["Conflict"] = "Conflict";
|
|
15
|
+
})(MergeRegionKind || (MergeRegionKind = {}));
|
|
16
|
+
//# sourceMappingURL=merge-region-kind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-region-kind.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/enums/merge-region-kind.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,wCAAqB,CAAA;AACvB,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class DiffChange {
|
|
9
|
+
originalStart;
|
|
10
|
+
originalEnd;
|
|
11
|
+
modifiedStart;
|
|
12
|
+
modifiedEnd;
|
|
13
|
+
constructor(originalStart, originalEnd, modifiedStart, modifiedEnd) {
|
|
14
|
+
this.originalStart = originalStart;
|
|
15
|
+
this.originalEnd = originalEnd;
|
|
16
|
+
this.modifiedStart = modifiedStart;
|
|
17
|
+
this.modifiedEnd = modifiedEnd;
|
|
18
|
+
}
|
|
19
|
+
get originalLength() {
|
|
20
|
+
return this.originalEnd - this.originalStart;
|
|
21
|
+
}
|
|
22
|
+
get modifiedLength() {
|
|
23
|
+
return this.modifiedEnd - this.modifiedStart;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=diff-change.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-change.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/models/diff-change.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,UAAU;IACL,aAAa,CAAS;IACtB,WAAW,CAAS;IACpB,aAAa,CAAS;IACtB,WAAW,CAAS;IAEpC,YAAmB,aAAqB,EAAE,WAAmB,EAAE,aAAqB,EAAE,WAAmB;QACvG,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC;IAC/C,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC;IAC/C,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class DiffRegion {
|
|
9
|
+
originalStart;
|
|
10
|
+
originalEnd;
|
|
11
|
+
modifiedStart;
|
|
12
|
+
modifiedEnd;
|
|
13
|
+
canAnchor;
|
|
14
|
+
constructor(originalStart, originalEnd, modifiedStart, modifiedEnd, canAnchor) {
|
|
15
|
+
this.originalStart = originalStart;
|
|
16
|
+
this.originalEnd = originalEnd;
|
|
17
|
+
this.modifiedStart = modifiedStart;
|
|
18
|
+
this.modifiedEnd = modifiedEnd;
|
|
19
|
+
this.canAnchor = canAnchor;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=diff-region.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-region.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/models/diff-region.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,UAAU;IACL,aAAa,CAAS;IACtB,WAAW,CAAS;IACpB,aAAa,CAAS;IACtB,WAAW,CAAS;IACpB,SAAS,CAAU;IAEnC,YAAmB,aAAqB,EAAE,WAAmB,EAAE,aAAqB,EAAE,WAAmB,EAAE,SAAkB;QAC3H,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class DiffSplit {
|
|
9
|
+
original;
|
|
10
|
+
modified;
|
|
11
|
+
constructor(original, modified) {
|
|
12
|
+
this.original = original;
|
|
13
|
+
this.modified = modified;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=diff-split.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-split.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/models/diff-split.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,SAAS;IACJ,QAAQ,CAAS;IACjB,QAAQ,CAAS;IAEjC,YAAmB,QAAgB,EAAE,QAAgB;QACnD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class MergeRegion {
|
|
9
|
+
kind;
|
|
10
|
+
baseStart;
|
|
11
|
+
baseEnd;
|
|
12
|
+
oursStart;
|
|
13
|
+
oursEnd;
|
|
14
|
+
theirsStart;
|
|
15
|
+
theirsEnd;
|
|
16
|
+
constructor(kind, baseStart, baseEnd, oursStart, oursEnd, theirsStart, theirsEnd) {
|
|
17
|
+
this.kind = kind;
|
|
18
|
+
this.baseStart = baseStart;
|
|
19
|
+
this.baseEnd = baseEnd;
|
|
20
|
+
this.oursStart = oursStart;
|
|
21
|
+
this.oursEnd = oursEnd;
|
|
22
|
+
this.theirsStart = theirsStart;
|
|
23
|
+
this.theirsEnd = theirsEnd;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=merge-region.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-region.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/models/merge-region.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,WAAW;IACN,IAAI,CAAkB;IACtB,SAAS,CAAS;IAClB,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,OAAO,CAAS;IAChB,WAAW,CAAS;IACpB,SAAS,CAAS;IAElC,YAAmB,IAAqB,EAAE,SAAiB,EAAE,OAAe,EAAE,SAAiB,EAAE,OAAe,EAAE,WAAmB,EAAE,SAAiB;QACtJ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class SideChange {
|
|
9
|
+
change;
|
|
10
|
+
isOurs;
|
|
11
|
+
constructor(change, isOurs) {
|
|
12
|
+
this.change = change;
|
|
13
|
+
this.isOurs = isOurs;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=side-change.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side-change.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/models/side-change.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,UAAU;IACL,MAAM,CAAa;IACnB,MAAM,CAAU;IAEhC,YAAmB,MAAkB,EAAE,MAAe;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/diff",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Line and character diffs and a 3-way merge of line sequences, framework-free, for diff and merge views such as the code editor's.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "api/index.js",
|
|
7
|
+
"types": "api/index.d.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/noldova-com/diff.git",
|
|
12
|
+
"directory": "src/noldova.diff"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/noldova-com/diff#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/noldova-com/diff/issues"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org/"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@noldova/context.core": ">=0.0.12 <0.1.0",
|
|
24
|
+
"@noldova/context.exceptions": ">=0.0.12 <0.1.0"
|
|
25
|
+
},
|
|
26
|
+
"gitHead": "443d740a7a2c6217d2030d5c9b691ad75ceddb92"
|
|
27
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { MergeRegionKind } from "../enums/merge-region-kind.js";
|
|
10
|
+
import { MergeRegion } from "../models/merge-region.js";
|
|
11
|
+
import { SideChange } from "../models/side-change.js";
|
|
12
|
+
import { SequenceDiff } from "./sequence-diff.js";
|
|
13
|
+
import { StringIds } from "./string-ids.js";
|
|
14
|
+
export class Merge3 {
|
|
15
|
+
static lines(base, ours, theirs) {
|
|
16
|
+
const ids = new StringIds();
|
|
17
|
+
const baseIds = ids.encode(base);
|
|
18
|
+
const oursIds = ids.encode(ours);
|
|
19
|
+
const theirsIds = ids.encode(theirs);
|
|
20
|
+
const changes = [
|
|
21
|
+
...SequenceDiff.compute(baseIds, oursIds).map(t => new SideChange(t, true)),
|
|
22
|
+
...SequenceDiff.compute(baseIds, theirsIds).map(t => new SideChange(t, false))
|
|
23
|
+
].sort((a, b) => a.change.originalStart - b.change.originalStart);
|
|
24
|
+
const regions = [];
|
|
25
|
+
let basePosition = 0;
|
|
26
|
+
let oursDelta = 0;
|
|
27
|
+
let theirsDelta = 0;
|
|
28
|
+
for (const cluster of Merge3.clusters(changes)) {
|
|
29
|
+
const low = cluster.reduce((least, t) => Math.min(least, t.change.originalStart), Infinity);
|
|
30
|
+
const high = cluster.reduce((most, t) => Math.max(most, t.change.originalEnd), low);
|
|
31
|
+
if (low > basePosition)
|
|
32
|
+
regions.push(new MergeRegion(MergeRegionKind.Unchanged, basePosition, low, basePosition + oursDelta, low + oursDelta, basePosition + theirsDelta, low + theirsDelta));
|
|
33
|
+
const oursGrowth = Merge3.growth(cluster, true);
|
|
34
|
+
const theirsGrowth = Merge3.growth(cluster, false);
|
|
35
|
+
const oursStart = low + oursDelta;
|
|
36
|
+
const oursEnd = high + oursDelta + oursGrowth;
|
|
37
|
+
const theirsStart = low + theirsDelta;
|
|
38
|
+
const theirsEnd = high + theirsDelta + theirsGrowth;
|
|
39
|
+
regions.push(new MergeRegion(Merge3.kind(cluster, oursIds.subarray(oursStart, oursEnd), theirsIds.subarray(theirsStart, theirsEnd)), low, high, oursStart, oursEnd, theirsStart, theirsEnd));
|
|
40
|
+
oursDelta += oursGrowth;
|
|
41
|
+
theirsDelta += theirsGrowth;
|
|
42
|
+
basePosition = high;
|
|
43
|
+
}
|
|
44
|
+
if (basePosition < base.length)
|
|
45
|
+
regions.push(new MergeRegion(MergeRegionKind.Unchanged, basePosition, base.length, basePosition + oursDelta, base.length + oursDelta, basePosition + theirsDelta, base.length + theirsDelta));
|
|
46
|
+
return regions;
|
|
47
|
+
}
|
|
48
|
+
static clusters(changes) {
|
|
49
|
+
const clusters = [];
|
|
50
|
+
let high = -1;
|
|
51
|
+
for (const change of changes) {
|
|
52
|
+
const current = clusters.at(-1);
|
|
53
|
+
if (!Object.isUndefined(current) && change.change.originalStart <= high) {
|
|
54
|
+
current.push(change);
|
|
55
|
+
high = Math.max(high, change.change.originalEnd);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
clusters.push([change]);
|
|
59
|
+
high = change.change.originalEnd;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return clusters;
|
|
63
|
+
}
|
|
64
|
+
static growth(cluster, isOurs) {
|
|
65
|
+
return cluster.filter(t => t.isOurs === isOurs).reduce((sum, t) => sum + t.change.modifiedLength - t.change.originalLength, 0);
|
|
66
|
+
}
|
|
67
|
+
static kind(cluster, ours, theirs) {
|
|
68
|
+
if (cluster.every(t => t.isOurs))
|
|
69
|
+
return MergeRegionKind.Ours;
|
|
70
|
+
if (cluster.every(t => !t.isOurs))
|
|
71
|
+
return MergeRegionKind.Theirs;
|
|
72
|
+
return ours.length === theirs.length && ours.every((t, i) => t === theirs[i]) ? MergeRegionKind.Both : MergeRegionKind.Conflict;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceM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in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { DiffChange } from "../models/diff-change.js";
|
|
10
|
+
import { DiffRegion } from "../models/diff-region.js";
|
|
11
|
+
import { DiffSplit } from "../models/diff-split.js";
|
|
12
|
+
export class SequenceDiff {
|
|
13
|
+
static ANCHORED_LENGTH = 2048;
|
|
14
|
+
static COST_LIMIT = 256;
|
|
15
|
+
original;
|
|
16
|
+
modified;
|
|
17
|
+
changes = [];
|
|
18
|
+
originalCounts;
|
|
19
|
+
modifiedCounts;
|
|
20
|
+
originalCounted;
|
|
21
|
+
modifiedCounted;
|
|
22
|
+
modifiedPositions;
|
|
23
|
+
generation = 0;
|
|
24
|
+
constructor(original, modified) {
|
|
25
|
+
this.original = original;
|
|
26
|
+
this.modified = modified;
|
|
27
|
+
const size = Math.max(SequenceDiff.largest(original), SequenceDiff.largest(modified)) + 1;
|
|
28
|
+
this.originalCounts = new Int32Array(size);
|
|
29
|
+
this.modifiedCounts = new Int32Array(size);
|
|
30
|
+
this.originalCounted = new Int32Array(size);
|
|
31
|
+
this.modifiedCounted = new Int32Array(size);
|
|
32
|
+
this.modifiedPositions = new Int32Array(size);
|
|
33
|
+
}
|
|
34
|
+
static compute(original, modified) {
|
|
35
|
+
const diff = new SequenceDiff(original, modified);
|
|
36
|
+
const regions = [new DiffRegion(0, original.length, 0, modified.length, true)];
|
|
37
|
+
for (let region = regions.pop(); !Object.isUndefined(region); region = regions.pop()) {
|
|
38
|
+
for (const part of diff.split(region).toReversed())
|
|
39
|
+
regions.push(part);
|
|
40
|
+
}
|
|
41
|
+
return SequenceDiff.coalesce(diff.changes);
|
|
42
|
+
}
|
|
43
|
+
split(region) {
|
|
44
|
+
let aLo = region.originalStart;
|
|
45
|
+
let aHi = region.originalEnd;
|
|
46
|
+
let bLo = region.modifiedStart;
|
|
47
|
+
let bHi = region.modifiedEnd;
|
|
48
|
+
while (aLo < aHi && bLo < bHi && this.original[aLo] === this.modified[bLo]) {
|
|
49
|
+
aLo++;
|
|
50
|
+
bLo++;
|
|
51
|
+
}
|
|
52
|
+
while (aLo < aHi && bLo < bHi && this.original[aHi - 1] === this.modified[bHi - 1]) {
|
|
53
|
+
aHi--;
|
|
54
|
+
bHi--;
|
|
55
|
+
}
|
|
56
|
+
if (aLo === aHi || bLo === bHi) {
|
|
57
|
+
if (aLo !== aHi || bLo !== bHi)
|
|
58
|
+
this.changes.push(new DiffChange(aLo, aHi, bLo, bHi));
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
const anchors = region.canAnchor && aHi - aLo + bHi - bLo > SequenceDiff.ANCHORED_LENGTH ? this.anchors(aLo, aHi, bLo, bHi) : [];
|
|
62
|
+
if (anchors.length > 0) {
|
|
63
|
+
const parts = [];
|
|
64
|
+
let original = aLo;
|
|
65
|
+
let modified = bLo;
|
|
66
|
+
for (const anchor of anchors) {
|
|
67
|
+
parts.push(new DiffRegion(original, anchor.original, modified, anchor.modified, true));
|
|
68
|
+
original = anchor.original + 1;
|
|
69
|
+
modified = anchor.modified + 1;
|
|
70
|
+
}
|
|
71
|
+
parts.push(new DiffRegion(original, aHi, modified, bHi, true));
|
|
72
|
+
return parts;
|
|
73
|
+
}
|
|
74
|
+
const split = this.bisect(aLo, aHi, bLo, bHi);
|
|
75
|
+
return [new DiffRegion(aLo, split.original, bLo, split.modified, false), new DiffRegion(split.original, aHi, split.modified, bHi, false)];
|
|
76
|
+
}
|
|
77
|
+
bisect(aLo, aHi, bLo, bHi) {
|
|
78
|
+
const n = aHi - aLo;
|
|
79
|
+
const m = bHi - bLo;
|
|
80
|
+
const limit = Math.min(Math.ceil((n + m) / 2), SequenceDiff.COST_LIMIT);
|
|
81
|
+
const offset = limit;
|
|
82
|
+
const size = 2 * limit + 2;
|
|
83
|
+
const forward = new Int32Array(size).fill(-1);
|
|
84
|
+
const backward = new Int32Array(size).fill(-1);
|
|
85
|
+
forward[offset + 1] = 0;
|
|
86
|
+
backward[offset + 1] = 0;
|
|
87
|
+
const delta = n - m;
|
|
88
|
+
const checksForward = delta % 2 !== 0;
|
|
89
|
+
let forwardStart = 0;
|
|
90
|
+
let forwardEnd = 0;
|
|
91
|
+
let backwardStart = 0;
|
|
92
|
+
let backwardEnd = 0;
|
|
93
|
+
let furthest = new DiffSplit(aLo, bLo);
|
|
94
|
+
let reach = 0;
|
|
95
|
+
for (let d = 0; d <= limit; d++) {
|
|
96
|
+
for (let k = -d + forwardStart; k <= d - forwardEnd; k += 2) {
|
|
97
|
+
const index = offset + k;
|
|
98
|
+
let x = k === -d || (k !== d && SequenceDiff.at(forward, index - 1) < SequenceDiff.at(forward, index + 1))
|
|
99
|
+
? SequenceDiff.at(forward, index + 1)
|
|
100
|
+
: SequenceDiff.at(forward, index - 1) + 1;
|
|
101
|
+
let y = x - k;
|
|
102
|
+
while (x < n && y < m && this.original[aLo + x] === this.modified[bLo + y]) {
|
|
103
|
+
x++;
|
|
104
|
+
y++;
|
|
105
|
+
}
|
|
106
|
+
forward[index] = x;
|
|
107
|
+
if (x > n)
|
|
108
|
+
forwardEnd += 2;
|
|
109
|
+
else if (y > m)
|
|
110
|
+
forwardStart += 2;
|
|
111
|
+
else {
|
|
112
|
+
const other = offset + delta - k;
|
|
113
|
+
if (checksForward && other >= 0 && other < size && SequenceDiff.at(backward, other) !== -1 && x >= n - SequenceDiff.at(backward, other))
|
|
114
|
+
return new DiffSplit(aLo + x, bLo + y);
|
|
115
|
+
if (d === limit && x + y > reach) {
|
|
116
|
+
reach = x + y;
|
|
117
|
+
furthest = new DiffSplit(aLo + x, bLo + y);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
for (let k = -d + backwardStart; k <= d - backwardEnd; k += 2) {
|
|
122
|
+
const index = offset + k;
|
|
123
|
+
let x = k === -d || (k !== d && SequenceDiff.at(backward, index - 1) < SequenceDiff.at(backward, index + 1))
|
|
124
|
+
? SequenceDiff.at(backward, index + 1)
|
|
125
|
+
: SequenceDiff.at(backward, index - 1) + 1;
|
|
126
|
+
let y = x - k;
|
|
127
|
+
while (x < n && y < m && this.original[aHi - x - 1] === this.modified[bHi - y - 1]) {
|
|
128
|
+
x++;
|
|
129
|
+
y++;
|
|
130
|
+
}
|
|
131
|
+
backward[index] = x;
|
|
132
|
+
if (x > n)
|
|
133
|
+
backwardEnd += 2;
|
|
134
|
+
else if (y > m)
|
|
135
|
+
backwardStart += 2;
|
|
136
|
+
else {
|
|
137
|
+
const other = offset + delta - k;
|
|
138
|
+
if (!checksForward && other >= 0 && other < size && SequenceDiff.at(forward, other) !== -1 && SequenceDiff.at(forward, other) >= n - x)
|
|
139
|
+
return new DiffSplit(aLo + SequenceDiff.at(forward, other), bLo + SequenceDiff.at(forward, other) - (other - offset));
|
|
140
|
+
if (d === limit && x + y > reach) {
|
|
141
|
+
reach = x + y;
|
|
142
|
+
furthest = new DiffSplit(aHi - x, bHi - y);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return furthest;
|
|
148
|
+
}
|
|
149
|
+
anchors(aLo, aHi, bLo, bHi) {
|
|
150
|
+
this.generation++;
|
|
151
|
+
const values = new Int32Array(aHi - aLo);
|
|
152
|
+
for (let index = aLo; index < aHi; index++) {
|
|
153
|
+
const value = SequenceDiff.at(this.original, index);
|
|
154
|
+
values[index - aLo] = value;
|
|
155
|
+
this.count(this.originalCounts, this.originalCounted, value);
|
|
156
|
+
}
|
|
157
|
+
for (let index = bLo; index < bHi; index++) {
|
|
158
|
+
const value = SequenceDiff.at(this.modified, index);
|
|
159
|
+
this.count(this.modifiedCounts, this.modifiedCounted, value);
|
|
160
|
+
this.modifiedPositions[value] = index;
|
|
161
|
+
}
|
|
162
|
+
const originalAnchors = [];
|
|
163
|
+
const modifiedAnchors = [];
|
|
164
|
+
values.forEach((value, index) => {
|
|
165
|
+
if (SequenceDiff.at(this.originalCounts, value) === 1 && SequenceDiff.at(this.modifiedCounted, value) === this.generation
|
|
166
|
+
&& SequenceDiff.at(this.modifiedCounts, value) === 1) {
|
|
167
|
+
originalAnchors.push(aLo + index);
|
|
168
|
+
modifiedAnchors.push(SequenceDiff.at(this.modifiedPositions, value));
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
const tails = [];
|
|
172
|
+
const previous = [];
|
|
173
|
+
modifiedAnchors.forEach((position, index) => {
|
|
174
|
+
let low = 0;
|
|
175
|
+
let high = tails.length;
|
|
176
|
+
while (low < high) {
|
|
177
|
+
const middle = (low + high) >>> 1;
|
|
178
|
+
if (SequenceDiff.at(modifiedAnchors, SequenceDiff.at(tails, middle)) < position)
|
|
179
|
+
low = middle + 1;
|
|
180
|
+
else
|
|
181
|
+
high = middle;
|
|
182
|
+
}
|
|
183
|
+
previous.push(low > 0 ? SequenceDiff.at(tails, low - 1) : -1);
|
|
184
|
+
tails[low] = index;
|
|
185
|
+
});
|
|
186
|
+
const anchors = [];
|
|
187
|
+
for (let index = tails.length > 0 ? SequenceDiff.at(tails, tails.length - 1) : -1; index >= 0; index = SequenceDiff.at(previous, index))
|
|
188
|
+
anchors.push(new DiffSplit(SequenceDiff.at(originalAnchors, index), SequenceDiff.at(modifiedAnchors, index)));
|
|
189
|
+
return anchors.reverse();
|
|
190
|
+
}
|
|
191
|
+
count(counts, counted, value) {
|
|
192
|
+
if (SequenceDiff.at(counted, value) === this.generation)
|
|
193
|
+
counts[value] = SequenceDiff.at(counts, value) + 1;
|
|
194
|
+
else {
|
|
195
|
+
counted[value] = this.generation;
|
|
196
|
+
counts[value] = 1;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
static largest(values) {
|
|
200
|
+
let largest = -1;
|
|
201
|
+
for (let index = 0; index < values.length; index++)
|
|
202
|
+
largest = Math.max(largest, SequenceDiff.at(values, index));
|
|
203
|
+
return largest;
|
|
204
|
+
}
|
|
205
|
+
static at(values, index) {
|
|
206
|
+
return Number(values[index]);
|
|
207
|
+
}
|
|
208
|
+
static coalesce(changes) {
|
|
209
|
+
const result = [];
|
|
210
|
+
for (const change of changes) {
|
|
211
|
+
const last = result.at(-1);
|
|
212
|
+
if (!Object.isUndefined(last) && last.originalEnd === change.originalStart && last.modifiedEnd === change.modifiedStart)
|
|
213
|
+
result[result.length - 1] = new DiffChange(last.originalStart, change.originalEnd, last.modifiedStart, change.modifiedEnd);
|
|
214
|
+
else
|
|
215
|
+
result.push(change);
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=sequence-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequence-diff.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/services/sequence-diff.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,OAAO,YAAY;IACf,MAAM,CAAU,eAAe,GAAW,IAAI,CAAC;IAC/C,MAAM,CAAU,UAAU,GAAW,GAAG,CAAC;IAEhC,QAAQ,CAAa;IACrB,QAAQ,CAAa;IACrB,OAAO,GAAiB,EAAE,CAAC;IAC3B,cAAc,CAAa;IAC3B,cAAc,CAAa;IAC3B,eAAe,CAAa;IAC5B,eAAe,CAAa;IAC5B,iBAAiB,CAAa;IACvC,UAAU,GAAW,CAAC,CAAC;IAE/B,YAAoB,QAAoB,EAAE,QAAoB;QAC5D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,MAAM,IAAI,GAAW,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,C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
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
export class StringIds {
|
|
10
|
+
ids;
|
|
11
|
+
constructor(ids = new Map()) {
|
|
12
|
+
this.ids = ids;
|
|
13
|
+
}
|
|
14
|
+
encode(values) {
|
|
15
|
+
const encoded = new Int32Array(values.length);
|
|
16
|
+
values.forEach((value, index) => {
|
|
17
|
+
let id = this.ids.get(value);
|
|
18
|
+
if (Object.isUndefined(id)) {
|
|
19
|
+
id = this.ids.size;
|
|
20
|
+
this.ids.set(value, id);
|
|
21
|
+
}
|
|
22
|
+
encoded[index] = id;
|
|
23
|
+
});
|
|
24
|
+
return encoded;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=string-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-ids.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/services/string-ids.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,MAAM,OAAO,SAAS;IACH,GAAG,CAAsB;IAE1C,YAAmB,GAAG,GAAwB,IAAI,GAAG,EAAkB;QACrE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,MAAyB;QACrC,MAAM,OAAO,GAAe,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC9B,IAAI,EAAE,GAAuB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACjD,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC3B,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;gBACnB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC1B,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { DiffChange } from "../models/diff-change.js";
|
|
10
|
+
import { SequenceDiff } from "./sequence-diff.js";
|
|
11
|
+
import { StringIds } from "./string-ids.js";
|
|
12
|
+
export class TextDiff {
|
|
13
|
+
static WORD_DIFF_LENGTH = 2048;
|
|
14
|
+
static WORD = /[\p{L}\p{N}_]+|[\s\S]/gu;
|
|
15
|
+
static lines(original, modified) {
|
|
16
|
+
const ids = new StringIds();
|
|
17
|
+
return SequenceDiff.compute(ids.encode(original), ids.encode(modified));
|
|
18
|
+
}
|
|
19
|
+
static characters(original, modified) {
|
|
20
|
+
if (original.length + modified.length <= TextDiff.WORD_DIFF_LENGTH)
|
|
21
|
+
return TextDiff.points(original, modified, 0, 0);
|
|
22
|
+
const originalWords = original.match(TextDiff.WORD) ?? [];
|
|
23
|
+
const modifiedWords = modified.match(TextDiff.WORD) ?? [];
|
|
24
|
+
const originalOffsets = TextDiff.offsets(originalWords);
|
|
25
|
+
const modifiedOffsets = TextDiff.offsets(modifiedWords);
|
|
26
|
+
const ids = new StringIds();
|
|
27
|
+
return SequenceDiff.compute(ids.encode(originalWords), ids.encode(modifiedWords)).flatMap(t => {
|
|
28
|
+
const originalStart = TextDiff.offsetAt(originalOffsets, t.originalStart);
|
|
29
|
+
const modifiedStart = TextDiff.offsetAt(modifiedOffsets, t.modifiedStart);
|
|
30
|
+
return TextDiff.points(original.slice(originalStart, TextDiff.offsetAt(originalOffsets, t.originalEnd)), modified.slice(modifiedStart, TextDiff.offsetAt(modifiedOffsets, t.modifiedEnd)), originalStart, modifiedStart);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
static encode(values, ids) {
|
|
34
|
+
return new StringIds(ids).encode(values);
|
|
35
|
+
}
|
|
36
|
+
static points(original, modified, originalBase, modifiedBase) {
|
|
37
|
+
const originalPoints = Array.from(original);
|
|
38
|
+
const modifiedPoints = Array.from(modified);
|
|
39
|
+
const originalOffsets = TextDiff.offsets(originalPoints);
|
|
40
|
+
const modifiedOffsets = TextDiff.offsets(modifiedPoints);
|
|
41
|
+
const ids = new StringIds();
|
|
42
|
+
return SequenceDiff.compute(ids.encode(originalPoints), ids.encode(modifiedPoints)).map(t => new DiffChange(originalBase + TextDiff.offsetAt(originalOffsets, t.originalStart), originalBase + TextDiff.offsetAt(originalOffsets, t.originalEnd), modifiedBase + TextDiff.offsetAt(modifiedOffsets, t.modifiedStart), modifiedBase + TextDiff.offsetAt(modifiedOffsets, t.modifiedEnd)));
|
|
43
|
+
}
|
|
44
|
+
static offsets(points) {
|
|
45
|
+
const offsets = [0];
|
|
46
|
+
let offset = 0;
|
|
47
|
+
for (const point of points) {
|
|
48
|
+
offset += point.length;
|
|
49
|
+
offsets.push(offset);
|
|
50
|
+
}
|
|
51
|
+
return offsets;
|
|
52
|
+
}
|
|
53
|
+
static offsetAt(offsets, index) {
|
|
54
|
+
return Number(offsets[index]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=text-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-diff.js","sourceRoot":"","sources":["../../../../src/noldova.diff/src/services/text-diff.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YA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