@unicom-cloud/utils 0.1.17 → 0.1.18
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/diff/index.js +7 -0
- package/diff/src/diff.d.ts +21 -0
- package/diff/src/diff.js +381 -0
- package/diff.js +7 -0
- package/index.js +31 -27
- package/mitt/index.js +4 -0
- package/mitt/src/index.js +37 -0
- package/mitt.js +4 -0
- package/package.json +1 -1
- package/pinyin/index.js +4 -0
- package/pinyin/simplified.js +4 -0
- package/pinyin/src/core.js +143 -0
- package/pinyin/src/simplified.js +8 -0
- package/pinyin/src/simplified_dict.js +410 -0
- package/pinyin/src/traditional.js +8 -0
- package/pinyin/src/traditional_dict.js +403 -0
- package/pinyin/traditional.js +4 -0
- package/pinyin.js +4 -0
- package/types/diff/index.d.ts +2 -0
- package/types/diff/src/diff.d.ts +40 -0
- package/types/index.d.ts +3 -1
- package/types/mitt/index.d.ts +2 -0
- package/types/mitt/src/index.d.ts +29 -0
- package/types/pinyin/index.d.ts +1 -0
- package/types/pinyin/simplified.d.ts +1 -0
- package/types/pinyin/src/core.d.ts +3 -0
- package/types/pinyin/src/simplified.d.ts +4 -0
- package/types/pinyin/src/simplified_dict.d.ts +408 -0
- package/types/pinyin/src/traditional.d.ts +4 -0
- package/types/pinyin/src/traditional_dict.d.ts +401 -0
- package/types/pinyin/traditional.d.ts +1 -0
- package/event-emitter/index.js +0 -46
- package/eventEmitter.js +0 -4
- package/types/event-emitter/index.d.ts +0 -17
package/diff/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare function diff(
|
|
2
|
+
text1: string,
|
|
3
|
+
text2: string,
|
|
4
|
+
cursorPos?: number | diff.CursorInfo,
|
|
5
|
+
cleanup?: boolean,
|
|
6
|
+
): diff.Diff[];
|
|
7
|
+
|
|
8
|
+
declare namespace diff {
|
|
9
|
+
type Diff = [-1 | 0 | 1, string];
|
|
10
|
+
|
|
11
|
+
const DELETE: -1;
|
|
12
|
+
const INSERT: 1;
|
|
13
|
+
const EQUAL: 0;
|
|
14
|
+
|
|
15
|
+
interface CursorInfo {
|
|
16
|
+
oldRange: { index: number; length: number };
|
|
17
|
+
newRange: { index: number; length: number };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export = diff;
|
package/diff/src/diff.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
let L = -1, w = 1, A = 0;
|
|
2
|
+
function S(e, t, l, r, i) {
|
|
3
|
+
if (e === t)
|
|
4
|
+
return e ? [[A, e]] : [];
|
|
5
|
+
if (l != null) {
|
|
6
|
+
let a = T(e, t, l);
|
|
7
|
+
if (a)
|
|
8
|
+
return a;
|
|
9
|
+
}
|
|
10
|
+
let n = D(e, t), h = e.substring(0, n);
|
|
11
|
+
e = e.substring(n), t = t.substring(n), n = I(e, t);
|
|
12
|
+
let g = e.substring(e.length - n);
|
|
13
|
+
e = e.substring(0, e.length - n), t = t.substring(0, t.length - n);
|
|
14
|
+
let s = G(e, t);
|
|
15
|
+
return h && s.unshift([A, h]), g && s.push([A, g]), F(s, i), r && K(s), s;
|
|
16
|
+
}
|
|
17
|
+
function G(e, t) {
|
|
18
|
+
let l;
|
|
19
|
+
if (!e)
|
|
20
|
+
return [[w, t]];
|
|
21
|
+
if (!t)
|
|
22
|
+
return [[L, e]];
|
|
23
|
+
let r = e.length > t.length ? e : t, i = e.length > t.length ? t : e, n = r.indexOf(i);
|
|
24
|
+
if (n !== -1)
|
|
25
|
+
return l = [
|
|
26
|
+
[w, r.substring(0, n)],
|
|
27
|
+
[A, i],
|
|
28
|
+
[w, r.substring(n + i.length)]
|
|
29
|
+
], e.length > t.length && (l[0][0] = l[2][0] = L), l;
|
|
30
|
+
if (i.length === 1)
|
|
31
|
+
return [
|
|
32
|
+
[L, e],
|
|
33
|
+
[w, t]
|
|
34
|
+
];
|
|
35
|
+
let h = J(e, t);
|
|
36
|
+
if (h) {
|
|
37
|
+
let g = h[0], s = h[1], a = h[2], u = h[3], c = h[4], f = S(g, a), b = S(s, u);
|
|
38
|
+
return f.concat([[A, c]], b);
|
|
39
|
+
}
|
|
40
|
+
return H(e, t);
|
|
41
|
+
}
|
|
42
|
+
function H(e, t) {
|
|
43
|
+
let l = e.length, r = t.length, i = Math.ceil((l + r) / 2), n = i, h = 2 * i, g = new Array(h), s = new Array(h);
|
|
44
|
+
for (let _ = 0; _ < h; _++)
|
|
45
|
+
g[_] = -1, s[_] = -1;
|
|
46
|
+
g[n + 1] = 0, s[n + 1] = 0;
|
|
47
|
+
let a = l - r, u = a % 2 !== 0, c = 0, f = 0, b = 0, p = 0;
|
|
48
|
+
for (let _ = 0; _ < i; _++) {
|
|
49
|
+
for (let k = -_ + c; k <= _ - f; k += 2) {
|
|
50
|
+
let m = n + k, o;
|
|
51
|
+
k === -_ || k !== _ && g[m - 1] < g[m + 1] ? o = g[m + 1] : o = g[m - 1] + 1;
|
|
52
|
+
let M = o - k;
|
|
53
|
+
for (; o < l && M < r && e.charAt(o) === t.charAt(M); )
|
|
54
|
+
o++, M++;
|
|
55
|
+
if (g[m] = o, o > l)
|
|
56
|
+
f += 2;
|
|
57
|
+
else if (M > r)
|
|
58
|
+
c += 2;
|
|
59
|
+
else if (u) {
|
|
60
|
+
let E = n + a - k;
|
|
61
|
+
if (E >= 0 && E < h && s[E] !== -1) {
|
|
62
|
+
let y = l - s[E];
|
|
63
|
+
if (o >= y)
|
|
64
|
+
return C(e, t, o, M);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (let k = -_ + b; k <= _ - p; k += 2) {
|
|
69
|
+
let m = n + k, o;
|
|
70
|
+
k === -_ || k !== _ && s[m - 1] < s[m + 1] ? o = s[m + 1] : o = s[m - 1] + 1;
|
|
71
|
+
let M = o - k;
|
|
72
|
+
for (; o < l && M < r && e.charAt(l - o - 1) === t.charAt(r - M - 1); )
|
|
73
|
+
o++, M++;
|
|
74
|
+
if (s[m] = o, o > l)
|
|
75
|
+
p += 2;
|
|
76
|
+
else if (M > r)
|
|
77
|
+
b += 2;
|
|
78
|
+
else if (!u) {
|
|
79
|
+
let E = n + a - k;
|
|
80
|
+
if (E >= 0 && E < h && g[E] !== -1) {
|
|
81
|
+
let y = g[E], R = n + y - E;
|
|
82
|
+
if (o = l - o, y >= o)
|
|
83
|
+
return C(e, t, y, R);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [
|
|
89
|
+
[L, e],
|
|
90
|
+
[w, t]
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
function C(e, t, l, r) {
|
|
94
|
+
let i = e.substring(0, l), n = t.substring(0, r), h = e.substring(l), g = t.substring(r), s = S(i, n), a = S(h, g);
|
|
95
|
+
return s.concat(a);
|
|
96
|
+
}
|
|
97
|
+
function D(e, t) {
|
|
98
|
+
if (!e || !t || e.charAt(0) !== t.charAt(0))
|
|
99
|
+
return 0;
|
|
100
|
+
let l = 0, r = Math.min(e.length, t.length), i = r, n = 0;
|
|
101
|
+
for (; l < i; )
|
|
102
|
+
e.substring(n, i) == t.substring(n, i) ? (l = i, n = l) : r = i, i = Math.floor((r - l) / 2 + l);
|
|
103
|
+
return j(e.charCodeAt(i - 1)) && i--, i;
|
|
104
|
+
}
|
|
105
|
+
function O(e, t) {
|
|
106
|
+
let l = e.length, r = t.length;
|
|
107
|
+
if (l == 0 || r == 0)
|
|
108
|
+
return 0;
|
|
109
|
+
l > r ? e = e.substring(l - r) : l < r && (t = t.substring(0, l));
|
|
110
|
+
let i = Math.min(l, r);
|
|
111
|
+
if (e == t)
|
|
112
|
+
return i;
|
|
113
|
+
let n = 0, h = 1;
|
|
114
|
+
for (; ; ) {
|
|
115
|
+
let g = e.substring(i - h), s = t.indexOf(g);
|
|
116
|
+
if (s == -1)
|
|
117
|
+
return n;
|
|
118
|
+
h += s, (s == 0 || e.substring(i - h) == t.substring(0, h)) && (n = h, h++);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function I(e, t) {
|
|
122
|
+
if (!e || !t || e.slice(-1) !== t.slice(-1))
|
|
123
|
+
return 0;
|
|
124
|
+
let l = 0, r = Math.min(e.length, t.length), i = r, n = 0;
|
|
125
|
+
for (; l < i; )
|
|
126
|
+
e.substring(e.length - i, e.length - n) == t.substring(t.length - i, t.length - n) ? (l = i, n = l) : r = i, i = Math.floor((r - l) / 2 + l);
|
|
127
|
+
return z(e.charCodeAt(e.length - i)) && i--, i;
|
|
128
|
+
}
|
|
129
|
+
function J(e, t) {
|
|
130
|
+
let l = e.length > t.length ? e : t, r = e.length > t.length ? t : e;
|
|
131
|
+
if (l.length < 4 || r.length * 2 < l.length)
|
|
132
|
+
return null;
|
|
133
|
+
function i(b, p, _) {
|
|
134
|
+
let k = b.substring(_, _ + Math.floor(b.length / 4)), m = -1, o = "", M, E, y, R;
|
|
135
|
+
for (; (m = p.indexOf(k, m + 1)) !== -1; ) {
|
|
136
|
+
let v = D(
|
|
137
|
+
b.substring(_),
|
|
138
|
+
p.substring(m)
|
|
139
|
+
), q = I(
|
|
140
|
+
b.substring(0, _),
|
|
141
|
+
p.substring(0, m)
|
|
142
|
+
);
|
|
143
|
+
o.length < q + v && (o = p.substring(m - q, m) + p.substring(m, m + v), M = b.substring(0, _ - q), E = b.substring(_ + v), y = p.substring(0, m - q), R = p.substring(m + v));
|
|
144
|
+
}
|
|
145
|
+
return o.length * 2 >= b.length ? [
|
|
146
|
+
M,
|
|
147
|
+
E,
|
|
148
|
+
y,
|
|
149
|
+
R,
|
|
150
|
+
o
|
|
151
|
+
] : null;
|
|
152
|
+
}
|
|
153
|
+
let n = i(
|
|
154
|
+
l,
|
|
155
|
+
r,
|
|
156
|
+
Math.ceil(l.length / 4)
|
|
157
|
+
), h = i(
|
|
158
|
+
l,
|
|
159
|
+
r,
|
|
160
|
+
Math.ceil(l.length / 2)
|
|
161
|
+
), g;
|
|
162
|
+
if (!n && !h)
|
|
163
|
+
return null;
|
|
164
|
+
h ? n ? g = n[4].length > h[4].length ? n : h : g = h : g = n;
|
|
165
|
+
let s, a, u, c;
|
|
166
|
+
e.length > t.length ? (s = g[0], a = g[1], u = g[2], c = g[3]) : (u = g[0], c = g[1], s = g[2], a = g[3]);
|
|
167
|
+
let f = g[4];
|
|
168
|
+
return [s, a, u, c, f];
|
|
169
|
+
}
|
|
170
|
+
function K(e) {
|
|
171
|
+
let t = !1, l = [], r = 0, i = null, n = 0, h = 0, g = 0, s = 0, a = 0;
|
|
172
|
+
for (; n < e.length; )
|
|
173
|
+
e[n][0] == A ? (l[r++] = n, h = s, g = a, s = 0, a = 0, i = e[n][1]) : (e[n][0] == w ? s += e[n][1].length : a += e[n][1].length, i && i.length <= Math.max(h, g) && i.length <= Math.max(s, a) && (e.splice(l[r - 1], 0, [
|
|
174
|
+
L,
|
|
175
|
+
i
|
|
176
|
+
]), e[l[r - 1] + 1][0] = w, r--, r--, n = r > 0 ? l[r - 1] : -1, h = 0, g = 0, s = 0, a = 0, i = null, t = !0)), n++;
|
|
177
|
+
for (t && F(e), X(e), n = 1; n < e.length; ) {
|
|
178
|
+
if (e[n - 1][0] == L && e[n][0] == w) {
|
|
179
|
+
let u = e[n - 1][1], c = e[n][1], f = O(u, c), b = O(c, u);
|
|
180
|
+
f >= b ? (f >= u.length / 2 || f >= c.length / 2) && (e.splice(n, 0, [
|
|
181
|
+
A,
|
|
182
|
+
c.substring(0, f)
|
|
183
|
+
]), e[n - 1][1] = u.substring(
|
|
184
|
+
0,
|
|
185
|
+
u.length - f
|
|
186
|
+
), e[n + 1][1] = c.substring(f), n++) : (b >= u.length / 2 || b >= c.length / 2) && (e.splice(n, 0, [
|
|
187
|
+
A,
|
|
188
|
+
u.substring(0, b)
|
|
189
|
+
]), e[n - 1][0] = w, e[n - 1][1] = c.substring(
|
|
190
|
+
0,
|
|
191
|
+
c.length - b
|
|
192
|
+
), e[n + 1][0] = L, e[n + 1][1] = u.substring(b), n++), n++;
|
|
193
|
+
}
|
|
194
|
+
n++;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
let P = /[^a-zA-Z0-9]/, Q = /\s/, U = /[\r\n]/, V = /\n\r?\n$/, W = /^\r?\n\r?\n/;
|
|
198
|
+
function X(e) {
|
|
199
|
+
function t(r, i) {
|
|
200
|
+
if (!r || !i)
|
|
201
|
+
return 6;
|
|
202
|
+
let n = r.charAt(r.length - 1), h = i.charAt(0), g = n.match(P), s = h.match(P), a = g && n.match(Q), u = s && h.match(Q), c = a && n.match(U), f = u && h.match(U), b = c && r.match(V), p = f && i.match(W);
|
|
203
|
+
return b || p ? 5 : c || f ? 4 : g && !a && u ? 3 : a || u ? 2 : g || s ? 1 : 0;
|
|
204
|
+
}
|
|
205
|
+
let l = 1;
|
|
206
|
+
for (; l < e.length - 1; ) {
|
|
207
|
+
if (e[l - 1][0] == A && e[l + 1][0] == A) {
|
|
208
|
+
let r = e[l - 1][1], i = e[l][1], n = e[l + 1][1], h = I(r, i);
|
|
209
|
+
if (h) {
|
|
210
|
+
let c = i.substring(i.length - h);
|
|
211
|
+
r = r.substring(0, r.length - h), i = c + i.substring(0, i.length - h), n = c + n;
|
|
212
|
+
}
|
|
213
|
+
let g = r, s = i, a = n, u = t(r, i) + t(i, n);
|
|
214
|
+
for (; i.charAt(0) === n.charAt(0); ) {
|
|
215
|
+
r += i.charAt(0), i = i.substring(1) + n.charAt(0), n = n.substring(1);
|
|
216
|
+
let c = t(r, i) + t(i, n);
|
|
217
|
+
c >= u && (u = c, g = r, s = i, a = n);
|
|
218
|
+
}
|
|
219
|
+
e[l - 1][1] != g && (g ? e[l - 1][1] = g : (e.splice(l - 1, 1), l--), e[l][1] = s, a ? e[l + 1][1] = a : (e.splice(l + 1, 1), l--));
|
|
220
|
+
}
|
|
221
|
+
l++;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function F(e, t) {
|
|
225
|
+
e.push([A, ""]);
|
|
226
|
+
let l = 0, r = 0, i = 0, n = "", h = "", g;
|
|
227
|
+
for (; l < e.length; ) {
|
|
228
|
+
if (l < e.length - 1 && !e[l][1]) {
|
|
229
|
+
e.splice(l, 1);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
switch (e[l][0]) {
|
|
233
|
+
case w: {
|
|
234
|
+
i++, h += e[l][1], l++;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
case L:
|
|
238
|
+
r++, n += e[l][1], l++;
|
|
239
|
+
break;
|
|
240
|
+
case A: {
|
|
241
|
+
let a = l - i - r - 1;
|
|
242
|
+
if (t) {
|
|
243
|
+
if (a >= 0 && $(e[a][1])) {
|
|
244
|
+
let u = e[a][1].slice(-1);
|
|
245
|
+
if (e[a][1] = e[a][1].slice(
|
|
246
|
+
0,
|
|
247
|
+
-1
|
|
248
|
+
), n = u + n, h = u + h, !e[a][1]) {
|
|
249
|
+
e.splice(a, 1), l--;
|
|
250
|
+
let c = a - 1;
|
|
251
|
+
e[c] && e[c][0] === w && (i++, h = e[c][1] + h, c--), e[c] && e[c][0] === L && (r++, n = e[c][1] + n, c--), a = c;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (Z(e[l][1])) {
|
|
255
|
+
let u = e[l][1].charAt(0);
|
|
256
|
+
e[l][1] = e[l][1].slice(1), n += u, h += u;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (l < e.length - 1 && !e[l][1]) {
|
|
260
|
+
e.splice(l, 1);
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
if (n.length > 0 || h.length > 0) {
|
|
264
|
+
n.length > 0 && h.length > 0 && (g = D(h, n), g !== 0 && (a >= 0 ? e[a][1] += h.substring(
|
|
265
|
+
0,
|
|
266
|
+
g
|
|
267
|
+
) : (e.splice(0, 0, [
|
|
268
|
+
A,
|
|
269
|
+
h.substring(0, g)
|
|
270
|
+
]), l++), h = h.substring(g), n = n.substring(g)), g = I(h, n), g !== 0 && (e[l][1] = h.substring(h.length - g) + e[l][1], h = h.substring(
|
|
271
|
+
0,
|
|
272
|
+
h.length - g
|
|
273
|
+
), n = n.substring(
|
|
274
|
+
0,
|
|
275
|
+
n.length - g
|
|
276
|
+
)));
|
|
277
|
+
let u = i + r;
|
|
278
|
+
n.length === 0 && h.length === 0 ? (e.splice(l - u, u), l = l - u) : n.length === 0 ? (e.splice(l - u, u, [w, h]), l = l - u + 1) : h.length === 0 ? (e.splice(l - u, u, [L, n]), l = l - u + 1) : (e.splice(
|
|
279
|
+
l - u,
|
|
280
|
+
u,
|
|
281
|
+
[L, n],
|
|
282
|
+
[w, h]
|
|
283
|
+
), l = l - u + 2);
|
|
284
|
+
}
|
|
285
|
+
l !== 0 && e[l - 1][0] === A ? (e[l - 1][1] += e[l][1], e.splice(l, 1)) : l++, i = 0, r = 0, n = "", h = "";
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
e[e.length - 1][1] === "" && e.pop();
|
|
291
|
+
let s = !1;
|
|
292
|
+
for (l = 1; l < e.length - 1; )
|
|
293
|
+
e[l - 1][0] === A && e[l + 1][0] === A && (e[l][1].substring(
|
|
294
|
+
e[l][1].length - e[l - 1][1].length
|
|
295
|
+
) === e[l - 1][1] ? (e[l][1] = e[l - 1][1] + e[l][1].substring(
|
|
296
|
+
0,
|
|
297
|
+
e[l][1].length - e[l - 1][1].length
|
|
298
|
+
), e[l + 1][1] = e[l - 1][1] + e[l + 1][1], e.splice(l - 1, 1), s = !0) : e[l][1].substring(0, e[l + 1][1].length) == e[l + 1][1] && (e[l - 1][1] += e[l + 1][1], e[l][1] = e[l][1].substring(e[l + 1][1].length) + e[l + 1][1], e.splice(l + 1, 1), s = !0)), l++;
|
|
299
|
+
s && F(e, t);
|
|
300
|
+
}
|
|
301
|
+
function j(e) {
|
|
302
|
+
return e >= 55296 && e <= 56319;
|
|
303
|
+
}
|
|
304
|
+
function z(e) {
|
|
305
|
+
return e >= 56320 && e <= 57343;
|
|
306
|
+
}
|
|
307
|
+
function Z(e) {
|
|
308
|
+
return z(e.charCodeAt(0));
|
|
309
|
+
}
|
|
310
|
+
function $(e) {
|
|
311
|
+
return j(e.charCodeAt(e.length - 1));
|
|
312
|
+
}
|
|
313
|
+
function Y(e) {
|
|
314
|
+
let t = [];
|
|
315
|
+
for (let l = 0; l < e.length; l++)
|
|
316
|
+
e[l][1].length > 0 && t.push(e[l]);
|
|
317
|
+
return t;
|
|
318
|
+
}
|
|
319
|
+
function N(e, t, l, r) {
|
|
320
|
+
return $(e) || Z(r) ? null : Y([
|
|
321
|
+
[A, e],
|
|
322
|
+
[L, t],
|
|
323
|
+
[w, l],
|
|
324
|
+
[A, r]
|
|
325
|
+
]);
|
|
326
|
+
}
|
|
327
|
+
function T(e, t, l) {
|
|
328
|
+
let r = typeof l == "number" ? { index: l, length: 0 } : l.oldRange, i = typeof l == "number" ? null : l.newRange, n = e.length, h = t.length;
|
|
329
|
+
if (r.length === 0 && (i === null || i.length === 0)) {
|
|
330
|
+
let g = r.index, s = e.slice(0, g), a = e.slice(g), u = i ? i.index : null;
|
|
331
|
+
e: {
|
|
332
|
+
let c = g + h - n;
|
|
333
|
+
if (u !== null && u !== c || c < 0 || c > h)
|
|
334
|
+
break e;
|
|
335
|
+
let f = t.slice(0, c);
|
|
336
|
+
if (t.slice(c) !== a)
|
|
337
|
+
break e;
|
|
338
|
+
let p = Math.min(g, c), _ = s.slice(0, p), k = f.slice(0, p);
|
|
339
|
+
if (_ !== k)
|
|
340
|
+
break e;
|
|
341
|
+
let m = s.slice(p), o = f.slice(p);
|
|
342
|
+
return N(_, m, o, a);
|
|
343
|
+
}
|
|
344
|
+
e: {
|
|
345
|
+
if (u !== null && u !== g)
|
|
346
|
+
break e;
|
|
347
|
+
let c = g, f = t.slice(0, c), b = t.slice(c);
|
|
348
|
+
if (f !== s)
|
|
349
|
+
break e;
|
|
350
|
+
let p = Math.min(n - c, h - c), _ = a.slice(a.length - p), k = b.slice(b.length - p);
|
|
351
|
+
if (_ !== k)
|
|
352
|
+
break e;
|
|
353
|
+
let m = a.slice(0, a.length - p), o = b.slice(0, b.length - p);
|
|
354
|
+
return N(s, m, o, _);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (r.length > 0 && i && i.length === 0)
|
|
358
|
+
e: {
|
|
359
|
+
let g = e.slice(0, r.index), s = e.slice(r.index + r.length), a = g.length, u = s.length;
|
|
360
|
+
if (h < a + u)
|
|
361
|
+
break e;
|
|
362
|
+
let c = t.slice(0, a), f = t.slice(h - u);
|
|
363
|
+
if (g !== c || s !== f)
|
|
364
|
+
break e;
|
|
365
|
+
let b = e.slice(a, n - u), p = t.slice(a, h - u);
|
|
366
|
+
return N(g, b, p, s);
|
|
367
|
+
}
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
function B(e, t, l, r) {
|
|
371
|
+
return S(e, t, l, r, !0);
|
|
372
|
+
}
|
|
373
|
+
B.INSERT = w;
|
|
374
|
+
B.DELETE = L;
|
|
375
|
+
B.EQUAL = A;
|
|
376
|
+
export {
|
|
377
|
+
L as DELETE,
|
|
378
|
+
A as EQUAL,
|
|
379
|
+
w as INSERT,
|
|
380
|
+
B as default
|
|
381
|
+
};
|
package/diff.js
ADDED
package/index.js
CHANGED
|
@@ -10,24 +10,26 @@ import * as p from "./url-toolkit/index.js";
|
|
|
10
10
|
import { default as u } from "./case-name/index.js";
|
|
11
11
|
import { default as C } from "./class-name/index.js";
|
|
12
12
|
import { default as b } from "./clipboard-copy/index.js";
|
|
13
|
-
import { default as k, getContentDispositionFromHeader as
|
|
13
|
+
import { default as k, getContentDispositionFromHeader as y, getContentDispositionParametersFilenameFromHeader as T, getContentDispositionParametersFromHeader as g } from "./content-disposition/index.js";
|
|
14
14
|
import { splitCookiesString as D } from "./cookie/index.js";
|
|
15
15
|
import { default as S } from "./decimal/decimal.js";
|
|
16
|
-
import { default as
|
|
16
|
+
import { default as j } from "./diff/src/diff.js";
|
|
17
17
|
import { fileToURL as L } from "./file/fileToURL.js";
|
|
18
18
|
import { saveAs as P } from "./file/saveAs.js";
|
|
19
19
|
import * as f from "./filesize/src/constants.js";
|
|
20
|
-
import { filesize as
|
|
21
|
-
import { default as
|
|
22
|
-
import { default as
|
|
20
|
+
import { filesize as K, partial as R } from "./filesize/src/filesize.js";
|
|
21
|
+
import { default as W } from "./invariant/index.js";
|
|
22
|
+
import { default as q } from "./js-cookie/src/api.js";
|
|
23
23
|
import * as n from "./lunar/lib/index.js";
|
|
24
|
-
import { default as
|
|
25
|
-
import { default as G } from "./
|
|
26
|
-
import { default as J } from "./
|
|
27
|
-
import { default as O } from "./
|
|
28
|
-
import { default as V } from "./
|
|
29
|
-
import { default as Y } from "./
|
|
30
|
-
import {
|
|
24
|
+
import { default as B } from "./md5/index.js";
|
|
25
|
+
import { default as G } from "./mitt/src/index.js";
|
|
26
|
+
import { default as J } from "./normalize-wheel/index.js";
|
|
27
|
+
import { default as O } from "./number-to-chinese/index.js";
|
|
28
|
+
import { default as V } from "./nzh/nzh.js";
|
|
29
|
+
import { default as Y } from "./object-keys-sort/index.js";
|
|
30
|
+
import { default as oo } from "./pinyin/src/simplified.js";
|
|
31
|
+
import { default as ro } from "./screenfull/index.js";
|
|
32
|
+
import { TinyColor as ao } from "./tinycolor/src/index.js";
|
|
31
33
|
import * as x from "./cookie/src/index.js";
|
|
32
34
|
export {
|
|
33
35
|
n as Lunar,
|
|
@@ -39,28 +41,30 @@ export {
|
|
|
39
41
|
x as cookie,
|
|
40
42
|
e as date,
|
|
41
43
|
S as decimal,
|
|
42
|
-
|
|
44
|
+
j as diff,
|
|
43
45
|
L as fileToURL,
|
|
44
|
-
|
|
46
|
+
K as filesize,
|
|
45
47
|
f as filesizeConstants,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
y as getContentDispositionFromHeader,
|
|
49
|
+
T as getContentDispositionParametersFilenameFromHeader,
|
|
50
|
+
g as getContentDispositionParametersFromHeader,
|
|
51
|
+
W as invariant,
|
|
50
52
|
r as is,
|
|
51
|
-
|
|
53
|
+
q as jsCookie,
|
|
52
54
|
t as math,
|
|
53
|
-
|
|
54
|
-
G as
|
|
55
|
-
J as
|
|
56
|
-
O as
|
|
57
|
-
V as
|
|
58
|
-
|
|
55
|
+
B as md5,
|
|
56
|
+
G as mitt,
|
|
57
|
+
J as normalizeWheel,
|
|
58
|
+
O as numberToChinese,
|
|
59
|
+
V as nzh,
|
|
60
|
+
Y as objectKeysSort,
|
|
61
|
+
R as partial,
|
|
62
|
+
oo as pinyin,
|
|
59
63
|
P as saveAs,
|
|
60
|
-
|
|
64
|
+
ro as screenfull,
|
|
61
65
|
a as snapdom,
|
|
62
66
|
D as splitCookiesString,
|
|
63
|
-
|
|
67
|
+
ao as tinycolor,
|
|
64
68
|
s as tree,
|
|
65
69
|
i as turboStream,
|
|
66
70
|
m as uiColor,
|
package/mitt/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function S(i = /* @__PURE__ */ new Map()) {
|
|
2
|
+
function d(e, o, t, n = !1, f = !1) {
|
|
3
|
+
const c = { handler: o, context: t, once: n }, s = i.get(e);
|
|
4
|
+
s ? s.add(c) : i.set(e, /* @__PURE__ */ new Set([c])), f && a(e);
|
|
5
|
+
}
|
|
6
|
+
function u(e, o, t) {
|
|
7
|
+
d(e, o, t, !0);
|
|
8
|
+
}
|
|
9
|
+
function l(e, o, t) {
|
|
10
|
+
const n = i.get(e);
|
|
11
|
+
n && (o ? new Set(n).forEach((f) => {
|
|
12
|
+
f.handler === o && (t === void 0 || f.context === t) && n.delete(f);
|
|
13
|
+
}) : t ? new Set(n).forEach((f) => {
|
|
14
|
+
f.context === t && n.delete(f);
|
|
15
|
+
}) : n.clear(), n.size || r(e));
|
|
16
|
+
}
|
|
17
|
+
function r(e) {
|
|
18
|
+
e ? i.delete(e) : i.clear();
|
|
19
|
+
}
|
|
20
|
+
function a(e, o, ...t) {
|
|
21
|
+
const n = i.get(e);
|
|
22
|
+
n && new Set(n).forEach((f) => {
|
|
23
|
+
const { handler: c, context: s, once: h } = f;
|
|
24
|
+
h && l(e, c, s), c.call(s, o, ...t);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
on: d,
|
|
29
|
+
once: u,
|
|
30
|
+
off: l,
|
|
31
|
+
offAll: r,
|
|
32
|
+
emit: a
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
S as default
|
|
37
|
+
};
|
package/mitt.js
ADDED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@unicom-cloud/utils","version":"0.1.
|
|
1
|
+
{"name":"@unicom-cloud/utils","version":"0.1.18","dependencies":{},"peerDependencies":{"lodash":"^4.17.21"},"main":"./index.js","type":"module","types":"types/index.d.ts","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
|
package/pinyin/index.js
ADDED