@batijs/build 0.0.1

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.
@@ -0,0 +1,837 @@
1
+ // ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.mjs
2
+ var has = Object.prototype.hasOwnProperty;
3
+ function find(iter, tar, key) {
4
+ for (key of iter.keys()) {
5
+ if (dequal(key, tar))
6
+ return key;
7
+ }
8
+ }
9
+ function dequal(foo, bar) {
10
+ var ctor, len, tmp;
11
+ if (foo === bar)
12
+ return true;
13
+ if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
14
+ if (ctor === Date)
15
+ return foo.getTime() === bar.getTime();
16
+ if (ctor === RegExp)
17
+ return foo.toString() === bar.toString();
18
+ if (ctor === Array) {
19
+ if ((len = foo.length) === bar.length) {
20
+ while (len-- && dequal(foo[len], bar[len]))
21
+ ;
22
+ }
23
+ return len === -1;
24
+ }
25
+ if (ctor === Set) {
26
+ if (foo.size !== bar.size) {
27
+ return false;
28
+ }
29
+ for (len of foo) {
30
+ tmp = len;
31
+ if (tmp && typeof tmp === "object") {
32
+ tmp = find(bar, tmp);
33
+ if (!tmp)
34
+ return false;
35
+ }
36
+ if (!bar.has(tmp))
37
+ return false;
38
+ }
39
+ return true;
40
+ }
41
+ if (ctor === Map) {
42
+ if (foo.size !== bar.size) {
43
+ return false;
44
+ }
45
+ for (len of foo) {
46
+ tmp = len[0];
47
+ if (tmp && typeof tmp === "object") {
48
+ tmp = find(bar, tmp);
49
+ if (!tmp)
50
+ return false;
51
+ }
52
+ if (!dequal(len[1], bar.get(tmp))) {
53
+ return false;
54
+ }
55
+ }
56
+ return true;
57
+ }
58
+ if (ctor === ArrayBuffer) {
59
+ foo = new Uint8Array(foo);
60
+ bar = new Uint8Array(bar);
61
+ } else if (ctor === DataView) {
62
+ if ((len = foo.byteLength) === bar.byteLength) {
63
+ while (len-- && foo.getInt8(len) === bar.getInt8(len))
64
+ ;
65
+ }
66
+ return len === -1;
67
+ }
68
+ if (ArrayBuffer.isView(foo)) {
69
+ if ((len = foo.byteLength) === bar.byteLength) {
70
+ while (len-- && foo[len] === bar[len])
71
+ ;
72
+ }
73
+ return len === -1;
74
+ }
75
+ if (!ctor || typeof foo === "object") {
76
+ len = 0;
77
+ for (ctor in foo) {
78
+ if (has.call(foo, ctor) && ++len && !has.call(bar, ctor))
79
+ return false;
80
+ if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor]))
81
+ return false;
82
+ }
83
+ return Object.keys(bar).length === len;
84
+ }
85
+ }
86
+ return foo !== foo && bar !== bar;
87
+ }
88
+
89
+ // ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/index.mjs
90
+ var FORCE_COLOR;
91
+ var NODE_DISABLE_COLORS;
92
+ var NO_COLOR;
93
+ var TERM;
94
+ var isTTY = true;
95
+ if (typeof process !== "undefined") {
96
+ ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
97
+ isTTY = process.stdout && process.stdout.isTTY;
98
+ }
99
+ var $ = {
100
+ enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
101
+ // modifiers
102
+ reset: init(0, 0),
103
+ bold: init(1, 22),
104
+ dim: init(2, 22),
105
+ italic: init(3, 23),
106
+ underline: init(4, 24),
107
+ inverse: init(7, 27),
108
+ hidden: init(8, 28),
109
+ strikethrough: init(9, 29),
110
+ // colors
111
+ black: init(30, 39),
112
+ red: init(31, 39),
113
+ green: init(32, 39),
114
+ yellow: init(33, 39),
115
+ blue: init(34, 39),
116
+ magenta: init(35, 39),
117
+ cyan: init(36, 39),
118
+ white: init(37, 39),
119
+ gray: init(90, 39),
120
+ grey: init(90, 39),
121
+ // background colors
122
+ bgBlack: init(40, 49),
123
+ bgRed: init(41, 49),
124
+ bgGreen: init(42, 49),
125
+ bgYellow: init(43, 49),
126
+ bgBlue: init(44, 49),
127
+ bgMagenta: init(45, 49),
128
+ bgCyan: init(46, 49),
129
+ bgWhite: init(47, 49)
130
+ };
131
+ function run(arr, str) {
132
+ let i = 0, tmp, beg = "", end = "";
133
+ for (; i < arr.length; i++) {
134
+ tmp = arr[i];
135
+ beg += tmp.open;
136
+ end += tmp.close;
137
+ if (!!~str.indexOf(tmp.close)) {
138
+ str = str.replace(tmp.rgx, tmp.close + tmp.open);
139
+ }
140
+ }
141
+ return beg + str + end;
142
+ }
143
+ function chain(has2, keys) {
144
+ let ctx = { has: has2, keys };
145
+ ctx.reset = $.reset.bind(ctx);
146
+ ctx.bold = $.bold.bind(ctx);
147
+ ctx.dim = $.dim.bind(ctx);
148
+ ctx.italic = $.italic.bind(ctx);
149
+ ctx.underline = $.underline.bind(ctx);
150
+ ctx.inverse = $.inverse.bind(ctx);
151
+ ctx.hidden = $.hidden.bind(ctx);
152
+ ctx.strikethrough = $.strikethrough.bind(ctx);
153
+ ctx.black = $.black.bind(ctx);
154
+ ctx.red = $.red.bind(ctx);
155
+ ctx.green = $.green.bind(ctx);
156
+ ctx.yellow = $.yellow.bind(ctx);
157
+ ctx.blue = $.blue.bind(ctx);
158
+ ctx.magenta = $.magenta.bind(ctx);
159
+ ctx.cyan = $.cyan.bind(ctx);
160
+ ctx.white = $.white.bind(ctx);
161
+ ctx.gray = $.gray.bind(ctx);
162
+ ctx.grey = $.grey.bind(ctx);
163
+ ctx.bgBlack = $.bgBlack.bind(ctx);
164
+ ctx.bgRed = $.bgRed.bind(ctx);
165
+ ctx.bgGreen = $.bgGreen.bind(ctx);
166
+ ctx.bgYellow = $.bgYellow.bind(ctx);
167
+ ctx.bgBlue = $.bgBlue.bind(ctx);
168
+ ctx.bgMagenta = $.bgMagenta.bind(ctx);
169
+ ctx.bgCyan = $.bgCyan.bind(ctx);
170
+ ctx.bgWhite = $.bgWhite.bind(ctx);
171
+ return ctx;
172
+ }
173
+ function init(open, close) {
174
+ let blk = {
175
+ open: `\x1B[${open}m`,
176
+ close: `\x1B[${close}m`,
177
+ rgx: new RegExp(`\\x1b\\[${close}m`, "g")
178
+ };
179
+ return function(txt) {
180
+ if (this !== void 0 && this.has !== void 0) {
181
+ !!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
182
+ return txt === void 0 ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
183
+ }
184
+ return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
185
+ };
186
+ }
187
+ var kleur_default = $;
188
+
189
+ // ../../node_modules/.pnpm/diff@5.1.0/node_modules/diff/lib/index.mjs
190
+ function Diff() {
191
+ }
192
+ Diff.prototype = {
193
+ diff: function diff(oldString, newString) {
194
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
195
+ var callback = options.callback;
196
+ if (typeof options === "function") {
197
+ callback = options;
198
+ options = {};
199
+ }
200
+ this.options = options;
201
+ var self = this;
202
+ function done(value) {
203
+ if (callback) {
204
+ setTimeout(function() {
205
+ callback(void 0, value);
206
+ }, 0);
207
+ return true;
208
+ } else {
209
+ return value;
210
+ }
211
+ }
212
+ oldString = this.castInput(oldString);
213
+ newString = this.castInput(newString);
214
+ oldString = this.removeEmpty(this.tokenize(oldString));
215
+ newString = this.removeEmpty(this.tokenize(newString));
216
+ var newLen = newString.length, oldLen = oldString.length;
217
+ var editLength = 1;
218
+ var maxEditLength = newLen + oldLen;
219
+ if (options.maxEditLength) {
220
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
221
+ }
222
+ var bestPath = [{
223
+ newPos: -1,
224
+ components: []
225
+ }];
226
+ var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
227
+ if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
228
+ return done([{
229
+ value: this.join(newString),
230
+ count: newString.length
231
+ }]);
232
+ }
233
+ function execEditLength() {
234
+ for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
235
+ var basePath = void 0;
236
+ var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
237
+ if (addPath) {
238
+ bestPath[diagonalPath - 1] = void 0;
239
+ }
240
+ var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
241
+ if (!canAdd && !canRemove) {
242
+ bestPath[diagonalPath] = void 0;
243
+ continue;
244
+ }
245
+ if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
246
+ basePath = clonePath(removePath);
247
+ self.pushComponent(basePath.components, void 0, true);
248
+ } else {
249
+ basePath = addPath;
250
+ basePath.newPos++;
251
+ self.pushComponent(basePath.components, true, void 0);
252
+ }
253
+ _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
254
+ if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
255
+ return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
256
+ } else {
257
+ bestPath[diagonalPath] = basePath;
258
+ }
259
+ }
260
+ editLength++;
261
+ }
262
+ if (callback) {
263
+ (function exec() {
264
+ setTimeout(function() {
265
+ if (editLength > maxEditLength) {
266
+ return callback();
267
+ }
268
+ if (!execEditLength()) {
269
+ exec();
270
+ }
271
+ }, 0);
272
+ })();
273
+ } else {
274
+ while (editLength <= maxEditLength) {
275
+ var ret = execEditLength();
276
+ if (ret) {
277
+ return ret;
278
+ }
279
+ }
280
+ }
281
+ },
282
+ pushComponent: function pushComponent(components, added, removed) {
283
+ var last = components[components.length - 1];
284
+ if (last && last.added === added && last.removed === removed) {
285
+ components[components.length - 1] = {
286
+ count: last.count + 1,
287
+ added,
288
+ removed
289
+ };
290
+ } else {
291
+ components.push({
292
+ count: 1,
293
+ added,
294
+ removed
295
+ });
296
+ }
297
+ },
298
+ extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
299
+ var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0;
300
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
301
+ newPos++;
302
+ oldPos++;
303
+ commonCount++;
304
+ }
305
+ if (commonCount) {
306
+ basePath.components.push({
307
+ count: commonCount
308
+ });
309
+ }
310
+ basePath.newPos = newPos;
311
+ return oldPos;
312
+ },
313
+ equals: function equals(left, right) {
314
+ if (this.options.comparator) {
315
+ return this.options.comparator(left, right);
316
+ } else {
317
+ return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
318
+ }
319
+ },
320
+ removeEmpty: function removeEmpty(array) {
321
+ var ret = [];
322
+ for (var i = 0; i < array.length; i++) {
323
+ if (array[i]) {
324
+ ret.push(array[i]);
325
+ }
326
+ }
327
+ return ret;
328
+ },
329
+ castInput: function castInput(value) {
330
+ return value;
331
+ },
332
+ tokenize: function tokenize(value) {
333
+ return value.split("");
334
+ },
335
+ join: function join(chars2) {
336
+ return chars2.join("");
337
+ }
338
+ };
339
+ function buildValues(diff2, components, newString, oldString, useLongestToken) {
340
+ var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
341
+ for (; componentPos < componentLen; componentPos++) {
342
+ var component = components[componentPos];
343
+ if (!component.removed) {
344
+ if (!component.added && useLongestToken) {
345
+ var value = newString.slice(newPos, newPos + component.count);
346
+ value = value.map(function(value2, i) {
347
+ var oldValue = oldString[oldPos + i];
348
+ return oldValue.length > value2.length ? oldValue : value2;
349
+ });
350
+ component.value = diff2.join(value);
351
+ } else {
352
+ component.value = diff2.join(newString.slice(newPos, newPos + component.count));
353
+ }
354
+ newPos += component.count;
355
+ if (!component.added) {
356
+ oldPos += component.count;
357
+ }
358
+ } else {
359
+ component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
360
+ oldPos += component.count;
361
+ if (componentPos && components[componentPos - 1].added) {
362
+ var tmp = components[componentPos - 1];
363
+ components[componentPos - 1] = components[componentPos];
364
+ components[componentPos] = tmp;
365
+ }
366
+ }
367
+ }
368
+ var lastComponent = components[componentLen - 1];
369
+ if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff2.equals("", lastComponent.value)) {
370
+ components[componentLen - 2].value += lastComponent.value;
371
+ components.pop();
372
+ }
373
+ return components;
374
+ }
375
+ function clonePath(path) {
376
+ return {
377
+ newPos: path.newPos,
378
+ components: path.components.slice(0)
379
+ };
380
+ }
381
+ var characterDiff = new Diff();
382
+ function diffChars(oldStr, newStr, options) {
383
+ return characterDiff.diff(oldStr, newStr, options);
384
+ }
385
+ var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
386
+ var reWhitespace = /\S/;
387
+ var wordDiff = new Diff();
388
+ wordDiff.equals = function(left, right) {
389
+ if (this.options.ignoreCase) {
390
+ left = left.toLowerCase();
391
+ right = right.toLowerCase();
392
+ }
393
+ return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
394
+ };
395
+ wordDiff.tokenize = function(value) {
396
+ var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
397
+ for (var i = 0; i < tokens.length - 1; i++) {
398
+ if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
399
+ tokens[i] += tokens[i + 2];
400
+ tokens.splice(i + 1, 2);
401
+ i--;
402
+ }
403
+ }
404
+ return tokens;
405
+ };
406
+ var lineDiff = new Diff();
407
+ lineDiff.tokenize = function(value) {
408
+ var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
409
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
410
+ linesAndNewlines.pop();
411
+ }
412
+ for (var i = 0; i < linesAndNewlines.length; i++) {
413
+ var line2 = linesAndNewlines[i];
414
+ if (i % 2 && !this.options.newlineIsToken) {
415
+ retLines[retLines.length - 1] += line2;
416
+ } else {
417
+ if (this.options.ignoreWhitespace) {
418
+ line2 = line2.trim();
419
+ }
420
+ retLines.push(line2);
421
+ }
422
+ }
423
+ return retLines;
424
+ };
425
+ function diffLines(oldStr, newStr, callback) {
426
+ return lineDiff.diff(oldStr, newStr, callback);
427
+ }
428
+ var sentenceDiff = new Diff();
429
+ sentenceDiff.tokenize = function(value) {
430
+ return value.split(/(\S.+?[.!?])(?=\s+|$)/);
431
+ };
432
+ var cssDiff = new Diff();
433
+ cssDiff.tokenize = function(value) {
434
+ return value.split(/([{}:;,]|\s+)/);
435
+ };
436
+ function _typeof(obj) {
437
+ "@babel/helpers - typeof";
438
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
439
+ _typeof = function(obj2) {
440
+ return typeof obj2;
441
+ };
442
+ } else {
443
+ _typeof = function(obj2) {
444
+ return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
445
+ };
446
+ }
447
+ return _typeof(obj);
448
+ }
449
+ var objectPrototypeToString = Object.prototype.toString;
450
+ var jsonDiff = new Diff();
451
+ jsonDiff.useLongestToken = true;
452
+ jsonDiff.tokenize = lineDiff.tokenize;
453
+ jsonDiff.castInput = function(value) {
454
+ var _this$options = this.options, undefinedReplacement = _this$options.undefinedReplacement, _this$options$stringi = _this$options.stringifyReplacer, stringifyReplacer = _this$options$stringi === void 0 ? function(k, v) {
455
+ return typeof v === "undefined" ? undefinedReplacement : v;
456
+ } : _this$options$stringi;
457
+ return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, " ");
458
+ };
459
+ jsonDiff.equals = function(left, right) {
460
+ return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"));
461
+ };
462
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
463
+ stack = stack || [];
464
+ replacementStack = replacementStack || [];
465
+ if (replacer) {
466
+ obj = replacer(key, obj);
467
+ }
468
+ var i;
469
+ for (i = 0; i < stack.length; i += 1) {
470
+ if (stack[i] === obj) {
471
+ return replacementStack[i];
472
+ }
473
+ }
474
+ var canonicalizedObj;
475
+ if ("[object Array]" === objectPrototypeToString.call(obj)) {
476
+ stack.push(obj);
477
+ canonicalizedObj = new Array(obj.length);
478
+ replacementStack.push(canonicalizedObj);
479
+ for (i = 0; i < obj.length; i += 1) {
480
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
481
+ }
482
+ stack.pop();
483
+ replacementStack.pop();
484
+ return canonicalizedObj;
485
+ }
486
+ if (obj && obj.toJSON) {
487
+ obj = obj.toJSON();
488
+ }
489
+ if (_typeof(obj) === "object" && obj !== null) {
490
+ stack.push(obj);
491
+ canonicalizedObj = {};
492
+ replacementStack.push(canonicalizedObj);
493
+ var sortedKeys = [], _key;
494
+ for (_key in obj) {
495
+ if (obj.hasOwnProperty(_key)) {
496
+ sortedKeys.push(_key);
497
+ }
498
+ }
499
+ sortedKeys.sort();
500
+ for (i = 0; i < sortedKeys.length; i += 1) {
501
+ _key = sortedKeys[i];
502
+ canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
503
+ }
504
+ stack.pop();
505
+ replacementStack.pop();
506
+ } else {
507
+ canonicalizedObj = obj;
508
+ }
509
+ return canonicalizedObj;
510
+ }
511
+ var arrayDiff = new Diff();
512
+ arrayDiff.tokenize = function(value) {
513
+ return value.slice();
514
+ };
515
+ arrayDiff.join = arrayDiff.removeEmpty = function(value) {
516
+ return value;
517
+ };
518
+ function diffArrays(oldArr, newArr, callback) {
519
+ return arrayDiff.diff(oldArr, newArr, callback);
520
+ }
521
+
522
+ // ../../node_modules/.pnpm/uvu@0.5.6/node_modules/uvu/diff/index.mjs
523
+ var colors = {
524
+ "--": kleur_default.red,
525
+ "\xB7\xB7": kleur_default.grey,
526
+ "++": kleur_default.green
527
+ };
528
+ var TITLE = kleur_default.dim().italic;
529
+ var TAB = kleur_default.dim("\u2192");
530
+ var SPACE = kleur_default.dim("\xB7");
531
+ var NL = kleur_default.dim("\u21B5");
532
+ var LOG = (sym, str) => colors[sym](sym + PRETTY(str)) + "\n";
533
+ var LINE = (num, x) => kleur_default.dim("L" + String(num).padStart(x, "0") + " ");
534
+ var PRETTY = (str) => str.replace(/[ ]/g, SPACE).replace(/\t/g, TAB).replace(/(\r?\n)/g, NL);
535
+ function line(obj, prev, pad) {
536
+ let char = obj.removed ? "--" : obj.added ? "++" : "\xB7\xB7";
537
+ let arr = obj.value.replace(/\r?\n$/, "").split("\n");
538
+ let i = 0, tmp, out = "";
539
+ if (obj.added)
540
+ out += colors[char]().underline(TITLE("Expected:")) + "\n";
541
+ else if (obj.removed)
542
+ out += colors[char]().underline(TITLE("Actual:")) + "\n";
543
+ for (; i < arr.length; i++) {
544
+ tmp = arr[i];
545
+ if (tmp != null) {
546
+ if (prev)
547
+ out += LINE(prev + i, pad);
548
+ out += LOG(char, tmp || "\n");
549
+ }
550
+ }
551
+ return out;
552
+ }
553
+ function arrays(input, expect) {
554
+ let arr = diffArrays(input, expect);
555
+ let i = 0, j = 0, k = 0, tmp, val, char, isObj, str;
556
+ let out = LOG("\xB7\xB7", "[");
557
+ for (; i < arr.length; i++) {
558
+ char = (tmp = arr[i]).removed ? "--" : tmp.added ? "++" : "\xB7\xB7";
559
+ if (tmp.added) {
560
+ out += colors[char]().underline(TITLE("Expected:")) + "\n";
561
+ } else if (tmp.removed) {
562
+ out += colors[char]().underline(TITLE("Actual:")) + "\n";
563
+ }
564
+ for (j = 0; j < tmp.value.length; j++) {
565
+ isObj = tmp.value[j] && typeof tmp.value[j] === "object";
566
+ val = stringify(tmp.value[j]).split(/\r?\n/g);
567
+ for (k = 0; k < val.length; ) {
568
+ str = " " + val[k++] + (isObj ? "" : ",");
569
+ if (isObj && k === val.length && j + 1 < tmp.value.length)
570
+ str += ",";
571
+ out += LOG(char, str);
572
+ }
573
+ }
574
+ }
575
+ return out + LOG("\xB7\xB7", "]");
576
+ }
577
+ function lines(input, expect, linenum = 0) {
578
+ let i = 0, tmp, output = "";
579
+ let arr = diffLines(input, expect);
580
+ let pad = String(expect.split(/\r?\n/g).length - linenum).length;
581
+ for (; i < arr.length; i++) {
582
+ output += line(tmp = arr[i], linenum, pad);
583
+ if (linenum && !tmp.removed)
584
+ linenum += tmp.count;
585
+ }
586
+ return output;
587
+ }
588
+ function chars(input, expect) {
589
+ let arr = diffChars(input, expect);
590
+ let i = 0, output = "", tmp;
591
+ let l1 = input.length;
592
+ let l2 = expect.length;
593
+ let p1 = PRETTY(input);
594
+ let p2 = PRETTY(expect);
595
+ tmp = arr[i];
596
+ if (l1 === l2) {
597
+ } else if (tmp.removed && arr[i + 1]) {
598
+ let del = tmp.count - arr[i + 1].count;
599
+ if (del == 0) {
600
+ } else if (del > 0) {
601
+ expect = " ".repeat(del) + expect;
602
+ p2 = " ".repeat(del) + p2;
603
+ l2 += del;
604
+ } else if (del < 0) {
605
+ input = " ".repeat(-del) + input;
606
+ p1 = " ".repeat(-del) + p1;
607
+ l1 += -del;
608
+ }
609
+ }
610
+ output += direct(p1, p2, l1, l2);
611
+ if (l1 === l2) {
612
+ for (tmp = " "; i < l1; i++) {
613
+ tmp += input[i] === expect[i] ? " " : "^";
614
+ }
615
+ } else {
616
+ for (tmp = " "; i < arr.length; i++) {
617
+ tmp += (arr[i].added || arr[i].removed ? "^" : " ").repeat(Math.max(arr[i].count, 0));
618
+ if (i + 1 < arr.length && (arr[i].added && arr[i + 1].removed || arr[i].removed && arr[i + 1].added)) {
619
+ arr[i + 1].count -= arr[i].count;
620
+ }
621
+ }
622
+ }
623
+ return output + kleur_default.red(tmp);
624
+ }
625
+ function direct(input, expect, lenA = String(input).length, lenB = String(expect).length) {
626
+ let gutter = 4;
627
+ let lenC = Math.max(lenA, lenB);
628
+ let typeA = typeof input, typeB = typeof expect;
629
+ if (typeA !== typeB) {
630
+ gutter = 2;
631
+ let delA = gutter + lenC - lenA;
632
+ let delB = gutter + lenC - lenB;
633
+ input += " ".repeat(delA) + kleur_default.dim(`[${typeA}]`);
634
+ expect += " ".repeat(delB) + kleur_default.dim(`[${typeB}]`);
635
+ lenA += delA + typeA.length + 2;
636
+ lenB += delB + typeB.length + 2;
637
+ lenC = Math.max(lenA, lenB);
638
+ }
639
+ let output = colors["++"]("++" + expect + " ".repeat(gutter + lenC - lenB) + TITLE("(Expected)")) + "\n";
640
+ return output + colors["--"]("--" + input + " ".repeat(gutter + lenC - lenA) + TITLE("(Actual)")) + "\n";
641
+ }
642
+ function sort(input, expect) {
643
+ var k, i = 0, tmp, isArr = Array.isArray(input);
644
+ var keys = [], out = isArr ? Array(input.length) : {};
645
+ if (isArr) {
646
+ for (i = 0; i < out.length; i++) {
647
+ tmp = input[i];
648
+ if (!tmp || typeof tmp !== "object")
649
+ out[i] = tmp;
650
+ else
651
+ out[i] = sort(tmp, expect[i]);
652
+ }
653
+ } else {
654
+ for (k in expect)
655
+ keys.push(k);
656
+ for (; i < keys.length; i++) {
657
+ if (Object.prototype.hasOwnProperty.call(input, k = keys[i])) {
658
+ if (!(tmp = input[k]) || typeof tmp !== "object")
659
+ out[k] = tmp;
660
+ else
661
+ out[k] = sort(tmp, expect[k]);
662
+ }
663
+ }
664
+ for (k in input) {
665
+ if (!out.hasOwnProperty(k)) {
666
+ out[k] = input[k];
667
+ }
668
+ }
669
+ }
670
+ return out;
671
+ }
672
+ function circular() {
673
+ var cache = /* @__PURE__ */ new Set();
674
+ return function print(key, val) {
675
+ if (val === void 0)
676
+ return "[__VOID__]";
677
+ if (typeof val === "number" && val !== val)
678
+ return "[__NAN__]";
679
+ if (typeof val === "bigint")
680
+ return val.toString();
681
+ if (!val || typeof val !== "object")
682
+ return val;
683
+ if (cache.has(val))
684
+ return "[Circular]";
685
+ cache.add(val);
686
+ return val;
687
+ };
688
+ }
689
+ function stringify(input) {
690
+ return JSON.stringify(input, circular(), 2).replace(/"\[__NAN__\]"/g, "NaN").replace(/"\[__VOID__\]"/g, "undefined");
691
+ }
692
+ function compare(input, expect) {
693
+ if (Array.isArray(expect) && Array.isArray(input))
694
+ return arrays(input, expect);
695
+ if (expect instanceof RegExp)
696
+ return chars("" + input, "" + expect);
697
+ let isA = input && typeof input == "object";
698
+ let isB = expect && typeof expect == "object";
699
+ if (isA && isB)
700
+ input = sort(input, expect);
701
+ if (isB)
702
+ expect = stringify(expect);
703
+ if (isA)
704
+ input = stringify(input);
705
+ if (expect && typeof expect == "object") {
706
+ input = stringify(sort(input, expect));
707
+ expect = stringify(expect);
708
+ }
709
+ isA = typeof input == "string";
710
+ isB = typeof expect == "string";
711
+ if (isA && /\r?\n/.test(input))
712
+ return lines(input, "" + expect);
713
+ if (isB && /\r?\n/.test(expect))
714
+ return lines("" + input, expect);
715
+ if (isA && isB)
716
+ return chars(input, expect);
717
+ return direct(input, expect);
718
+ }
719
+
720
+ // ../../node_modules/.pnpm/uvu@0.5.6/node_modules/uvu/assert/index.mjs
721
+ function dedent(str) {
722
+ str = str.replace(/\r?\n/g, "\n");
723
+ let arr = str.match(/^[ \t]*(?=\S)/gm);
724
+ let i = 0, min = 1 / 0, len = (arr || []).length;
725
+ for (; i < len; i++)
726
+ min = Math.min(min, arr[i].length);
727
+ return len && min ? str.replace(new RegExp(`^[ \\t]{${min}}`, "gm"), "") : str;
728
+ }
729
+ var Assertion = class extends Error {
730
+ constructor(opts = {}) {
731
+ super(opts.message);
732
+ this.name = "Assertion";
733
+ this.code = "ERR_ASSERTION";
734
+ if (Error.captureStackTrace) {
735
+ Error.captureStackTrace(this, this.constructor);
736
+ }
737
+ this.details = opts.details || false;
738
+ this.generated = !!opts.generated;
739
+ this.operator = opts.operator;
740
+ this.expects = opts.expects;
741
+ this.actual = opts.actual;
742
+ }
743
+ };
744
+ function assert(bool, actual, expects, operator, detailer, backup, msg) {
745
+ if (bool)
746
+ return;
747
+ let message = msg || backup;
748
+ if (msg instanceof Error)
749
+ throw msg;
750
+ let details = detailer && detailer(actual, expects);
751
+ throw new Assertion({ actual, expects, operator, message, details, generated: !msg });
752
+ }
753
+ function ok(val, msg) {
754
+ assert(!!val, false, true, "ok", false, "Expected value to be truthy", msg);
755
+ }
756
+ function is(val, exp, msg) {
757
+ assert(val === exp, val, exp, "is", compare, "Expected values to be strictly equal:", msg);
758
+ }
759
+ function equal(val, exp, msg) {
760
+ assert(dequal(val, exp), val, exp, "equal", compare, "Expected values to be deeply equal:", msg);
761
+ }
762
+ function not(val, msg) {
763
+ assert(!val, true, false, "not", false, "Expected value to be falsey", msg);
764
+ }
765
+ not.ok = not;
766
+ is.not = function(val, exp, msg) {
767
+ assert(val !== exp, val, exp, "is.not", false, "Expected values not to be strictly equal", msg);
768
+ };
769
+ not.equal = function(val, exp, msg) {
770
+ assert(!dequal(val, exp), val, exp, "not.equal", false, "Expected values not to be deeply equal", msg);
771
+ };
772
+ not.type = function(val, exp, msg) {
773
+ let tmp = typeof val;
774
+ assert(tmp !== exp, tmp, exp, "not.type", false, `Expected "${tmp}" not to be "${exp}"`, msg);
775
+ };
776
+ not.instance = function(val, exp, msg) {
777
+ let name = "`" + (exp.name || exp.constructor.name) + "`";
778
+ assert(!(val instanceof exp), val, exp, "not.instance", false, `Expected value not to be an instance of ${name}`, msg);
779
+ };
780
+ not.snapshot = function(val, exp, msg) {
781
+ val = dedent(val);
782
+ exp = dedent(exp);
783
+ assert(val !== exp, val, exp, "not.snapshot", false, "Expected value not to match snapshot", msg);
784
+ };
785
+ not.fixture = function(val, exp, msg) {
786
+ val = dedent(val);
787
+ exp = dedent(exp);
788
+ assert(val !== exp, val, exp, "not.fixture", false, "Expected value not to match fixture", msg);
789
+ };
790
+ not.match = function(val, exp, msg) {
791
+ if (typeof exp === "string") {
792
+ assert(!val.includes(exp), val, exp, "not.match", false, `Expected value not to include "${exp}" substring`, msg);
793
+ } else {
794
+ assert(!exp.test(val), val, exp, "not.match", false, `Expected value not to match \`${String(exp)}\` pattern`, msg);
795
+ }
796
+ };
797
+ not.throws = function(blk, exp, msg) {
798
+ if (!msg && typeof exp === "string") {
799
+ msg = exp;
800
+ exp = null;
801
+ }
802
+ try {
803
+ blk();
804
+ } catch (err) {
805
+ if (typeof exp === "function") {
806
+ assert(!exp(err), true, false, "not.throws", false, "Expected function not to throw matching exception", msg);
807
+ } else if (exp instanceof RegExp) {
808
+ assert(!exp.test(err.message), true, false, "not.throws", false, `Expected function not to throw exception matching \`${String(exp)}\` pattern`, msg);
809
+ } else if (!exp) {
810
+ assert(false, true, false, "not.throws", false, "Expected function not to throw", msg);
811
+ }
812
+ }
813
+ };
814
+
815
+ // src/testUtils.ts
816
+ import { prettyPrint, types } from "recast";
817
+ function assertEquivalentAst(ast1, ast2) {
818
+ if (types.astNodesAreEquivalent(ast1, ast2)) {
819
+ return ok(true);
820
+ } else {
821
+ return equal(
822
+ prettyPrint(ast1, {
823
+ tabWidth: 2,
824
+ reuseWhitespace: false,
825
+ wrapColumn: 120
826
+ }).code,
827
+ prettyPrint(ast2, {
828
+ tabWidth: 2,
829
+ reuseWhitespace: false,
830
+ wrapColumn: 120
831
+ }).code
832
+ );
833
+ }
834
+ }
835
+ export {
836
+ assertEquivalentAst
837
+ };