@nldd/design-system 0.11.0 → 0.12.0
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/custom-elements.json +2188 -621
- package/dist/components/components.js +2475 -1602
- package/dist/components/content/code-viewer/code-viewer.d.ts +14 -1
- package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.diff.d.ts +40 -0
- package/dist/components/content/code-viewer/code-viewer.diff.d.ts.map +1 -0
- package/dist/components/content/code-viewer/code-viewer.diff.js +261 -0
- package/dist/components/content/code-viewer/code-viewer.diff.js.map +1 -0
- package/dist/components/content/code-viewer/code-viewer.i18n.d.ts +5 -0
- package/dist/components/content/code-viewer/code-viewer.i18n.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.i18n.js +9 -0
- package/dist/components/content/code-viewer/code-viewer.i18n.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.js +98 -6
- package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.styles.js +134 -1
- package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.template.d.ts.map +1 -1
- package/dist/components/content/code-viewer/code-viewer.template.js +5 -4
- package/dist/components/content/code-viewer/code-viewer.template.js.map +1 -1
- package/dist/components/content/icon/icon-aliases.d.ts.map +1 -1
- package/dist/components/content/icon/icon-aliases.js +13 -4
- package/dist/components/content/icon/icon-aliases.js.map +1 -1
- package/dist/components/content/icon/icon-gallery-status.d.ts.map +1 -1
- package/dist/components/content/icon/icon-gallery-status.js +9 -0
- package/dist/components/content/icon/icon-gallery-status.js.map +1 -1
- package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
- package/dist/components/content/icon/icon-registry.js +9 -2
- package/dist/components/content/icon/icon-registry.js.map +1 -1
- package/dist/components/content/rich-text/rich-text.d.ts +10 -0
- package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
- package/dist/components/content/rich-text/rich-text.js +10 -0
- package/dist/components/content/rich-text/rich-text.js.map +1 -1
- package/dist/components/{dist-Bo5Jeyfn.js → dist-B5E3q-ea.js} +2 -1
- package/dist/components/{dist-DbNhCpS5.js → dist-BFw_yEMS.js} +2 -1
- package/dist/components/{dist-DnZmcpbQ.js → dist-BNLAXAyO.js} +2 -1
- package/dist/components/{dist-DkqAbJH8.js → dist-BOVSVPSz.js} +1 -1
- package/dist/components/{dist-Ch3gNAuT.js → dist-BPB3rWnd.js} +2 -1
- package/dist/components/{dist-Bud_7w5g.js → dist-BWlUmyq3.js} +34 -2869
- package/dist/components/dist-CC8oiVtm.js +366 -0
- package/dist/components/dist-COKR0tYU.js +2860 -0
- package/dist/components/{dist-CaxHkqR2.js → dist-Co-tsc9S.js} +4 -3
- package/dist/components/{dist-iC2RTM0V.js → dist-D_9ZyZ5v.js} +3 -2
- package/dist/components/{dist-BB5mlo7D.js → dist-Dn9pjiud.js} +3 -2
- package/dist/components/{dist-B2QcygzG.js → dist-Dz28se9B.js} +2 -1
- package/dist/components/{dist-CA0yDFIt.js → dist-IPm8ilWf.js} +3 -2
- package/dist/components/{icon-zNX9A6d3.js → icon-DFhgRf3P.js} +18 -6
- package/dist/components/{icon-button-Cntrg4_E.js → icon-button-Sxkh5cVr.js} +1 -1
- package/dist/components/inputs/code-editor/code-editor.d.ts +4 -54
- package/dist/components/inputs/code-editor/code-editor.d.ts.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.js +22 -262
- package/dist/components/inputs/code-editor/code-editor.js.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.styles.d.ts.map +1 -1
- package/dist/components/inputs/code-editor/code-editor.styles.js +7 -0
- package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js +9 -7
- package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.annotations.js +1 -1
- package/dist/components/inputs/text-editor/text-editor.annotations.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.clipboard.d.ts +16 -0
- package/dist/components/inputs/text-editor/text-editor.clipboard.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.clipboard.js +50 -0
- package/dist/components/inputs/text-editor/text-editor.clipboard.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.commands.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.commands.js +31 -58
- package/dist/components/inputs/text-editor/text-editor.commands.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.d.ts +17 -64
- package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.drag.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.drag.js +2 -1
- package/dist/components/inputs/text-editor/text-editor.drag.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.focus-selection.d.ts +3 -0
- package/dist/components/inputs/text-editor/text-editor.focus-selection.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.focus-selection.js +55 -0
- package/dist/components/inputs/text-editor/text-editor.focus-selection.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts +6 -0
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js +257 -0
- package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.js +93 -313
- package/dist/components/inputs/text-editor/text-editor.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.keymap.d.ts +6 -0
- package/dist/components/inputs/text-editor/text-editor.keymap.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.keymap.js +38 -0
- package/dist/components/inputs/text-editor/text-editor.keymap.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.links.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.links.js +11 -9
- package/dist/components/inputs/text-editor/text-editor.links.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.markdown.d.ts +1 -17
- package/dist/components/inputs/text-editor/text-editor.markdown.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.markdown.js +26 -186
- package/dist/components/inputs/text-editor/text-editor.markdown.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.mention.d.ts +52 -0
- package/dist/components/inputs/text-editor/text-editor.mention.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.mention.js +186 -0
- package/dist/components/inputs/text-editor/text-editor.mention.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.mentions.d.ts +0 -16
- package/dist/components/inputs/text-editor/text-editor.mentions.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.mentions.js +1 -41
- package/dist/components/inputs/text-editor/text-editor.mentions.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.selection.d.ts +13 -0
- package/dist/components/inputs/text-editor/text-editor.selection.d.ts.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.selection.js +62 -0
- package/dist/components/inputs/text-editor/text-editor.selection.js.map +1 -0
- package/dist/components/inputs/text-editor/text-editor.spellcheck.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.spellcheck.js +4 -6
- package/dist/components/inputs/text-editor/text-editor.spellcheck.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.styles.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.styles.js +172 -54
- package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.syntax.d.ts +22 -0
- package/dist/components/inputs/text-editor/text-editor.syntax.d.ts.map +1 -1
- package/dist/components/inputs/text-editor/text-editor.syntax.js +44 -0
- package/dist/components/inputs/text-editor/text-editor.syntax.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.d.ts +2 -1
- package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.js +5 -2
- package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.styles.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notification.styles.js +18 -0
- package/dist/components/status-and-feedback/notification/notification.styles.js.map +1 -1
- package/dist/components/status-and-feedback/notification/notifications-area.d.ts.map +1 -1
- package/dist/components/status-and-feedback/notification/notifications-area.js +14 -0
- package/dist/components/status-and-feedback/notification/notifications-area.js.map +1 -1
- package/dist/css/rich-text.css +61 -1
- package/dist/css/themes/donkergeel.css +7 -3
- package/dist/css/themes/geel.css +7 -3
- package/dist/css/themes.css +14 -6
- package/dist/css/variables.css +10 -4
- package/dist/nldd.min.js +853 -557
- package/dist/translations/en-US.d.ts.map +1 -1
- package/dist/translations/en-US.js +5 -0
- package/dist/translations/en-US.js.map +1 -1
- package/dist/translations/nl.generated.d.ts +5 -0
- package/dist/translations/nl.generated.d.ts.map +1 -1
- package/dist/types/vue.d.ts +34 -30
- package/dist/utilities/codemirror/codemirror-input.d.ts +90 -0
- package/dist/utilities/codemirror/codemirror-input.d.ts.map +1 -0
- package/dist/utilities/codemirror/codemirror-input.js +250 -0
- package/dist/utilities/codemirror/codemirror-input.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import "./dist-COKR0tYU.js";
|
|
2
|
+
//#region node_modules/@codemirror/merge/dist/index.js
|
|
3
|
+
/**
|
|
4
|
+
A changed range.
|
|
5
|
+
*/
|
|
6
|
+
var Change = class Change {
|
|
7
|
+
constructor(fromA, toA, fromB, toB) {
|
|
8
|
+
this.fromA = fromA;
|
|
9
|
+
this.toA = toA;
|
|
10
|
+
this.fromB = fromB;
|
|
11
|
+
this.toB = toB;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
@internal
|
|
15
|
+
*/
|
|
16
|
+
offset(offA, offB = offA) {
|
|
17
|
+
return new Change(this.fromA + offA, this.toA + offA, this.fromB + offB, this.toB + offB);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function findDiff(a, fromA, toA, b, fromB, toB) {
|
|
21
|
+
if (a == b) return [];
|
|
22
|
+
let prefix = commonPrefix(a, fromA, toA, b, fromB, toB);
|
|
23
|
+
let suffix = commonSuffix(a, fromA + prefix, toA, b, fromB + prefix, toB);
|
|
24
|
+
fromA += prefix;
|
|
25
|
+
toA -= suffix;
|
|
26
|
+
fromB += prefix;
|
|
27
|
+
toB -= suffix;
|
|
28
|
+
let lenA = toA - fromA, lenB = toB - fromB;
|
|
29
|
+
if (!lenA || !lenB) return [new Change(fromA, toA, fromB, toB)];
|
|
30
|
+
if (lenA > lenB) {
|
|
31
|
+
let found = a.slice(fromA, toA).indexOf(b.slice(fromB, toB));
|
|
32
|
+
if (found > -1) return [new Change(fromA, fromA + found, fromB, fromB), new Change(fromA + found + lenB, toA, toB, toB)];
|
|
33
|
+
} else if (lenB > lenA) {
|
|
34
|
+
let found = b.slice(fromB, toB).indexOf(a.slice(fromA, toA));
|
|
35
|
+
if (found > -1) return [new Change(fromA, fromA, fromB, fromB + found), new Change(toA, toA, fromB + found + lenA, toB)];
|
|
36
|
+
}
|
|
37
|
+
if (lenA == 1 || lenB == 1) return [new Change(fromA, toA, fromB, toB)];
|
|
38
|
+
let half = halfMatch(a, fromA, toA, b, fromB, toB);
|
|
39
|
+
if (half) {
|
|
40
|
+
let [sharedA, sharedB, sharedLen] = half;
|
|
41
|
+
return findDiff(a, fromA, sharedA, b, fromB, sharedB).concat(findDiff(a, sharedA + sharedLen, toA, b, sharedB + sharedLen, toB));
|
|
42
|
+
}
|
|
43
|
+
return findSnake(a, fromA, toA, b, fromB, toB);
|
|
44
|
+
}
|
|
45
|
+
var scanLimit = 1e9;
|
|
46
|
+
var timeout = 0;
|
|
47
|
+
function findSnake(a, fromA, toA, b, fromB, toB) {
|
|
48
|
+
let lenA = toA - fromA, lenB = toB - fromB;
|
|
49
|
+
if (scanLimit < 1e9 && Math.min(lenA, lenB) > scanLimit * 16 || timeout > 0 && Date.now() > timeout) {
|
|
50
|
+
if (Math.min(lenA, lenB) > scanLimit * 64) return [new Change(fromA, toA, fromB, toB)];
|
|
51
|
+
return crudeMatch(a, fromA, toA, b, fromB, toB);
|
|
52
|
+
}
|
|
53
|
+
let off = Math.ceil((lenA + lenB) / 2);
|
|
54
|
+
frontier1.reset(off);
|
|
55
|
+
frontier2.reset(off);
|
|
56
|
+
let match1 = (x, y) => a.charCodeAt(fromA + x) == b.charCodeAt(fromB + y);
|
|
57
|
+
let match2 = (x, y) => a.charCodeAt(toA - x - 1) == b.charCodeAt(toB - y - 1);
|
|
58
|
+
let test1 = (lenA - lenB) % 2 != 0 ? frontier2 : null, test2 = test1 ? null : frontier1;
|
|
59
|
+
for (let depth = 0; depth < off; depth++) {
|
|
60
|
+
if (depth > scanLimit || timeout > 0 && !(depth & 63) && Date.now() > timeout) return crudeMatch(a, fromA, toA, b, fromB, toB);
|
|
61
|
+
let done = frontier1.advance(depth, lenA, lenB, off, test1, false, match1) || frontier2.advance(depth, lenA, lenB, off, test2, true, match2);
|
|
62
|
+
if (done) return bisect(a, fromA, toA, fromA + done[0], b, fromB, toB, fromB + done[1]);
|
|
63
|
+
}
|
|
64
|
+
return [new Change(fromA, toA, fromB, toB)];
|
|
65
|
+
}
|
|
66
|
+
var Frontier = class {
|
|
67
|
+
constructor() {
|
|
68
|
+
this.vec = [];
|
|
69
|
+
}
|
|
70
|
+
reset(off) {
|
|
71
|
+
this.len = off << 1;
|
|
72
|
+
for (let i = 0; i < this.len; i++) this.vec[i] = -1;
|
|
73
|
+
this.vec[off + 1] = 0;
|
|
74
|
+
this.start = this.end = 0;
|
|
75
|
+
}
|
|
76
|
+
advance(depth, lenX, lenY, vOff, other, fromBack, match) {
|
|
77
|
+
for (let k = -depth + this.start; k <= depth - this.end; k += 2) {
|
|
78
|
+
let off = vOff + k;
|
|
79
|
+
let x = k == -depth || k != depth && this.vec[off - 1] < this.vec[off + 1] ? this.vec[off + 1] : this.vec[off - 1] + 1;
|
|
80
|
+
let y = x - k;
|
|
81
|
+
while (x < lenX && y < lenY && match(x, y)) {
|
|
82
|
+
x++;
|
|
83
|
+
y++;
|
|
84
|
+
}
|
|
85
|
+
this.vec[off] = x;
|
|
86
|
+
if (x > lenX) this.end += 2;
|
|
87
|
+
else if (y > lenY) this.start += 2;
|
|
88
|
+
else if (other) {
|
|
89
|
+
let offOther = vOff + (lenX - lenY) - k;
|
|
90
|
+
if (offOther >= 0 && offOther < this.len && other.vec[offOther] != -1) {
|
|
91
|
+
if (!fromBack) {
|
|
92
|
+
let xOther = lenX - other.vec[offOther];
|
|
93
|
+
if (x >= xOther) return [x, y];
|
|
94
|
+
} else {
|
|
95
|
+
let xOther = other.vec[offOther];
|
|
96
|
+
if (xOther >= lenX - x) return [xOther, vOff + xOther - offOther];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var frontier1 = /*@__PURE__*/ new Frontier();
|
|
105
|
+
var frontier2 = /*@__PURE__*/ new Frontier();
|
|
106
|
+
function bisect(a, fromA, toA, splitA, b, fromB, toB, splitB) {
|
|
107
|
+
let stop = false;
|
|
108
|
+
if (!validIndex(a, splitA) && ++splitA == toA) stop = true;
|
|
109
|
+
if (!validIndex(b, splitB) && ++splitB == toB) stop = true;
|
|
110
|
+
if (stop) return [new Change(fromA, toA, fromB, toB)];
|
|
111
|
+
return findDiff(a, fromA, splitA, b, fromB, splitB).concat(findDiff(a, splitA, toA, b, splitB, toB));
|
|
112
|
+
}
|
|
113
|
+
function chunkSize(lenA, lenB) {
|
|
114
|
+
let size = 1, max = Math.min(lenA, lenB);
|
|
115
|
+
while (size < max) size = size << 1;
|
|
116
|
+
return size;
|
|
117
|
+
}
|
|
118
|
+
function commonPrefix(a, fromA, toA, b, fromB, toB) {
|
|
119
|
+
if (fromA == toA || fromA == toB || a.charCodeAt(fromA) != b.charCodeAt(fromB)) return 0;
|
|
120
|
+
let chunk = chunkSize(toA - fromA, toB - fromB);
|
|
121
|
+
for (let pA = fromA, pB = fromB;;) {
|
|
122
|
+
let endA = pA + chunk, endB = pB + chunk;
|
|
123
|
+
if (endA > toA || endB > toB || a.slice(pA, endA) != b.slice(pB, endB)) {
|
|
124
|
+
if (chunk == 1) return pA - fromA - (validIndex(a, pA) ? 0 : 1);
|
|
125
|
+
chunk = chunk >> 1;
|
|
126
|
+
} else if (endA == toA || endB == toB) return endA - fromA;
|
|
127
|
+
else {
|
|
128
|
+
pA = endA;
|
|
129
|
+
pB = endB;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function commonSuffix(a, fromA, toA, b, fromB, toB) {
|
|
134
|
+
if (fromA == toA || fromB == toB || a.charCodeAt(toA - 1) != b.charCodeAt(toB - 1)) return 0;
|
|
135
|
+
let chunk = chunkSize(toA - fromA, toB - fromB);
|
|
136
|
+
for (let pA = toA, pB = toB;;) {
|
|
137
|
+
let sA = pA - chunk, sB = pB - chunk;
|
|
138
|
+
if (sA < fromA || sB < fromB || a.slice(sA, pA) != b.slice(sB, pB)) {
|
|
139
|
+
if (chunk == 1) return toA - pA - (validIndex(a, pA) ? 0 : 1);
|
|
140
|
+
chunk = chunk >> 1;
|
|
141
|
+
} else if (sA == fromA || sB == fromB) return toA - sA;
|
|
142
|
+
else {
|
|
143
|
+
pA = sA;
|
|
144
|
+
pB = sB;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function findMatch(a, fromA, toA, b, fromB, toB, size, divideTo) {
|
|
149
|
+
let rangeB = b.slice(fromB, toB);
|
|
150
|
+
let best = null;
|
|
151
|
+
for (;;) {
|
|
152
|
+
if (best || size < divideTo) return best;
|
|
153
|
+
for (let start = fromA + size;;) {
|
|
154
|
+
if (!validIndex(a, start)) start++;
|
|
155
|
+
let end = start + size;
|
|
156
|
+
if (!validIndex(a, end)) end += end == start + 1 ? 1 : -1;
|
|
157
|
+
if (end >= toA) break;
|
|
158
|
+
let seed = a.slice(start, end);
|
|
159
|
+
let found = -1;
|
|
160
|
+
while ((found = rangeB.indexOf(seed, found + 1)) != -1) {
|
|
161
|
+
let prefixAfter = commonPrefix(a, end, toA, b, fromB + found + seed.length, toB);
|
|
162
|
+
let suffixBefore = commonSuffix(a, fromA, start, b, fromB, fromB + found);
|
|
163
|
+
let length = seed.length + prefixAfter + suffixBefore;
|
|
164
|
+
if (!best || best[2] < length) best = [
|
|
165
|
+
start - suffixBefore,
|
|
166
|
+
fromB + found - suffixBefore,
|
|
167
|
+
length
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
start = end;
|
|
171
|
+
}
|
|
172
|
+
if (divideTo < 0) return best;
|
|
173
|
+
size = size >> 1;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function halfMatch(a, fromA, toA, b, fromB, toB) {
|
|
177
|
+
let lenA = toA - fromA, lenB = toB - fromB;
|
|
178
|
+
if (lenA < lenB) {
|
|
179
|
+
let result = halfMatch(b, fromB, toB, a, fromA, toA);
|
|
180
|
+
return result && [
|
|
181
|
+
result[1],
|
|
182
|
+
result[0],
|
|
183
|
+
result[2]
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
if (lenA < 4 || lenB * 2 < lenA) return null;
|
|
187
|
+
return findMatch(a, fromA, toA, b, fromB, toB, Math.floor(lenA / 4), -1);
|
|
188
|
+
}
|
|
189
|
+
function crudeMatch(a, fromA, toA, b, fromB, toB) {
|
|
190
|
+
let lenA = toA - fromA, lenB = toB - fromB;
|
|
191
|
+
let result;
|
|
192
|
+
if (lenA < lenB) {
|
|
193
|
+
let inv = findMatch(b, fromB, toB, a, fromA, toA, Math.floor(lenA / 6), 50);
|
|
194
|
+
result = inv && [
|
|
195
|
+
inv[1],
|
|
196
|
+
inv[0],
|
|
197
|
+
inv[2]
|
|
198
|
+
];
|
|
199
|
+
} else result = findMatch(a, fromA, toA, b, fromB, toB, Math.floor(lenB / 6), 50);
|
|
200
|
+
if (!result) return [new Change(fromA, toA, fromB, toB)];
|
|
201
|
+
let [sharedA, sharedB, sharedLen] = result;
|
|
202
|
+
return findDiff(a, fromA, sharedA, b, fromB, sharedB).concat(findDiff(a, sharedA + sharedLen, toA, b, sharedB + sharedLen, toB));
|
|
203
|
+
}
|
|
204
|
+
function mergeAdjacent(changes, minGap) {
|
|
205
|
+
for (let i = 1; i < changes.length; i++) {
|
|
206
|
+
let prev = changes[i - 1], cur = changes[i];
|
|
207
|
+
if (prev.toA > cur.fromA - minGap && prev.toB > cur.fromB - minGap) {
|
|
208
|
+
changes[i - 1] = new Change(prev.fromA, cur.toA, prev.fromB, cur.toB);
|
|
209
|
+
changes.splice(i--, 1);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function normalize(a, b, changes) {
|
|
214
|
+
for (;;) {
|
|
215
|
+
mergeAdjacent(changes, 1);
|
|
216
|
+
let moved = false;
|
|
217
|
+
for (let i = 0; i < changes.length; i++) {
|
|
218
|
+
let ch = changes[i], pre, post;
|
|
219
|
+
if (pre = commonPrefix(a, ch.fromA, ch.toA, b, ch.fromB, ch.toB)) ch = changes[i] = new Change(ch.fromA + pre, ch.toA, ch.fromB + pre, ch.toB);
|
|
220
|
+
if (post = commonSuffix(a, ch.fromA, ch.toA, b, ch.fromB, ch.toB)) ch = changes[i] = new Change(ch.fromA, ch.toA - post, ch.fromB, ch.toB - post);
|
|
221
|
+
let lenA = ch.toA - ch.fromA, lenB = ch.toB - ch.fromB;
|
|
222
|
+
if (lenA && lenB) continue;
|
|
223
|
+
let beforeLen = ch.fromA - (i ? changes[i - 1].toA : 0);
|
|
224
|
+
let afterLen = (i < changes.length - 1 ? changes[i + 1].fromA : a.length) - ch.toA;
|
|
225
|
+
if (!beforeLen || !afterLen) continue;
|
|
226
|
+
let text = lenA ? a.slice(ch.fromA, ch.toA) : b.slice(ch.fromB, ch.toB);
|
|
227
|
+
if (beforeLen <= text.length && a.slice(ch.fromA - beforeLen, ch.fromA) == text.slice(text.length - beforeLen)) {
|
|
228
|
+
changes[i] = new Change(ch.fromA - beforeLen, ch.toA - beforeLen, ch.fromB - beforeLen, ch.toB - beforeLen);
|
|
229
|
+
moved = true;
|
|
230
|
+
} else if (afterLen <= text.length && a.slice(ch.toA, ch.toA + afterLen) == text.slice(0, afterLen)) {
|
|
231
|
+
changes[i] = new Change(ch.fromA + afterLen, ch.toA + afterLen, ch.fromB + afterLen, ch.toB + afterLen);
|
|
232
|
+
moved = true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (!moved) break;
|
|
236
|
+
}
|
|
237
|
+
return changes;
|
|
238
|
+
}
|
|
239
|
+
function makePresentable(changes, a, b) {
|
|
240
|
+
for (let posA = 0, i = 0; i < changes.length; i++) {
|
|
241
|
+
let change = changes[i];
|
|
242
|
+
let lenA = change.toA - change.fromA, lenB = change.toB - change.fromB;
|
|
243
|
+
if (lenA && lenB || lenA > 3 || lenB > 3) {
|
|
244
|
+
let nextChangeA = i == changes.length - 1 ? a.length : changes[i + 1].fromA;
|
|
245
|
+
let maxScanBefore = change.fromA - posA, maxScanAfter = nextChangeA - change.toA;
|
|
246
|
+
let boundBefore = findWordBoundaryBefore(a, change.fromA, maxScanBefore);
|
|
247
|
+
let boundAfter = findWordBoundaryAfter(a, change.toA, maxScanAfter);
|
|
248
|
+
let lenBefore = change.fromA - boundBefore, lenAfter = boundAfter - change.toA;
|
|
249
|
+
if ((!lenA || !lenB) && lenBefore && lenAfter) {
|
|
250
|
+
let changeLen = Math.max(lenA, lenB);
|
|
251
|
+
let [changeText, changeFrom, changeTo] = lenA ? [
|
|
252
|
+
a,
|
|
253
|
+
change.fromA,
|
|
254
|
+
change.toA
|
|
255
|
+
] : [
|
|
256
|
+
b,
|
|
257
|
+
change.fromB,
|
|
258
|
+
change.toB
|
|
259
|
+
];
|
|
260
|
+
if (changeLen > lenBefore && a.slice(boundBefore, change.fromA) == changeText.slice(changeTo - lenBefore, changeTo)) {
|
|
261
|
+
change = changes[i] = new Change(boundBefore, boundBefore + lenA, change.fromB - lenBefore, change.toB - lenBefore);
|
|
262
|
+
boundBefore = change.fromA;
|
|
263
|
+
boundAfter = findWordBoundaryAfter(a, change.toA, nextChangeA - change.toA);
|
|
264
|
+
} else if (changeLen > lenAfter && a.slice(change.toA, boundAfter) == changeText.slice(changeFrom, changeFrom + lenAfter)) {
|
|
265
|
+
change = changes[i] = new Change(boundAfter - lenA, boundAfter, change.fromB + lenAfter, change.toB + lenAfter);
|
|
266
|
+
boundAfter = change.toA;
|
|
267
|
+
boundBefore = findWordBoundaryBefore(a, change.fromA, change.fromA - posA);
|
|
268
|
+
}
|
|
269
|
+
lenBefore = change.fromA - boundBefore;
|
|
270
|
+
lenAfter = boundAfter - change.toA;
|
|
271
|
+
}
|
|
272
|
+
if (lenBefore || lenAfter) change = changes[i] = new Change(change.fromA - lenBefore, change.toA + lenAfter, change.fromB - lenBefore, change.toB + lenAfter);
|
|
273
|
+
else if (!lenA) {
|
|
274
|
+
let first = findLineBreakAfter(b, change.fromB, change.toB), len;
|
|
275
|
+
let last = first < 0 ? -1 : findLineBreakBefore(b, change.toB, change.fromB);
|
|
276
|
+
if (first > -1 && (len = first - change.fromB) <= maxScanAfter && b.slice(change.fromB, first) == b.slice(change.toB, change.toB + len)) change = changes[i] = change.offset(len);
|
|
277
|
+
else if (last > -1 && (len = change.toB - last) <= maxScanBefore && b.slice(change.fromB - len, change.fromB) == b.slice(last, change.toB)) change = changes[i] = change.offset(-len);
|
|
278
|
+
} else if (!lenB) {
|
|
279
|
+
let first = findLineBreakAfter(a, change.fromA, change.toA), len;
|
|
280
|
+
let last = first < 0 ? -1 : findLineBreakBefore(a, change.toA, change.fromA);
|
|
281
|
+
if (first > -1 && (len = first - change.fromA) <= maxScanAfter && a.slice(change.fromA, first) == a.slice(change.toA, change.toA + len)) change = changes[i] = change.offset(len);
|
|
282
|
+
else if (last > -1 && (len = change.toA - last) <= maxScanBefore && a.slice(change.fromA - len, change.fromA) == a.slice(last, change.toA)) change = changes[i] = change.offset(-len);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
posA = change.toA;
|
|
286
|
+
}
|
|
287
|
+
mergeAdjacent(changes, 3);
|
|
288
|
+
return changes;
|
|
289
|
+
}
|
|
290
|
+
var wordChar;
|
|
291
|
+
try {
|
|
292
|
+
wordChar = /*@__PURE__*/ new RegExp("[\\p{Alphabetic}\\p{Number}]", "u");
|
|
293
|
+
} catch (_) {}
|
|
294
|
+
function asciiWordChar(code) {
|
|
295
|
+
return code > 48 && code < 58 || code > 64 && code < 91 || code > 96 && code < 123;
|
|
296
|
+
}
|
|
297
|
+
function wordCharAfter(s, pos) {
|
|
298
|
+
if (pos == s.length) return 0;
|
|
299
|
+
let next = s.charCodeAt(pos);
|
|
300
|
+
if (next < 192) return asciiWordChar(next) ? 1 : 0;
|
|
301
|
+
if (!wordChar) return 0;
|
|
302
|
+
if (!isSurrogate1(next) || pos == s.length - 1) return wordChar.test(String.fromCharCode(next)) ? 1 : 0;
|
|
303
|
+
return wordChar.test(s.slice(pos, pos + 2)) ? 2 : 0;
|
|
304
|
+
}
|
|
305
|
+
function wordCharBefore(s, pos) {
|
|
306
|
+
if (!pos) return 0;
|
|
307
|
+
let prev = s.charCodeAt(pos - 1);
|
|
308
|
+
if (prev < 192) return asciiWordChar(prev) ? 1 : 0;
|
|
309
|
+
if (!wordChar) return 0;
|
|
310
|
+
if (!isSurrogate2(prev) || pos == 1) return wordChar.test(String.fromCharCode(prev)) ? 1 : 0;
|
|
311
|
+
return wordChar.test(s.slice(pos - 2, pos)) ? 2 : 0;
|
|
312
|
+
}
|
|
313
|
+
var MAX_SCAN = 8;
|
|
314
|
+
function findWordBoundaryAfter(s, pos, max) {
|
|
315
|
+
if (pos == s.length || !wordCharBefore(s, pos)) return pos;
|
|
316
|
+
for (let cur = pos, end = pos + max, i = 0; i < MAX_SCAN; i++) {
|
|
317
|
+
let size = wordCharAfter(s, cur);
|
|
318
|
+
if (!size || cur + size > end) return cur;
|
|
319
|
+
cur += size;
|
|
320
|
+
}
|
|
321
|
+
return pos;
|
|
322
|
+
}
|
|
323
|
+
function findWordBoundaryBefore(s, pos, max) {
|
|
324
|
+
if (!pos || !wordCharAfter(s, pos)) return pos;
|
|
325
|
+
for (let cur = pos, end = pos - max, i = 0; i < MAX_SCAN; i++) {
|
|
326
|
+
let size = wordCharBefore(s, cur);
|
|
327
|
+
if (!size || cur - size < end) return cur;
|
|
328
|
+
cur -= size;
|
|
329
|
+
}
|
|
330
|
+
return pos;
|
|
331
|
+
}
|
|
332
|
+
function findLineBreakBefore(s, pos, stop) {
|
|
333
|
+
for (; pos != stop; pos--) if (s.charCodeAt(pos - 1) == 10) return pos;
|
|
334
|
+
return -1;
|
|
335
|
+
}
|
|
336
|
+
function findLineBreakAfter(s, pos, stop) {
|
|
337
|
+
for (; pos != stop; pos++) if (s.charCodeAt(pos) == 10) return pos;
|
|
338
|
+
return -1;
|
|
339
|
+
}
|
|
340
|
+
var isSurrogate1 = (code) => code >= 55296 && code <= 56319;
|
|
341
|
+
var isSurrogate2 = (code) => code >= 56320 && code <= 57343;
|
|
342
|
+
function validIndex(s, index) {
|
|
343
|
+
return !index || index == s.length || !isSurrogate1(s.charCodeAt(index - 1)) || !isSurrogate2(s.charCodeAt(index));
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
Compute the difference between two strings.
|
|
347
|
+
*/
|
|
348
|
+
function diff(a, b, config) {
|
|
349
|
+
var _a;
|
|
350
|
+
let override = config === null || config === void 0 ? void 0 : config.override;
|
|
351
|
+
if (override) return override(a, b);
|
|
352
|
+
scanLimit = ((_a = config === null || config === void 0 ? void 0 : config.scanLimit) !== null && _a !== void 0 ? _a : 1e9) >> 1;
|
|
353
|
+
timeout = (config === null || config === void 0 ? void 0 : config.timeout) ? Date.now() + config.timeout : 0;
|
|
354
|
+
return normalize(a, b, findDiff(a, 0, a.length, b, 0, b.length));
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
Compute the difference between the given strings, and clean up the
|
|
358
|
+
resulting diff for presentation to users by dropping short
|
|
359
|
+
unchanged ranges, and aligning changes to word boundaries when
|
|
360
|
+
appropriate.
|
|
361
|
+
*/
|
|
362
|
+
function presentableDiff(a, b, config) {
|
|
363
|
+
return makePresentable(diff(a, b, config), a, b);
|
|
364
|
+
}
|
|
365
|
+
//#endregion
|
|
366
|
+
export { presentableDiff };
|