@tiptap/core 3.0.0-beta.24 → 3.0.0-beta.25

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.
@@ -1,4742 +0,0 @@
1
- import {
2
- IdleScheduler
3
- } from "./chunk-GRT2MR5L.js";
4
- import {
5
- require_color_convert
6
- } from "./chunk-UNIMJOD2.js";
7
- import {
8
- __commonJS,
9
- __require,
10
- __toESM
11
- } from "./chunk-PR4QN5HX.js";
12
-
13
- // ../../node_modules/.pnpm/diff-match-patch@1.0.5/node_modules/diff-match-patch/index.js
14
- var require_diff_match_patch = __commonJS({
15
- "../../node_modules/.pnpm/diff-match-patch@1.0.5/node_modules/diff-match-patch/index.js"(exports, module) {
16
- "use strict";
17
- var diff_match_patch2 = function() {
18
- this.Diff_Timeout = 1;
19
- this.Diff_EditCost = 4;
20
- this.Match_Threshold = 0.5;
21
- this.Match_Distance = 1e3;
22
- this.Patch_DeleteThreshold = 0.5;
23
- this.Patch_Margin = 4;
24
- this.Match_MaxBits = 32;
25
- };
26
- var DIFF_DELETE = -1;
27
- var DIFF_INSERT = 1;
28
- var DIFF_EQUAL = 0;
29
- diff_match_patch2.Diff = function(op, text) {
30
- return [op, text];
31
- };
32
- diff_match_patch2.prototype.diff_main = function(text1, text2, opt_checklines, opt_deadline) {
33
- if (typeof opt_deadline == "undefined") {
34
- if (this.Diff_Timeout <= 0) {
35
- opt_deadline = Number.MAX_VALUE;
36
- } else {
37
- opt_deadline = (/* @__PURE__ */ new Date()).getTime() + this.Diff_Timeout * 1e3;
38
- }
39
- }
40
- var deadline = opt_deadline;
41
- if (text1 == null || text2 == null) {
42
- throw new Error("Null input. (diff_main)");
43
- }
44
- if (text1 == text2) {
45
- if (text1) {
46
- return [new diff_match_patch2.Diff(DIFF_EQUAL, text1)];
47
- }
48
- return [];
49
- }
50
- if (typeof opt_checklines == "undefined") {
51
- opt_checklines = true;
52
- }
53
- var checklines = opt_checklines;
54
- var commonlength = this.diff_commonPrefix(text1, text2);
55
- var commonprefix = text1.substring(0, commonlength);
56
- text1 = text1.substring(commonlength);
57
- text2 = text2.substring(commonlength);
58
- commonlength = this.diff_commonSuffix(text1, text2);
59
- var commonsuffix = text1.substring(text1.length - commonlength);
60
- text1 = text1.substring(0, text1.length - commonlength);
61
- text2 = text2.substring(0, text2.length - commonlength);
62
- var diffs = this.diff_compute_(text1, text2, checklines, deadline);
63
- if (commonprefix) {
64
- diffs.unshift(new diff_match_patch2.Diff(DIFF_EQUAL, commonprefix));
65
- }
66
- if (commonsuffix) {
67
- diffs.push(new diff_match_patch2.Diff(DIFF_EQUAL, commonsuffix));
68
- }
69
- this.diff_cleanupMerge(diffs);
70
- return diffs;
71
- };
72
- diff_match_patch2.prototype.diff_compute_ = function(text1, text2, checklines, deadline) {
73
- var diffs;
74
- if (!text1) {
75
- return [new diff_match_patch2.Diff(DIFF_INSERT, text2)];
76
- }
77
- if (!text2) {
78
- return [new diff_match_patch2.Diff(DIFF_DELETE, text1)];
79
- }
80
- var longtext = text1.length > text2.length ? text1 : text2;
81
- var shorttext = text1.length > text2.length ? text2 : text1;
82
- var i = longtext.indexOf(shorttext);
83
- if (i != -1) {
84
- diffs = [
85
- new diff_match_patch2.Diff(DIFF_INSERT, longtext.substring(0, i)),
86
- new diff_match_patch2.Diff(DIFF_EQUAL, shorttext),
87
- new diff_match_patch2.Diff(
88
- DIFF_INSERT,
89
- longtext.substring(i + shorttext.length)
90
- )
91
- ];
92
- if (text1.length > text2.length) {
93
- diffs[0][0] = diffs[2][0] = DIFF_DELETE;
94
- }
95
- return diffs;
96
- }
97
- if (shorttext.length == 1) {
98
- return [
99
- new diff_match_patch2.Diff(DIFF_DELETE, text1),
100
- new diff_match_patch2.Diff(DIFF_INSERT, text2)
101
- ];
102
- }
103
- var hm = this.diff_halfMatch_(text1, text2);
104
- if (hm) {
105
- var text1_a = hm[0];
106
- var text1_b = hm[1];
107
- var text2_a = hm[2];
108
- var text2_b = hm[3];
109
- var mid_common = hm[4];
110
- var diffs_a = this.diff_main(text1_a, text2_a, checklines, deadline);
111
- var diffs_b = this.diff_main(text1_b, text2_b, checklines, deadline);
112
- return diffs_a.concat(
113
- [new diff_match_patch2.Diff(DIFF_EQUAL, mid_common)],
114
- diffs_b
115
- );
116
- }
117
- if (checklines && text1.length > 100 && text2.length > 100) {
118
- return this.diff_lineMode_(text1, text2, deadline);
119
- }
120
- return this.diff_bisect_(text1, text2, deadline);
121
- };
122
- diff_match_patch2.prototype.diff_lineMode_ = function(text1, text2, deadline) {
123
- var a = this.diff_linesToChars_(text1, text2);
124
- text1 = a.chars1;
125
- text2 = a.chars2;
126
- var linearray = a.lineArray;
127
- var diffs = this.diff_main(text1, text2, false, deadline);
128
- this.diff_charsToLines_(diffs, linearray);
129
- this.diff_cleanupSemantic(diffs);
130
- diffs.push(new diff_match_patch2.Diff(DIFF_EQUAL, ""));
131
- var pointer = 0;
132
- var count_delete = 0;
133
- var count_insert = 0;
134
- var text_delete = "";
135
- var text_insert = "";
136
- while (pointer < diffs.length) {
137
- switch (diffs[pointer][0]) {
138
- case DIFF_INSERT:
139
- count_insert++;
140
- text_insert += diffs[pointer][1];
141
- break;
142
- case DIFF_DELETE:
143
- count_delete++;
144
- text_delete += diffs[pointer][1];
145
- break;
146
- case DIFF_EQUAL:
147
- if (count_delete >= 1 && count_insert >= 1) {
148
- diffs.splice(
149
- pointer - count_delete - count_insert,
150
- count_delete + count_insert
151
- );
152
- pointer = pointer - count_delete - count_insert;
153
- var subDiff = this.diff_main(text_delete, text_insert, false, deadline);
154
- for (var j = subDiff.length - 1; j >= 0; j--) {
155
- diffs.splice(pointer, 0, subDiff[j]);
156
- }
157
- pointer = pointer + subDiff.length;
158
- }
159
- count_insert = 0;
160
- count_delete = 0;
161
- text_delete = "";
162
- text_insert = "";
163
- break;
164
- }
165
- pointer++;
166
- }
167
- diffs.pop();
168
- return diffs;
169
- };
170
- diff_match_patch2.prototype.diff_bisect_ = function(text1, text2, deadline) {
171
- var text1_length = text1.length;
172
- var text2_length = text2.length;
173
- var max_d = Math.ceil((text1_length + text2_length) / 2);
174
- var v_offset = max_d;
175
- var v_length = 2 * max_d;
176
- var v1 = new Array(v_length);
177
- var v2 = new Array(v_length);
178
- for (var x = 0; x < v_length; x++) {
179
- v1[x] = -1;
180
- v2[x] = -1;
181
- }
182
- v1[v_offset + 1] = 0;
183
- v2[v_offset + 1] = 0;
184
- var delta = text1_length - text2_length;
185
- var front = delta % 2 != 0;
186
- var k1start = 0;
187
- var k1end = 0;
188
- var k2start = 0;
189
- var k2end = 0;
190
- for (var d = 0; d < max_d; d++) {
191
- if ((/* @__PURE__ */ new Date()).getTime() > deadline) {
192
- break;
193
- }
194
- for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
195
- var k1_offset = v_offset + k1;
196
- var x1;
197
- if (k1 == -d || k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1]) {
198
- x1 = v1[k1_offset + 1];
199
- } else {
200
- x1 = v1[k1_offset - 1] + 1;
201
- }
202
- var y1 = x1 - k1;
203
- while (x1 < text1_length && y1 < text2_length && text1.charAt(x1) == text2.charAt(y1)) {
204
- x1++;
205
- y1++;
206
- }
207
- v1[k1_offset] = x1;
208
- if (x1 > text1_length) {
209
- k1end += 2;
210
- } else if (y1 > text2_length) {
211
- k1start += 2;
212
- } else if (front) {
213
- var k2_offset = v_offset + delta - k1;
214
- if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
215
- var x2 = text1_length - v2[k2_offset];
216
- if (x1 >= x2) {
217
- return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
218
- }
219
- }
220
- }
221
- }
222
- for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
223
- var k2_offset = v_offset + k2;
224
- var x2;
225
- if (k2 == -d || k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1]) {
226
- x2 = v2[k2_offset + 1];
227
- } else {
228
- x2 = v2[k2_offset - 1] + 1;
229
- }
230
- var y2 = x2 - k2;
231
- while (x2 < text1_length && y2 < text2_length && text1.charAt(text1_length - x2 - 1) == text2.charAt(text2_length - y2 - 1)) {
232
- x2++;
233
- y2++;
234
- }
235
- v2[k2_offset] = x2;
236
- if (x2 > text1_length) {
237
- k2end += 2;
238
- } else if (y2 > text2_length) {
239
- k2start += 2;
240
- } else if (!front) {
241
- var k1_offset = v_offset + delta - k2;
242
- if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
243
- var x1 = v1[k1_offset];
244
- var y1 = v_offset + x1 - k1_offset;
245
- x2 = text1_length - x2;
246
- if (x1 >= x2) {
247
- return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
248
- }
249
- }
250
- }
251
- }
252
- }
253
- return [
254
- new diff_match_patch2.Diff(DIFF_DELETE, text1),
255
- new diff_match_patch2.Diff(DIFF_INSERT, text2)
256
- ];
257
- };
258
- diff_match_patch2.prototype.diff_bisectSplit_ = function(text1, text2, x, y, deadline) {
259
- var text1a = text1.substring(0, x);
260
- var text2a = text2.substring(0, y);
261
- var text1b = text1.substring(x);
262
- var text2b = text2.substring(y);
263
- var diffs = this.diff_main(text1a, text2a, false, deadline);
264
- var diffsb = this.diff_main(text1b, text2b, false, deadline);
265
- return diffs.concat(diffsb);
266
- };
267
- diff_match_patch2.prototype.diff_linesToChars_ = function(text1, text2) {
268
- var lineArray = [];
269
- var lineHash = {};
270
- lineArray[0] = "";
271
- function diff_linesToCharsMunge_(text) {
272
- var chars = "";
273
- var lineStart = 0;
274
- var lineEnd = -1;
275
- var lineArrayLength = lineArray.length;
276
- while (lineEnd < text.length - 1) {
277
- lineEnd = text.indexOf("\n", lineStart);
278
- if (lineEnd == -1) {
279
- lineEnd = text.length - 1;
280
- }
281
- var line = text.substring(lineStart, lineEnd + 1);
282
- if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : lineHash[line] !== void 0) {
283
- chars += String.fromCharCode(lineHash[line]);
284
- } else {
285
- if (lineArrayLength == maxLines) {
286
- line = text.substring(lineStart);
287
- lineEnd = text.length;
288
- }
289
- chars += String.fromCharCode(lineArrayLength);
290
- lineHash[line] = lineArrayLength;
291
- lineArray[lineArrayLength++] = line;
292
- }
293
- lineStart = lineEnd + 1;
294
- }
295
- return chars;
296
- }
297
- var maxLines = 4e4;
298
- var chars1 = diff_linesToCharsMunge_(text1);
299
- maxLines = 65535;
300
- var chars2 = diff_linesToCharsMunge_(text2);
301
- return { chars1, chars2, lineArray };
302
- };
303
- diff_match_patch2.prototype.diff_charsToLines_ = function(diffs, lineArray) {
304
- for (var i = 0; i < diffs.length; i++) {
305
- var chars = diffs[i][1];
306
- var text = [];
307
- for (var j = 0; j < chars.length; j++) {
308
- text[j] = lineArray[chars.charCodeAt(j)];
309
- }
310
- diffs[i][1] = text.join("");
311
- }
312
- };
313
- diff_match_patch2.prototype.diff_commonPrefix = function(text1, text2) {
314
- if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
315
- return 0;
316
- }
317
- var pointermin = 0;
318
- var pointermax = Math.min(text1.length, text2.length);
319
- var pointermid = pointermax;
320
- var pointerstart = 0;
321
- while (pointermin < pointermid) {
322
- if (text1.substring(pointerstart, pointermid) == text2.substring(pointerstart, pointermid)) {
323
- pointermin = pointermid;
324
- pointerstart = pointermin;
325
- } else {
326
- pointermax = pointermid;
327
- }
328
- pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
329
- }
330
- return pointermid;
331
- };
332
- diff_match_patch2.prototype.diff_commonSuffix = function(text1, text2) {
333
- if (!text1 || !text2 || text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
334
- return 0;
335
- }
336
- var pointermin = 0;
337
- var pointermax = Math.min(text1.length, text2.length);
338
- var pointermid = pointermax;
339
- var pointerend = 0;
340
- while (pointermin < pointermid) {
341
- if (text1.substring(text1.length - pointermid, text1.length - pointerend) == text2.substring(text2.length - pointermid, text2.length - pointerend)) {
342
- pointermin = pointermid;
343
- pointerend = pointermin;
344
- } else {
345
- pointermax = pointermid;
346
- }
347
- pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
348
- }
349
- return pointermid;
350
- };
351
- diff_match_patch2.prototype.diff_commonOverlap_ = function(text1, text2) {
352
- var text1_length = text1.length;
353
- var text2_length = text2.length;
354
- if (text1_length == 0 || text2_length == 0) {
355
- return 0;
356
- }
357
- if (text1_length > text2_length) {
358
- text1 = text1.substring(text1_length - text2_length);
359
- } else if (text1_length < text2_length) {
360
- text2 = text2.substring(0, text1_length);
361
- }
362
- var text_length = Math.min(text1_length, text2_length);
363
- if (text1 == text2) {
364
- return text_length;
365
- }
366
- var best = 0;
367
- var length = 1;
368
- while (true) {
369
- var pattern = text1.substring(text_length - length);
370
- var found = text2.indexOf(pattern);
371
- if (found == -1) {
372
- return best;
373
- }
374
- length += found;
375
- if (found == 0 || text1.substring(text_length - length) == text2.substring(0, length)) {
376
- best = length;
377
- length++;
378
- }
379
- }
380
- };
381
- diff_match_patch2.prototype.diff_halfMatch_ = function(text1, text2) {
382
- if (this.Diff_Timeout <= 0) {
383
- return null;
384
- }
385
- var longtext = text1.length > text2.length ? text1 : text2;
386
- var shorttext = text1.length > text2.length ? text2 : text1;
387
- if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
388
- return null;
389
- }
390
- var dmp2 = this;
391
- function diff_halfMatchI_(longtext2, shorttext2, i) {
392
- var seed = longtext2.substring(i, i + Math.floor(longtext2.length / 4));
393
- var j = -1;
394
- var best_common = "";
395
- var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
396
- while ((j = shorttext2.indexOf(seed, j + 1)) != -1) {
397
- var prefixLength = dmp2.diff_commonPrefix(
398
- longtext2.substring(i),
399
- shorttext2.substring(j)
400
- );
401
- var suffixLength = dmp2.diff_commonSuffix(
402
- longtext2.substring(0, i),
403
- shorttext2.substring(0, j)
404
- );
405
- if (best_common.length < suffixLength + prefixLength) {
406
- best_common = shorttext2.substring(j - suffixLength, j) + shorttext2.substring(j, j + prefixLength);
407
- best_longtext_a = longtext2.substring(0, i - suffixLength);
408
- best_longtext_b = longtext2.substring(i + prefixLength);
409
- best_shorttext_a = shorttext2.substring(0, j - suffixLength);
410
- best_shorttext_b = shorttext2.substring(j + prefixLength);
411
- }
412
- }
413
- if (best_common.length * 2 >= longtext2.length) {
414
- return [
415
- best_longtext_a,
416
- best_longtext_b,
417
- best_shorttext_a,
418
- best_shorttext_b,
419
- best_common
420
- ];
421
- } else {
422
- return null;
423
- }
424
- }
425
- var hm1 = diff_halfMatchI_(
426
- longtext,
427
- shorttext,
428
- Math.ceil(longtext.length / 4)
429
- );
430
- var hm2 = diff_halfMatchI_(
431
- longtext,
432
- shorttext,
433
- Math.ceil(longtext.length / 2)
434
- );
435
- var hm;
436
- if (!hm1 && !hm2) {
437
- return null;
438
- } else if (!hm2) {
439
- hm = hm1;
440
- } else if (!hm1) {
441
- hm = hm2;
442
- } else {
443
- hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
444
- }
445
- var text1_a, text1_b, text2_a, text2_b;
446
- if (text1.length > text2.length) {
447
- text1_a = hm[0];
448
- text1_b = hm[1];
449
- text2_a = hm[2];
450
- text2_b = hm[3];
451
- } else {
452
- text2_a = hm[0];
453
- text2_b = hm[1];
454
- text1_a = hm[2];
455
- text1_b = hm[3];
456
- }
457
- var mid_common = hm[4];
458
- return [text1_a, text1_b, text2_a, text2_b, mid_common];
459
- };
460
- diff_match_patch2.prototype.diff_cleanupSemantic = function(diffs) {
461
- var changes = false;
462
- var equalities = [];
463
- var equalitiesLength = 0;
464
- var lastEquality = null;
465
- var pointer = 0;
466
- var length_insertions1 = 0;
467
- var length_deletions1 = 0;
468
- var length_insertions2 = 0;
469
- var length_deletions2 = 0;
470
- while (pointer < diffs.length) {
471
- if (diffs[pointer][0] == DIFF_EQUAL) {
472
- equalities[equalitiesLength++] = pointer;
473
- length_insertions1 = length_insertions2;
474
- length_deletions1 = length_deletions2;
475
- length_insertions2 = 0;
476
- length_deletions2 = 0;
477
- lastEquality = diffs[pointer][1];
478
- } else {
479
- if (diffs[pointer][0] == DIFF_INSERT) {
480
- length_insertions2 += diffs[pointer][1].length;
481
- } else {
482
- length_deletions2 += diffs[pointer][1].length;
483
- }
484
- if (lastEquality && lastEquality.length <= Math.max(length_insertions1, length_deletions1) && lastEquality.length <= Math.max(
485
- length_insertions2,
486
- length_deletions2
487
- )) {
488
- diffs.splice(
489
- equalities[equalitiesLength - 1],
490
- 0,
491
- new diff_match_patch2.Diff(DIFF_DELETE, lastEquality)
492
- );
493
- diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
494
- equalitiesLength--;
495
- equalitiesLength--;
496
- pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
497
- length_insertions1 = 0;
498
- length_deletions1 = 0;
499
- length_insertions2 = 0;
500
- length_deletions2 = 0;
501
- lastEquality = null;
502
- changes = true;
503
- }
504
- }
505
- pointer++;
506
- }
507
- if (changes) {
508
- this.diff_cleanupMerge(diffs);
509
- }
510
- this.diff_cleanupSemanticLossless(diffs);
511
- pointer = 1;
512
- while (pointer < diffs.length) {
513
- if (diffs[pointer - 1][0] == DIFF_DELETE && diffs[pointer][0] == DIFF_INSERT) {
514
- var deletion = diffs[pointer - 1][1];
515
- var insertion = diffs[pointer][1];
516
- var overlap_length1 = this.diff_commonOverlap_(deletion, insertion);
517
- var overlap_length2 = this.diff_commonOverlap_(insertion, deletion);
518
- if (overlap_length1 >= overlap_length2) {
519
- if (overlap_length1 >= deletion.length / 2 || overlap_length1 >= insertion.length / 2) {
520
- diffs.splice(pointer, 0, new diff_match_patch2.Diff(
521
- DIFF_EQUAL,
522
- insertion.substring(0, overlap_length1)
523
- ));
524
- diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlap_length1);
525
- diffs[pointer + 1][1] = insertion.substring(overlap_length1);
526
- pointer++;
527
- }
528
- } else {
529
- if (overlap_length2 >= deletion.length / 2 || overlap_length2 >= insertion.length / 2) {
530
- diffs.splice(pointer, 0, new diff_match_patch2.Diff(
531
- DIFF_EQUAL,
532
- deletion.substring(0, overlap_length2)
533
- ));
534
- diffs[pointer - 1][0] = DIFF_INSERT;
535
- diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlap_length2);
536
- diffs[pointer + 1][0] = DIFF_DELETE;
537
- diffs[pointer + 1][1] = deletion.substring(overlap_length2);
538
- pointer++;
539
- }
540
- }
541
- pointer++;
542
- }
543
- pointer++;
544
- }
545
- };
546
- diff_match_patch2.prototype.diff_cleanupSemanticLossless = function(diffs) {
547
- function diff_cleanupSemanticScore_(one, two) {
548
- if (!one || !two) {
549
- return 6;
550
- }
551
- var char1 = one.charAt(one.length - 1);
552
- var char2 = two.charAt(0);
553
- var nonAlphaNumeric1 = char1.match(diff_match_patch2.nonAlphaNumericRegex_);
554
- var nonAlphaNumeric2 = char2.match(diff_match_patch2.nonAlphaNumericRegex_);
555
- var whitespace1 = nonAlphaNumeric1 && char1.match(diff_match_patch2.whitespaceRegex_);
556
- var whitespace2 = nonAlphaNumeric2 && char2.match(diff_match_patch2.whitespaceRegex_);
557
- var lineBreak1 = whitespace1 && char1.match(diff_match_patch2.linebreakRegex_);
558
- var lineBreak2 = whitespace2 && char2.match(diff_match_patch2.linebreakRegex_);
559
- var blankLine1 = lineBreak1 && one.match(diff_match_patch2.blanklineEndRegex_);
560
- var blankLine2 = lineBreak2 && two.match(diff_match_patch2.blanklineStartRegex_);
561
- if (blankLine1 || blankLine2) {
562
- return 5;
563
- } else if (lineBreak1 || lineBreak2) {
564
- return 4;
565
- } else if (nonAlphaNumeric1 && !whitespace1 && whitespace2) {
566
- return 3;
567
- } else if (whitespace1 || whitespace2) {
568
- return 2;
569
- } else if (nonAlphaNumeric1 || nonAlphaNumeric2) {
570
- return 1;
571
- }
572
- return 0;
573
- }
574
- var pointer = 1;
575
- while (pointer < diffs.length - 1) {
576
- if (diffs[pointer - 1][0] == DIFF_EQUAL && diffs[pointer + 1][0] == DIFF_EQUAL) {
577
- var equality1 = diffs[pointer - 1][1];
578
- var edit = diffs[pointer][1];
579
- var equality2 = diffs[pointer + 1][1];
580
- var commonOffset = this.diff_commonSuffix(equality1, edit);
581
- if (commonOffset) {
582
- var commonString = edit.substring(edit.length - commonOffset);
583
- equality1 = equality1.substring(0, equality1.length - commonOffset);
584
- edit = commonString + edit.substring(0, edit.length - commonOffset);
585
- equality2 = commonString + equality2;
586
- }
587
- var bestEquality1 = equality1;
588
- var bestEdit = edit;
589
- var bestEquality2 = equality2;
590
- var bestScore = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2);
591
- while (edit.charAt(0) === equality2.charAt(0)) {
592
- equality1 += edit.charAt(0);
593
- edit = edit.substring(1) + equality2.charAt(0);
594
- equality2 = equality2.substring(1);
595
- var score = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2);
596
- if (score >= bestScore) {
597
- bestScore = score;
598
- bestEquality1 = equality1;
599
- bestEdit = edit;
600
- bestEquality2 = equality2;
601
- }
602
- }
603
- if (diffs[pointer - 1][1] != bestEquality1) {
604
- if (bestEquality1) {
605
- diffs[pointer - 1][1] = bestEquality1;
606
- } else {
607
- diffs.splice(pointer - 1, 1);
608
- pointer--;
609
- }
610
- diffs[pointer][1] = bestEdit;
611
- if (bestEquality2) {
612
- diffs[pointer + 1][1] = bestEquality2;
613
- } else {
614
- diffs.splice(pointer + 1, 1);
615
- pointer--;
616
- }
617
- }
618
- }
619
- pointer++;
620
- }
621
- };
622
- diff_match_patch2.nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/;
623
- diff_match_patch2.whitespaceRegex_ = /\s/;
624
- diff_match_patch2.linebreakRegex_ = /[\r\n]/;
625
- diff_match_patch2.blanklineEndRegex_ = /\n\r?\n$/;
626
- diff_match_patch2.blanklineStartRegex_ = /^\r?\n\r?\n/;
627
- diff_match_patch2.prototype.diff_cleanupEfficiency = function(diffs) {
628
- var changes = false;
629
- var equalities = [];
630
- var equalitiesLength = 0;
631
- var lastEquality = null;
632
- var pointer = 0;
633
- var pre_ins = false;
634
- var pre_del = false;
635
- var post_ins = false;
636
- var post_del = false;
637
- while (pointer < diffs.length) {
638
- if (diffs[pointer][0] == DIFF_EQUAL) {
639
- if (diffs[pointer][1].length < this.Diff_EditCost && (post_ins || post_del)) {
640
- equalities[equalitiesLength++] = pointer;
641
- pre_ins = post_ins;
642
- pre_del = post_del;
643
- lastEquality = diffs[pointer][1];
644
- } else {
645
- equalitiesLength = 0;
646
- lastEquality = null;
647
- }
648
- post_ins = post_del = false;
649
- } else {
650
- if (diffs[pointer][0] == DIFF_DELETE) {
651
- post_del = true;
652
- } else {
653
- post_ins = true;
654
- }
655
- if (lastEquality && (pre_ins && pre_del && post_ins && post_del || lastEquality.length < this.Diff_EditCost / 2 && pre_ins + pre_del + post_ins + post_del == 3)) {
656
- diffs.splice(
657
- equalities[equalitiesLength - 1],
658
- 0,
659
- new diff_match_patch2.Diff(DIFF_DELETE, lastEquality)
660
- );
661
- diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
662
- equalitiesLength--;
663
- lastEquality = null;
664
- if (pre_ins && pre_del) {
665
- post_ins = post_del = true;
666
- equalitiesLength = 0;
667
- } else {
668
- equalitiesLength--;
669
- pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
670
- post_ins = post_del = false;
671
- }
672
- changes = true;
673
- }
674
- }
675
- pointer++;
676
- }
677
- if (changes) {
678
- this.diff_cleanupMerge(diffs);
679
- }
680
- };
681
- diff_match_patch2.prototype.diff_cleanupMerge = function(diffs) {
682
- diffs.push(new diff_match_patch2.Diff(DIFF_EQUAL, ""));
683
- var pointer = 0;
684
- var count_delete = 0;
685
- var count_insert = 0;
686
- var text_delete = "";
687
- var text_insert = "";
688
- var commonlength;
689
- while (pointer < diffs.length) {
690
- switch (diffs[pointer][0]) {
691
- case DIFF_INSERT:
692
- count_insert++;
693
- text_insert += diffs[pointer][1];
694
- pointer++;
695
- break;
696
- case DIFF_DELETE:
697
- count_delete++;
698
- text_delete += diffs[pointer][1];
699
- pointer++;
700
- break;
701
- case DIFF_EQUAL:
702
- if (count_delete + count_insert > 1) {
703
- if (count_delete !== 0 && count_insert !== 0) {
704
- commonlength = this.diff_commonPrefix(text_insert, text_delete);
705
- if (commonlength !== 0) {
706
- if (pointer - count_delete - count_insert > 0 && diffs[pointer - count_delete - count_insert - 1][0] == DIFF_EQUAL) {
707
- diffs[pointer - count_delete - count_insert - 1][1] += text_insert.substring(0, commonlength);
708
- } else {
709
- diffs.splice(0, 0, new diff_match_patch2.Diff(
710
- DIFF_EQUAL,
711
- text_insert.substring(0, commonlength)
712
- ));
713
- pointer++;
714
- }
715
- text_insert = text_insert.substring(commonlength);
716
- text_delete = text_delete.substring(commonlength);
717
- }
718
- commonlength = this.diff_commonSuffix(text_insert, text_delete);
719
- if (commonlength !== 0) {
720
- diffs[pointer][1] = text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1];
721
- text_insert = text_insert.substring(0, text_insert.length - commonlength);
722
- text_delete = text_delete.substring(0, text_delete.length - commonlength);
723
- }
724
- }
725
- pointer -= count_delete + count_insert;
726
- diffs.splice(pointer, count_delete + count_insert);
727
- if (text_delete.length) {
728
- diffs.splice(
729
- pointer,
730
- 0,
731
- new diff_match_patch2.Diff(DIFF_DELETE, text_delete)
732
- );
733
- pointer++;
734
- }
735
- if (text_insert.length) {
736
- diffs.splice(
737
- pointer,
738
- 0,
739
- new diff_match_patch2.Diff(DIFF_INSERT, text_insert)
740
- );
741
- pointer++;
742
- }
743
- pointer++;
744
- } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
745
- diffs[pointer - 1][1] += diffs[pointer][1];
746
- diffs.splice(pointer, 1);
747
- } else {
748
- pointer++;
749
- }
750
- count_insert = 0;
751
- count_delete = 0;
752
- text_delete = "";
753
- text_insert = "";
754
- break;
755
- }
756
- }
757
- if (diffs[diffs.length - 1][1] === "") {
758
- diffs.pop();
759
- }
760
- var changes = false;
761
- pointer = 1;
762
- while (pointer < diffs.length - 1) {
763
- if (diffs[pointer - 1][0] == DIFF_EQUAL && diffs[pointer + 1][0] == DIFF_EQUAL) {
764
- if (diffs[pointer][1].substring(diffs[pointer][1].length - diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
765
- diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length);
766
- diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
767
- diffs.splice(pointer - 1, 1);
768
- changes = true;
769
- } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) == diffs[pointer + 1][1]) {
770
- diffs[pointer - 1][1] += diffs[pointer + 1][1];
771
- diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1];
772
- diffs.splice(pointer + 1, 1);
773
- changes = true;
774
- }
775
- }
776
- pointer++;
777
- }
778
- if (changes) {
779
- this.diff_cleanupMerge(diffs);
780
- }
781
- };
782
- diff_match_patch2.prototype.diff_xIndex = function(diffs, loc) {
783
- var chars1 = 0;
784
- var chars2 = 0;
785
- var last_chars1 = 0;
786
- var last_chars2 = 0;
787
- var x;
788
- for (x = 0; x < diffs.length; x++) {
789
- if (diffs[x][0] !== DIFF_INSERT) {
790
- chars1 += diffs[x][1].length;
791
- }
792
- if (diffs[x][0] !== DIFF_DELETE) {
793
- chars2 += diffs[x][1].length;
794
- }
795
- if (chars1 > loc) {
796
- break;
797
- }
798
- last_chars1 = chars1;
799
- last_chars2 = chars2;
800
- }
801
- if (diffs.length != x && diffs[x][0] === DIFF_DELETE) {
802
- return last_chars2;
803
- }
804
- return last_chars2 + (loc - last_chars1);
805
- };
806
- diff_match_patch2.prototype.diff_prettyHtml = function(diffs) {
807
- var html2 = [];
808
- var pattern_amp = /&/g;
809
- var pattern_lt = /</g;
810
- var pattern_gt = />/g;
811
- var pattern_para = /\n/g;
812
- for (var x = 0; x < diffs.length; x++) {
813
- var op = diffs[x][0];
814
- var data = diffs[x][1];
815
- var text = data.replace(pattern_amp, "&amp;").replace(pattern_lt, "&lt;").replace(pattern_gt, "&gt;").replace(pattern_para, "&para;<br>");
816
- switch (op) {
817
- case DIFF_INSERT:
818
- html2[x] = '<ins style="background:#e6ffe6;">' + text + "</ins>";
819
- break;
820
- case DIFF_DELETE:
821
- html2[x] = '<del style="background:#ffe6e6;">' + text + "</del>";
822
- break;
823
- case DIFF_EQUAL:
824
- html2[x] = "<span>" + text + "</span>";
825
- break;
826
- }
827
- }
828
- return html2.join("");
829
- };
830
- diff_match_patch2.prototype.diff_text1 = function(diffs) {
831
- var text = [];
832
- for (var x = 0; x < diffs.length; x++) {
833
- if (diffs[x][0] !== DIFF_INSERT) {
834
- text[x] = diffs[x][1];
835
- }
836
- }
837
- return text.join("");
838
- };
839
- diff_match_patch2.prototype.diff_text2 = function(diffs) {
840
- var text = [];
841
- for (var x = 0; x < diffs.length; x++) {
842
- if (diffs[x][0] !== DIFF_DELETE) {
843
- text[x] = diffs[x][1];
844
- }
845
- }
846
- return text.join("");
847
- };
848
- diff_match_patch2.prototype.diff_levenshtein = function(diffs) {
849
- var levenshtein = 0;
850
- var insertions = 0;
851
- var deletions = 0;
852
- for (var x = 0; x < diffs.length; x++) {
853
- var op = diffs[x][0];
854
- var data = diffs[x][1];
855
- switch (op) {
856
- case DIFF_INSERT:
857
- insertions += data.length;
858
- break;
859
- case DIFF_DELETE:
860
- deletions += data.length;
861
- break;
862
- case DIFF_EQUAL:
863
- levenshtein += Math.max(insertions, deletions);
864
- insertions = 0;
865
- deletions = 0;
866
- break;
867
- }
868
- }
869
- levenshtein += Math.max(insertions, deletions);
870
- return levenshtein;
871
- };
872
- diff_match_patch2.prototype.diff_toDelta = function(diffs) {
873
- var text = [];
874
- for (var x = 0; x < diffs.length; x++) {
875
- switch (diffs[x][0]) {
876
- case DIFF_INSERT:
877
- text[x] = "+" + encodeURI(diffs[x][1]);
878
- break;
879
- case DIFF_DELETE:
880
- text[x] = "-" + diffs[x][1].length;
881
- break;
882
- case DIFF_EQUAL:
883
- text[x] = "=" + diffs[x][1].length;
884
- break;
885
- }
886
- }
887
- return text.join(" ").replace(/%20/g, " ");
888
- };
889
- diff_match_patch2.prototype.diff_fromDelta = function(text1, delta) {
890
- var diffs = [];
891
- var diffsLength = 0;
892
- var pointer = 0;
893
- var tokens = delta.split(/\t/g);
894
- for (var x = 0; x < tokens.length; x++) {
895
- var param = tokens[x].substring(1);
896
- switch (tokens[x].charAt(0)) {
897
- case "+":
898
- try {
899
- diffs[diffsLength++] = new diff_match_patch2.Diff(DIFF_INSERT, decodeURI(param));
900
- } catch (ex) {
901
- throw new Error("Illegal escape in diff_fromDelta: " + param);
902
- }
903
- break;
904
- case "-":
905
- // Fall through.
906
- case "=":
907
- var n = parseInt(param, 10);
908
- if (isNaN(n) || n < 0) {
909
- throw new Error("Invalid number in diff_fromDelta: " + param);
910
- }
911
- var text = text1.substring(pointer, pointer += n);
912
- if (tokens[x].charAt(0) == "=") {
913
- diffs[diffsLength++] = new diff_match_patch2.Diff(DIFF_EQUAL, text);
914
- } else {
915
- diffs[diffsLength++] = new diff_match_patch2.Diff(DIFF_DELETE, text);
916
- }
917
- break;
918
- default:
919
- if (tokens[x]) {
920
- throw new Error("Invalid diff operation in diff_fromDelta: " + tokens[x]);
921
- }
922
- }
923
- }
924
- if (pointer != text1.length) {
925
- throw new Error("Delta length (" + pointer + ") does not equal source text length (" + text1.length + ").");
926
- }
927
- return diffs;
928
- };
929
- diff_match_patch2.prototype.match_main = function(text, pattern, loc) {
930
- if (text == null || pattern == null || loc == null) {
931
- throw new Error("Null input. (match_main)");
932
- }
933
- loc = Math.max(0, Math.min(loc, text.length));
934
- if (text == pattern) {
935
- return 0;
936
- } else if (!text.length) {
937
- return -1;
938
- } else if (text.substring(loc, loc + pattern.length) == pattern) {
939
- return loc;
940
- } else {
941
- return this.match_bitap_(text, pattern, loc);
942
- }
943
- };
944
- diff_match_patch2.prototype.match_bitap_ = function(text, pattern, loc) {
945
- if (pattern.length > this.Match_MaxBits) {
946
- throw new Error("Pattern too long for this browser.");
947
- }
948
- var s = this.match_alphabet_(pattern);
949
- var dmp2 = this;
950
- function match_bitapScore_(e, x) {
951
- var accuracy = e / pattern.length;
952
- var proximity = Math.abs(loc - x);
953
- if (!dmp2.Match_Distance) {
954
- return proximity ? 1 : accuracy;
955
- }
956
- return accuracy + proximity / dmp2.Match_Distance;
957
- }
958
- var score_threshold = this.Match_Threshold;
959
- var best_loc = text.indexOf(pattern, loc);
960
- if (best_loc != -1) {
961
- score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold);
962
- best_loc = text.lastIndexOf(pattern, loc + pattern.length);
963
- if (best_loc != -1) {
964
- score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold);
965
- }
966
- }
967
- var matchmask = 1 << pattern.length - 1;
968
- best_loc = -1;
969
- var bin_min, bin_mid;
970
- var bin_max = pattern.length + text.length;
971
- var last_rd;
972
- for (var d = 0; d < pattern.length; d++) {
973
- bin_min = 0;
974
- bin_mid = bin_max;
975
- while (bin_min < bin_mid) {
976
- if (match_bitapScore_(d, loc + bin_mid) <= score_threshold) {
977
- bin_min = bin_mid;
978
- } else {
979
- bin_max = bin_mid;
980
- }
981
- bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min);
982
- }
983
- bin_max = bin_mid;
984
- var start = Math.max(1, loc - bin_mid + 1);
985
- var finish = Math.min(loc + bin_mid, text.length) + pattern.length;
986
- var rd = Array(finish + 2);
987
- rd[finish + 1] = (1 << d) - 1;
988
- for (var j = finish; j >= start; j--) {
989
- var charMatch = s[text.charAt(j - 1)];
990
- if (d === 0) {
991
- rd[j] = (rd[j + 1] << 1 | 1) & charMatch;
992
- } else {
993
- rd[j] = (rd[j + 1] << 1 | 1) & charMatch | ((last_rd[j + 1] | last_rd[j]) << 1 | 1) | last_rd[j + 1];
994
- }
995
- if (rd[j] & matchmask) {
996
- var score = match_bitapScore_(d, j - 1);
997
- if (score <= score_threshold) {
998
- score_threshold = score;
999
- best_loc = j - 1;
1000
- if (best_loc > loc) {
1001
- start = Math.max(1, 2 * loc - best_loc);
1002
- } else {
1003
- break;
1004
- }
1005
- }
1006
- }
1007
- }
1008
- if (match_bitapScore_(d + 1, loc) > score_threshold) {
1009
- break;
1010
- }
1011
- last_rd = rd;
1012
- }
1013
- return best_loc;
1014
- };
1015
- diff_match_patch2.prototype.match_alphabet_ = function(pattern) {
1016
- var s = {};
1017
- for (var i = 0; i < pattern.length; i++) {
1018
- s[pattern.charAt(i)] = 0;
1019
- }
1020
- for (var i = 0; i < pattern.length; i++) {
1021
- s[pattern.charAt(i)] |= 1 << pattern.length - i - 1;
1022
- }
1023
- return s;
1024
- };
1025
- diff_match_patch2.prototype.patch_addContext_ = function(patch, text) {
1026
- if (text.length == 0) {
1027
- return;
1028
- }
1029
- if (patch.start2 === null) {
1030
- throw Error("patch not initialized");
1031
- }
1032
- var pattern = text.substring(patch.start2, patch.start2 + patch.length1);
1033
- var padding = 0;
1034
- while (text.indexOf(pattern) != text.lastIndexOf(pattern) && pattern.length < this.Match_MaxBits - this.Patch_Margin - this.Patch_Margin) {
1035
- padding += this.Patch_Margin;
1036
- pattern = text.substring(
1037
- patch.start2 - padding,
1038
- patch.start2 + patch.length1 + padding
1039
- );
1040
- }
1041
- padding += this.Patch_Margin;
1042
- var prefix = text.substring(patch.start2 - padding, patch.start2);
1043
- if (prefix) {
1044
- patch.diffs.unshift(new diff_match_patch2.Diff(DIFF_EQUAL, prefix));
1045
- }
1046
- var suffix = text.substring(
1047
- patch.start2 + patch.length1,
1048
- patch.start2 + patch.length1 + padding
1049
- );
1050
- if (suffix) {
1051
- patch.diffs.push(new diff_match_patch2.Diff(DIFF_EQUAL, suffix));
1052
- }
1053
- patch.start1 -= prefix.length;
1054
- patch.start2 -= prefix.length;
1055
- patch.length1 += prefix.length + suffix.length;
1056
- patch.length2 += prefix.length + suffix.length;
1057
- };
1058
- diff_match_patch2.prototype.patch_make = function(a, opt_b, opt_c) {
1059
- var text1, diffs;
1060
- if (typeof a == "string" && typeof opt_b == "string" && typeof opt_c == "undefined") {
1061
- text1 = /** @type {string} */
1062
- a;
1063
- diffs = this.diff_main(
1064
- text1,
1065
- /** @type {string} */
1066
- opt_b,
1067
- true
1068
- );
1069
- if (diffs.length > 2) {
1070
- this.diff_cleanupSemantic(diffs);
1071
- this.diff_cleanupEfficiency(diffs);
1072
- }
1073
- } else if (a && typeof a == "object" && typeof opt_b == "undefined" && typeof opt_c == "undefined") {
1074
- diffs = /** @type {!Array.<!diff_match_patch.Diff>} */
1075
- a;
1076
- text1 = this.diff_text1(diffs);
1077
- } else if (typeof a == "string" && opt_b && typeof opt_b == "object" && typeof opt_c == "undefined") {
1078
- text1 = /** @type {string} */
1079
- a;
1080
- diffs = /** @type {!Array.<!diff_match_patch.Diff>} */
1081
- opt_b;
1082
- } else if (typeof a == "string" && typeof opt_b == "string" && opt_c && typeof opt_c == "object") {
1083
- text1 = /** @type {string} */
1084
- a;
1085
- diffs = /** @type {!Array.<!diff_match_patch.Diff>} */
1086
- opt_c;
1087
- } else {
1088
- throw new Error("Unknown call format to patch_make.");
1089
- }
1090
- if (diffs.length === 0) {
1091
- return [];
1092
- }
1093
- var patches = [];
1094
- var patch = new diff_match_patch2.patch_obj();
1095
- var patchDiffLength = 0;
1096
- var char_count1 = 0;
1097
- var char_count2 = 0;
1098
- var prepatch_text = text1;
1099
- var postpatch_text = text1;
1100
- for (var x = 0; x < diffs.length; x++) {
1101
- var diff_type = diffs[x][0];
1102
- var diff_text = diffs[x][1];
1103
- if (!patchDiffLength && diff_type !== DIFF_EQUAL) {
1104
- patch.start1 = char_count1;
1105
- patch.start2 = char_count2;
1106
- }
1107
- switch (diff_type) {
1108
- case DIFF_INSERT:
1109
- patch.diffs[patchDiffLength++] = diffs[x];
1110
- patch.length2 += diff_text.length;
1111
- postpatch_text = postpatch_text.substring(0, char_count2) + diff_text + postpatch_text.substring(char_count2);
1112
- break;
1113
- case DIFF_DELETE:
1114
- patch.length1 += diff_text.length;
1115
- patch.diffs[patchDiffLength++] = diffs[x];
1116
- postpatch_text = postpatch_text.substring(0, char_count2) + postpatch_text.substring(char_count2 + diff_text.length);
1117
- break;
1118
- case DIFF_EQUAL:
1119
- if (diff_text.length <= 2 * this.Patch_Margin && patchDiffLength && diffs.length != x + 1) {
1120
- patch.diffs[patchDiffLength++] = diffs[x];
1121
- patch.length1 += diff_text.length;
1122
- patch.length2 += diff_text.length;
1123
- } else if (diff_text.length >= 2 * this.Patch_Margin) {
1124
- if (patchDiffLength) {
1125
- this.patch_addContext_(patch, prepatch_text);
1126
- patches.push(patch);
1127
- patch = new diff_match_patch2.patch_obj();
1128
- patchDiffLength = 0;
1129
- prepatch_text = postpatch_text;
1130
- char_count1 = char_count2;
1131
- }
1132
- }
1133
- break;
1134
- }
1135
- if (diff_type !== DIFF_INSERT) {
1136
- char_count1 += diff_text.length;
1137
- }
1138
- if (diff_type !== DIFF_DELETE) {
1139
- char_count2 += diff_text.length;
1140
- }
1141
- }
1142
- if (patchDiffLength) {
1143
- this.patch_addContext_(patch, prepatch_text);
1144
- patches.push(patch);
1145
- }
1146
- return patches;
1147
- };
1148
- diff_match_patch2.prototype.patch_deepCopy = function(patches) {
1149
- var patchesCopy = [];
1150
- for (var x = 0; x < patches.length; x++) {
1151
- var patch = patches[x];
1152
- var patchCopy = new diff_match_patch2.patch_obj();
1153
- patchCopy.diffs = [];
1154
- for (var y = 0; y < patch.diffs.length; y++) {
1155
- patchCopy.diffs[y] = new diff_match_patch2.Diff(patch.diffs[y][0], patch.diffs[y][1]);
1156
- }
1157
- patchCopy.start1 = patch.start1;
1158
- patchCopy.start2 = patch.start2;
1159
- patchCopy.length1 = patch.length1;
1160
- patchCopy.length2 = patch.length2;
1161
- patchesCopy[x] = patchCopy;
1162
- }
1163
- return patchesCopy;
1164
- };
1165
- diff_match_patch2.prototype.patch_apply = function(patches, text) {
1166
- if (patches.length == 0) {
1167
- return [text, []];
1168
- }
1169
- patches = this.patch_deepCopy(patches);
1170
- var nullPadding = this.patch_addPadding(patches);
1171
- text = nullPadding + text + nullPadding;
1172
- this.patch_splitMax(patches);
1173
- var delta = 0;
1174
- var results = [];
1175
- for (var x = 0; x < patches.length; x++) {
1176
- var expected_loc = patches[x].start2 + delta;
1177
- var text1 = this.diff_text1(patches[x].diffs);
1178
- var start_loc;
1179
- var end_loc = -1;
1180
- if (text1.length > this.Match_MaxBits) {
1181
- start_loc = this.match_main(
1182
- text,
1183
- text1.substring(0, this.Match_MaxBits),
1184
- expected_loc
1185
- );
1186
- if (start_loc != -1) {
1187
- end_loc = this.match_main(
1188
- text,
1189
- text1.substring(text1.length - this.Match_MaxBits),
1190
- expected_loc + text1.length - this.Match_MaxBits
1191
- );
1192
- if (end_loc == -1 || start_loc >= end_loc) {
1193
- start_loc = -1;
1194
- }
1195
- }
1196
- } else {
1197
- start_loc = this.match_main(text, text1, expected_loc);
1198
- }
1199
- if (start_loc == -1) {
1200
- results[x] = false;
1201
- delta -= patches[x].length2 - patches[x].length1;
1202
- } else {
1203
- results[x] = true;
1204
- delta = start_loc - expected_loc;
1205
- var text2;
1206
- if (end_loc == -1) {
1207
- text2 = text.substring(start_loc, start_loc + text1.length);
1208
- } else {
1209
- text2 = text.substring(start_loc, end_loc + this.Match_MaxBits);
1210
- }
1211
- if (text1 == text2) {
1212
- text = text.substring(0, start_loc) + this.diff_text2(patches[x].diffs) + text.substring(start_loc + text1.length);
1213
- } else {
1214
- var diffs = this.diff_main(text1, text2, false);
1215
- if (text1.length > this.Match_MaxBits && this.diff_levenshtein(diffs) / text1.length > this.Patch_DeleteThreshold) {
1216
- results[x] = false;
1217
- } else {
1218
- this.diff_cleanupSemanticLossless(diffs);
1219
- var index1 = 0;
1220
- var index2;
1221
- for (var y = 0; y < patches[x].diffs.length; y++) {
1222
- var mod = patches[x].diffs[y];
1223
- if (mod[0] !== DIFF_EQUAL) {
1224
- index2 = this.diff_xIndex(diffs, index1);
1225
- }
1226
- if (mod[0] === DIFF_INSERT) {
1227
- text = text.substring(0, start_loc + index2) + mod[1] + text.substring(start_loc + index2);
1228
- } else if (mod[0] === DIFF_DELETE) {
1229
- text = text.substring(0, start_loc + index2) + text.substring(start_loc + this.diff_xIndex(
1230
- diffs,
1231
- index1 + mod[1].length
1232
- ));
1233
- }
1234
- if (mod[0] !== DIFF_DELETE) {
1235
- index1 += mod[1].length;
1236
- }
1237
- }
1238
- }
1239
- }
1240
- }
1241
- }
1242
- text = text.substring(nullPadding.length, text.length - nullPadding.length);
1243
- return [text, results];
1244
- };
1245
- diff_match_patch2.prototype.patch_addPadding = function(patches) {
1246
- var paddingLength = this.Patch_Margin;
1247
- var nullPadding = "";
1248
- for (var x = 1; x <= paddingLength; x++) {
1249
- nullPadding += String.fromCharCode(x);
1250
- }
1251
- for (var x = 0; x < patches.length; x++) {
1252
- patches[x].start1 += paddingLength;
1253
- patches[x].start2 += paddingLength;
1254
- }
1255
- var patch = patches[0];
1256
- var diffs = patch.diffs;
1257
- if (diffs.length == 0 || diffs[0][0] != DIFF_EQUAL) {
1258
- diffs.unshift(new diff_match_patch2.Diff(DIFF_EQUAL, nullPadding));
1259
- patch.start1 -= paddingLength;
1260
- patch.start2 -= paddingLength;
1261
- patch.length1 += paddingLength;
1262
- patch.length2 += paddingLength;
1263
- } else if (paddingLength > diffs[0][1].length) {
1264
- var extraLength = paddingLength - diffs[0][1].length;
1265
- diffs[0][1] = nullPadding.substring(diffs[0][1].length) + diffs[0][1];
1266
- patch.start1 -= extraLength;
1267
- patch.start2 -= extraLength;
1268
- patch.length1 += extraLength;
1269
- patch.length2 += extraLength;
1270
- }
1271
- patch = patches[patches.length - 1];
1272
- diffs = patch.diffs;
1273
- if (diffs.length == 0 || diffs[diffs.length - 1][0] != DIFF_EQUAL) {
1274
- diffs.push(new diff_match_patch2.Diff(DIFF_EQUAL, nullPadding));
1275
- patch.length1 += paddingLength;
1276
- patch.length2 += paddingLength;
1277
- } else if (paddingLength > diffs[diffs.length - 1][1].length) {
1278
- var extraLength = paddingLength - diffs[diffs.length - 1][1].length;
1279
- diffs[diffs.length - 1][1] += nullPadding.substring(0, extraLength);
1280
- patch.length1 += extraLength;
1281
- patch.length2 += extraLength;
1282
- }
1283
- return nullPadding;
1284
- };
1285
- diff_match_patch2.prototype.patch_splitMax = function(patches) {
1286
- var patch_size = this.Match_MaxBits;
1287
- for (var x = 0; x < patches.length; x++) {
1288
- if (patches[x].length1 <= patch_size) {
1289
- continue;
1290
- }
1291
- var bigpatch = patches[x];
1292
- patches.splice(x--, 1);
1293
- var start1 = bigpatch.start1;
1294
- var start2 = bigpatch.start2;
1295
- var precontext = "";
1296
- while (bigpatch.diffs.length !== 0) {
1297
- var patch = new diff_match_patch2.patch_obj();
1298
- var empty = true;
1299
- patch.start1 = start1 - precontext.length;
1300
- patch.start2 = start2 - precontext.length;
1301
- if (precontext !== "") {
1302
- patch.length1 = patch.length2 = precontext.length;
1303
- patch.diffs.push(new diff_match_patch2.Diff(DIFF_EQUAL, precontext));
1304
- }
1305
- while (bigpatch.diffs.length !== 0 && patch.length1 < patch_size - this.Patch_Margin) {
1306
- var diff_type = bigpatch.diffs[0][0];
1307
- var diff_text = bigpatch.diffs[0][1];
1308
- if (diff_type === DIFF_INSERT) {
1309
- patch.length2 += diff_text.length;
1310
- start2 += diff_text.length;
1311
- patch.diffs.push(bigpatch.diffs.shift());
1312
- empty = false;
1313
- } else if (diff_type === DIFF_DELETE && patch.diffs.length == 1 && patch.diffs[0][0] == DIFF_EQUAL && diff_text.length > 2 * patch_size) {
1314
- patch.length1 += diff_text.length;
1315
- start1 += diff_text.length;
1316
- empty = false;
1317
- patch.diffs.push(new diff_match_patch2.Diff(diff_type, diff_text));
1318
- bigpatch.diffs.shift();
1319
- } else {
1320
- diff_text = diff_text.substring(
1321
- 0,
1322
- patch_size - patch.length1 - this.Patch_Margin
1323
- );
1324
- patch.length1 += diff_text.length;
1325
- start1 += diff_text.length;
1326
- if (diff_type === DIFF_EQUAL) {
1327
- patch.length2 += diff_text.length;
1328
- start2 += diff_text.length;
1329
- } else {
1330
- empty = false;
1331
- }
1332
- patch.diffs.push(new diff_match_patch2.Diff(diff_type, diff_text));
1333
- if (diff_text == bigpatch.diffs[0][1]) {
1334
- bigpatch.diffs.shift();
1335
- } else {
1336
- bigpatch.diffs[0][1] = bigpatch.diffs[0][1].substring(diff_text.length);
1337
- }
1338
- }
1339
- }
1340
- precontext = this.diff_text2(patch.diffs);
1341
- precontext = precontext.substring(precontext.length - this.Patch_Margin);
1342
- var postcontext = this.diff_text1(bigpatch.diffs).substring(0, this.Patch_Margin);
1343
- if (postcontext !== "") {
1344
- patch.length1 += postcontext.length;
1345
- patch.length2 += postcontext.length;
1346
- if (patch.diffs.length !== 0 && patch.diffs[patch.diffs.length - 1][0] === DIFF_EQUAL) {
1347
- patch.diffs[patch.diffs.length - 1][1] += postcontext;
1348
- } else {
1349
- patch.diffs.push(new diff_match_patch2.Diff(DIFF_EQUAL, postcontext));
1350
- }
1351
- }
1352
- if (!empty) {
1353
- patches.splice(++x, 0, patch);
1354
- }
1355
- }
1356
- }
1357
- };
1358
- diff_match_patch2.prototype.patch_toText = function(patches) {
1359
- var text = [];
1360
- for (var x = 0; x < patches.length; x++) {
1361
- text[x] = patches[x];
1362
- }
1363
- return text.join("");
1364
- };
1365
- diff_match_patch2.prototype.patch_fromText = function(textline) {
1366
- var patches = [];
1367
- if (!textline) {
1368
- return patches;
1369
- }
1370
- var text = textline.split("\n");
1371
- var textPointer = 0;
1372
- var patchHeader = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;
1373
- while (textPointer < text.length) {
1374
- var m = text[textPointer].match(patchHeader);
1375
- if (!m) {
1376
- throw new Error("Invalid patch string: " + text[textPointer]);
1377
- }
1378
- var patch = new diff_match_patch2.patch_obj();
1379
- patches.push(patch);
1380
- patch.start1 = parseInt(m[1], 10);
1381
- if (m[2] === "") {
1382
- patch.start1--;
1383
- patch.length1 = 1;
1384
- } else if (m[2] == "0") {
1385
- patch.length1 = 0;
1386
- } else {
1387
- patch.start1--;
1388
- patch.length1 = parseInt(m[2], 10);
1389
- }
1390
- patch.start2 = parseInt(m[3], 10);
1391
- if (m[4] === "") {
1392
- patch.start2--;
1393
- patch.length2 = 1;
1394
- } else if (m[4] == "0") {
1395
- patch.length2 = 0;
1396
- } else {
1397
- patch.start2--;
1398
- patch.length2 = parseInt(m[4], 10);
1399
- }
1400
- textPointer++;
1401
- while (textPointer < text.length) {
1402
- var sign = text[textPointer].charAt(0);
1403
- try {
1404
- var line = decodeURI(text[textPointer].substring(1));
1405
- } catch (ex) {
1406
- throw new Error("Illegal escape in patch_fromText: " + line);
1407
- }
1408
- if (sign == "-") {
1409
- patch.diffs.push(new diff_match_patch2.Diff(DIFF_DELETE, line));
1410
- } else if (sign == "+") {
1411
- patch.diffs.push(new diff_match_patch2.Diff(DIFF_INSERT, line));
1412
- } else if (sign == " ") {
1413
- patch.diffs.push(new diff_match_patch2.Diff(DIFF_EQUAL, line));
1414
- } else if (sign == "@") {
1415
- break;
1416
- } else if (sign === "") {
1417
- } else {
1418
- throw new Error('Invalid patch mode "' + sign + '" in: ' + line);
1419
- }
1420
- textPointer++;
1421
- }
1422
- }
1423
- return patches;
1424
- };
1425
- diff_match_patch2.patch_obj = function() {
1426
- this.diffs = [];
1427
- this.start1 = null;
1428
- this.start2 = null;
1429
- this.length1 = 0;
1430
- this.length2 = 0;
1431
- };
1432
- diff_match_patch2.patch_obj.prototype.toString = function() {
1433
- var coords1, coords2;
1434
- if (this.length1 === 0) {
1435
- coords1 = this.start1 + ",0";
1436
- } else if (this.length1 == 1) {
1437
- coords1 = this.start1 + 1;
1438
- } else {
1439
- coords1 = this.start1 + 1 + "," + this.length1;
1440
- }
1441
- if (this.length2 === 0) {
1442
- coords2 = this.start2 + ",0";
1443
- } else if (this.length2 == 1) {
1444
- coords2 = this.start2 + 1;
1445
- } else {
1446
- coords2 = this.start2 + 1 + "," + this.length2;
1447
- }
1448
- var text = ["@@ -" + coords1 + " +" + coords2 + " @@\n"];
1449
- var op;
1450
- for (var x = 0; x < this.diffs.length; x++) {
1451
- switch (this.diffs[x][0]) {
1452
- case DIFF_INSERT:
1453
- op = "+";
1454
- break;
1455
- case DIFF_DELETE:
1456
- op = "-";
1457
- break;
1458
- case DIFF_EQUAL:
1459
- op = " ";
1460
- break;
1461
- }
1462
- text[x + 1] = op + encodeURI(this.diffs[x][1]) + "\n";
1463
- }
1464
- return text.join("").replace(/%20/g, " ");
1465
- };
1466
- module.exports = diff_match_patch2;
1467
- module.exports["diff_match_patch"] = diff_match_patch2;
1468
- module.exports["DIFF_DELETE"] = DIFF_DELETE;
1469
- module.exports["DIFF_INSERT"] = DIFF_INSERT;
1470
- module.exports["DIFF_EQUAL"] = DIFF_EQUAL;
1471
- }
1472
- });
1473
-
1474
- // ../../node_modules/.pnpm/escape-string-regexp@1.0.5/node_modules/escape-string-regexp/index.js
1475
- var require_escape_string_regexp = __commonJS({
1476
- "../../node_modules/.pnpm/escape-string-regexp@1.0.5/node_modules/escape-string-regexp/index.js"(exports, module) {
1477
- "use strict";
1478
- var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
1479
- module.exports = function(str) {
1480
- if (typeof str !== "string") {
1481
- throw new TypeError("Expected a string");
1482
- }
1483
- return str.replace(matchOperatorsRe, "\\$&");
1484
- };
1485
- }
1486
- });
1487
-
1488
- // ../../node_modules/.pnpm/ansi-styles@3.2.1/node_modules/ansi-styles/index.js
1489
- var require_ansi_styles = __commonJS({
1490
- "../../node_modules/.pnpm/ansi-styles@3.2.1/node_modules/ansi-styles/index.js"(exports, module) {
1491
- "use strict";
1492
- var colorConvert = require_color_convert();
1493
- var wrapAnsi16 = (fn, offset) => function() {
1494
- const code = fn.apply(colorConvert, arguments);
1495
- return `\x1B[${code + offset}m`;
1496
- };
1497
- var wrapAnsi256 = (fn, offset) => function() {
1498
- const code = fn.apply(colorConvert, arguments);
1499
- return `\x1B[${38 + offset};5;${code}m`;
1500
- };
1501
- var wrapAnsi16m = (fn, offset) => function() {
1502
- const rgb = fn.apply(colorConvert, arguments);
1503
- return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1504
- };
1505
- function assembleStyles() {
1506
- const codes = /* @__PURE__ */ new Map();
1507
- const styles = {
1508
- modifier: {
1509
- reset: [0, 0],
1510
- // 21 isn't widely supported and 22 does the same thing
1511
- bold: [1, 22],
1512
- dim: [2, 22],
1513
- italic: [3, 23],
1514
- underline: [4, 24],
1515
- inverse: [7, 27],
1516
- hidden: [8, 28],
1517
- strikethrough: [9, 29]
1518
- },
1519
- color: {
1520
- black: [30, 39],
1521
- red: [31, 39],
1522
- green: [32, 39],
1523
- yellow: [33, 39],
1524
- blue: [34, 39],
1525
- magenta: [35, 39],
1526
- cyan: [36, 39],
1527
- white: [37, 39],
1528
- gray: [90, 39],
1529
- // Bright color
1530
- redBright: [91, 39],
1531
- greenBright: [92, 39],
1532
- yellowBright: [93, 39],
1533
- blueBright: [94, 39],
1534
- magentaBright: [95, 39],
1535
- cyanBright: [96, 39],
1536
- whiteBright: [97, 39]
1537
- },
1538
- bgColor: {
1539
- bgBlack: [40, 49],
1540
- bgRed: [41, 49],
1541
- bgGreen: [42, 49],
1542
- bgYellow: [43, 49],
1543
- bgBlue: [44, 49],
1544
- bgMagenta: [45, 49],
1545
- bgCyan: [46, 49],
1546
- bgWhite: [47, 49],
1547
- // Bright color
1548
- bgBlackBright: [100, 49],
1549
- bgRedBright: [101, 49],
1550
- bgGreenBright: [102, 49],
1551
- bgYellowBright: [103, 49],
1552
- bgBlueBright: [104, 49],
1553
- bgMagentaBright: [105, 49],
1554
- bgCyanBright: [106, 49],
1555
- bgWhiteBright: [107, 49]
1556
- }
1557
- };
1558
- styles.color.grey = styles.color.gray;
1559
- for (const groupName of Object.keys(styles)) {
1560
- const group = styles[groupName];
1561
- for (const styleName of Object.keys(group)) {
1562
- const style = group[styleName];
1563
- styles[styleName] = {
1564
- open: `\x1B[${style[0]}m`,
1565
- close: `\x1B[${style[1]}m`
1566
- };
1567
- group[styleName] = styles[styleName];
1568
- codes.set(style[0], style[1]);
1569
- }
1570
- Object.defineProperty(styles, groupName, {
1571
- value: group,
1572
- enumerable: false
1573
- });
1574
- Object.defineProperty(styles, "codes", {
1575
- value: codes,
1576
- enumerable: false
1577
- });
1578
- }
1579
- const ansi2ansi = (n) => n;
1580
- const rgb2rgb = (r, g, b) => [r, g, b];
1581
- styles.color.close = "\x1B[39m";
1582
- styles.bgColor.close = "\x1B[49m";
1583
- styles.color.ansi = {
1584
- ansi: wrapAnsi16(ansi2ansi, 0)
1585
- };
1586
- styles.color.ansi256 = {
1587
- ansi256: wrapAnsi256(ansi2ansi, 0)
1588
- };
1589
- styles.color.ansi16m = {
1590
- rgb: wrapAnsi16m(rgb2rgb, 0)
1591
- };
1592
- styles.bgColor.ansi = {
1593
- ansi: wrapAnsi16(ansi2ansi, 10)
1594
- };
1595
- styles.bgColor.ansi256 = {
1596
- ansi256: wrapAnsi256(ansi2ansi, 10)
1597
- };
1598
- styles.bgColor.ansi16m = {
1599
- rgb: wrapAnsi16m(rgb2rgb, 10)
1600
- };
1601
- for (let key of Object.keys(colorConvert)) {
1602
- if (typeof colorConvert[key] !== "object") {
1603
- continue;
1604
- }
1605
- const suite = colorConvert[key];
1606
- if (key === "ansi16") {
1607
- key = "ansi";
1608
- }
1609
- if ("ansi16" in suite) {
1610
- styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
1611
- styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
1612
- }
1613
- if ("ansi256" in suite) {
1614
- styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
1615
- styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
1616
- }
1617
- if ("rgb" in suite) {
1618
- styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
1619
- styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
1620
- }
1621
- }
1622
- return styles;
1623
- }
1624
- Object.defineProperty(module, "exports", {
1625
- enumerable: true,
1626
- get: assembleStyles
1627
- });
1628
- }
1629
- });
1630
-
1631
- // ../../node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js
1632
- var require_has_flag = __commonJS({
1633
- "../../node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js"(exports, module) {
1634
- "use strict";
1635
- module.exports = (flag, argv) => {
1636
- argv = argv || process.argv;
1637
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1638
- const pos = argv.indexOf(prefix + flag);
1639
- const terminatorPos = argv.indexOf("--");
1640
- return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
1641
- };
1642
- }
1643
- });
1644
-
1645
- // ../../node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js
1646
- var require_supports_color = __commonJS({
1647
- "../../node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports, module) {
1648
- "use strict";
1649
- var os = __require("os");
1650
- var hasFlag = require_has_flag();
1651
- var env = process.env;
1652
- var forceColor;
1653
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
1654
- forceColor = false;
1655
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1656
- forceColor = true;
1657
- }
1658
- if ("FORCE_COLOR" in env) {
1659
- forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
1660
- }
1661
- function translateLevel(level) {
1662
- if (level === 0) {
1663
- return false;
1664
- }
1665
- return {
1666
- level,
1667
- hasBasic: true,
1668
- has256: level >= 2,
1669
- has16m: level >= 3
1670
- };
1671
- }
1672
- function supportsColor(stream) {
1673
- if (forceColor === false) {
1674
- return 0;
1675
- }
1676
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1677
- return 3;
1678
- }
1679
- if (hasFlag("color=256")) {
1680
- return 2;
1681
- }
1682
- if (stream && !stream.isTTY && forceColor !== true) {
1683
- return 0;
1684
- }
1685
- const min = forceColor ? 1 : 0;
1686
- if (process.platform === "win32") {
1687
- const osRelease = os.release().split(".");
1688
- if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1689
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1690
- }
1691
- return 1;
1692
- }
1693
- if ("CI" in env) {
1694
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1695
- return 1;
1696
- }
1697
- return min;
1698
- }
1699
- if ("TEAMCITY_VERSION" in env) {
1700
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1701
- }
1702
- if (env.COLORTERM === "truecolor") {
1703
- return 3;
1704
- }
1705
- if ("TERM_PROGRAM" in env) {
1706
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1707
- switch (env.TERM_PROGRAM) {
1708
- case "iTerm.app":
1709
- return version >= 3 ? 3 : 2;
1710
- case "Apple_Terminal":
1711
- return 2;
1712
- }
1713
- }
1714
- if (/-256(color)?$/i.test(env.TERM)) {
1715
- return 2;
1716
- }
1717
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1718
- return 1;
1719
- }
1720
- if ("COLORTERM" in env) {
1721
- return 1;
1722
- }
1723
- if (env.TERM === "dumb") {
1724
- return min;
1725
- }
1726
- return min;
1727
- }
1728
- function getSupportLevel(stream) {
1729
- const level = supportsColor(stream);
1730
- return translateLevel(level);
1731
- }
1732
- module.exports = {
1733
- supportsColor: getSupportLevel,
1734
- stdout: getSupportLevel(process.stdout),
1735
- stderr: getSupportLevel(process.stderr)
1736
- };
1737
- }
1738
- });
1739
-
1740
- // ../../node_modules/.pnpm/chalk@2.4.2/node_modules/chalk/templates.js
1741
- var require_templates = __commonJS({
1742
- "../../node_modules/.pnpm/chalk@2.4.2/node_modules/chalk/templates.js"(exports, module) {
1743
- "use strict";
1744
- var TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1745
- var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1746
- var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1747
- var ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
1748
- var ESCAPES = /* @__PURE__ */ new Map([
1749
- ["n", "\n"],
1750
- ["r", "\r"],
1751
- ["t", " "],
1752
- ["b", "\b"],
1753
- ["f", "\f"],
1754
- ["v", "\v"],
1755
- ["0", "\0"],
1756
- ["\\", "\\"],
1757
- ["e", "\x1B"],
1758
- ["a", "\x07"]
1759
- ]);
1760
- function unescape(c) {
1761
- if (c[0] === "u" && c.length === 5 || c[0] === "x" && c.length === 3) {
1762
- return String.fromCharCode(parseInt(c.slice(1), 16));
1763
- }
1764
- return ESCAPES.get(c) || c;
1765
- }
1766
- function parseArguments(name, args) {
1767
- const results = [];
1768
- const chunks = args.trim().split(/\s*,\s*/g);
1769
- let matches;
1770
- for (const chunk of chunks) {
1771
- if (!isNaN(chunk)) {
1772
- results.push(Number(chunk));
1773
- } else if (matches = chunk.match(STRING_REGEX)) {
1774
- results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
1775
- } else {
1776
- throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1777
- }
1778
- }
1779
- return results;
1780
- }
1781
- function parseStyle(style) {
1782
- STYLE_REGEX.lastIndex = 0;
1783
- const results = [];
1784
- let matches;
1785
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
1786
- const name = matches[1];
1787
- if (matches[2]) {
1788
- const args = parseArguments(name, matches[2]);
1789
- results.push([name].concat(args));
1790
- } else {
1791
- results.push([name]);
1792
- }
1793
- }
1794
- return results;
1795
- }
1796
- function buildStyle(chalk2, styles) {
1797
- const enabled = {};
1798
- for (const layer of styles) {
1799
- for (const style of layer.styles) {
1800
- enabled[style[0]] = layer.inverse ? null : style.slice(1);
1801
- }
1802
- }
1803
- let current = chalk2;
1804
- for (const styleName of Object.keys(enabled)) {
1805
- if (Array.isArray(enabled[styleName])) {
1806
- if (!(styleName in current)) {
1807
- throw new Error(`Unknown Chalk style: ${styleName}`);
1808
- }
1809
- if (enabled[styleName].length > 0) {
1810
- current = current[styleName].apply(current, enabled[styleName]);
1811
- } else {
1812
- current = current[styleName];
1813
- }
1814
- }
1815
- }
1816
- return current;
1817
- }
1818
- module.exports = (chalk2, tmp) => {
1819
- const styles = [];
1820
- const chunks = [];
1821
- let chunk = [];
1822
- tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
1823
- if (escapeChar) {
1824
- chunk.push(unescape(escapeChar));
1825
- } else if (style) {
1826
- const str = chunk.join("");
1827
- chunk = [];
1828
- chunks.push(styles.length === 0 ? str : buildStyle(chalk2, styles)(str));
1829
- styles.push({ inverse, styles: parseStyle(style) });
1830
- } else if (close) {
1831
- if (styles.length === 0) {
1832
- throw new Error("Found extraneous } in Chalk template literal");
1833
- }
1834
- chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
1835
- chunk = [];
1836
- styles.pop();
1837
- } else {
1838
- chunk.push(chr);
1839
- }
1840
- });
1841
- chunks.push(chunk.join(""));
1842
- if (styles.length > 0) {
1843
- const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
1844
- throw new Error(errMsg);
1845
- }
1846
- return chunks.join("");
1847
- };
1848
- }
1849
- });
1850
-
1851
- // ../../node_modules/.pnpm/chalk@2.4.2/node_modules/chalk/index.js
1852
- var require_chalk = __commonJS({
1853
- "../../node_modules/.pnpm/chalk@2.4.2/node_modules/chalk/index.js"(exports, module) {
1854
- "use strict";
1855
- var escapeStringRegexp = require_escape_string_regexp();
1856
- var ansiStyles = require_ansi_styles();
1857
- var stdoutColor = require_supports_color().stdout;
1858
- var template = require_templates();
1859
- var isSimpleWindowsTerm = process.platform === "win32" && !(process.env.TERM || "").toLowerCase().startsWith("xterm");
1860
- var levelMapping = ["ansi", "ansi", "ansi256", "ansi16m"];
1861
- var skipModels = /* @__PURE__ */ new Set(["gray"]);
1862
- var styles = /* @__PURE__ */ Object.create(null);
1863
- function applyOptions(obj, options) {
1864
- options = options || {};
1865
- const scLevel = stdoutColor ? stdoutColor.level : 0;
1866
- obj.level = options.level === void 0 ? scLevel : options.level;
1867
- obj.enabled = "enabled" in options ? options.enabled : obj.level > 0;
1868
- }
1869
- function Chalk(options) {
1870
- if (!this || !(this instanceof Chalk) || this.template) {
1871
- const chalk2 = {};
1872
- applyOptions(chalk2, options);
1873
- chalk2.template = function() {
1874
- const args = [].slice.call(arguments);
1875
- return chalkTag.apply(null, [chalk2.template].concat(args));
1876
- };
1877
- Object.setPrototypeOf(chalk2, Chalk.prototype);
1878
- Object.setPrototypeOf(chalk2.template, chalk2);
1879
- chalk2.template.constructor = Chalk;
1880
- return chalk2.template;
1881
- }
1882
- applyOptions(this, options);
1883
- }
1884
- if (isSimpleWindowsTerm) {
1885
- ansiStyles.blue.open = "\x1B[94m";
1886
- }
1887
- for (const key of Object.keys(ansiStyles)) {
1888
- ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), "g");
1889
- styles[key] = {
1890
- get() {
1891
- const codes = ansiStyles[key];
1892
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
1893
- }
1894
- };
1895
- }
1896
- styles.visible = {
1897
- get() {
1898
- return build.call(this, this._styles || [], true, "visible");
1899
- }
1900
- };
1901
- ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), "g");
1902
- for (const model of Object.keys(ansiStyles.color.ansi)) {
1903
- if (skipModels.has(model)) {
1904
- continue;
1905
- }
1906
- styles[model] = {
1907
- get() {
1908
- const level = this.level;
1909
- return function() {
1910
- const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
1911
- const codes = {
1912
- open,
1913
- close: ansiStyles.color.close,
1914
- closeRe: ansiStyles.color.closeRe
1915
- };
1916
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
1917
- };
1918
- }
1919
- };
1920
- }
1921
- ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), "g");
1922
- for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
1923
- if (skipModels.has(model)) {
1924
- continue;
1925
- }
1926
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1927
- styles[bgModel] = {
1928
- get() {
1929
- const level = this.level;
1930
- return function() {
1931
- const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
1932
- const codes = {
1933
- open,
1934
- close: ansiStyles.bgColor.close,
1935
- closeRe: ansiStyles.bgColor.closeRe
1936
- };
1937
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
1938
- };
1939
- }
1940
- };
1941
- }
1942
- var proto = Object.defineProperties(() => {
1943
- }, styles);
1944
- function build(_styles, _empty, key) {
1945
- const builder = function() {
1946
- return applyStyle.apply(builder, arguments);
1947
- };
1948
- builder._styles = _styles;
1949
- builder._empty = _empty;
1950
- const self = this;
1951
- Object.defineProperty(builder, "level", {
1952
- enumerable: true,
1953
- get() {
1954
- return self.level;
1955
- },
1956
- set(level) {
1957
- self.level = level;
1958
- }
1959
- });
1960
- Object.defineProperty(builder, "enabled", {
1961
- enumerable: true,
1962
- get() {
1963
- return self.enabled;
1964
- },
1965
- set(enabled) {
1966
- self.enabled = enabled;
1967
- }
1968
- });
1969
- builder.hasGrey = this.hasGrey || key === "gray" || key === "grey";
1970
- builder.__proto__ = proto;
1971
- return builder;
1972
- }
1973
- function applyStyle() {
1974
- const args = arguments;
1975
- const argsLen = args.length;
1976
- let str = String(arguments[0]);
1977
- if (argsLen === 0) {
1978
- return "";
1979
- }
1980
- if (argsLen > 1) {
1981
- for (let a = 1; a < argsLen; a++) {
1982
- str += " " + args[a];
1983
- }
1984
- }
1985
- if (!this.enabled || this.level <= 0 || !str) {
1986
- return this._empty ? "" : str;
1987
- }
1988
- const originalDim = ansiStyles.dim.open;
1989
- if (isSimpleWindowsTerm && this.hasGrey) {
1990
- ansiStyles.dim.open = "";
1991
- }
1992
- for (const code of this._styles.slice().reverse()) {
1993
- str = code.open + str.replace(code.closeRe, code.open) + code.close;
1994
- str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
1995
- }
1996
- ansiStyles.dim.open = originalDim;
1997
- return str;
1998
- }
1999
- function chalkTag(chalk2, strings) {
2000
- if (!Array.isArray(strings)) {
2001
- return [].slice.call(arguments, 1).join(" ");
2002
- }
2003
- const args = [].slice.call(arguments, 2);
2004
- const parts = [strings.raw[0]];
2005
- for (let i = 1; i < strings.length; i++) {
2006
- parts.push(String(args[i - 1]).replace(/[{}\\]/g, "\\$&"));
2007
- parts.push(String(strings.raw[i]));
2008
- }
2009
- return template(chalk2, parts.join(""));
2010
- }
2011
- Object.defineProperties(Chalk.prototype, styles);
2012
- module.exports = Chalk();
2013
- module.exports.supportsColor = stdoutColor;
2014
- module.exports.default = module.exports;
2015
- }
2016
- });
2017
-
2018
- // ../../node_modules/.pnpm/jsondiffpatch@0.4.1/node_modules/jsondiffpatch/dist/jsondiffpatch.esm.js
2019
- var import_diff_match_patch = __toESM(require_diff_match_patch());
2020
- var import_chalk = __toESM(require_chalk());
2021
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
2022
- return typeof obj;
2023
- } : function(obj) {
2024
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2025
- };
2026
- var classCallCheck = function(instance, Constructor) {
2027
- if (!(instance instanceof Constructor)) {
2028
- throw new TypeError("Cannot call a class as a function");
2029
- }
2030
- };
2031
- var createClass = /* @__PURE__ */ function() {
2032
- function defineProperties(target, props) {
2033
- for (var i = 0; i < props.length; i++) {
2034
- var descriptor = props[i];
2035
- descriptor.enumerable = descriptor.enumerable || false;
2036
- descriptor.configurable = true;
2037
- if ("value" in descriptor) descriptor.writable = true;
2038
- Object.defineProperty(target, descriptor.key, descriptor);
2039
- }
2040
- }
2041
- return function(Constructor, protoProps, staticProps) {
2042
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
2043
- if (staticProps) defineProperties(Constructor, staticProps);
2044
- return Constructor;
2045
- };
2046
- }();
2047
- var get = function get2(object, property, receiver) {
2048
- if (object === null) object = Function.prototype;
2049
- var desc = Object.getOwnPropertyDescriptor(object, property);
2050
- if (desc === void 0) {
2051
- var parent = Object.getPrototypeOf(object);
2052
- if (parent === null) {
2053
- return void 0;
2054
- } else {
2055
- return get2(parent, property, receiver);
2056
- }
2057
- } else if ("value" in desc) {
2058
- return desc.value;
2059
- } else {
2060
- var getter = desc.get;
2061
- if (getter === void 0) {
2062
- return void 0;
2063
- }
2064
- return getter.call(receiver);
2065
- }
2066
- };
2067
- var inherits = function(subClass, superClass) {
2068
- if (typeof superClass !== "function" && superClass !== null) {
2069
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
2070
- }
2071
- subClass.prototype = Object.create(superClass && superClass.prototype, {
2072
- constructor: {
2073
- value: subClass,
2074
- enumerable: false,
2075
- writable: true,
2076
- configurable: true
2077
- }
2078
- });
2079
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
2080
- };
2081
- var possibleConstructorReturn = function(self, call) {
2082
- if (!self) {
2083
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2084
- }
2085
- return call && (typeof call === "object" || typeof call === "function") ? call : self;
2086
- };
2087
- var slicedToArray = /* @__PURE__ */ function() {
2088
- function sliceIterator(arr, i) {
2089
- var _arr = [];
2090
- var _n = true;
2091
- var _d = false;
2092
- var _e = void 0;
2093
- try {
2094
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
2095
- _arr.push(_s.value);
2096
- if (i && _arr.length === i) break;
2097
- }
2098
- } catch (err) {
2099
- _d = true;
2100
- _e = err;
2101
- } finally {
2102
- try {
2103
- if (!_n && _i["return"]) _i["return"]();
2104
- } finally {
2105
- if (_d) throw _e;
2106
- }
2107
- }
2108
- return _arr;
2109
- }
2110
- return function(arr, i) {
2111
- if (Array.isArray(arr)) {
2112
- return arr;
2113
- } else if (Symbol.iterator in Object(arr)) {
2114
- return sliceIterator(arr, i);
2115
- } else {
2116
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
2117
- }
2118
- };
2119
- }();
2120
- var toConsumableArray = function(arr) {
2121
- if (Array.isArray(arr)) {
2122
- for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
2123
- return arr2;
2124
- } else {
2125
- return Array.from(arr);
2126
- }
2127
- };
2128
- var Processor = function() {
2129
- function Processor2(options) {
2130
- classCallCheck(this, Processor2);
2131
- this.selfOptions = options || {};
2132
- this.pipes = {};
2133
- }
2134
- createClass(Processor2, [{
2135
- key: "options",
2136
- value: function options(_options) {
2137
- if (_options) {
2138
- this.selfOptions = _options;
2139
- }
2140
- return this.selfOptions;
2141
- }
2142
- }, {
2143
- key: "pipe",
2144
- value: function pipe(name, pipeArg) {
2145
- var pipe2 = pipeArg;
2146
- if (typeof name === "string") {
2147
- if (typeof pipe2 === "undefined") {
2148
- return this.pipes[name];
2149
- } else {
2150
- this.pipes[name] = pipe2;
2151
- }
2152
- }
2153
- if (name && name.name) {
2154
- pipe2 = name;
2155
- if (pipe2.processor === this) {
2156
- return pipe2;
2157
- }
2158
- this.pipes[pipe2.name] = pipe2;
2159
- }
2160
- pipe2.processor = this;
2161
- return pipe2;
2162
- }
2163
- }, {
2164
- key: "process",
2165
- value: function process2(input, pipe) {
2166
- var context = input;
2167
- context.options = this.options();
2168
- var nextPipe = pipe || input.pipe || "default";
2169
- var lastPipe = void 0;
2170
- var lastContext = void 0;
2171
- while (nextPipe) {
2172
- if (typeof context.nextAfterChildren !== "undefined") {
2173
- context.next = context.nextAfterChildren;
2174
- context.nextAfterChildren = null;
2175
- }
2176
- if (typeof nextPipe === "string") {
2177
- nextPipe = this.pipe(nextPipe);
2178
- }
2179
- nextPipe.process(context);
2180
- lastContext = context;
2181
- lastPipe = nextPipe;
2182
- nextPipe = null;
2183
- if (context) {
2184
- if (context.next) {
2185
- context = context.next;
2186
- nextPipe = lastContext.nextPipe || context.pipe || lastPipe;
2187
- }
2188
- }
2189
- }
2190
- return context.hasResult ? context.result : void 0;
2191
- }
2192
- }]);
2193
- return Processor2;
2194
- }();
2195
- var Pipe = function() {
2196
- function Pipe2(name) {
2197
- classCallCheck(this, Pipe2);
2198
- this.name = name;
2199
- this.filters = [];
2200
- }
2201
- createClass(Pipe2, [{
2202
- key: "process",
2203
- value: function process2(input) {
2204
- if (!this.processor) {
2205
- throw new Error("add this pipe to a processor before using it");
2206
- }
2207
- var debug = this.debug;
2208
- var length = this.filters.length;
2209
- var context = input;
2210
- for (var index2 = 0; index2 < length; index2++) {
2211
- var filter = this.filters[index2];
2212
- if (debug) {
2213
- this.log("filter: " + filter.filterName);
2214
- }
2215
- filter(context);
2216
- if ((typeof context === "undefined" ? "undefined" : _typeof(context)) === "object" && context.exiting) {
2217
- context.exiting = false;
2218
- break;
2219
- }
2220
- }
2221
- if (!context.next && this.resultCheck) {
2222
- this.resultCheck(context);
2223
- }
2224
- }
2225
- }, {
2226
- key: "log",
2227
- value: function log3(msg) {
2228
- console.log("[jsondiffpatch] " + this.name + " pipe, " + msg);
2229
- }
2230
- }, {
2231
- key: "append",
2232
- value: function append() {
2233
- var _filters;
2234
- (_filters = this.filters).push.apply(_filters, arguments);
2235
- return this;
2236
- }
2237
- }, {
2238
- key: "prepend",
2239
- value: function prepend() {
2240
- var _filters2;
2241
- (_filters2 = this.filters).unshift.apply(_filters2, arguments);
2242
- return this;
2243
- }
2244
- }, {
2245
- key: "indexOf",
2246
- value: function indexOf(filterName) {
2247
- if (!filterName) {
2248
- throw new Error("a filter name is required");
2249
- }
2250
- for (var index2 = 0; index2 < this.filters.length; index2++) {
2251
- var filter = this.filters[index2];
2252
- if (filter.filterName === filterName) {
2253
- return index2;
2254
- }
2255
- }
2256
- throw new Error("filter not found: " + filterName);
2257
- }
2258
- }, {
2259
- key: "list",
2260
- value: function list() {
2261
- return this.filters.map(function(f) {
2262
- return f.filterName;
2263
- });
2264
- }
2265
- }, {
2266
- key: "after",
2267
- value: function after(filterName) {
2268
- var index2 = this.indexOf(filterName);
2269
- var params = Array.prototype.slice.call(arguments, 1);
2270
- if (!params.length) {
2271
- throw new Error("a filter is required");
2272
- }
2273
- params.unshift(index2 + 1, 0);
2274
- Array.prototype.splice.apply(this.filters, params);
2275
- return this;
2276
- }
2277
- }, {
2278
- key: "before",
2279
- value: function before(filterName) {
2280
- var index2 = this.indexOf(filterName);
2281
- var params = Array.prototype.slice.call(arguments, 1);
2282
- if (!params.length) {
2283
- throw new Error("a filter is required");
2284
- }
2285
- params.unshift(index2, 0);
2286
- Array.prototype.splice.apply(this.filters, params);
2287
- return this;
2288
- }
2289
- }, {
2290
- key: "replace",
2291
- value: function replace(filterName) {
2292
- var index2 = this.indexOf(filterName);
2293
- var params = Array.prototype.slice.call(arguments, 1);
2294
- if (!params.length) {
2295
- throw new Error("a filter is required");
2296
- }
2297
- params.unshift(index2, 1);
2298
- Array.prototype.splice.apply(this.filters, params);
2299
- return this;
2300
- }
2301
- }, {
2302
- key: "remove",
2303
- value: function remove(filterName) {
2304
- var index2 = this.indexOf(filterName);
2305
- this.filters.splice(index2, 1);
2306
- return this;
2307
- }
2308
- }, {
2309
- key: "clear",
2310
- value: function clear() {
2311
- this.filters.length = 0;
2312
- return this;
2313
- }
2314
- }, {
2315
- key: "shouldHaveResult",
2316
- value: function shouldHaveResult(should) {
2317
- if (should === false) {
2318
- this.resultCheck = null;
2319
- return;
2320
- }
2321
- if (this.resultCheck) {
2322
- return;
2323
- }
2324
- var pipe = this;
2325
- this.resultCheck = function(context) {
2326
- if (!context.hasResult) {
2327
- console.log(context);
2328
- var error = new Error(pipe.name + " failed");
2329
- error.noResult = true;
2330
- throw error;
2331
- }
2332
- };
2333
- return this;
2334
- }
2335
- }]);
2336
- return Pipe2;
2337
- }();
2338
- var Context = function() {
2339
- function Context2() {
2340
- classCallCheck(this, Context2);
2341
- }
2342
- createClass(Context2, [{
2343
- key: "setResult",
2344
- value: function setResult(result) {
2345
- this.result = result;
2346
- this.hasResult = true;
2347
- return this;
2348
- }
2349
- }, {
2350
- key: "exit",
2351
- value: function exit() {
2352
- this.exiting = true;
2353
- return this;
2354
- }
2355
- }, {
2356
- key: "switchTo",
2357
- value: function switchTo(next, pipe) {
2358
- if (typeof next === "string" || next instanceof Pipe) {
2359
- this.nextPipe = next;
2360
- } else {
2361
- this.next = next;
2362
- if (pipe) {
2363
- this.nextPipe = pipe;
2364
- }
2365
- }
2366
- return this;
2367
- }
2368
- }, {
2369
- key: "push",
2370
- value: function push(child, name) {
2371
- child.parent = this;
2372
- if (typeof name !== "undefined") {
2373
- child.childName = name;
2374
- }
2375
- child.root = this.root || this;
2376
- child.options = child.options || this.options;
2377
- if (!this.children) {
2378
- this.children = [child];
2379
- this.nextAfterChildren = this.next || null;
2380
- this.next = child;
2381
- } else {
2382
- this.children[this.children.length - 1].next = child;
2383
- this.children.push(child);
2384
- }
2385
- child.next = this;
2386
- return this;
2387
- }
2388
- }]);
2389
- return Context2;
2390
- }();
2391
- var isArray = typeof Array.isArray === "function" ? Array.isArray : function(a) {
2392
- return a instanceof Array;
2393
- };
2394
- function cloneRegExp(re) {
2395
- var regexMatch = /^\/(.*)\/([gimyu]*)$/.exec(re.toString());
2396
- return new RegExp(regexMatch[1], regexMatch[2]);
2397
- }
2398
- function clone(arg) {
2399
- if ((typeof arg === "undefined" ? "undefined" : _typeof(arg)) !== "object") {
2400
- return arg;
2401
- }
2402
- if (arg === null) {
2403
- return null;
2404
- }
2405
- if (isArray(arg)) {
2406
- return arg.map(clone);
2407
- }
2408
- if (arg instanceof Date) {
2409
- return new Date(arg.getTime());
2410
- }
2411
- if (arg instanceof RegExp) {
2412
- return cloneRegExp(arg);
2413
- }
2414
- var cloned = {};
2415
- for (var name in arg) {
2416
- if (Object.prototype.hasOwnProperty.call(arg, name)) {
2417
- cloned[name] = clone(arg[name]);
2418
- }
2419
- }
2420
- return cloned;
2421
- }
2422
- var DiffContext = function(_Context) {
2423
- inherits(DiffContext2, _Context);
2424
- function DiffContext2(left, right) {
2425
- classCallCheck(this, DiffContext2);
2426
- var _this = possibleConstructorReturn(this, (DiffContext2.__proto__ || Object.getPrototypeOf(DiffContext2)).call(this));
2427
- _this.left = left;
2428
- _this.right = right;
2429
- _this.pipe = "diff";
2430
- return _this;
2431
- }
2432
- createClass(DiffContext2, [{
2433
- key: "setResult",
2434
- value: function setResult(result) {
2435
- if (this.options.cloneDiffValues && (typeof result === "undefined" ? "undefined" : _typeof(result)) === "object") {
2436
- var clone$$1 = typeof this.options.cloneDiffValues === "function" ? this.options.cloneDiffValues : clone;
2437
- if (_typeof(result[0]) === "object") {
2438
- result[0] = clone$$1(result[0]);
2439
- }
2440
- if (_typeof(result[1]) === "object") {
2441
- result[1] = clone$$1(result[1]);
2442
- }
2443
- }
2444
- return Context.prototype.setResult.apply(this, arguments);
2445
- }
2446
- }]);
2447
- return DiffContext2;
2448
- }(Context);
2449
- var PatchContext = function(_Context) {
2450
- inherits(PatchContext2, _Context);
2451
- function PatchContext2(left, delta) {
2452
- classCallCheck(this, PatchContext2);
2453
- var _this = possibleConstructorReturn(this, (PatchContext2.__proto__ || Object.getPrototypeOf(PatchContext2)).call(this));
2454
- _this.left = left;
2455
- _this.delta = delta;
2456
- _this.pipe = "patch";
2457
- return _this;
2458
- }
2459
- return PatchContext2;
2460
- }(Context);
2461
- var ReverseContext = function(_Context) {
2462
- inherits(ReverseContext2, _Context);
2463
- function ReverseContext2(delta) {
2464
- classCallCheck(this, ReverseContext2);
2465
- var _this = possibleConstructorReturn(this, (ReverseContext2.__proto__ || Object.getPrototypeOf(ReverseContext2)).call(this));
2466
- _this.delta = delta;
2467
- _this.pipe = "reverse";
2468
- return _this;
2469
- }
2470
- return ReverseContext2;
2471
- }(Context);
2472
- var isArray$1 = typeof Array.isArray === "function" ? Array.isArray : function(a) {
2473
- return a instanceof Array;
2474
- };
2475
- var diffFilter = function trivialMatchesDiffFilter(context) {
2476
- if (context.left === context.right) {
2477
- context.setResult(void 0).exit();
2478
- return;
2479
- }
2480
- if (typeof context.left === "undefined") {
2481
- if (typeof context.right === "function") {
2482
- throw new Error("functions are not supported");
2483
- }
2484
- context.setResult([context.right]).exit();
2485
- return;
2486
- }
2487
- if (typeof context.right === "undefined") {
2488
- context.setResult([context.left, 0, 0]).exit();
2489
- return;
2490
- }
2491
- if (typeof context.left === "function" || typeof context.right === "function") {
2492
- throw new Error("functions are not supported");
2493
- }
2494
- context.leftType = context.left === null ? "null" : _typeof(context.left);
2495
- context.rightType = context.right === null ? "null" : _typeof(context.right);
2496
- if (context.leftType !== context.rightType) {
2497
- context.setResult([context.left, context.right]).exit();
2498
- return;
2499
- }
2500
- if (context.leftType === "boolean" || context.leftType === "number") {
2501
- context.setResult([context.left, context.right]).exit();
2502
- return;
2503
- }
2504
- if (context.leftType === "object") {
2505
- context.leftIsArray = isArray$1(context.left);
2506
- }
2507
- if (context.rightType === "object") {
2508
- context.rightIsArray = isArray$1(context.right);
2509
- }
2510
- if (context.leftIsArray !== context.rightIsArray) {
2511
- context.setResult([context.left, context.right]).exit();
2512
- return;
2513
- }
2514
- if (context.left instanceof RegExp) {
2515
- if (context.right instanceof RegExp) {
2516
- context.setResult([context.left.toString(), context.right.toString()]).exit();
2517
- } else {
2518
- context.setResult([context.left, context.right]).exit();
2519
- }
2520
- }
2521
- };
2522
- diffFilter.filterName = "trivial";
2523
- var patchFilter = function trivialMatchesPatchFilter(context) {
2524
- if (typeof context.delta === "undefined") {
2525
- context.setResult(context.left).exit();
2526
- return;
2527
- }
2528
- context.nested = !isArray$1(context.delta);
2529
- if (context.nested) {
2530
- return;
2531
- }
2532
- if (context.delta.length === 1) {
2533
- context.setResult(context.delta[0]).exit();
2534
- return;
2535
- }
2536
- if (context.delta.length === 2) {
2537
- if (context.left instanceof RegExp) {
2538
- var regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(context.delta[1]);
2539
- if (regexArgs) {
2540
- context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
2541
- return;
2542
- }
2543
- }
2544
- context.setResult(context.delta[1]).exit();
2545
- return;
2546
- }
2547
- if (context.delta.length === 3 && context.delta[2] === 0) {
2548
- context.setResult(void 0).exit();
2549
- }
2550
- };
2551
- patchFilter.filterName = "trivial";
2552
- var reverseFilter = function trivialReferseFilter(context) {
2553
- if (typeof context.delta === "undefined") {
2554
- context.setResult(context.delta).exit();
2555
- return;
2556
- }
2557
- context.nested = !isArray$1(context.delta);
2558
- if (context.nested) {
2559
- return;
2560
- }
2561
- if (context.delta.length === 1) {
2562
- context.setResult([context.delta[0], 0, 0]).exit();
2563
- return;
2564
- }
2565
- if (context.delta.length === 2) {
2566
- context.setResult([context.delta[1], context.delta[0]]).exit();
2567
- return;
2568
- }
2569
- if (context.delta.length === 3 && context.delta[2] === 0) {
2570
- context.setResult([context.delta[0]]).exit();
2571
- }
2572
- };
2573
- reverseFilter.filterName = "trivial";
2574
- function collectChildrenDiffFilter(context) {
2575
- if (!context || !context.children) {
2576
- return;
2577
- }
2578
- var length = context.children.length;
2579
- var child = void 0;
2580
- var result = context.result;
2581
- for (var index2 = 0; index2 < length; index2++) {
2582
- child = context.children[index2];
2583
- if (typeof child.result === "undefined") {
2584
- continue;
2585
- }
2586
- result = result || {};
2587
- result[child.childName] = child.result;
2588
- }
2589
- if (result && context.leftIsArray) {
2590
- result._t = "a";
2591
- }
2592
- context.setResult(result).exit();
2593
- }
2594
- collectChildrenDiffFilter.filterName = "collectChildren";
2595
- function objectsDiffFilter(context) {
2596
- if (context.leftIsArray || context.leftType !== "object") {
2597
- return;
2598
- }
2599
- var name = void 0;
2600
- var child = void 0;
2601
- var propertyFilter = context.options.propertyFilter;
2602
- for (name in context.left) {
2603
- if (!Object.prototype.hasOwnProperty.call(context.left, name)) {
2604
- continue;
2605
- }
2606
- if (propertyFilter && !propertyFilter(name, context)) {
2607
- continue;
2608
- }
2609
- child = new DiffContext(context.left[name], context.right[name]);
2610
- context.push(child, name);
2611
- }
2612
- for (name in context.right) {
2613
- if (!Object.prototype.hasOwnProperty.call(context.right, name)) {
2614
- continue;
2615
- }
2616
- if (propertyFilter && !propertyFilter(name, context)) {
2617
- continue;
2618
- }
2619
- if (typeof context.left[name] === "undefined") {
2620
- child = new DiffContext(void 0, context.right[name]);
2621
- context.push(child, name);
2622
- }
2623
- }
2624
- if (!context.children || context.children.length === 0) {
2625
- context.setResult(void 0).exit();
2626
- return;
2627
- }
2628
- context.exit();
2629
- }
2630
- objectsDiffFilter.filterName = "objects";
2631
- var patchFilter$1 = function nestedPatchFilter(context) {
2632
- if (!context.nested) {
2633
- return;
2634
- }
2635
- if (context.delta._t) {
2636
- return;
2637
- }
2638
- var name = void 0;
2639
- var child = void 0;
2640
- for (name in context.delta) {
2641
- child = new PatchContext(context.left[name], context.delta[name]);
2642
- context.push(child, name);
2643
- }
2644
- context.exit();
2645
- };
2646
- patchFilter$1.filterName = "objects";
2647
- var collectChildrenPatchFilter = function collectChildrenPatchFilter2(context) {
2648
- if (!context || !context.children) {
2649
- return;
2650
- }
2651
- if (context.delta._t) {
2652
- return;
2653
- }
2654
- var length = context.children.length;
2655
- var child = void 0;
2656
- for (var index2 = 0; index2 < length; index2++) {
2657
- child = context.children[index2];
2658
- if (Object.prototype.hasOwnProperty.call(context.left, child.childName) && child.result === void 0) {
2659
- delete context.left[child.childName];
2660
- } else if (context.left[child.childName] !== child.result) {
2661
- context.left[child.childName] = child.result;
2662
- }
2663
- }
2664
- context.setResult(context.left).exit();
2665
- };
2666
- collectChildrenPatchFilter.filterName = "collectChildren";
2667
- var reverseFilter$1 = function nestedReverseFilter(context) {
2668
- if (!context.nested) {
2669
- return;
2670
- }
2671
- if (context.delta._t) {
2672
- return;
2673
- }
2674
- var name = void 0;
2675
- var child = void 0;
2676
- for (name in context.delta) {
2677
- child = new ReverseContext(context.delta[name]);
2678
- context.push(child, name);
2679
- }
2680
- context.exit();
2681
- };
2682
- reverseFilter$1.filterName = "objects";
2683
- function collectChildrenReverseFilter(context) {
2684
- if (!context || !context.children) {
2685
- return;
2686
- }
2687
- if (context.delta._t) {
2688
- return;
2689
- }
2690
- var length = context.children.length;
2691
- var child = void 0;
2692
- var delta = {};
2693
- for (var index2 = 0; index2 < length; index2++) {
2694
- child = context.children[index2];
2695
- if (delta[child.childName] !== child.result) {
2696
- delta[child.childName] = child.result;
2697
- }
2698
- }
2699
- context.setResult(delta).exit();
2700
- }
2701
- collectChildrenReverseFilter.filterName = "collectChildren";
2702
- var defaultMatch = function defaultMatch2(array1, array2, index1, index2) {
2703
- return array1[index1] === array2[index2];
2704
- };
2705
- var lengthMatrix = function lengthMatrix2(array1, array2, match, context) {
2706
- var len1 = array1.length;
2707
- var len2 = array2.length;
2708
- var x = void 0, y = void 0;
2709
- var matrix = [len1 + 1];
2710
- for (x = 0; x < len1 + 1; x++) {
2711
- matrix[x] = [len2 + 1];
2712
- for (y = 0; y < len2 + 1; y++) {
2713
- matrix[x][y] = 0;
2714
- }
2715
- }
2716
- matrix.match = match;
2717
- for (x = 1; x < len1 + 1; x++) {
2718
- for (y = 1; y < len2 + 1; y++) {
2719
- if (match(array1, array2, x - 1, y - 1, context)) {
2720
- matrix[x][y] = matrix[x - 1][y - 1] + 1;
2721
- } else {
2722
- matrix[x][y] = Math.max(matrix[x - 1][y], matrix[x][y - 1]);
2723
- }
2724
- }
2725
- }
2726
- return matrix;
2727
- };
2728
- var backtrack = function backtrack2(matrix, array1, array2, context) {
2729
- var index1 = array1.length;
2730
- var index2 = array2.length;
2731
- var subsequence = {
2732
- sequence: [],
2733
- indices1: [],
2734
- indices2: []
2735
- };
2736
- while (index1 !== 0 && index2 !== 0) {
2737
- var sameLetter = matrix.match(array1, array2, index1 - 1, index2 - 1, context);
2738
- if (sameLetter) {
2739
- subsequence.sequence.unshift(array1[index1 - 1]);
2740
- subsequence.indices1.unshift(index1 - 1);
2741
- subsequence.indices2.unshift(index2 - 1);
2742
- --index1;
2743
- --index2;
2744
- } else {
2745
- var valueAtMatrixAbove = matrix[index1][index2 - 1];
2746
- var valueAtMatrixLeft = matrix[index1 - 1][index2];
2747
- if (valueAtMatrixAbove > valueAtMatrixLeft) {
2748
- --index2;
2749
- } else {
2750
- --index1;
2751
- }
2752
- }
2753
- }
2754
- return subsequence;
2755
- };
2756
- var get$1 = function get3(array1, array2, match, context) {
2757
- var innerContext = context || {};
2758
- var matrix = lengthMatrix(array1, array2, match || defaultMatch, innerContext);
2759
- var result = backtrack(matrix, array1, array2, innerContext);
2760
- if (typeof array1 === "string" && typeof array2 === "string") {
2761
- result.sequence = result.sequence.join("");
2762
- }
2763
- return result;
2764
- };
2765
- var lcs = {
2766
- get: get$1
2767
- };
2768
- var ARRAY_MOVE = 3;
2769
- var isArray$2 = typeof Array.isArray === "function" ? Array.isArray : function(a) {
2770
- return a instanceof Array;
2771
- };
2772
- var arrayIndexOf = typeof Array.prototype.indexOf === "function" ? function(array, item) {
2773
- return array.indexOf(item);
2774
- } : function(array, item) {
2775
- var length = array.length;
2776
- for (var i = 0; i < length; i++) {
2777
- if (array[i] === item) {
2778
- return i;
2779
- }
2780
- }
2781
- return -1;
2782
- };
2783
- function arraysHaveMatchByRef(array1, array2, len1, len2) {
2784
- for (var index1 = 0; index1 < len1; index1++) {
2785
- var val1 = array1[index1];
2786
- for (var index2 = 0; index2 < len2; index2++) {
2787
- var val2 = array2[index2];
2788
- if (index1 !== index2 && val1 === val2) {
2789
- return true;
2790
- }
2791
- }
2792
- }
2793
- }
2794
- function matchItems(array1, array2, index1, index2, context) {
2795
- var value1 = array1[index1];
2796
- var value2 = array2[index2];
2797
- if (value1 === value2) {
2798
- return true;
2799
- }
2800
- if ((typeof value1 === "undefined" ? "undefined" : _typeof(value1)) !== "object" || (typeof value2 === "undefined" ? "undefined" : _typeof(value2)) !== "object") {
2801
- return false;
2802
- }
2803
- var objectHash = context.objectHash;
2804
- if (!objectHash) {
2805
- return context.matchByPosition && index1 === index2;
2806
- }
2807
- var hash1 = void 0;
2808
- var hash2 = void 0;
2809
- if (typeof index1 === "number") {
2810
- context.hashCache1 = context.hashCache1 || [];
2811
- hash1 = context.hashCache1[index1];
2812
- if (typeof hash1 === "undefined") {
2813
- context.hashCache1[index1] = hash1 = objectHash(value1, index1);
2814
- }
2815
- } else {
2816
- hash1 = objectHash(value1);
2817
- }
2818
- if (typeof hash1 === "undefined") {
2819
- return false;
2820
- }
2821
- if (typeof index2 === "number") {
2822
- context.hashCache2 = context.hashCache2 || [];
2823
- hash2 = context.hashCache2[index2];
2824
- if (typeof hash2 === "undefined") {
2825
- context.hashCache2[index2] = hash2 = objectHash(value2, index2);
2826
- }
2827
- } else {
2828
- hash2 = objectHash(value2);
2829
- }
2830
- if (typeof hash2 === "undefined") {
2831
- return false;
2832
- }
2833
- return hash1 === hash2;
2834
- }
2835
- var diffFilter$1 = function arraysDiffFilter(context) {
2836
- if (!context.leftIsArray) {
2837
- return;
2838
- }
2839
- var matchContext = {
2840
- objectHash: context.options && context.options.objectHash,
2841
- matchByPosition: context.options && context.options.matchByPosition
2842
- };
2843
- var commonHead = 0;
2844
- var commonTail = 0;
2845
- var index2 = void 0;
2846
- var index1 = void 0;
2847
- var index22 = void 0;
2848
- var array1 = context.left;
2849
- var array2 = context.right;
2850
- var len1 = array1.length;
2851
- var len2 = array2.length;
2852
- var child = void 0;
2853
- if (len1 > 0 && len2 > 0 && !matchContext.objectHash && typeof matchContext.matchByPosition !== "boolean") {
2854
- matchContext.matchByPosition = !arraysHaveMatchByRef(array1, array2, len1, len2);
2855
- }
2856
- while (commonHead < len1 && commonHead < len2 && matchItems(array1, array2, commonHead, commonHead, matchContext)) {
2857
- index2 = commonHead;
2858
- child = new DiffContext(context.left[index2], context.right[index2]);
2859
- context.push(child, index2);
2860
- commonHead++;
2861
- }
2862
- while (commonTail + commonHead < len1 && commonTail + commonHead < len2 && matchItems(array1, array2, len1 - 1 - commonTail, len2 - 1 - commonTail, matchContext)) {
2863
- index1 = len1 - 1 - commonTail;
2864
- index22 = len2 - 1 - commonTail;
2865
- child = new DiffContext(context.left[index1], context.right[index22]);
2866
- context.push(child, index22);
2867
- commonTail++;
2868
- }
2869
- var result = void 0;
2870
- if (commonHead + commonTail === len1) {
2871
- if (len1 === len2) {
2872
- context.setResult(void 0).exit();
2873
- return;
2874
- }
2875
- result = result || {
2876
- _t: "a"
2877
- };
2878
- for (index2 = commonHead; index2 < len2 - commonTail; index2++) {
2879
- result[index2] = [array2[index2]];
2880
- }
2881
- context.setResult(result).exit();
2882
- return;
2883
- }
2884
- if (commonHead + commonTail === len2) {
2885
- result = result || {
2886
- _t: "a"
2887
- };
2888
- for (index2 = commonHead; index2 < len1 - commonTail; index2++) {
2889
- result["_" + index2] = [array1[index2], 0, 0];
2890
- }
2891
- context.setResult(result).exit();
2892
- return;
2893
- }
2894
- delete matchContext.hashCache1;
2895
- delete matchContext.hashCache2;
2896
- var trimmed1 = array1.slice(commonHead, len1 - commonTail);
2897
- var trimmed2 = array2.slice(commonHead, len2 - commonTail);
2898
- var seq = lcs.get(trimmed1, trimmed2, matchItems, matchContext);
2899
- var removedItems = [];
2900
- result = result || {
2901
- _t: "a"
2902
- };
2903
- for (index2 = commonHead; index2 < len1 - commonTail; index2++) {
2904
- if (arrayIndexOf(seq.indices1, index2 - commonHead) < 0) {
2905
- result["_" + index2] = [array1[index2], 0, 0];
2906
- removedItems.push(index2);
2907
- }
2908
- }
2909
- var detectMove = true;
2910
- if (context.options && context.options.arrays && context.options.arrays.detectMove === false) {
2911
- detectMove = false;
2912
- }
2913
- var includeValueOnMove = false;
2914
- if (context.options && context.options.arrays && context.options.arrays.includeValueOnMove) {
2915
- includeValueOnMove = true;
2916
- }
2917
- var removedItemsLength = removedItems.length;
2918
- for (index2 = commonHead; index2 < len2 - commonTail; index2++) {
2919
- var indexOnArray2 = arrayIndexOf(seq.indices2, index2 - commonHead);
2920
- if (indexOnArray2 < 0) {
2921
- var isMove = false;
2922
- if (detectMove && removedItemsLength > 0) {
2923
- for (var removeItemIndex1 = 0; removeItemIndex1 < removedItemsLength; removeItemIndex1++) {
2924
- index1 = removedItems[removeItemIndex1];
2925
- if (matchItems(trimmed1, trimmed2, index1 - commonHead, index2 - commonHead, matchContext)) {
2926
- result["_" + index1].splice(1, 2, index2, ARRAY_MOVE);
2927
- if (!includeValueOnMove) {
2928
- result["_" + index1][0] = "";
2929
- }
2930
- index22 = index2;
2931
- child = new DiffContext(context.left[index1], context.right[index22]);
2932
- context.push(child, index22);
2933
- removedItems.splice(removeItemIndex1, 1);
2934
- isMove = true;
2935
- break;
2936
- }
2937
- }
2938
- }
2939
- if (!isMove) {
2940
- result[index2] = [array2[index2]];
2941
- }
2942
- } else {
2943
- index1 = seq.indices1[indexOnArray2] + commonHead;
2944
- index22 = seq.indices2[indexOnArray2] + commonHead;
2945
- child = new DiffContext(context.left[index1], context.right[index22]);
2946
- context.push(child, index22);
2947
- }
2948
- }
2949
- context.setResult(result).exit();
2950
- };
2951
- diffFilter$1.filterName = "arrays";
2952
- var compare = {
2953
- numerically: function numerically(a, b) {
2954
- return a - b;
2955
- },
2956
- numericallyBy: function numericallyBy(name) {
2957
- return function(a, b) {
2958
- return a[name] - b[name];
2959
- };
2960
- }
2961
- };
2962
- var patchFilter$2 = function nestedPatchFilter2(context) {
2963
- if (!context.nested) {
2964
- return;
2965
- }
2966
- if (context.delta._t !== "a") {
2967
- return;
2968
- }
2969
- var index2 = void 0;
2970
- var index1 = void 0;
2971
- var delta = context.delta;
2972
- var array = context.left;
2973
- var toRemove = [];
2974
- var toInsert = [];
2975
- var toModify = [];
2976
- for (index2 in delta) {
2977
- if (index2 !== "_t") {
2978
- if (index2[0] === "_") {
2979
- if (delta[index2][2] === 0 || delta[index2][2] === ARRAY_MOVE) {
2980
- toRemove.push(parseInt(index2.slice(1), 10));
2981
- } else {
2982
- throw new Error("only removal or move can be applied at original array indices," + (" invalid diff type: " + delta[index2][2]));
2983
- }
2984
- } else {
2985
- if (delta[index2].length === 1) {
2986
- toInsert.push({
2987
- index: parseInt(index2, 10),
2988
- value: delta[index2][0]
2989
- });
2990
- } else {
2991
- toModify.push({
2992
- index: parseInt(index2, 10),
2993
- delta: delta[index2]
2994
- });
2995
- }
2996
- }
2997
- }
2998
- }
2999
- toRemove = toRemove.sort(compare.numerically);
3000
- for (index2 = toRemove.length - 1; index2 >= 0; index2--) {
3001
- index1 = toRemove[index2];
3002
- var indexDiff = delta["_" + index1];
3003
- var removedValue = array.splice(index1, 1)[0];
3004
- if (indexDiff[2] === ARRAY_MOVE) {
3005
- toInsert.push({
3006
- index: indexDiff[1],
3007
- value: removedValue
3008
- });
3009
- }
3010
- }
3011
- toInsert = toInsert.sort(compare.numericallyBy("index"));
3012
- var toInsertLength = toInsert.length;
3013
- for (index2 = 0; index2 < toInsertLength; index2++) {
3014
- var insertion = toInsert[index2];
3015
- array.splice(insertion.index, 0, insertion.value);
3016
- }
3017
- var toModifyLength = toModify.length;
3018
- var child = void 0;
3019
- if (toModifyLength > 0) {
3020
- for (index2 = 0; index2 < toModifyLength; index2++) {
3021
- var modification = toModify[index2];
3022
- child = new PatchContext(context.left[modification.index], modification.delta);
3023
- context.push(child, modification.index);
3024
- }
3025
- }
3026
- if (!context.children) {
3027
- context.setResult(context.left).exit();
3028
- return;
3029
- }
3030
- context.exit();
3031
- };
3032
- patchFilter$2.filterName = "arrays";
3033
- var collectChildrenPatchFilter$1 = function collectChildrenPatchFilter3(context) {
3034
- if (!context || !context.children) {
3035
- return;
3036
- }
3037
- if (context.delta._t !== "a") {
3038
- return;
3039
- }
3040
- var length = context.children.length;
3041
- var child = void 0;
3042
- for (var index2 = 0; index2 < length; index2++) {
3043
- child = context.children[index2];
3044
- context.left[child.childName] = child.result;
3045
- }
3046
- context.setResult(context.left).exit();
3047
- };
3048
- collectChildrenPatchFilter$1.filterName = "arraysCollectChildren";
3049
- var reverseFilter$2 = function arraysReverseFilter(context) {
3050
- if (!context.nested) {
3051
- if (context.delta[2] === ARRAY_MOVE) {
3052
- context.newName = "_" + context.delta[1];
3053
- context.setResult([context.delta[0], parseInt(context.childName.substr(1), 10), ARRAY_MOVE]).exit();
3054
- }
3055
- return;
3056
- }
3057
- if (context.delta._t !== "a") {
3058
- return;
3059
- }
3060
- var name = void 0;
3061
- var child = void 0;
3062
- for (name in context.delta) {
3063
- if (name === "_t") {
3064
- continue;
3065
- }
3066
- child = new ReverseContext(context.delta[name]);
3067
- context.push(child, name);
3068
- }
3069
- context.exit();
3070
- };
3071
- reverseFilter$2.filterName = "arrays";
3072
- var reverseArrayDeltaIndex = function reverseArrayDeltaIndex2(delta, index2, itemDelta) {
3073
- if (typeof index2 === "string" && index2[0] === "_") {
3074
- return parseInt(index2.substr(1), 10);
3075
- } else if (isArray$2(itemDelta) && itemDelta[2] === 0) {
3076
- return "_" + index2;
3077
- }
3078
- var reverseIndex = +index2;
3079
- for (var deltaIndex in delta) {
3080
- var deltaItem = delta[deltaIndex];
3081
- if (isArray$2(deltaItem)) {
3082
- if (deltaItem[2] === ARRAY_MOVE) {
3083
- var moveFromIndex = parseInt(deltaIndex.substr(1), 10);
3084
- var moveToIndex = deltaItem[1];
3085
- if (moveToIndex === +index2) {
3086
- return moveFromIndex;
3087
- }
3088
- if (moveFromIndex <= reverseIndex && moveToIndex > reverseIndex) {
3089
- reverseIndex++;
3090
- } else if (moveFromIndex >= reverseIndex && moveToIndex < reverseIndex) {
3091
- reverseIndex--;
3092
- }
3093
- } else if (deltaItem[2] === 0) {
3094
- var deleteIndex = parseInt(deltaIndex.substr(1), 10);
3095
- if (deleteIndex <= reverseIndex) {
3096
- reverseIndex++;
3097
- }
3098
- } else if (deltaItem.length === 1 && deltaIndex <= reverseIndex) {
3099
- reverseIndex--;
3100
- }
3101
- }
3102
- }
3103
- return reverseIndex;
3104
- };
3105
- function collectChildrenReverseFilter$1(context) {
3106
- if (!context || !context.children) {
3107
- return;
3108
- }
3109
- if (context.delta._t !== "a") {
3110
- return;
3111
- }
3112
- var length = context.children.length;
3113
- var child = void 0;
3114
- var delta = {
3115
- _t: "a"
3116
- };
3117
- for (var index2 = 0; index2 < length; index2++) {
3118
- child = context.children[index2];
3119
- var name = child.newName;
3120
- if (typeof name === "undefined") {
3121
- name = reverseArrayDeltaIndex(context.delta, child.childName, child.result);
3122
- }
3123
- if (delta[name] !== child.result) {
3124
- delta[name] = child.result;
3125
- }
3126
- }
3127
- context.setResult(delta).exit();
3128
- }
3129
- collectChildrenReverseFilter$1.filterName = "arraysCollectChildren";
3130
- var diffFilter$2 = function datesDiffFilter(context) {
3131
- if (context.left instanceof Date) {
3132
- if (context.right instanceof Date) {
3133
- if (context.left.getTime() !== context.right.getTime()) {
3134
- context.setResult([context.left, context.right]);
3135
- } else {
3136
- context.setResult(void 0);
3137
- }
3138
- } else {
3139
- context.setResult([context.left, context.right]);
3140
- }
3141
- context.exit();
3142
- } else if (context.right instanceof Date) {
3143
- context.setResult([context.left, context.right]).exit();
3144
- }
3145
- };
3146
- diffFilter$2.filterName = "dates";
3147
- var TEXT_DIFF = 2;
3148
- var DEFAULT_MIN_LENGTH = 60;
3149
- var cachedDiffPatch = null;
3150
- var getDiffMatchPatch = function getDiffMatchPatch2(required) {
3151
- if (!cachedDiffPatch) {
3152
- var instance = void 0;
3153
- if (typeof diff_match_patch !== "undefined") {
3154
- instance = typeof diff_match_patch === "function" ? new diff_match_patch() : new diff_match_patch.diff_match_patch();
3155
- } else if (import_diff_match_patch.default) {
3156
- try {
3157
- instance = import_diff_match_patch.default && new import_diff_match_patch.default();
3158
- } catch (err) {
3159
- instance = null;
3160
- }
3161
- }
3162
- if (!instance) {
3163
- if (!required) {
3164
- return null;
3165
- }
3166
- var error = new Error("text diff_match_patch library not found");
3167
- error.diff_match_patch_not_found = true;
3168
- throw error;
3169
- }
3170
- cachedDiffPatch = {
3171
- diff: function diff(txt1, txt2) {
3172
- return instance.patch_toText(instance.patch_make(txt1, txt2));
3173
- },
3174
- patch: function patch(txt1, _patch) {
3175
- var results = instance.patch_apply(instance.patch_fromText(_patch), txt1);
3176
- for (var i = 0; i < results[1].length; i++) {
3177
- if (!results[1][i]) {
3178
- var _error = new Error("text patch failed");
3179
- _error.textPatchFailed = true;
3180
- }
3181
- }
3182
- return results[0];
3183
- }
3184
- };
3185
- }
3186
- return cachedDiffPatch;
3187
- };
3188
- var diffFilter$3 = function textsDiffFilter(context) {
3189
- if (context.leftType !== "string") {
3190
- return;
3191
- }
3192
- var minLength = context.options && context.options.textDiff && context.options.textDiff.minLength || DEFAULT_MIN_LENGTH;
3193
- if (context.left.length < minLength || context.right.length < minLength) {
3194
- context.setResult([context.left, context.right]).exit();
3195
- return;
3196
- }
3197
- var diffMatchPatch = getDiffMatchPatch();
3198
- if (!diffMatchPatch) {
3199
- context.setResult([context.left, context.right]).exit();
3200
- return;
3201
- }
3202
- var diff = diffMatchPatch.diff;
3203
- context.setResult([diff(context.left, context.right), 0, TEXT_DIFF]).exit();
3204
- };
3205
- diffFilter$3.filterName = "texts";
3206
- var patchFilter$3 = function textsPatchFilter(context) {
3207
- if (context.nested) {
3208
- return;
3209
- }
3210
- if (context.delta[2] !== TEXT_DIFF) {
3211
- return;
3212
- }
3213
- var patch = getDiffMatchPatch(true).patch;
3214
- context.setResult(patch(context.left, context.delta[0])).exit();
3215
- };
3216
- patchFilter$3.filterName = "texts";
3217
- var textDeltaReverse = function textDeltaReverse2(delta) {
3218
- var i = void 0;
3219
- var l = void 0;
3220
- var lines = void 0;
3221
- var line = void 0;
3222
- var lineTmp = void 0;
3223
- var header = null;
3224
- var headerRegex = /^@@ +-(\d+),(\d+) +\+(\d+),(\d+) +@@$/;
3225
- var lineHeader = void 0;
3226
- lines = delta.split("\n");
3227
- for (i = 0, l = lines.length; i < l; i++) {
3228
- line = lines[i];
3229
- var lineStart = line.slice(0, 1);
3230
- if (lineStart === "@") {
3231
- header = headerRegex.exec(line);
3232
- lineHeader = i;
3233
- lines[lineHeader] = "@@ -" + header[3] + "," + header[4] + " +" + header[1] + "," + header[2] + " @@";
3234
- } else if (lineStart === "+") {
3235
- lines[i] = "-" + lines[i].slice(1);
3236
- if (lines[i - 1].slice(0, 1) === "+") {
3237
- lineTmp = lines[i];
3238
- lines[i] = lines[i - 1];
3239
- lines[i - 1] = lineTmp;
3240
- }
3241
- } else if (lineStart === "-") {
3242
- lines[i] = "+" + lines[i].slice(1);
3243
- }
3244
- }
3245
- return lines.join("\n");
3246
- };
3247
- var reverseFilter$3 = function textsReverseFilter(context) {
3248
- if (context.nested) {
3249
- return;
3250
- }
3251
- if (context.delta[2] !== TEXT_DIFF) {
3252
- return;
3253
- }
3254
- context.setResult([textDeltaReverse(context.delta[0]), 0, TEXT_DIFF]).exit();
3255
- };
3256
- reverseFilter$3.filterName = "texts";
3257
- var DiffPatcher = function() {
3258
- function DiffPatcher2(options) {
3259
- classCallCheck(this, DiffPatcher2);
3260
- this.processor = new Processor(options);
3261
- this.processor.pipe(new Pipe("diff").append(collectChildrenDiffFilter, diffFilter, diffFilter$2, diffFilter$3, objectsDiffFilter, diffFilter$1).shouldHaveResult());
3262
- this.processor.pipe(new Pipe("patch").append(collectChildrenPatchFilter, collectChildrenPatchFilter$1, patchFilter, patchFilter$3, patchFilter$1, patchFilter$2).shouldHaveResult());
3263
- this.processor.pipe(new Pipe("reverse").append(collectChildrenReverseFilter, collectChildrenReverseFilter$1, reverseFilter, reverseFilter$3, reverseFilter$1, reverseFilter$2).shouldHaveResult());
3264
- }
3265
- createClass(DiffPatcher2, [{
3266
- key: "options",
3267
- value: function options() {
3268
- var _processor;
3269
- return (_processor = this.processor).options.apply(_processor, arguments);
3270
- }
3271
- }, {
3272
- key: "diff",
3273
- value: function diff(left, right) {
3274
- return this.processor.process(new DiffContext(left, right));
3275
- }
3276
- }, {
3277
- key: "patch",
3278
- value: function patch(left, delta) {
3279
- return this.processor.process(new PatchContext(left, delta));
3280
- }
3281
- }, {
3282
- key: "reverse",
3283
- value: function reverse(delta) {
3284
- return this.processor.process(new ReverseContext(delta));
3285
- }
3286
- }, {
3287
- key: "unpatch",
3288
- value: function unpatch(right, delta) {
3289
- return this.patch(right, this.reverse(delta));
3290
- }
3291
- }, {
3292
- key: "clone",
3293
- value: function clone$$1(value) {
3294
- return clone(value);
3295
- }
3296
- }]);
3297
- return DiffPatcher2;
3298
- }();
3299
- var isArray$3 = typeof Array.isArray === "function" ? Array.isArray : function(a) {
3300
- return a instanceof Array;
3301
- };
3302
- var getObjectKeys = typeof Object.keys === "function" ? function(obj) {
3303
- return Object.keys(obj);
3304
- } : function(obj) {
3305
- var names = [];
3306
- for (var property in obj) {
3307
- if (Object.prototype.hasOwnProperty.call(obj, property)) {
3308
- names.push(property);
3309
- }
3310
- }
3311
- return names;
3312
- };
3313
- var trimUnderscore = function trimUnderscore2(str) {
3314
- if (str.substr(0, 1) === "_") {
3315
- return str.slice(1);
3316
- }
3317
- return str;
3318
- };
3319
- var arrayKeyToSortNumber = function arrayKeyToSortNumber2(key) {
3320
- if (key === "_t") {
3321
- return -1;
3322
- } else {
3323
- if (key.substr(0, 1) === "_") {
3324
- return parseInt(key.slice(1), 10);
3325
- } else {
3326
- return parseInt(key, 10) + 0.1;
3327
- }
3328
- }
3329
- };
3330
- var arrayKeyComparer = function arrayKeyComparer2(key1, key2) {
3331
- return arrayKeyToSortNumber(key1) - arrayKeyToSortNumber(key2);
3332
- };
3333
- var BaseFormatter = function() {
3334
- function BaseFormatter2() {
3335
- classCallCheck(this, BaseFormatter2);
3336
- }
3337
- createClass(BaseFormatter2, [{
3338
- key: "format",
3339
- value: function format4(delta, left) {
3340
- var context = {};
3341
- this.prepareContext(context);
3342
- this.recurse(context, delta, left);
3343
- return this.finalize(context);
3344
- }
3345
- }, {
3346
- key: "prepareContext",
3347
- value: function prepareContext(context) {
3348
- context.buffer = [];
3349
- context.out = function() {
3350
- var _buffer;
3351
- (_buffer = this.buffer).push.apply(_buffer, arguments);
3352
- };
3353
- }
3354
- }, {
3355
- key: "typeFormattterNotFound",
3356
- value: function typeFormattterNotFound(context, deltaType) {
3357
- throw new Error("cannot format delta type: " + deltaType);
3358
- }
3359
- }, {
3360
- key: "typeFormattterErrorFormatter",
3361
- value: function typeFormattterErrorFormatter(context, err) {
3362
- return err.toString();
3363
- }
3364
- }, {
3365
- key: "finalize",
3366
- value: function finalize(_ref) {
3367
- var buffer = _ref.buffer;
3368
- if (isArray$3(buffer)) {
3369
- return buffer.join("");
3370
- }
3371
- }
3372
- }, {
3373
- key: "recurse",
3374
- value: function recurse(context, delta, left, key, leftKey, movedFrom, isLast) {
3375
- var useMoveOriginHere = delta && movedFrom;
3376
- var leftValue = useMoveOriginHere ? movedFrom.value : left;
3377
- if (typeof delta === "undefined" && typeof key === "undefined") {
3378
- return void 0;
3379
- }
3380
- var type = this.getDeltaType(delta, movedFrom);
3381
- var nodeType = type === "node" ? delta._t === "a" ? "array" : "object" : "";
3382
- if (typeof key !== "undefined") {
3383
- this.nodeBegin(context, key, leftKey, type, nodeType, isLast);
3384
- } else {
3385
- this.rootBegin(context, type, nodeType);
3386
- }
3387
- var typeFormattter = void 0;
3388
- try {
3389
- typeFormattter = this["format_" + type] || this.typeFormattterNotFound(context, type);
3390
- typeFormattter.call(this, context, delta, leftValue, key, leftKey, movedFrom);
3391
- } catch (err) {
3392
- this.typeFormattterErrorFormatter(context, err, delta, leftValue, key, leftKey, movedFrom);
3393
- if (typeof console !== "undefined" && console.error) {
3394
- console.error(err.stack);
3395
- }
3396
- }
3397
- if (typeof key !== "undefined") {
3398
- this.nodeEnd(context, key, leftKey, type, nodeType, isLast);
3399
- } else {
3400
- this.rootEnd(context, type, nodeType);
3401
- }
3402
- }
3403
- }, {
3404
- key: "formatDeltaChildren",
3405
- value: function formatDeltaChildren(context, delta, left) {
3406
- var self = this;
3407
- this.forEachDeltaKey(delta, left, function(key, leftKey, movedFrom, isLast) {
3408
- self.recurse(context, delta[key], left ? left[leftKey] : void 0, key, leftKey, movedFrom, isLast);
3409
- });
3410
- }
3411
- }, {
3412
- key: "forEachDeltaKey",
3413
- value: function forEachDeltaKey(delta, left, fn) {
3414
- var keys = getObjectKeys(delta);
3415
- var arrayKeys = delta._t === "a";
3416
- var moveDestinations = {};
3417
- var name = void 0;
3418
- if (typeof left !== "undefined") {
3419
- for (name in left) {
3420
- if (Object.prototype.hasOwnProperty.call(left, name)) {
3421
- if (typeof delta[name] === "undefined" && (!arrayKeys || typeof delta["_" + name] === "undefined")) {
3422
- keys.push(name);
3423
- }
3424
- }
3425
- }
3426
- }
3427
- for (name in delta) {
3428
- if (Object.prototype.hasOwnProperty.call(delta, name)) {
3429
- var value = delta[name];
3430
- if (isArray$3(value) && value[2] === 3) {
3431
- moveDestinations[value[1].toString()] = {
3432
- key: name,
3433
- value: left && left[parseInt(name.substr(1))]
3434
- };
3435
- if (this.includeMoveDestinations !== false) {
3436
- if (typeof left === "undefined" && typeof delta[value[1]] === "undefined") {
3437
- keys.push(value[1].toString());
3438
- }
3439
- }
3440
- }
3441
- }
3442
- }
3443
- if (arrayKeys) {
3444
- keys.sort(arrayKeyComparer);
3445
- } else {
3446
- keys.sort();
3447
- }
3448
- for (var index2 = 0, length = keys.length; index2 < length; index2++) {
3449
- var key = keys[index2];
3450
- if (arrayKeys && key === "_t") {
3451
- continue;
3452
- }
3453
- var leftKey = arrayKeys ? typeof key === "number" ? key : parseInt(trimUnderscore(key), 10) : key;
3454
- var isLast = index2 === length - 1;
3455
- fn(key, leftKey, moveDestinations[leftKey], isLast);
3456
- }
3457
- }
3458
- }, {
3459
- key: "getDeltaType",
3460
- value: function getDeltaType(delta, movedFrom) {
3461
- if (typeof delta === "undefined") {
3462
- if (typeof movedFrom !== "undefined") {
3463
- return "movedestination";
3464
- }
3465
- return "unchanged";
3466
- }
3467
- if (isArray$3(delta)) {
3468
- if (delta.length === 1) {
3469
- return "added";
3470
- }
3471
- if (delta.length === 2) {
3472
- return "modified";
3473
- }
3474
- if (delta.length === 3 && delta[2] === 0) {
3475
- return "deleted";
3476
- }
3477
- if (delta.length === 3 && delta[2] === 2) {
3478
- return "textdiff";
3479
- }
3480
- if (delta.length === 3 && delta[2] === 3) {
3481
- return "moved";
3482
- }
3483
- } else if ((typeof delta === "undefined" ? "undefined" : _typeof(delta)) === "object") {
3484
- return "node";
3485
- }
3486
- return "unknown";
3487
- }
3488
- }, {
3489
- key: "parseTextDiff",
3490
- value: function parseTextDiff(value) {
3491
- var output = [];
3492
- var lines = value.split("\n@@ ");
3493
- for (var i = 0, l = lines.length; i < l; i++) {
3494
- var line = lines[i];
3495
- var lineOutput = {
3496
- pieces: []
3497
- };
3498
- var location = /^(?:@@ )?[-+]?(\d+),(\d+)/.exec(line).slice(1);
3499
- lineOutput.location = {
3500
- line: location[0],
3501
- chr: location[1]
3502
- };
3503
- var pieces = line.split("\n").slice(1);
3504
- for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
3505
- var piece = pieces[pieceIndex];
3506
- if (!piece.length) {
3507
- continue;
3508
- }
3509
- var pieceOutput = {
3510
- type: "context"
3511
- };
3512
- if (piece.substr(0, 1) === "+") {
3513
- pieceOutput.type = "added";
3514
- } else if (piece.substr(0, 1) === "-") {
3515
- pieceOutput.type = "deleted";
3516
- }
3517
- pieceOutput.text = piece.slice(1);
3518
- lineOutput.pieces.push(pieceOutput);
3519
- }
3520
- output.push(lineOutput);
3521
- }
3522
- return output;
3523
- }
3524
- }]);
3525
- return BaseFormatter2;
3526
- }();
3527
- var base = Object.freeze({
3528
- default: BaseFormatter
3529
- });
3530
- var HtmlFormatter = function(_BaseFormatter) {
3531
- inherits(HtmlFormatter2, _BaseFormatter);
3532
- function HtmlFormatter2() {
3533
- classCallCheck(this, HtmlFormatter2);
3534
- return possibleConstructorReturn(this, (HtmlFormatter2.__proto__ || Object.getPrototypeOf(HtmlFormatter2)).apply(this, arguments));
3535
- }
3536
- createClass(HtmlFormatter2, [{
3537
- key: "typeFormattterErrorFormatter",
3538
- value: function typeFormattterErrorFormatter(context, err) {
3539
- context.out('<pre class="jsondiffpatch-error">' + err + "</pre>");
3540
- }
3541
- }, {
3542
- key: "formatValue",
3543
- value: function formatValue(context, value) {
3544
- context.out("<pre>" + htmlEscape(JSON.stringify(value, null, 2)) + "</pre>");
3545
- }
3546
- }, {
3547
- key: "formatTextDiffString",
3548
- value: function formatTextDiffString(context, value) {
3549
- var lines = this.parseTextDiff(value);
3550
- context.out('<ul class="jsondiffpatch-textdiff">');
3551
- for (var i = 0, l = lines.length; i < l; i++) {
3552
- var line = lines[i];
3553
- context.out('<li><div class="jsondiffpatch-textdiff-location">' + ('<span class="jsondiffpatch-textdiff-line-number">' + line.location.line + '</span><span class="jsondiffpatch-textdiff-char">' + line.location.chr + '</span></div><div class="jsondiffpatch-textdiff-line">'));
3554
- var pieces = line.pieces;
3555
- for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
3556
- var piece = pieces[pieceIndex];
3557
- context.out('<span class="jsondiffpatch-textdiff-' + piece.type + '">' + htmlEscape(decodeURI(piece.text)) + "</span>");
3558
- }
3559
- context.out("</div></li>");
3560
- }
3561
- context.out("</ul>");
3562
- }
3563
- }, {
3564
- key: "rootBegin",
3565
- value: function rootBegin(context, type, nodeType) {
3566
- var nodeClass = "jsondiffpatch-" + type + (nodeType ? " jsondiffpatch-child-node-type-" + nodeType : "");
3567
- context.out('<div class="jsondiffpatch-delta ' + nodeClass + '">');
3568
- }
3569
- }, {
3570
- key: "rootEnd",
3571
- value: function rootEnd(context) {
3572
- context.out("</div>" + (context.hasArrows ? '<script type="text/javascript">setTimeout(' + (adjustArrows.toString() + ",10);</script>") : ""));
3573
- }
3574
- }, {
3575
- key: "nodeBegin",
3576
- value: function nodeBegin(context, key, leftKey, type, nodeType) {
3577
- var nodeClass = "jsondiffpatch-" + type + (nodeType ? " jsondiffpatch-child-node-type-" + nodeType : "");
3578
- context.out('<li class="' + nodeClass + '" data-key="' + leftKey + '">' + ('<div class="jsondiffpatch-property-name">' + leftKey + "</div>"));
3579
- }
3580
- }, {
3581
- key: "nodeEnd",
3582
- value: function nodeEnd(context) {
3583
- context.out("</li>");
3584
- }
3585
- /* jshint camelcase: false */
3586
- /* eslint-disable camelcase */
3587
- }, {
3588
- key: "format_unchanged",
3589
- value: function format_unchanged(context, delta, left) {
3590
- if (typeof left === "undefined") {
3591
- return;
3592
- }
3593
- context.out('<div class="jsondiffpatch-value">');
3594
- this.formatValue(context, left);
3595
- context.out("</div>");
3596
- }
3597
- }, {
3598
- key: "format_movedestination",
3599
- value: function format_movedestination(context, delta, left) {
3600
- if (typeof left === "undefined") {
3601
- return;
3602
- }
3603
- context.out('<div class="jsondiffpatch-value">');
3604
- this.formatValue(context, left);
3605
- context.out("</div>");
3606
- }
3607
- }, {
3608
- key: "format_node",
3609
- value: function format_node(context, delta, left) {
3610
- var nodeType = delta._t === "a" ? "array" : "object";
3611
- context.out('<ul class="jsondiffpatch-node jsondiffpatch-node-type-' + nodeType + '">');
3612
- this.formatDeltaChildren(context, delta, left);
3613
- context.out("</ul>");
3614
- }
3615
- }, {
3616
- key: "format_added",
3617
- value: function format_added(context, delta) {
3618
- context.out('<div class="jsondiffpatch-value">');
3619
- this.formatValue(context, delta[0]);
3620
- context.out("</div>");
3621
- }
3622
- }, {
3623
- key: "format_modified",
3624
- value: function format_modified(context, delta) {
3625
- context.out('<div class="jsondiffpatch-value jsondiffpatch-left-value">');
3626
- this.formatValue(context, delta[0]);
3627
- context.out('</div><div class="jsondiffpatch-value jsondiffpatch-right-value">');
3628
- this.formatValue(context, delta[1]);
3629
- context.out("</div>");
3630
- }
3631
- }, {
3632
- key: "format_deleted",
3633
- value: function format_deleted(context, delta) {
3634
- context.out('<div class="jsondiffpatch-value">');
3635
- this.formatValue(context, delta[0]);
3636
- context.out("</div>");
3637
- }
3638
- }, {
3639
- key: "format_moved",
3640
- value: function format_moved(context, delta) {
3641
- context.out('<div class="jsondiffpatch-value">');
3642
- this.formatValue(context, delta[0]);
3643
- context.out('</div><div class="jsondiffpatch-moved-destination">' + delta[1] + "</div>");
3644
- context.out(
3645
- /* jshint multistr: true */
3646
- '<div class="jsondiffpatch-arrow" style="position: relative; left: -34px;">\n <svg width="30" height="60" style="position: absolute; display: none;">\n <defs>\n <marker id="markerArrow" markerWidth="8" markerHeight="8"\n refx="2" refy="4"\n orient="auto" markerUnits="userSpaceOnUse">\n <path d="M1,1 L1,7 L7,4 L1,1" style="fill: #339;" />\n </marker>\n </defs>\n <path d="M30,0 Q-10,25 26,50"\n style="stroke: #88f; stroke-width: 2px; fill: none; stroke-opacity: 0.5; marker-end: url(#markerArrow);"\n ></path>\n </svg>\n </div>'
3647
- );
3648
- context.hasArrows = true;
3649
- }
3650
- }, {
3651
- key: "format_textdiff",
3652
- value: function format_textdiff(context, delta) {
3653
- context.out('<div class="jsondiffpatch-value">');
3654
- this.formatTextDiffString(context, delta[0]);
3655
- context.out("</div>");
3656
- }
3657
- }]);
3658
- return HtmlFormatter2;
3659
- }(BaseFormatter);
3660
- function htmlEscape(text) {
3661
- var html2 = text;
3662
- var replacements = [[/&/g, "&amp;"], [/</g, "&lt;"], [/>/g, "&gt;"], [/'/g, "&apos;"], [/"/g, "&quot;"]];
3663
- for (var i = 0; i < replacements.length; i++) {
3664
- html2 = html2.replace(replacements[i][0], replacements[i][1]);
3665
- }
3666
- return html2;
3667
- }
3668
- var adjustArrows = function jsondiffpatchHtmlFormatterAdjustArrows(nodeArg) {
3669
- var node = nodeArg || document;
3670
- var getElementText = function getElementText2(_ref) {
3671
- var textContent = _ref.textContent, innerText = _ref.innerText;
3672
- return textContent || innerText;
3673
- };
3674
- var eachByQuery = function eachByQuery2(el, query, fn) {
3675
- var elems = el.querySelectorAll(query);
3676
- for (var i = 0, l = elems.length; i < l; i++) {
3677
- fn(elems[i]);
3678
- }
3679
- };
3680
- var eachChildren = function eachChildren2(_ref2, fn) {
3681
- var children = _ref2.children;
3682
- for (var i = 0, l = children.length; i < l; i++) {
3683
- fn(children[i], i);
3684
- }
3685
- };
3686
- eachByQuery(node, ".jsondiffpatch-arrow", function(_ref3) {
3687
- var parentNode = _ref3.parentNode, children = _ref3.children, style = _ref3.style;
3688
- var arrowParent = parentNode;
3689
- var svg = children[0];
3690
- var path = svg.children[1];
3691
- svg.style.display = "none";
3692
- var destination = getElementText(arrowParent.querySelector(".jsondiffpatch-moved-destination"));
3693
- var container = arrowParent.parentNode;
3694
- var destinationElem = void 0;
3695
- eachChildren(container, function(child) {
3696
- if (child.getAttribute("data-key") === destination) {
3697
- destinationElem = child;
3698
- }
3699
- });
3700
- if (!destinationElem) {
3701
- return;
3702
- }
3703
- try {
3704
- var distance = destinationElem.offsetTop - arrowParent.offsetTop;
3705
- svg.setAttribute("height", Math.abs(distance) + 6);
3706
- style.top = -8 + (distance > 0 ? 0 : distance) + "px";
3707
- var curve = distance > 0 ? "M30,0 Q-10," + Math.round(distance / 2) + " 26," + (distance - 4) : "M30," + -distance + " Q-10," + Math.round(-distance / 2) + " 26,4";
3708
- path.setAttribute("d", curve);
3709
- svg.style.display = "";
3710
- } catch (err) {
3711
- }
3712
- });
3713
- };
3714
- var showUnchanged = function showUnchanged2(show, node, delay) {
3715
- var el = node || document.body;
3716
- var prefix = "jsondiffpatch-unchanged-";
3717
- var classes = {
3718
- showing: prefix + "showing",
3719
- hiding: prefix + "hiding",
3720
- visible: prefix + "visible",
3721
- hidden: prefix + "hidden"
3722
- };
3723
- var list = el.classList;
3724
- if (!list) {
3725
- return;
3726
- }
3727
- if (!delay) {
3728
- list.remove(classes.showing);
3729
- list.remove(classes.hiding);
3730
- list.remove(classes.visible);
3731
- list.remove(classes.hidden);
3732
- if (show === false) {
3733
- list.add(classes.hidden);
3734
- }
3735
- return;
3736
- }
3737
- if (show === false) {
3738
- list.remove(classes.showing);
3739
- list.add(classes.visible);
3740
- setTimeout(function() {
3741
- list.add(classes.hiding);
3742
- }, 10);
3743
- } else {
3744
- list.remove(classes.hiding);
3745
- list.add(classes.showing);
3746
- list.remove(classes.hidden);
3747
- }
3748
- var intervalId = setInterval(function() {
3749
- adjustArrows(el);
3750
- }, 100);
3751
- setTimeout(function() {
3752
- list.remove(classes.showing);
3753
- list.remove(classes.hiding);
3754
- if (show === false) {
3755
- list.add(classes.hidden);
3756
- list.remove(classes.visible);
3757
- } else {
3758
- list.add(classes.visible);
3759
- list.remove(classes.hidden);
3760
- }
3761
- setTimeout(function() {
3762
- list.remove(classes.visible);
3763
- clearInterval(intervalId);
3764
- }, delay + 400);
3765
- }, delay);
3766
- };
3767
- var hideUnchanged = function hideUnchanged2(node, delay) {
3768
- return showUnchanged(false, node, delay);
3769
- };
3770
- var defaultInstance = void 0;
3771
- function format(delta, left) {
3772
- if (!defaultInstance) {
3773
- defaultInstance = new HtmlFormatter();
3774
- }
3775
- return defaultInstance.format(delta, left);
3776
- }
3777
- var html = Object.freeze({
3778
- showUnchanged,
3779
- hideUnchanged,
3780
- default: HtmlFormatter,
3781
- format
3782
- });
3783
- var AnnotatedFormatter = function(_BaseFormatter) {
3784
- inherits(AnnotatedFormatter2, _BaseFormatter);
3785
- function AnnotatedFormatter2() {
3786
- classCallCheck(this, AnnotatedFormatter2);
3787
- var _this = possibleConstructorReturn(this, (AnnotatedFormatter2.__proto__ || Object.getPrototypeOf(AnnotatedFormatter2)).call(this));
3788
- _this.includeMoveDestinations = false;
3789
- return _this;
3790
- }
3791
- createClass(AnnotatedFormatter2, [{
3792
- key: "prepareContext",
3793
- value: function prepareContext(context) {
3794
- get(AnnotatedFormatter2.prototype.__proto__ || Object.getPrototypeOf(AnnotatedFormatter2.prototype), "prepareContext", this).call(this, context);
3795
- context.indent = function(levels) {
3796
- this.indentLevel = (this.indentLevel || 0) + (typeof levels === "undefined" ? 1 : levels);
3797
- this.indentPad = new Array(this.indentLevel + 1).join("&nbsp;&nbsp;");
3798
- };
3799
- context.row = function(json, htmlNote) {
3800
- context.out('<tr><td style="white-space: nowrap;"><pre class="jsondiffpatch-annotated-indent" style="display: inline-block">');
3801
- context.out(context.indentPad);
3802
- context.out('</pre><pre style="display: inline-block">');
3803
- context.out(json);
3804
- context.out('</pre></td><td class="jsondiffpatch-delta-note"><div>');
3805
- context.out(htmlNote);
3806
- context.out("</div></td></tr>");
3807
- };
3808
- }
3809
- }, {
3810
- key: "typeFormattterErrorFormatter",
3811
- value: function typeFormattterErrorFormatter(context, err) {
3812
- context.row("", '<pre class="jsondiffpatch-error">' + err + "</pre>");
3813
- }
3814
- }, {
3815
- key: "formatTextDiffString",
3816
- value: function formatTextDiffString(context, value) {
3817
- var lines = this.parseTextDiff(value);
3818
- context.out('<ul class="jsondiffpatch-textdiff">');
3819
- for (var i = 0, l = lines.length; i < l; i++) {
3820
- var line = lines[i];
3821
- context.out('<li><div class="jsondiffpatch-textdiff-location">' + ('<span class="jsondiffpatch-textdiff-line-number">' + line.location.line + '</span><span class="jsondiffpatch-textdiff-char">' + line.location.chr + '</span></div><div class="jsondiffpatch-textdiff-line">'));
3822
- var pieces = line.pieces;
3823
- for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
3824
- var piece = pieces[pieceIndex];
3825
- context.out('<span class="jsondiffpatch-textdiff-' + piece.type + '">' + piece.text + "</span>");
3826
- }
3827
- context.out("</div></li>");
3828
- }
3829
- context.out("</ul>");
3830
- }
3831
- }, {
3832
- key: "rootBegin",
3833
- value: function rootBegin(context, type, nodeType) {
3834
- context.out('<table class="jsondiffpatch-annotated-delta">');
3835
- if (type === "node") {
3836
- context.row("{");
3837
- context.indent();
3838
- }
3839
- if (nodeType === "array") {
3840
- context.row('"_t": "a",', "Array delta (member names indicate array indices)");
3841
- }
3842
- }
3843
- }, {
3844
- key: "rootEnd",
3845
- value: function rootEnd(context, type) {
3846
- if (type === "node") {
3847
- context.indent(-1);
3848
- context.row("}");
3849
- }
3850
- context.out("</table>");
3851
- }
3852
- }, {
3853
- key: "nodeBegin",
3854
- value: function nodeBegin(context, key, leftKey, type, nodeType) {
3855
- context.row("&quot;" + key + "&quot;: {");
3856
- if (type === "node") {
3857
- context.indent();
3858
- }
3859
- if (nodeType === "array") {
3860
- context.row('"_t": "a",', "Array delta (member names indicate array indices)");
3861
- }
3862
- }
3863
- }, {
3864
- key: "nodeEnd",
3865
- value: function nodeEnd(context, key, leftKey, type, nodeType, isLast) {
3866
- if (type === "node") {
3867
- context.indent(-1);
3868
- }
3869
- context.row("}" + (isLast ? "" : ","));
3870
- }
3871
- /* jshint camelcase: false */
3872
- /* eslint-disable camelcase */
3873
- }, {
3874
- key: "format_unchanged",
3875
- value: function format_unchanged() {
3876
- }
3877
- }, {
3878
- key: "format_movedestination",
3879
- value: function format_movedestination() {
3880
- }
3881
- }, {
3882
- key: "format_node",
3883
- value: function format_node(context, delta, left) {
3884
- this.formatDeltaChildren(context, delta, left);
3885
- }
3886
- }]);
3887
- return AnnotatedFormatter2;
3888
- }(BaseFormatter);
3889
- var wrapPropertyName = function wrapPropertyName2(name) {
3890
- return '<pre style="display:inline-block">&quot;' + name + "&quot;</pre>";
3891
- };
3892
- var deltaAnnotations = {
3893
- added: function added(delta, left, key, leftKey) {
3894
- var formatLegend = " <pre>([newValue])</pre>";
3895
- if (typeof leftKey === "undefined") {
3896
- return "new value" + formatLegend;
3897
- }
3898
- if (typeof leftKey === "number") {
3899
- return "insert at index " + leftKey + formatLegend;
3900
- }
3901
- return "add property " + wrapPropertyName(leftKey) + formatLegend;
3902
- },
3903
- modified: function modified(delta, left, key, leftKey) {
3904
- var formatLegend = " <pre>([previousValue, newValue])</pre>";
3905
- if (typeof leftKey === "undefined") {
3906
- return "modify value" + formatLegend;
3907
- }
3908
- if (typeof leftKey === "number") {
3909
- return "modify at index " + leftKey + formatLegend;
3910
- }
3911
- return "modify property " + wrapPropertyName(leftKey) + formatLegend;
3912
- },
3913
- deleted: function deleted(delta, left, key, leftKey) {
3914
- var formatLegend = " <pre>([previousValue, 0, 0])</pre>";
3915
- if (typeof leftKey === "undefined") {
3916
- return "delete value" + formatLegend;
3917
- }
3918
- if (typeof leftKey === "number") {
3919
- return "remove index " + leftKey + formatLegend;
3920
- }
3921
- return "delete property " + wrapPropertyName(leftKey) + formatLegend;
3922
- },
3923
- moved: function moved(delta, left, key, leftKey) {
3924
- return 'move from <span title="(position to remove at original state)">' + ("index " + leftKey + '</span> to <span title="(position to insert at final') + (' state)">index ' + delta[1] + "</span>");
3925
- },
3926
- textdiff: function textdiff(delta, left, key, leftKey) {
3927
- var location = typeof leftKey === "undefined" ? "" : typeof leftKey === "number" ? " at index " + leftKey : " at property " + wrapPropertyName(leftKey);
3928
- return "text diff" + location + ', format is <a href="https://code.google.com/p/google-diff-match-patch/wiki/Unidiff">a variation of Unidiff</a>';
3929
- }
3930
- };
3931
- var formatAnyChange = function formatAnyChange2(context, delta) {
3932
- var deltaType = this.getDeltaType(delta);
3933
- var annotator = deltaAnnotations[deltaType];
3934
- var htmlNote = annotator && annotator.apply(annotator, Array.prototype.slice.call(arguments, 1));
3935
- var json = JSON.stringify(delta, null, 2);
3936
- if (deltaType === "textdiff") {
3937
- json = json.split("\\n").join('\\n"+\n "');
3938
- }
3939
- context.indent();
3940
- context.row(json, htmlNote);
3941
- context.indent(-1);
3942
- };
3943
- AnnotatedFormatter.prototype.format_added = formatAnyChange;
3944
- AnnotatedFormatter.prototype.format_modified = formatAnyChange;
3945
- AnnotatedFormatter.prototype.format_deleted = formatAnyChange;
3946
- AnnotatedFormatter.prototype.format_moved = formatAnyChange;
3947
- AnnotatedFormatter.prototype.format_textdiff = formatAnyChange;
3948
- var defaultInstance$1 = void 0;
3949
- function format$1(delta, left) {
3950
- if (!defaultInstance$1) {
3951
- defaultInstance$1 = new AnnotatedFormatter();
3952
- }
3953
- return defaultInstance$1.format(delta, left);
3954
- }
3955
- var annotated = Object.freeze({
3956
- default: AnnotatedFormatter,
3957
- format: format$1
3958
- });
3959
- var OPERATIONS = {
3960
- add: "add",
3961
- remove: "remove",
3962
- replace: "replace",
3963
- move: "move"
3964
- };
3965
- var JSONFormatter = function(_BaseFormatter) {
3966
- inherits(JSONFormatter2, _BaseFormatter);
3967
- function JSONFormatter2() {
3968
- classCallCheck(this, JSONFormatter2);
3969
- var _this = possibleConstructorReturn(this, (JSONFormatter2.__proto__ || Object.getPrototypeOf(JSONFormatter2)).call(this));
3970
- _this.includeMoveDestinations = true;
3971
- return _this;
3972
- }
3973
- createClass(JSONFormatter2, [{
3974
- key: "prepareContext",
3975
- value: function prepareContext(context) {
3976
- get(JSONFormatter2.prototype.__proto__ || Object.getPrototypeOf(JSONFormatter2.prototype), "prepareContext", this).call(this, context);
3977
- context.result = [];
3978
- context.path = [];
3979
- context.pushCurrentOp = function(obj) {
3980
- var op = obj.op, value = obj.value;
3981
- var val = {
3982
- op,
3983
- path: this.currentPath()
3984
- };
3985
- if (typeof value !== "undefined") {
3986
- val.value = value;
3987
- }
3988
- this.result.push(val);
3989
- };
3990
- context.pushMoveOp = function(to) {
3991
- var from = this.currentPath();
3992
- this.result.push({
3993
- op: OPERATIONS.move,
3994
- from,
3995
- path: this.toPath(to)
3996
- });
3997
- };
3998
- context.currentPath = function() {
3999
- return "/" + this.path.join("/");
4000
- };
4001
- context.toPath = function(toPath) {
4002
- var to = this.path.slice();
4003
- to[to.length - 1] = toPath;
4004
- return "/" + to.join("/");
4005
- };
4006
- }
4007
- }, {
4008
- key: "typeFormattterErrorFormatter",
4009
- value: function typeFormattterErrorFormatter(context, err) {
4010
- context.out("[ERROR] " + err);
4011
- }
4012
- }, {
4013
- key: "rootBegin",
4014
- value: function rootBegin() {
4015
- }
4016
- }, {
4017
- key: "rootEnd",
4018
- value: function rootEnd() {
4019
- }
4020
- }, {
4021
- key: "nodeBegin",
4022
- value: function nodeBegin(_ref, key, leftKey) {
4023
- var path = _ref.path;
4024
- path.push(leftKey);
4025
- }
4026
- }, {
4027
- key: "nodeEnd",
4028
- value: function nodeEnd(_ref2) {
4029
- var path = _ref2.path;
4030
- path.pop();
4031
- }
4032
- /* jshint camelcase: false */
4033
- /* eslint-disable camelcase */
4034
- }, {
4035
- key: "format_unchanged",
4036
- value: function format_unchanged() {
4037
- }
4038
- }, {
4039
- key: "format_movedestination",
4040
- value: function format_movedestination() {
4041
- }
4042
- }, {
4043
- key: "format_node",
4044
- value: function format_node(context, delta, left) {
4045
- this.formatDeltaChildren(context, delta, left);
4046
- }
4047
- }, {
4048
- key: "format_added",
4049
- value: function format_added(context, delta) {
4050
- context.pushCurrentOp({ op: OPERATIONS.add, value: delta[0] });
4051
- }
4052
- }, {
4053
- key: "format_modified",
4054
- value: function format_modified(context, delta) {
4055
- context.pushCurrentOp({ op: OPERATIONS.replace, value: delta[1] });
4056
- }
4057
- }, {
4058
- key: "format_deleted",
4059
- value: function format_deleted(context) {
4060
- context.pushCurrentOp({ op: OPERATIONS.remove });
4061
- }
4062
- }, {
4063
- key: "format_moved",
4064
- value: function format_moved(context, delta) {
4065
- var to = delta[1];
4066
- context.pushMoveOp(to);
4067
- }
4068
- }, {
4069
- key: "format_textdiff",
4070
- value: function format_textdiff() {
4071
- throw new Error("Not implemented");
4072
- }
4073
- }, {
4074
- key: "format",
4075
- value: function format4(delta, left) {
4076
- var context = {};
4077
- this.prepareContext(context);
4078
- this.recurse(context, delta, left);
4079
- return context.result;
4080
- }
4081
- }]);
4082
- return JSONFormatter2;
4083
- }(BaseFormatter);
4084
- var last = function last2(arr) {
4085
- return arr[arr.length - 1];
4086
- };
4087
- var sortBy = function sortBy2(arr, pred) {
4088
- arr.sort(pred);
4089
- return arr;
4090
- };
4091
- var compareByIndexDesc = function compareByIndexDesc2(indexA, indexB) {
4092
- var lastA = parseInt(indexA, 10);
4093
- var lastB = parseInt(indexB, 10);
4094
- if (!(isNaN(lastA) || isNaN(lastB))) {
4095
- return lastB - lastA;
4096
- } else {
4097
- return 0;
4098
- }
4099
- };
4100
- var opsByDescendingOrder = function opsByDescendingOrder2(removeOps) {
4101
- return sortBy(removeOps, function(a, b) {
4102
- var splitA = a.path.split("/");
4103
- var splitB = b.path.split("/");
4104
- if (splitA.length !== splitB.length) {
4105
- return splitA.length - splitB.length;
4106
- } else {
4107
- return compareByIndexDesc(last(splitA), last(splitB));
4108
- }
4109
- });
4110
- };
4111
- var partitionOps = function partitionOps2(arr, fns) {
4112
- var initArr = Array(fns.length + 1).fill().map(function() {
4113
- return [];
4114
- });
4115
- return arr.map(function(item) {
4116
- var position = fns.map(function(fn) {
4117
- return fn(item);
4118
- }).indexOf(true);
4119
- if (position < 0) {
4120
- position = fns.length;
4121
- }
4122
- return { item, position };
4123
- }).reduce(function(acc, item) {
4124
- acc[item.position].push(item.item);
4125
- return acc;
4126
- }, initArr);
4127
- };
4128
- var isMoveOp = function isMoveOp2(_ref3) {
4129
- var op = _ref3.op;
4130
- return op === "move";
4131
- };
4132
- var isRemoveOp = function isRemoveOp2(_ref4) {
4133
- var op = _ref4.op;
4134
- return op === "remove";
4135
- };
4136
- var reorderOps = function reorderOps2(diff) {
4137
- var _partitionOps = partitionOps(diff, [isMoveOp, isRemoveOp]), _partitionOps2 = slicedToArray(_partitionOps, 3), moveOps = _partitionOps2[0], removedOps = _partitionOps2[1], restOps = _partitionOps2[2];
4138
- var removeOpsReverse = opsByDescendingOrder(removedOps);
4139
- return [].concat(toConsumableArray(removeOpsReverse), toConsumableArray(moveOps), toConsumableArray(restOps));
4140
- };
4141
- var defaultInstance$2 = void 0;
4142
- var format$2 = function format2(delta, left) {
4143
- if (!defaultInstance$2) {
4144
- defaultInstance$2 = new JSONFormatter();
4145
- }
4146
- return reorderOps(defaultInstance$2.format(delta, left));
4147
- };
4148
- var log = function log2(delta, left) {
4149
- console.log(format$2(delta, left));
4150
- };
4151
- var jsonpatch = Object.freeze({
4152
- default: JSONFormatter,
4153
- partitionOps,
4154
- format: format$2,
4155
- log
4156
- });
4157
- function chalkColor(name) {
4158
- return import_chalk.default && import_chalk.default[name] || function() {
4159
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
4160
- args[_key] = arguments[_key];
4161
- }
4162
- return args;
4163
- };
4164
- }
4165
- var colors = {
4166
- added: chalkColor("green"),
4167
- deleted: chalkColor("red"),
4168
- movedestination: chalkColor("gray"),
4169
- moved: chalkColor("yellow"),
4170
- unchanged: chalkColor("gray"),
4171
- error: chalkColor("white.bgRed"),
4172
- textDiffLine: chalkColor("gray")
4173
- };
4174
- var ConsoleFormatter = function(_BaseFormatter) {
4175
- inherits(ConsoleFormatter2, _BaseFormatter);
4176
- function ConsoleFormatter2() {
4177
- classCallCheck(this, ConsoleFormatter2);
4178
- var _this = possibleConstructorReturn(this, (ConsoleFormatter2.__proto__ || Object.getPrototypeOf(ConsoleFormatter2)).call(this));
4179
- _this.includeMoveDestinations = false;
4180
- return _this;
4181
- }
4182
- createClass(ConsoleFormatter2, [{
4183
- key: "prepareContext",
4184
- value: function prepareContext(context) {
4185
- get(ConsoleFormatter2.prototype.__proto__ || Object.getPrototypeOf(ConsoleFormatter2.prototype), "prepareContext", this).call(this, context);
4186
- context.indent = function(levels) {
4187
- this.indentLevel = (this.indentLevel || 0) + (typeof levels === "undefined" ? 1 : levels);
4188
- this.indentPad = new Array(this.indentLevel + 1).join(" ");
4189
- this.outLine();
4190
- };
4191
- context.outLine = function() {
4192
- this.buffer.push("\n" + (this.indentPad || ""));
4193
- };
4194
- context.out = function() {
4195
- for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
4196
- args[_key2] = arguments[_key2];
4197
- }
4198
- for (var i = 0, l = args.length; i < l; i++) {
4199
- var lines = args[i].split("\n");
4200
- var text = lines.join("\n" + (this.indentPad || ""));
4201
- if (this.color && this.color[0]) {
4202
- text = this.color[0](text);
4203
- }
4204
- this.buffer.push(text);
4205
- }
4206
- };
4207
- context.pushColor = function(color) {
4208
- this.color = this.color || [];
4209
- this.color.unshift(color);
4210
- };
4211
- context.popColor = function() {
4212
- this.color = this.color || [];
4213
- this.color.shift();
4214
- };
4215
- }
4216
- }, {
4217
- key: "typeFormattterErrorFormatter",
4218
- value: function typeFormattterErrorFormatter(context, err) {
4219
- context.pushColor(colors.error);
4220
- context.out("[ERROR]" + err);
4221
- context.popColor();
4222
- }
4223
- }, {
4224
- key: "formatValue",
4225
- value: function formatValue(context, value) {
4226
- context.out(JSON.stringify(value, null, 2));
4227
- }
4228
- }, {
4229
- key: "formatTextDiffString",
4230
- value: function formatTextDiffString(context, value) {
4231
- var lines = this.parseTextDiff(value);
4232
- context.indent();
4233
- for (var i = 0, l = lines.length; i < l; i++) {
4234
- var line = lines[i];
4235
- context.pushColor(colors.textDiffLine);
4236
- context.out(line.location.line + "," + line.location.chr + " ");
4237
- context.popColor();
4238
- var pieces = line.pieces;
4239
- for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
4240
- var piece = pieces[pieceIndex];
4241
- context.pushColor(colors[piece.type]);
4242
- context.out(piece.text);
4243
- context.popColor();
4244
- }
4245
- if (i < l - 1) {
4246
- context.outLine();
4247
- }
4248
- }
4249
- context.indent(-1);
4250
- }
4251
- }, {
4252
- key: "rootBegin",
4253
- value: function rootBegin(context, type, nodeType) {
4254
- context.pushColor(colors[type]);
4255
- if (type === "node") {
4256
- context.out(nodeType === "array" ? "[" : "{");
4257
- context.indent();
4258
- }
4259
- }
4260
- }, {
4261
- key: "rootEnd",
4262
- value: function rootEnd(context, type, nodeType) {
4263
- if (type === "node") {
4264
- context.indent(-1);
4265
- context.out(nodeType === "array" ? "]" : "}");
4266
- }
4267
- context.popColor();
4268
- }
4269
- }, {
4270
- key: "nodeBegin",
4271
- value: function nodeBegin(context, key, leftKey, type, nodeType) {
4272
- context.pushColor(colors[type]);
4273
- context.out(leftKey + ": ");
4274
- if (type === "node") {
4275
- context.out(nodeType === "array" ? "[" : "{");
4276
- context.indent();
4277
- }
4278
- }
4279
- }, {
4280
- key: "nodeEnd",
4281
- value: function nodeEnd(context, key, leftKey, type, nodeType, isLast) {
4282
- if (type === "node") {
4283
- context.indent(-1);
4284
- context.out(nodeType === "array" ? "]" : "}" + (isLast ? "" : ","));
4285
- }
4286
- if (!isLast) {
4287
- context.outLine();
4288
- }
4289
- context.popColor();
4290
- }
4291
- /* jshint camelcase: false */
4292
- /* eslint-disable camelcase */
4293
- }, {
4294
- key: "format_unchanged",
4295
- value: function format_unchanged(context, delta, left) {
4296
- if (typeof left === "undefined") {
4297
- return;
4298
- }
4299
- this.formatValue(context, left);
4300
- }
4301
- }, {
4302
- key: "format_movedestination",
4303
- value: function format_movedestination(context, delta, left) {
4304
- if (typeof left === "undefined") {
4305
- return;
4306
- }
4307
- this.formatValue(context, left);
4308
- }
4309
- }, {
4310
- key: "format_node",
4311
- value: function format_node(context, delta, left) {
4312
- this.formatDeltaChildren(context, delta, left);
4313
- }
4314
- }, {
4315
- key: "format_added",
4316
- value: function format_added(context, delta) {
4317
- this.formatValue(context, delta[0]);
4318
- }
4319
- }, {
4320
- key: "format_modified",
4321
- value: function format_modified(context, delta) {
4322
- context.pushColor(colors.deleted);
4323
- this.formatValue(context, delta[0]);
4324
- context.popColor();
4325
- context.out(" => ");
4326
- context.pushColor(colors.added);
4327
- this.formatValue(context, delta[1]);
4328
- context.popColor();
4329
- }
4330
- }, {
4331
- key: "format_deleted",
4332
- value: function format_deleted(context, delta) {
4333
- this.formatValue(context, delta[0]);
4334
- }
4335
- }, {
4336
- key: "format_moved",
4337
- value: function format_moved(context, delta) {
4338
- context.out("==> " + delta[1]);
4339
- }
4340
- }, {
4341
- key: "format_textdiff",
4342
- value: function format_textdiff(context, delta) {
4343
- this.formatTextDiffString(context, delta[0]);
4344
- }
4345
- }]);
4346
- return ConsoleFormatter2;
4347
- }(BaseFormatter);
4348
- var defaultInstance$3 = void 0;
4349
- var format$3 = function format3(delta, left) {
4350
- if (!defaultInstance$3) {
4351
- defaultInstance$3 = new ConsoleFormatter();
4352
- }
4353
- return defaultInstance$3.format(delta, left);
4354
- };
4355
- function log$1(delta, left) {
4356
- console.log(format$3(delta, left));
4357
- }
4358
- var console$1 = Object.freeze({
4359
- default: ConsoleFormatter,
4360
- format: format$3,
4361
- log: log$1
4362
- });
4363
- var index = Object.freeze({
4364
- base,
4365
- html,
4366
- annotated,
4367
- jsonpatch,
4368
- console: console$1
4369
- });
4370
-
4371
- // ../../node_modules/.pnpm/prosemirror-dev-tools@4.2.0_@babel+core@7.26.0_@babel+template@7.25.9_@types+react@19.1.6_rea_wz3aei26oeuigobt6rwizjq3ci/node_modules/prosemirror-dev-tools/dist/esm/state/json-diff-main.js
4372
- function _typeof2(obj) {
4373
- "@babel/helpers - typeof";
4374
- return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
4375
- return typeof obj2;
4376
- } : function(obj2) {
4377
- return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
4378
- }, _typeof2(obj);
4379
- }
4380
- function _regeneratorRuntime() {
4381
- "use strict";
4382
- _regeneratorRuntime = function _regeneratorRuntime2() {
4383
- return exports;
4384
- };
4385
- var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function(obj, key, desc) {
4386
- obj[key] = desc.value;
4387
- }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
4388
- function define(obj, key, value) {
4389
- return Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }), obj[key];
4390
- }
4391
- try {
4392
- define({}, "");
4393
- } catch (err) {
4394
- define = function define2(obj, key, value) {
4395
- return obj[key] = value;
4396
- };
4397
- }
4398
- function wrap(innerFn, outerFn, self, tryLocsList) {
4399
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context2(tryLocsList || []);
4400
- return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator;
4401
- }
4402
- function tryCatch(fn, obj, arg) {
4403
- try {
4404
- return { type: "normal", arg: fn.call(obj, arg) };
4405
- } catch (err) {
4406
- return { type: "throw", arg: err };
4407
- }
4408
- }
4409
- exports.wrap = wrap;
4410
- var ContinueSentinel = {};
4411
- function Generator() {
4412
- }
4413
- function GeneratorFunction() {
4414
- }
4415
- function GeneratorFunctionPrototype() {
4416
- }
4417
- var IteratorPrototype = {};
4418
- define(IteratorPrototype, iteratorSymbol, function() {
4419
- return this;
4420
- });
4421
- var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
4422
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
4423
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
4424
- function defineIteratorMethods(prototype) {
4425
- ["next", "throw", "return"].forEach(function(method) {
4426
- define(prototype, method, function(arg) {
4427
- return this._invoke(method, arg);
4428
- });
4429
- });
4430
- }
4431
- function AsyncIterator(generator, PromiseImpl) {
4432
- function invoke(method, arg, resolve, reject) {
4433
- var record = tryCatch(generator[method], generator, arg);
4434
- if ("throw" !== record.type) {
4435
- var result = record.arg, value = result.value;
4436
- return value && "object" == _typeof2(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function(value2) {
4437
- invoke("next", value2, resolve, reject);
4438
- }, function(err) {
4439
- invoke("throw", err, resolve, reject);
4440
- }) : PromiseImpl.resolve(value).then(function(unwrapped) {
4441
- result.value = unwrapped, resolve(result);
4442
- }, function(error) {
4443
- return invoke("throw", error, resolve, reject);
4444
- });
4445
- }
4446
- reject(record.arg);
4447
- }
4448
- var previousPromise;
4449
- defineProperty(this, "_invoke", { value: function value(method, arg) {
4450
- function callInvokeWithMethodAndArg() {
4451
- return new PromiseImpl(function(resolve, reject) {
4452
- invoke(method, arg, resolve, reject);
4453
- });
4454
- }
4455
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
4456
- } });
4457
- }
4458
- function makeInvokeMethod(innerFn, self, context) {
4459
- var state = "suspendedStart";
4460
- return function(method, arg) {
4461
- if ("executing" === state) throw new Error("Generator is already running");
4462
- if ("completed" === state) {
4463
- if ("throw" === method) throw arg;
4464
- return doneResult();
4465
- }
4466
- for (context.method = method, context.arg = arg; ; ) {
4467
- var delegate = context.delegate;
4468
- if (delegate) {
4469
- var delegateResult = maybeInvokeDelegate(delegate, context);
4470
- if (delegateResult) {
4471
- if (delegateResult === ContinueSentinel) continue;
4472
- return delegateResult;
4473
- }
4474
- }
4475
- if ("next" === context.method) context.sent = context._sent = context.arg;
4476
- else if ("throw" === context.method) {
4477
- if ("suspendedStart" === state) throw state = "completed", context.arg;
4478
- context.dispatchException(context.arg);
4479
- } else "return" === context.method && context.abrupt("return", context.arg);
4480
- state = "executing";
4481
- var record = tryCatch(innerFn, self, context);
4482
- if ("normal" === record.type) {
4483
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
4484
- return { value: record.arg, done: context.done };
4485
- }
4486
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
4487
- }
4488
- };
4489
- }
4490
- function maybeInvokeDelegate(delegate, context) {
4491
- var method = delegate.iterator[context.method];
4492
- if (void 0 === method) {
4493
- if (context.delegate = null, "throw" === context.method) {
4494
- if (delegate.iterator["return"] && (context.method = "return", context.arg = void 0, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
4495
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
4496
- }
4497
- return ContinueSentinel;
4498
- }
4499
- var record = tryCatch(method, delegate.iterator, context.arg);
4500
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
4501
- var info = record.arg;
4502
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = void 0), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
4503
- }
4504
- function pushTryEntry(locs) {
4505
- var entry = { tryLoc: locs[0] };
4506
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
4507
- }
4508
- function resetTryEntry(entry) {
4509
- var record = entry.completion || {};
4510
- record.type = "normal", delete record.arg, entry.completion = record;
4511
- }
4512
- function Context2(tryLocsList) {
4513
- this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(true);
4514
- }
4515
- function values(iterable) {
4516
- if (iterable) {
4517
- var iteratorMethod = iterable[iteratorSymbol];
4518
- if (iteratorMethod) return iteratorMethod.call(iterable);
4519
- if ("function" == typeof iterable.next) return iterable;
4520
- if (!isNaN(iterable.length)) {
4521
- var i = -1, next = function next2() {
4522
- for (; ++i < iterable.length; ) {
4523
- if (hasOwn.call(iterable, i)) return next2.value = iterable[i], next2.done = false, next2;
4524
- }
4525
- return next2.value = void 0, next2.done = true, next2;
4526
- };
4527
- return next.next = next;
4528
- }
4529
- }
4530
- return { next: doneResult };
4531
- }
4532
- function doneResult() {
4533
- return { value: void 0, done: true };
4534
- }
4535
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: true }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function(genFun) {
4536
- var ctor = "function" == typeof genFun && genFun.constructor;
4537
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
4538
- }, exports.mark = function(genFun) {
4539
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
4540
- }, exports.awrap = function(arg) {
4541
- return { __await: arg };
4542
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
4543
- return this;
4544
- }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
4545
- void 0 === PromiseImpl && (PromiseImpl = Promise);
4546
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
4547
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
4548
- return result.done ? result.value : iter.next();
4549
- });
4550
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function() {
4551
- return this;
4552
- }), define(Gp, "toString", function() {
4553
- return "[object Generator]";
4554
- }), exports.keys = function(val) {
4555
- var object = Object(val), keys = [];
4556
- for (var key in object) {
4557
- keys.push(key);
4558
- }
4559
- return keys.reverse(), function next() {
4560
- for (; keys.length; ) {
4561
- var key2 = keys.pop();
4562
- if (key2 in object) return next.value = key2, next.done = false, next;
4563
- }
4564
- return next.done = true, next;
4565
- };
4566
- }, exports.values = values, Context2.prototype = { constructor: Context2, reset: function reset(skipTempReset) {
4567
- if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = false, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
4568
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = void 0);
4569
- }
4570
- }, stop: function stop() {
4571
- this.done = true;
4572
- var rootRecord = this.tryEntries[0].completion;
4573
- if ("throw" === rootRecord.type) throw rootRecord.arg;
4574
- return this.rval;
4575
- }, dispatchException: function dispatchException(exception) {
4576
- if (this.done) throw exception;
4577
- var context = this;
4578
- function handle(loc, caught) {
4579
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = void 0), !!caught;
4580
- }
4581
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
4582
- var entry = this.tryEntries[i], record = entry.completion;
4583
- if ("root" === entry.tryLoc) return handle("end");
4584
- if (entry.tryLoc <= this.prev) {
4585
- var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
4586
- if (hasCatch && hasFinally) {
4587
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
4588
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
4589
- } else if (hasCatch) {
4590
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
4591
- } else {
4592
- if (!hasFinally) throw new Error("try statement without catch or finally");
4593
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
4594
- }
4595
- }
4596
- }
4597
- }, abrupt: function abrupt(type, arg) {
4598
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
4599
- var entry = this.tryEntries[i];
4600
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
4601
- var finallyEntry = entry;
4602
- break;
4603
- }
4604
- }
4605
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
4606
- var record = finallyEntry ? finallyEntry.completion : {};
4607
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
4608
- }, complete: function complete(record, afterLoc) {
4609
- if ("throw" === record.type) throw record.arg;
4610
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
4611
- }, finish: function finish(finallyLoc) {
4612
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
4613
- var entry = this.tryEntries[i];
4614
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
4615
- }
4616
- }, "catch": function _catch(tryLoc) {
4617
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
4618
- var entry = this.tryEntries[i];
4619
- if (entry.tryLoc === tryLoc) {
4620
- var record = entry.completion;
4621
- if ("throw" === record.type) {
4622
- var thrown = record.arg;
4623
- resetTryEntry(entry);
4624
- }
4625
- return thrown;
4626
- }
4627
- }
4628
- throw new Error("illegal catch attempt");
4629
- }, delegateYield: function delegateYield(iterable, resultName, nextLoc) {
4630
- return this.delegate = { iterator: values(iterable), resultName, nextLoc }, "next" === this.method && (this.arg = void 0), ContinueSentinel;
4631
- } }, exports;
4632
- }
4633
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4634
- try {
4635
- var info = gen[key](arg);
4636
- var value = info.value;
4637
- } catch (error) {
4638
- reject(error);
4639
- return;
4640
- }
4641
- if (info.done) {
4642
- resolve(value);
4643
- } else {
4644
- Promise.resolve(value).then(_next, _throw);
4645
- }
4646
- }
4647
- function _asyncToGenerator(fn) {
4648
- return function() {
4649
- var self = this, args = arguments;
4650
- return new Promise(function(resolve, reject) {
4651
- var gen = fn.apply(self, args);
4652
- function _next(value) {
4653
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
4654
- }
4655
- function _throw(err) {
4656
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
4657
- }
4658
- _next(void 0);
4659
- });
4660
- };
4661
- }
4662
- function _classCallCheck(instance, Constructor) {
4663
- if (!(instance instanceof Constructor)) {
4664
- throw new TypeError("Cannot call a class as a function");
4665
- }
4666
- }
4667
- function _defineProperties(target, props) {
4668
- for (var i = 0; i < props.length; i++) {
4669
- var descriptor = props[i];
4670
- descriptor.enumerable = descriptor.enumerable || false;
4671
- descriptor.configurable = true;
4672
- if ("value" in descriptor) descriptor.writable = true;
4673
- Object.defineProperty(target, descriptor.key, descriptor);
4674
- }
4675
- }
4676
- function _createClass(Constructor, protoProps, staticProps) {
4677
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
4678
- if (staticProps) _defineProperties(Constructor, staticProps);
4679
- Object.defineProperty(Constructor, "prototype", { writable: false });
4680
- return Constructor;
4681
- }
4682
- function _defineProperty(obj, key, value) {
4683
- if (key in obj) {
4684
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
4685
- } else {
4686
- obj[key] = value;
4687
- }
4688
- return obj;
4689
- }
4690
- var JsonDiffMain = /* @__PURE__ */ function() {
4691
- function JsonDiffMain2() {
4692
- _classCallCheck(this, JsonDiffMain2);
4693
- _defineProperty(this, "diffPatcher", new DiffPatcher({
4694
- arrays: {
4695
- detectMove: false,
4696
- includeValueOnMove: false
4697
- },
4698
- textDiff: {
4699
- minLength: 1
4700
- }
4701
- }));
4702
- _defineProperty(this, "scheduler", new IdleScheduler());
4703
- }
4704
- _createClass(JsonDiffMain2, [{
4705
- key: "diff",
4706
- value: function() {
4707
- var _diff = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(input) {
4708
- return _regeneratorRuntime().wrap(function _callee$(_context) {
4709
- while (1) {
4710
- switch (_context.prev = _context.next) {
4711
- case 0:
4712
- _context.next = 2;
4713
- return this.scheduler.request();
4714
- case 2:
4715
- return _context.abrupt("return", {
4716
- id: input.id,
4717
- delta: this.diffPatcher.diff(input.a, input.b)
4718
- });
4719
- case 3:
4720
- case "end":
4721
- return _context.stop();
4722
- }
4723
- }
4724
- }, _callee, this);
4725
- }));
4726
- function diff(_x) {
4727
- return _diff.apply(this, arguments);
4728
- }
4729
- return diff;
4730
- }()
4731
- }]);
4732
- return JsonDiffMain2;
4733
- }();
4734
- export {
4735
- JsonDiffMain
4736
- };
4737
- /*! Bundled license information:
4738
-
4739
- prosemirror-dev-tools/dist/esm/state/json-diff-main.js:
4740
- (*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE *)
4741
- */
4742
- //# sourceMappingURL=json-diff-main-ASELUCBE.js.map