@kubb/core 0.45.1 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -2
- package/dist/index.global.js +4145 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/dist/index.global.js
CHANGED
|
@@ -382,7 +382,7 @@ var kubb = (function (exports) {
|
|
|
382
382
|
}
|
|
383
383
|
return path.slice(startDot, end);
|
|
384
384
|
},
|
|
385
|
-
format: function
|
|
385
|
+
format: function format2(pathObject) {
|
|
386
386
|
if (pathObject === null || typeof pathObject !== "object") {
|
|
387
387
|
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
388
388
|
}
|
|
@@ -16448,6 +16448,4125 @@ var kubb = (function (exports) {
|
|
|
16448
16448
|
}
|
|
16449
16449
|
});
|
|
16450
16450
|
|
|
16451
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/output.js
|
|
16452
|
+
var require_output = __commonJS({
|
|
16453
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/output.js"(exports, module) {
|
|
16454
|
+
init_define_process();
|
|
16455
|
+
function OutputLine(parent) {
|
|
16456
|
+
this.__parent = parent;
|
|
16457
|
+
this.__character_count = 0;
|
|
16458
|
+
this.__indent_count = -1;
|
|
16459
|
+
this.__alignment_count = 0;
|
|
16460
|
+
this.__wrap_point_index = 0;
|
|
16461
|
+
this.__wrap_point_character_count = 0;
|
|
16462
|
+
this.__wrap_point_indent_count = -1;
|
|
16463
|
+
this.__wrap_point_alignment_count = 0;
|
|
16464
|
+
this.__items = [];
|
|
16465
|
+
}
|
|
16466
|
+
OutputLine.prototype.clone_empty = function() {
|
|
16467
|
+
var line = new OutputLine(this.__parent);
|
|
16468
|
+
line.set_indent(this.__indent_count, this.__alignment_count);
|
|
16469
|
+
return line;
|
|
16470
|
+
};
|
|
16471
|
+
OutputLine.prototype.item = function(index) {
|
|
16472
|
+
if (index < 0) {
|
|
16473
|
+
return this.__items[this.__items.length + index];
|
|
16474
|
+
} else {
|
|
16475
|
+
return this.__items[index];
|
|
16476
|
+
}
|
|
16477
|
+
};
|
|
16478
|
+
OutputLine.prototype.has_match = function(pattern) {
|
|
16479
|
+
for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
|
|
16480
|
+
if (this.__items[lastCheckedOutput].match(pattern)) {
|
|
16481
|
+
return true;
|
|
16482
|
+
}
|
|
16483
|
+
}
|
|
16484
|
+
return false;
|
|
16485
|
+
};
|
|
16486
|
+
OutputLine.prototype.set_indent = function(indent, alignment) {
|
|
16487
|
+
if (this.is_empty()) {
|
|
16488
|
+
this.__indent_count = indent || 0;
|
|
16489
|
+
this.__alignment_count = alignment || 0;
|
|
16490
|
+
this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
|
|
16491
|
+
}
|
|
16492
|
+
};
|
|
16493
|
+
OutputLine.prototype._set_wrap_point = function() {
|
|
16494
|
+
if (this.__parent.wrap_line_length) {
|
|
16495
|
+
this.__wrap_point_index = this.__items.length;
|
|
16496
|
+
this.__wrap_point_character_count = this.__character_count;
|
|
16497
|
+
this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
|
|
16498
|
+
this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
|
|
16499
|
+
}
|
|
16500
|
+
};
|
|
16501
|
+
OutputLine.prototype._should_wrap = function() {
|
|
16502
|
+
return this.__wrap_point_index && this.__character_count > this.__parent.wrap_line_length && this.__wrap_point_character_count > this.__parent.next_line.__character_count;
|
|
16503
|
+
};
|
|
16504
|
+
OutputLine.prototype._allow_wrap = function() {
|
|
16505
|
+
if (this._should_wrap()) {
|
|
16506
|
+
this.__parent.add_new_line();
|
|
16507
|
+
var next = this.__parent.current_line;
|
|
16508
|
+
next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
|
|
16509
|
+
next.__items = this.__items.slice(this.__wrap_point_index);
|
|
16510
|
+
this.__items = this.__items.slice(0, this.__wrap_point_index);
|
|
16511
|
+
next.__character_count += this.__character_count - this.__wrap_point_character_count;
|
|
16512
|
+
this.__character_count = this.__wrap_point_character_count;
|
|
16513
|
+
if (next.__items[0] === " ") {
|
|
16514
|
+
next.__items.splice(0, 1);
|
|
16515
|
+
next.__character_count -= 1;
|
|
16516
|
+
}
|
|
16517
|
+
return true;
|
|
16518
|
+
}
|
|
16519
|
+
return false;
|
|
16520
|
+
};
|
|
16521
|
+
OutputLine.prototype.is_empty = function() {
|
|
16522
|
+
return this.__items.length === 0;
|
|
16523
|
+
};
|
|
16524
|
+
OutputLine.prototype.last = function() {
|
|
16525
|
+
if (!this.is_empty()) {
|
|
16526
|
+
return this.__items[this.__items.length - 1];
|
|
16527
|
+
} else {
|
|
16528
|
+
return null;
|
|
16529
|
+
}
|
|
16530
|
+
};
|
|
16531
|
+
OutputLine.prototype.push = function(item) {
|
|
16532
|
+
this.__items.push(item);
|
|
16533
|
+
var last_newline_index = item.lastIndexOf("\n");
|
|
16534
|
+
if (last_newline_index !== -1) {
|
|
16535
|
+
this.__character_count = item.length - last_newline_index;
|
|
16536
|
+
} else {
|
|
16537
|
+
this.__character_count += item.length;
|
|
16538
|
+
}
|
|
16539
|
+
};
|
|
16540
|
+
OutputLine.prototype.pop = function() {
|
|
16541
|
+
var item = null;
|
|
16542
|
+
if (!this.is_empty()) {
|
|
16543
|
+
item = this.__items.pop();
|
|
16544
|
+
this.__character_count -= item.length;
|
|
16545
|
+
}
|
|
16546
|
+
return item;
|
|
16547
|
+
};
|
|
16548
|
+
OutputLine.prototype._remove_indent = function() {
|
|
16549
|
+
if (this.__indent_count > 0) {
|
|
16550
|
+
this.__indent_count -= 1;
|
|
16551
|
+
this.__character_count -= this.__parent.indent_size;
|
|
16552
|
+
}
|
|
16553
|
+
};
|
|
16554
|
+
OutputLine.prototype._remove_wrap_indent = function() {
|
|
16555
|
+
if (this.__wrap_point_indent_count > 0) {
|
|
16556
|
+
this.__wrap_point_indent_count -= 1;
|
|
16557
|
+
}
|
|
16558
|
+
};
|
|
16559
|
+
OutputLine.prototype.trim = function() {
|
|
16560
|
+
while (this.last() === " ") {
|
|
16561
|
+
this.__items.pop();
|
|
16562
|
+
this.__character_count -= 1;
|
|
16563
|
+
}
|
|
16564
|
+
};
|
|
16565
|
+
OutputLine.prototype.toString = function() {
|
|
16566
|
+
var result = "";
|
|
16567
|
+
if (this.is_empty()) {
|
|
16568
|
+
if (this.__parent.indent_empty_lines) {
|
|
16569
|
+
result = this.__parent.get_indent_string(this.__indent_count);
|
|
16570
|
+
}
|
|
16571
|
+
} else {
|
|
16572
|
+
result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
|
|
16573
|
+
result += this.__items.join("");
|
|
16574
|
+
}
|
|
16575
|
+
return result;
|
|
16576
|
+
};
|
|
16577
|
+
function IndentStringCache(options, baseIndentString) {
|
|
16578
|
+
this.__cache = [""];
|
|
16579
|
+
this.__indent_size = options.indent_size;
|
|
16580
|
+
this.__indent_string = options.indent_char;
|
|
16581
|
+
if (!options.indent_with_tabs) {
|
|
16582
|
+
this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
|
|
16583
|
+
}
|
|
16584
|
+
baseIndentString = baseIndentString || "";
|
|
16585
|
+
if (options.indent_level > 0) {
|
|
16586
|
+
baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
|
|
16587
|
+
}
|
|
16588
|
+
this.__base_string = baseIndentString;
|
|
16589
|
+
this.__base_string_length = baseIndentString.length;
|
|
16590
|
+
}
|
|
16591
|
+
IndentStringCache.prototype.get_indent_size = function(indent, column) {
|
|
16592
|
+
var result = this.__base_string_length;
|
|
16593
|
+
column = column || 0;
|
|
16594
|
+
if (indent < 0) {
|
|
16595
|
+
result = 0;
|
|
16596
|
+
}
|
|
16597
|
+
result += indent * this.__indent_size;
|
|
16598
|
+
result += column;
|
|
16599
|
+
return result;
|
|
16600
|
+
};
|
|
16601
|
+
IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
|
|
16602
|
+
var result = this.__base_string;
|
|
16603
|
+
column = column || 0;
|
|
16604
|
+
if (indent_level < 0) {
|
|
16605
|
+
indent_level = 0;
|
|
16606
|
+
result = "";
|
|
16607
|
+
}
|
|
16608
|
+
column += indent_level * this.__indent_size;
|
|
16609
|
+
this.__ensure_cache(column);
|
|
16610
|
+
result += this.__cache[column];
|
|
16611
|
+
return result;
|
|
16612
|
+
};
|
|
16613
|
+
IndentStringCache.prototype.__ensure_cache = function(column) {
|
|
16614
|
+
while (column >= this.__cache.length) {
|
|
16615
|
+
this.__add_column();
|
|
16616
|
+
}
|
|
16617
|
+
};
|
|
16618
|
+
IndentStringCache.prototype.__add_column = function() {
|
|
16619
|
+
var column = this.__cache.length;
|
|
16620
|
+
var indent = 0;
|
|
16621
|
+
var result = "";
|
|
16622
|
+
if (this.__indent_size && column >= this.__indent_size) {
|
|
16623
|
+
indent = Math.floor(column / this.__indent_size);
|
|
16624
|
+
column -= indent * this.__indent_size;
|
|
16625
|
+
result = new Array(indent + 1).join(this.__indent_string);
|
|
16626
|
+
}
|
|
16627
|
+
if (column) {
|
|
16628
|
+
result += new Array(column + 1).join(" ");
|
|
16629
|
+
}
|
|
16630
|
+
this.__cache.push(result);
|
|
16631
|
+
};
|
|
16632
|
+
function Output(options, baseIndentString) {
|
|
16633
|
+
this.__indent_cache = new IndentStringCache(options, baseIndentString);
|
|
16634
|
+
this.raw = false;
|
|
16635
|
+
this._end_with_newline = options.end_with_newline;
|
|
16636
|
+
this.indent_size = options.indent_size;
|
|
16637
|
+
this.wrap_line_length = options.wrap_line_length;
|
|
16638
|
+
this.indent_empty_lines = options.indent_empty_lines;
|
|
16639
|
+
this.__lines = [];
|
|
16640
|
+
this.previous_line = null;
|
|
16641
|
+
this.current_line = null;
|
|
16642
|
+
this.next_line = new OutputLine(this);
|
|
16643
|
+
this.space_before_token = false;
|
|
16644
|
+
this.non_breaking_space = false;
|
|
16645
|
+
this.previous_token_wrapped = false;
|
|
16646
|
+
this.__add_outputline();
|
|
16647
|
+
}
|
|
16648
|
+
Output.prototype.__add_outputline = function() {
|
|
16649
|
+
this.previous_line = this.current_line;
|
|
16650
|
+
this.current_line = this.next_line.clone_empty();
|
|
16651
|
+
this.__lines.push(this.current_line);
|
|
16652
|
+
};
|
|
16653
|
+
Output.prototype.get_line_number = function() {
|
|
16654
|
+
return this.__lines.length;
|
|
16655
|
+
};
|
|
16656
|
+
Output.prototype.get_indent_string = function(indent, column) {
|
|
16657
|
+
return this.__indent_cache.get_indent_string(indent, column);
|
|
16658
|
+
};
|
|
16659
|
+
Output.prototype.get_indent_size = function(indent, column) {
|
|
16660
|
+
return this.__indent_cache.get_indent_size(indent, column);
|
|
16661
|
+
};
|
|
16662
|
+
Output.prototype.is_empty = function() {
|
|
16663
|
+
return !this.previous_line && this.current_line.is_empty();
|
|
16664
|
+
};
|
|
16665
|
+
Output.prototype.add_new_line = function(force_newline) {
|
|
16666
|
+
if (this.is_empty() || !force_newline && this.just_added_newline()) {
|
|
16667
|
+
return false;
|
|
16668
|
+
}
|
|
16669
|
+
if (!this.raw) {
|
|
16670
|
+
this.__add_outputline();
|
|
16671
|
+
}
|
|
16672
|
+
return true;
|
|
16673
|
+
};
|
|
16674
|
+
Output.prototype.get_code = function(eol) {
|
|
16675
|
+
this.trim(true);
|
|
16676
|
+
var last_item = this.current_line.pop();
|
|
16677
|
+
if (last_item) {
|
|
16678
|
+
if (last_item[last_item.length - 1] === "\n") {
|
|
16679
|
+
last_item = last_item.replace(/\n+$/g, "");
|
|
16680
|
+
}
|
|
16681
|
+
this.current_line.push(last_item);
|
|
16682
|
+
}
|
|
16683
|
+
if (this._end_with_newline) {
|
|
16684
|
+
this.__add_outputline();
|
|
16685
|
+
}
|
|
16686
|
+
var sweet_code = this.__lines.join("\n");
|
|
16687
|
+
if (eol !== "\n") {
|
|
16688
|
+
sweet_code = sweet_code.replace(/[\n]/g, eol);
|
|
16689
|
+
}
|
|
16690
|
+
return sweet_code;
|
|
16691
|
+
};
|
|
16692
|
+
Output.prototype.set_wrap_point = function() {
|
|
16693
|
+
this.current_line._set_wrap_point();
|
|
16694
|
+
};
|
|
16695
|
+
Output.prototype.set_indent = function(indent, alignment) {
|
|
16696
|
+
indent = indent || 0;
|
|
16697
|
+
alignment = alignment || 0;
|
|
16698
|
+
this.next_line.set_indent(indent, alignment);
|
|
16699
|
+
if (this.__lines.length > 1) {
|
|
16700
|
+
this.current_line.set_indent(indent, alignment);
|
|
16701
|
+
return true;
|
|
16702
|
+
}
|
|
16703
|
+
this.current_line.set_indent();
|
|
16704
|
+
return false;
|
|
16705
|
+
};
|
|
16706
|
+
Output.prototype.add_raw_token = function(token) {
|
|
16707
|
+
for (var x = 0; x < token.newlines; x++) {
|
|
16708
|
+
this.__add_outputline();
|
|
16709
|
+
}
|
|
16710
|
+
this.current_line.set_indent(-1);
|
|
16711
|
+
this.current_line.push(token.whitespace_before);
|
|
16712
|
+
this.current_line.push(token.text);
|
|
16713
|
+
this.space_before_token = false;
|
|
16714
|
+
this.non_breaking_space = false;
|
|
16715
|
+
this.previous_token_wrapped = false;
|
|
16716
|
+
};
|
|
16717
|
+
Output.prototype.add_token = function(printable_token) {
|
|
16718
|
+
this.__add_space_before_token();
|
|
16719
|
+
this.current_line.push(printable_token);
|
|
16720
|
+
this.space_before_token = false;
|
|
16721
|
+
this.non_breaking_space = false;
|
|
16722
|
+
this.previous_token_wrapped = this.current_line._allow_wrap();
|
|
16723
|
+
};
|
|
16724
|
+
Output.prototype.__add_space_before_token = function() {
|
|
16725
|
+
if (this.space_before_token && !this.just_added_newline()) {
|
|
16726
|
+
if (!this.non_breaking_space) {
|
|
16727
|
+
this.set_wrap_point();
|
|
16728
|
+
}
|
|
16729
|
+
this.current_line.push(" ");
|
|
16730
|
+
}
|
|
16731
|
+
};
|
|
16732
|
+
Output.prototype.remove_indent = function(index) {
|
|
16733
|
+
var output_length = this.__lines.length;
|
|
16734
|
+
while (index < output_length) {
|
|
16735
|
+
this.__lines[index]._remove_indent();
|
|
16736
|
+
index++;
|
|
16737
|
+
}
|
|
16738
|
+
this.current_line._remove_wrap_indent();
|
|
16739
|
+
};
|
|
16740
|
+
Output.prototype.trim = function(eat_newlines) {
|
|
16741
|
+
eat_newlines = eat_newlines === void 0 ? false : eat_newlines;
|
|
16742
|
+
this.current_line.trim();
|
|
16743
|
+
while (eat_newlines && this.__lines.length > 1 && this.current_line.is_empty()) {
|
|
16744
|
+
this.__lines.pop();
|
|
16745
|
+
this.current_line = this.__lines[this.__lines.length - 1];
|
|
16746
|
+
this.current_line.trim();
|
|
16747
|
+
}
|
|
16748
|
+
this.previous_line = this.__lines.length > 1 ? this.__lines[this.__lines.length - 2] : null;
|
|
16749
|
+
};
|
|
16750
|
+
Output.prototype.just_added_newline = function() {
|
|
16751
|
+
return this.current_line.is_empty();
|
|
16752
|
+
};
|
|
16753
|
+
Output.prototype.just_added_blankline = function() {
|
|
16754
|
+
return this.is_empty() || this.current_line.is_empty() && this.previous_line.is_empty();
|
|
16755
|
+
};
|
|
16756
|
+
Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
|
|
16757
|
+
var index = this.__lines.length - 2;
|
|
16758
|
+
while (index >= 0) {
|
|
16759
|
+
var potentialEmptyLine = this.__lines[index];
|
|
16760
|
+
if (potentialEmptyLine.is_empty()) {
|
|
16761
|
+
break;
|
|
16762
|
+
} else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 && potentialEmptyLine.item(-1) !== ends_with) {
|
|
16763
|
+
this.__lines.splice(index + 1, 0, new OutputLine(this));
|
|
16764
|
+
this.previous_line = this.__lines[this.__lines.length - 2];
|
|
16765
|
+
break;
|
|
16766
|
+
}
|
|
16767
|
+
index--;
|
|
16768
|
+
}
|
|
16769
|
+
};
|
|
16770
|
+
module.exports.Output = Output;
|
|
16771
|
+
}
|
|
16772
|
+
});
|
|
16773
|
+
|
|
16774
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/token.js
|
|
16775
|
+
var require_token = __commonJS({
|
|
16776
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/token.js"(exports, module) {
|
|
16777
|
+
init_define_process();
|
|
16778
|
+
function Token(type, text, newlines, whitespace_before) {
|
|
16779
|
+
this.type = type;
|
|
16780
|
+
this.text = text;
|
|
16781
|
+
this.comments_before = null;
|
|
16782
|
+
this.newlines = newlines || 0;
|
|
16783
|
+
this.whitespace_before = whitespace_before || "";
|
|
16784
|
+
this.parent = null;
|
|
16785
|
+
this.next = null;
|
|
16786
|
+
this.previous = null;
|
|
16787
|
+
this.opened = null;
|
|
16788
|
+
this.closed = null;
|
|
16789
|
+
this.directives = null;
|
|
16790
|
+
}
|
|
16791
|
+
module.exports.Token = Token;
|
|
16792
|
+
}
|
|
16793
|
+
});
|
|
16794
|
+
|
|
16795
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/acorn.js
|
|
16796
|
+
var require_acorn = __commonJS({
|
|
16797
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/acorn.js"(exports) {
|
|
16798
|
+
init_define_process();
|
|
16799
|
+
var baseASCIIidentifierStartChars = "\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
|
|
16800
|
+
var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
|
|
16801
|
+
var nonASCIIidentifierStartChars = "\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0\\u08a2-\\u08ac\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097f\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c3d\\u0c58\\u0c59\\u0c60\\u0c61\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d60\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f4\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f0\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191c\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19c1-\\u19c7\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2119-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u212d\\u212f-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u2e2f\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua697\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua78e\\ua790-\\ua793\\ua7a0-\\ua7aa\\ua7f8-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa80-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uabc0-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc";
|
|
16802
|
+
var nonASCIIidentifierChars = "\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f";
|
|
16803
|
+
var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
|
|
16804
|
+
var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
|
|
16805
|
+
exports.identifier = new RegExp(identifierStart + identifierChars, "g");
|
|
16806
|
+
exports.identifierStart = new RegExp(identifierStart);
|
|
16807
|
+
exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
|
|
16808
|
+
exports.newline = /[\n\r\u2028\u2029]/;
|
|
16809
|
+
exports.lineBreak = new RegExp("\r\n|" + exports.newline.source);
|
|
16810
|
+
exports.allLineBreaks = new RegExp(exports.lineBreak.source, "g");
|
|
16811
|
+
}
|
|
16812
|
+
});
|
|
16813
|
+
|
|
16814
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/options.js
|
|
16815
|
+
var require_options = __commonJS({
|
|
16816
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/options.js"(exports, module) {
|
|
16817
|
+
init_define_process();
|
|
16818
|
+
function Options(options, merge_child_field) {
|
|
16819
|
+
this.raw_options = _mergeOpts(options, merge_child_field);
|
|
16820
|
+
this.disabled = this._get_boolean("disabled");
|
|
16821
|
+
this.eol = this._get_characters("eol", "auto");
|
|
16822
|
+
this.end_with_newline = this._get_boolean("end_with_newline");
|
|
16823
|
+
this.indent_size = this._get_number("indent_size", 4);
|
|
16824
|
+
this.indent_char = this._get_characters("indent_char", " ");
|
|
16825
|
+
this.indent_level = this._get_number("indent_level");
|
|
16826
|
+
this.preserve_newlines = this._get_boolean("preserve_newlines", true);
|
|
16827
|
+
this.max_preserve_newlines = this._get_number("max_preserve_newlines", 32786);
|
|
16828
|
+
if (!this.preserve_newlines) {
|
|
16829
|
+
this.max_preserve_newlines = 0;
|
|
16830
|
+
}
|
|
16831
|
+
this.indent_with_tabs = this._get_boolean("indent_with_tabs", this.indent_char === " ");
|
|
16832
|
+
if (this.indent_with_tabs) {
|
|
16833
|
+
this.indent_char = " ";
|
|
16834
|
+
if (this.indent_size === 1) {
|
|
16835
|
+
this.indent_size = 4;
|
|
16836
|
+
}
|
|
16837
|
+
}
|
|
16838
|
+
this.wrap_line_length = this._get_number("wrap_line_length", this._get_number("max_char"));
|
|
16839
|
+
this.indent_empty_lines = this._get_boolean("indent_empty_lines");
|
|
16840
|
+
this.templating = this._get_selection_list("templating", ["auto", "none", "django", "erb", "handlebars", "php", "smarty"], ["auto"]);
|
|
16841
|
+
}
|
|
16842
|
+
Options.prototype._get_array = function(name2, default_value) {
|
|
16843
|
+
var option_value = this.raw_options[name2];
|
|
16844
|
+
var result = default_value || [];
|
|
16845
|
+
if (typeof option_value === "object") {
|
|
16846
|
+
if (option_value !== null && typeof option_value.concat === "function") {
|
|
16847
|
+
result = option_value.concat();
|
|
16848
|
+
}
|
|
16849
|
+
} else if (typeof option_value === "string") {
|
|
16850
|
+
result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
|
|
16851
|
+
}
|
|
16852
|
+
return result;
|
|
16853
|
+
};
|
|
16854
|
+
Options.prototype._get_boolean = function(name2, default_value) {
|
|
16855
|
+
var option_value = this.raw_options[name2];
|
|
16856
|
+
var result = option_value === void 0 ? !!default_value : !!option_value;
|
|
16857
|
+
return result;
|
|
16858
|
+
};
|
|
16859
|
+
Options.prototype._get_characters = function(name2, default_value) {
|
|
16860
|
+
var option_value = this.raw_options[name2];
|
|
16861
|
+
var result = default_value || "";
|
|
16862
|
+
if (typeof option_value === "string") {
|
|
16863
|
+
result = option_value.replace(/\\r/, "\r").replace(/\\n/, "\n").replace(/\\t/, " ");
|
|
16864
|
+
}
|
|
16865
|
+
return result;
|
|
16866
|
+
};
|
|
16867
|
+
Options.prototype._get_number = function(name2, default_value) {
|
|
16868
|
+
var option_value = this.raw_options[name2];
|
|
16869
|
+
default_value = parseInt(default_value, 10);
|
|
16870
|
+
if (isNaN(default_value)) {
|
|
16871
|
+
default_value = 0;
|
|
16872
|
+
}
|
|
16873
|
+
var result = parseInt(option_value, 10);
|
|
16874
|
+
if (isNaN(result)) {
|
|
16875
|
+
result = default_value;
|
|
16876
|
+
}
|
|
16877
|
+
return result;
|
|
16878
|
+
};
|
|
16879
|
+
Options.prototype._get_selection = function(name2, selection_list, default_value) {
|
|
16880
|
+
var result = this._get_selection_list(name2, selection_list, default_value);
|
|
16881
|
+
if (result.length !== 1) {
|
|
16882
|
+
throw new Error(
|
|
16883
|
+
"Invalid Option Value: The option '" + name2 + "' can only be one of the following values:\n" + selection_list + "\nYou passed in: '" + this.raw_options[name2] + "'"
|
|
16884
|
+
);
|
|
16885
|
+
}
|
|
16886
|
+
return result[0];
|
|
16887
|
+
};
|
|
16888
|
+
Options.prototype._get_selection_list = function(name2, selection_list, default_value) {
|
|
16889
|
+
if (!selection_list || selection_list.length === 0) {
|
|
16890
|
+
throw new Error("Selection list cannot be empty.");
|
|
16891
|
+
}
|
|
16892
|
+
default_value = default_value || [selection_list[0]];
|
|
16893
|
+
if (!this._is_valid_selection(default_value, selection_list)) {
|
|
16894
|
+
throw new Error("Invalid Default Value!");
|
|
16895
|
+
}
|
|
16896
|
+
var result = this._get_array(name2, default_value);
|
|
16897
|
+
if (!this._is_valid_selection(result, selection_list)) {
|
|
16898
|
+
throw new Error(
|
|
16899
|
+
"Invalid Option Value: The option '" + name2 + "' can contain only the following values:\n" + selection_list + "\nYou passed in: '" + this.raw_options[name2] + "'"
|
|
16900
|
+
);
|
|
16901
|
+
}
|
|
16902
|
+
return result;
|
|
16903
|
+
};
|
|
16904
|
+
Options.prototype._is_valid_selection = function(result, selection_list) {
|
|
16905
|
+
return result.length && selection_list.length && !result.some(function(item) {
|
|
16906
|
+
return selection_list.indexOf(item) === -1;
|
|
16907
|
+
});
|
|
16908
|
+
};
|
|
16909
|
+
function _mergeOpts(allOptions, childFieldName) {
|
|
16910
|
+
var finalOpts = {};
|
|
16911
|
+
allOptions = _normalizeOpts(allOptions);
|
|
16912
|
+
var name2;
|
|
16913
|
+
for (name2 in allOptions) {
|
|
16914
|
+
if (name2 !== childFieldName) {
|
|
16915
|
+
finalOpts[name2] = allOptions[name2];
|
|
16916
|
+
}
|
|
16917
|
+
}
|
|
16918
|
+
if (childFieldName && allOptions[childFieldName]) {
|
|
16919
|
+
for (name2 in allOptions[childFieldName]) {
|
|
16920
|
+
finalOpts[name2] = allOptions[childFieldName][name2];
|
|
16921
|
+
}
|
|
16922
|
+
}
|
|
16923
|
+
return finalOpts;
|
|
16924
|
+
}
|
|
16925
|
+
function _normalizeOpts(options) {
|
|
16926
|
+
var convertedOpts = {};
|
|
16927
|
+
var key;
|
|
16928
|
+
for (key in options) {
|
|
16929
|
+
var newKey = key.replace(/-/g, "_");
|
|
16930
|
+
convertedOpts[newKey] = options[key];
|
|
16931
|
+
}
|
|
16932
|
+
return convertedOpts;
|
|
16933
|
+
}
|
|
16934
|
+
module.exports.Options = Options;
|
|
16935
|
+
module.exports.normalizeOpts = _normalizeOpts;
|
|
16936
|
+
module.exports.mergeOpts = _mergeOpts;
|
|
16937
|
+
}
|
|
16938
|
+
});
|
|
16939
|
+
|
|
16940
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/options.js
|
|
16941
|
+
var require_options2 = __commonJS({
|
|
16942
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/options.js"(exports, module) {
|
|
16943
|
+
init_define_process();
|
|
16944
|
+
var BaseOptions = require_options().Options;
|
|
16945
|
+
var validPositionValues = ["before-newline", "after-newline", "preserve-newline"];
|
|
16946
|
+
function Options(options) {
|
|
16947
|
+
BaseOptions.call(this, options, "js");
|
|
16948
|
+
var raw_brace_style = this.raw_options.brace_style || null;
|
|
16949
|
+
if (raw_brace_style === "expand-strict") {
|
|
16950
|
+
this.raw_options.brace_style = "expand";
|
|
16951
|
+
} else if (raw_brace_style === "collapse-preserve-inline") {
|
|
16952
|
+
this.raw_options.brace_style = "collapse,preserve-inline";
|
|
16953
|
+
} else if (this.raw_options.braces_on_own_line !== void 0) {
|
|
16954
|
+
this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
|
|
16955
|
+
}
|
|
16956
|
+
var brace_style_split = this._get_selection_list("brace_style", ["collapse", "expand", "end-expand", "none", "preserve-inline"]);
|
|
16957
|
+
this.brace_preserve_inline = false;
|
|
16958
|
+
this.brace_style = "collapse";
|
|
16959
|
+
for (var bs = 0; bs < brace_style_split.length; bs++) {
|
|
16960
|
+
if (brace_style_split[bs] === "preserve-inline") {
|
|
16961
|
+
this.brace_preserve_inline = true;
|
|
16962
|
+
} else {
|
|
16963
|
+
this.brace_style = brace_style_split[bs];
|
|
16964
|
+
}
|
|
16965
|
+
}
|
|
16966
|
+
this.unindent_chained_methods = this._get_boolean("unindent_chained_methods");
|
|
16967
|
+
this.break_chained_methods = this._get_boolean("break_chained_methods");
|
|
16968
|
+
this.space_in_paren = this._get_boolean("space_in_paren");
|
|
16969
|
+
this.space_in_empty_paren = this._get_boolean("space_in_empty_paren");
|
|
16970
|
+
this.jslint_happy = this._get_boolean("jslint_happy");
|
|
16971
|
+
this.space_after_anon_function = this._get_boolean("space_after_anon_function");
|
|
16972
|
+
this.space_after_named_function = this._get_boolean("space_after_named_function");
|
|
16973
|
+
this.keep_array_indentation = this._get_boolean("keep_array_indentation");
|
|
16974
|
+
this.space_before_conditional = this._get_boolean("space_before_conditional", true);
|
|
16975
|
+
this.unescape_strings = this._get_boolean("unescape_strings");
|
|
16976
|
+
this.e4x = this._get_boolean("e4x");
|
|
16977
|
+
this.comma_first = this._get_boolean("comma_first");
|
|
16978
|
+
this.operator_position = this._get_selection("operator_position", validPositionValues);
|
|
16979
|
+
this.test_output_raw = this._get_boolean("test_output_raw");
|
|
16980
|
+
if (this.jslint_happy) {
|
|
16981
|
+
this.space_after_anon_function = true;
|
|
16982
|
+
}
|
|
16983
|
+
}
|
|
16984
|
+
Options.prototype = new BaseOptions();
|
|
16985
|
+
module.exports.Options = Options;
|
|
16986
|
+
}
|
|
16987
|
+
});
|
|
16988
|
+
|
|
16989
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/inputscanner.js
|
|
16990
|
+
var require_inputscanner = __commonJS({
|
|
16991
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/inputscanner.js"(exports, module) {
|
|
16992
|
+
init_define_process();
|
|
16993
|
+
var regexp_has_sticky = RegExp.prototype.hasOwnProperty("sticky");
|
|
16994
|
+
function InputScanner(input_string) {
|
|
16995
|
+
this.__input = input_string || "";
|
|
16996
|
+
this.__input_length = this.__input.length;
|
|
16997
|
+
this.__position = 0;
|
|
16998
|
+
}
|
|
16999
|
+
InputScanner.prototype.restart = function() {
|
|
17000
|
+
this.__position = 0;
|
|
17001
|
+
};
|
|
17002
|
+
InputScanner.prototype.back = function() {
|
|
17003
|
+
if (this.__position > 0) {
|
|
17004
|
+
this.__position -= 1;
|
|
17005
|
+
}
|
|
17006
|
+
};
|
|
17007
|
+
InputScanner.prototype.hasNext = function() {
|
|
17008
|
+
return this.__position < this.__input_length;
|
|
17009
|
+
};
|
|
17010
|
+
InputScanner.prototype.next = function() {
|
|
17011
|
+
var val = null;
|
|
17012
|
+
if (this.hasNext()) {
|
|
17013
|
+
val = this.__input.charAt(this.__position);
|
|
17014
|
+
this.__position += 1;
|
|
17015
|
+
}
|
|
17016
|
+
return val;
|
|
17017
|
+
};
|
|
17018
|
+
InputScanner.prototype.peek = function(index) {
|
|
17019
|
+
var val = null;
|
|
17020
|
+
index = index || 0;
|
|
17021
|
+
index += this.__position;
|
|
17022
|
+
if (index >= 0 && index < this.__input_length) {
|
|
17023
|
+
val = this.__input.charAt(index);
|
|
17024
|
+
}
|
|
17025
|
+
return val;
|
|
17026
|
+
};
|
|
17027
|
+
InputScanner.prototype.__match = function(pattern, index) {
|
|
17028
|
+
pattern.lastIndex = index;
|
|
17029
|
+
var pattern_match = pattern.exec(this.__input);
|
|
17030
|
+
if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
|
|
17031
|
+
if (pattern_match.index !== index) {
|
|
17032
|
+
pattern_match = null;
|
|
17033
|
+
}
|
|
17034
|
+
}
|
|
17035
|
+
return pattern_match;
|
|
17036
|
+
};
|
|
17037
|
+
InputScanner.prototype.test = function(pattern, index) {
|
|
17038
|
+
index = index || 0;
|
|
17039
|
+
index += this.__position;
|
|
17040
|
+
if (index >= 0 && index < this.__input_length) {
|
|
17041
|
+
return !!this.__match(pattern, index);
|
|
17042
|
+
} else {
|
|
17043
|
+
return false;
|
|
17044
|
+
}
|
|
17045
|
+
};
|
|
17046
|
+
InputScanner.prototype.testChar = function(pattern, index) {
|
|
17047
|
+
var val = this.peek(index);
|
|
17048
|
+
pattern.lastIndex = 0;
|
|
17049
|
+
return val !== null && pattern.test(val);
|
|
17050
|
+
};
|
|
17051
|
+
InputScanner.prototype.match = function(pattern) {
|
|
17052
|
+
var pattern_match = this.__match(pattern, this.__position);
|
|
17053
|
+
if (pattern_match) {
|
|
17054
|
+
this.__position += pattern_match[0].length;
|
|
17055
|
+
} else {
|
|
17056
|
+
pattern_match = null;
|
|
17057
|
+
}
|
|
17058
|
+
return pattern_match;
|
|
17059
|
+
};
|
|
17060
|
+
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
|
|
17061
|
+
var val = "";
|
|
17062
|
+
var match;
|
|
17063
|
+
if (starting_pattern) {
|
|
17064
|
+
match = this.match(starting_pattern);
|
|
17065
|
+
if (match) {
|
|
17066
|
+
val += match[0];
|
|
17067
|
+
}
|
|
17068
|
+
}
|
|
17069
|
+
if (until_pattern && (match || !starting_pattern)) {
|
|
17070
|
+
val += this.readUntil(until_pattern, until_after);
|
|
17071
|
+
}
|
|
17072
|
+
return val;
|
|
17073
|
+
};
|
|
17074
|
+
InputScanner.prototype.readUntil = function(pattern, until_after) {
|
|
17075
|
+
var val = "";
|
|
17076
|
+
var match_index = this.__position;
|
|
17077
|
+
pattern.lastIndex = this.__position;
|
|
17078
|
+
var pattern_match = pattern.exec(this.__input);
|
|
17079
|
+
if (pattern_match) {
|
|
17080
|
+
match_index = pattern_match.index;
|
|
17081
|
+
if (until_after) {
|
|
17082
|
+
match_index += pattern_match[0].length;
|
|
17083
|
+
}
|
|
17084
|
+
} else {
|
|
17085
|
+
match_index = this.__input_length;
|
|
17086
|
+
}
|
|
17087
|
+
val = this.__input.substring(this.__position, match_index);
|
|
17088
|
+
this.__position = match_index;
|
|
17089
|
+
return val;
|
|
17090
|
+
};
|
|
17091
|
+
InputScanner.prototype.readUntilAfter = function(pattern) {
|
|
17092
|
+
return this.readUntil(pattern, true);
|
|
17093
|
+
};
|
|
17094
|
+
InputScanner.prototype.get_regexp = function(pattern, match_from) {
|
|
17095
|
+
var result = null;
|
|
17096
|
+
var flags = "g";
|
|
17097
|
+
if (match_from && regexp_has_sticky) {
|
|
17098
|
+
flags = "y";
|
|
17099
|
+
}
|
|
17100
|
+
if (typeof pattern === "string" && pattern !== "") {
|
|
17101
|
+
result = new RegExp(pattern, flags);
|
|
17102
|
+
} else if (pattern) {
|
|
17103
|
+
result = new RegExp(pattern.source, flags);
|
|
17104
|
+
}
|
|
17105
|
+
return result;
|
|
17106
|
+
};
|
|
17107
|
+
InputScanner.prototype.get_literal_regexp = function(literal_string) {
|
|
17108
|
+
return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
|
|
17109
|
+
};
|
|
17110
|
+
InputScanner.prototype.peekUntilAfter = function(pattern) {
|
|
17111
|
+
var start = this.__position;
|
|
17112
|
+
var val = this.readUntilAfter(pattern);
|
|
17113
|
+
this.__position = start;
|
|
17114
|
+
return val;
|
|
17115
|
+
};
|
|
17116
|
+
InputScanner.prototype.lookBack = function(testVal) {
|
|
17117
|
+
var start = this.__position - 1;
|
|
17118
|
+
return start >= testVal.length && this.__input.substring(start - testVal.length, start).toLowerCase() === testVal;
|
|
17119
|
+
};
|
|
17120
|
+
module.exports.InputScanner = InputScanner;
|
|
17121
|
+
}
|
|
17122
|
+
});
|
|
17123
|
+
|
|
17124
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/tokenstream.js
|
|
17125
|
+
var require_tokenstream = __commonJS({
|
|
17126
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/tokenstream.js"(exports, module) {
|
|
17127
|
+
init_define_process();
|
|
17128
|
+
function TokenStream(parent_token) {
|
|
17129
|
+
this.__tokens = [];
|
|
17130
|
+
this.__tokens_length = this.__tokens.length;
|
|
17131
|
+
this.__position = 0;
|
|
17132
|
+
this.__parent_token = parent_token;
|
|
17133
|
+
}
|
|
17134
|
+
TokenStream.prototype.restart = function() {
|
|
17135
|
+
this.__position = 0;
|
|
17136
|
+
};
|
|
17137
|
+
TokenStream.prototype.isEmpty = function() {
|
|
17138
|
+
return this.__tokens_length === 0;
|
|
17139
|
+
};
|
|
17140
|
+
TokenStream.prototype.hasNext = function() {
|
|
17141
|
+
return this.__position < this.__tokens_length;
|
|
17142
|
+
};
|
|
17143
|
+
TokenStream.prototype.next = function() {
|
|
17144
|
+
var val = null;
|
|
17145
|
+
if (this.hasNext()) {
|
|
17146
|
+
val = this.__tokens[this.__position];
|
|
17147
|
+
this.__position += 1;
|
|
17148
|
+
}
|
|
17149
|
+
return val;
|
|
17150
|
+
};
|
|
17151
|
+
TokenStream.prototype.peek = function(index) {
|
|
17152
|
+
var val = null;
|
|
17153
|
+
index = index || 0;
|
|
17154
|
+
index += this.__position;
|
|
17155
|
+
if (index >= 0 && index < this.__tokens_length) {
|
|
17156
|
+
val = this.__tokens[index];
|
|
17157
|
+
}
|
|
17158
|
+
return val;
|
|
17159
|
+
};
|
|
17160
|
+
TokenStream.prototype.add = function(token) {
|
|
17161
|
+
if (this.__parent_token) {
|
|
17162
|
+
token.parent = this.__parent_token;
|
|
17163
|
+
}
|
|
17164
|
+
this.__tokens.push(token);
|
|
17165
|
+
this.__tokens_length += 1;
|
|
17166
|
+
};
|
|
17167
|
+
module.exports.TokenStream = TokenStream;
|
|
17168
|
+
}
|
|
17169
|
+
});
|
|
17170
|
+
|
|
17171
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/pattern.js
|
|
17172
|
+
var require_pattern = __commonJS({
|
|
17173
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/pattern.js"(exports, module) {
|
|
17174
|
+
init_define_process();
|
|
17175
|
+
function Pattern(input_scanner, parent) {
|
|
17176
|
+
this._input = input_scanner;
|
|
17177
|
+
this._starting_pattern = null;
|
|
17178
|
+
this._match_pattern = null;
|
|
17179
|
+
this._until_pattern = null;
|
|
17180
|
+
this._until_after = false;
|
|
17181
|
+
if (parent) {
|
|
17182
|
+
this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
|
|
17183
|
+
this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
|
|
17184
|
+
this._until_pattern = this._input.get_regexp(parent._until_pattern);
|
|
17185
|
+
this._until_after = parent._until_after;
|
|
17186
|
+
}
|
|
17187
|
+
}
|
|
17188
|
+
Pattern.prototype.read = function() {
|
|
17189
|
+
var result = this._input.read(this._starting_pattern);
|
|
17190
|
+
if (!this._starting_pattern || result) {
|
|
17191
|
+
result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
|
|
17192
|
+
}
|
|
17193
|
+
return result;
|
|
17194
|
+
};
|
|
17195
|
+
Pattern.prototype.read_match = function() {
|
|
17196
|
+
return this._input.match(this._match_pattern);
|
|
17197
|
+
};
|
|
17198
|
+
Pattern.prototype.until_after = function(pattern) {
|
|
17199
|
+
var result = this._create();
|
|
17200
|
+
result._until_after = true;
|
|
17201
|
+
result._until_pattern = this._input.get_regexp(pattern);
|
|
17202
|
+
result._update();
|
|
17203
|
+
return result;
|
|
17204
|
+
};
|
|
17205
|
+
Pattern.prototype.until = function(pattern) {
|
|
17206
|
+
var result = this._create();
|
|
17207
|
+
result._until_after = false;
|
|
17208
|
+
result._until_pattern = this._input.get_regexp(pattern);
|
|
17209
|
+
result._update();
|
|
17210
|
+
return result;
|
|
17211
|
+
};
|
|
17212
|
+
Pattern.prototype.starting_with = function(pattern) {
|
|
17213
|
+
var result = this._create();
|
|
17214
|
+
result._starting_pattern = this._input.get_regexp(pattern, true);
|
|
17215
|
+
result._update();
|
|
17216
|
+
return result;
|
|
17217
|
+
};
|
|
17218
|
+
Pattern.prototype.matching = function(pattern) {
|
|
17219
|
+
var result = this._create();
|
|
17220
|
+
result._match_pattern = this._input.get_regexp(pattern, true);
|
|
17221
|
+
result._update();
|
|
17222
|
+
return result;
|
|
17223
|
+
};
|
|
17224
|
+
Pattern.prototype._create = function() {
|
|
17225
|
+
return new Pattern(this._input, this);
|
|
17226
|
+
};
|
|
17227
|
+
Pattern.prototype._update = function() {
|
|
17228
|
+
};
|
|
17229
|
+
module.exports.Pattern = Pattern;
|
|
17230
|
+
}
|
|
17231
|
+
});
|
|
17232
|
+
|
|
17233
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/whitespacepattern.js
|
|
17234
|
+
var require_whitespacepattern = __commonJS({
|
|
17235
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/whitespacepattern.js"(exports, module) {
|
|
17236
|
+
init_define_process();
|
|
17237
|
+
var Pattern = require_pattern().Pattern;
|
|
17238
|
+
function WhitespacePattern(input_scanner, parent) {
|
|
17239
|
+
Pattern.call(this, input_scanner, parent);
|
|
17240
|
+
if (parent) {
|
|
17241
|
+
this._line_regexp = this._input.get_regexp(parent._line_regexp);
|
|
17242
|
+
} else {
|
|
17243
|
+
this.__set_whitespace_patterns("", "");
|
|
17244
|
+
}
|
|
17245
|
+
this.newline_count = 0;
|
|
17246
|
+
this.whitespace_before_token = "";
|
|
17247
|
+
}
|
|
17248
|
+
WhitespacePattern.prototype = new Pattern();
|
|
17249
|
+
WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
|
|
17250
|
+
whitespace_chars += "\\t ";
|
|
17251
|
+
newline_chars += "\\n\\r";
|
|
17252
|
+
this._match_pattern = this._input.get_regexp(
|
|
17253
|
+
"[" + whitespace_chars + newline_chars + "]+",
|
|
17254
|
+
true
|
|
17255
|
+
);
|
|
17256
|
+
this._newline_regexp = this._input.get_regexp(
|
|
17257
|
+
"\\r\\n|[" + newline_chars + "]"
|
|
17258
|
+
);
|
|
17259
|
+
};
|
|
17260
|
+
WhitespacePattern.prototype.read = function() {
|
|
17261
|
+
this.newline_count = 0;
|
|
17262
|
+
this.whitespace_before_token = "";
|
|
17263
|
+
var resulting_string = this._input.read(this._match_pattern);
|
|
17264
|
+
if (resulting_string === " ") {
|
|
17265
|
+
this.whitespace_before_token = " ";
|
|
17266
|
+
} else if (resulting_string) {
|
|
17267
|
+
var matches = this.__split(this._newline_regexp, resulting_string);
|
|
17268
|
+
this.newline_count = matches.length - 1;
|
|
17269
|
+
this.whitespace_before_token = matches[this.newline_count];
|
|
17270
|
+
}
|
|
17271
|
+
return resulting_string;
|
|
17272
|
+
};
|
|
17273
|
+
WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
|
|
17274
|
+
var result = this._create();
|
|
17275
|
+
result.__set_whitespace_patterns(whitespace_chars, newline_chars);
|
|
17276
|
+
result._update();
|
|
17277
|
+
return result;
|
|
17278
|
+
};
|
|
17279
|
+
WhitespacePattern.prototype._create = function() {
|
|
17280
|
+
return new WhitespacePattern(this._input, this);
|
|
17281
|
+
};
|
|
17282
|
+
WhitespacePattern.prototype.__split = function(regexp, input_string) {
|
|
17283
|
+
regexp.lastIndex = 0;
|
|
17284
|
+
var start_index = 0;
|
|
17285
|
+
var result = [];
|
|
17286
|
+
var next_match = regexp.exec(input_string);
|
|
17287
|
+
while (next_match) {
|
|
17288
|
+
result.push(input_string.substring(start_index, next_match.index));
|
|
17289
|
+
start_index = next_match.index + next_match[0].length;
|
|
17290
|
+
next_match = regexp.exec(input_string);
|
|
17291
|
+
}
|
|
17292
|
+
if (start_index < input_string.length) {
|
|
17293
|
+
result.push(input_string.substring(start_index, input_string.length));
|
|
17294
|
+
} else {
|
|
17295
|
+
result.push("");
|
|
17296
|
+
}
|
|
17297
|
+
return result;
|
|
17298
|
+
};
|
|
17299
|
+
module.exports.WhitespacePattern = WhitespacePattern;
|
|
17300
|
+
}
|
|
17301
|
+
});
|
|
17302
|
+
|
|
17303
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/tokenizer.js
|
|
17304
|
+
var require_tokenizer = __commonJS({
|
|
17305
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/tokenizer.js"(exports, module) {
|
|
17306
|
+
init_define_process();
|
|
17307
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
17308
|
+
var Token = require_token().Token;
|
|
17309
|
+
var TokenStream = require_tokenstream().TokenStream;
|
|
17310
|
+
var WhitespacePattern = require_whitespacepattern().WhitespacePattern;
|
|
17311
|
+
var TOKEN = {
|
|
17312
|
+
START: "TK_START",
|
|
17313
|
+
RAW: "TK_RAW",
|
|
17314
|
+
EOF: "TK_EOF"
|
|
17315
|
+
};
|
|
17316
|
+
var Tokenizer = function(input_string, options) {
|
|
17317
|
+
this._input = new InputScanner(input_string);
|
|
17318
|
+
this._options = options || {};
|
|
17319
|
+
this.__tokens = null;
|
|
17320
|
+
this._patterns = {};
|
|
17321
|
+
this._patterns.whitespace = new WhitespacePattern(this._input);
|
|
17322
|
+
};
|
|
17323
|
+
Tokenizer.prototype.tokenize = function() {
|
|
17324
|
+
this._input.restart();
|
|
17325
|
+
this.__tokens = new TokenStream();
|
|
17326
|
+
this._reset();
|
|
17327
|
+
var current;
|
|
17328
|
+
var previous = new Token(TOKEN.START, "");
|
|
17329
|
+
var open_token = null;
|
|
17330
|
+
var open_stack = [];
|
|
17331
|
+
var comments = new TokenStream();
|
|
17332
|
+
while (previous.type !== TOKEN.EOF) {
|
|
17333
|
+
current = this._get_next_token(previous, open_token);
|
|
17334
|
+
while (this._is_comment(current)) {
|
|
17335
|
+
comments.add(current);
|
|
17336
|
+
current = this._get_next_token(previous, open_token);
|
|
17337
|
+
}
|
|
17338
|
+
if (!comments.isEmpty()) {
|
|
17339
|
+
current.comments_before = comments;
|
|
17340
|
+
comments = new TokenStream();
|
|
17341
|
+
}
|
|
17342
|
+
current.parent = open_token;
|
|
17343
|
+
if (this._is_opening(current)) {
|
|
17344
|
+
open_stack.push(open_token);
|
|
17345
|
+
open_token = current;
|
|
17346
|
+
} else if (open_token && this._is_closing(current, open_token)) {
|
|
17347
|
+
current.opened = open_token;
|
|
17348
|
+
open_token.closed = current;
|
|
17349
|
+
open_token = open_stack.pop();
|
|
17350
|
+
current.parent = open_token;
|
|
17351
|
+
}
|
|
17352
|
+
current.previous = previous;
|
|
17353
|
+
previous.next = current;
|
|
17354
|
+
this.__tokens.add(current);
|
|
17355
|
+
previous = current;
|
|
17356
|
+
}
|
|
17357
|
+
return this.__tokens;
|
|
17358
|
+
};
|
|
17359
|
+
Tokenizer.prototype._is_first_token = function() {
|
|
17360
|
+
return this.__tokens.isEmpty();
|
|
17361
|
+
};
|
|
17362
|
+
Tokenizer.prototype._reset = function() {
|
|
17363
|
+
};
|
|
17364
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
17365
|
+
this._readWhitespace();
|
|
17366
|
+
var resulting_string = this._input.read(/.+/g);
|
|
17367
|
+
if (resulting_string) {
|
|
17368
|
+
return this._create_token(TOKEN.RAW, resulting_string);
|
|
17369
|
+
} else {
|
|
17370
|
+
return this._create_token(TOKEN.EOF, "");
|
|
17371
|
+
}
|
|
17372
|
+
};
|
|
17373
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
17374
|
+
return false;
|
|
17375
|
+
};
|
|
17376
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
17377
|
+
return false;
|
|
17378
|
+
};
|
|
17379
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
17380
|
+
return false;
|
|
17381
|
+
};
|
|
17382
|
+
Tokenizer.prototype._create_token = function(type, text) {
|
|
17383
|
+
var token = new Token(
|
|
17384
|
+
type,
|
|
17385
|
+
text,
|
|
17386
|
+
this._patterns.whitespace.newline_count,
|
|
17387
|
+
this._patterns.whitespace.whitespace_before_token
|
|
17388
|
+
);
|
|
17389
|
+
return token;
|
|
17390
|
+
};
|
|
17391
|
+
Tokenizer.prototype._readWhitespace = function() {
|
|
17392
|
+
return this._patterns.whitespace.read();
|
|
17393
|
+
};
|
|
17394
|
+
module.exports.Tokenizer = Tokenizer;
|
|
17395
|
+
module.exports.TOKEN = TOKEN;
|
|
17396
|
+
}
|
|
17397
|
+
});
|
|
17398
|
+
|
|
17399
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/directives.js
|
|
17400
|
+
var require_directives = __commonJS({
|
|
17401
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/directives.js"(exports, module) {
|
|
17402
|
+
init_define_process();
|
|
17403
|
+
function Directives(start_block_pattern, end_block_pattern) {
|
|
17404
|
+
start_block_pattern = typeof start_block_pattern === "string" ? start_block_pattern : start_block_pattern.source;
|
|
17405
|
+
end_block_pattern = typeof end_block_pattern === "string" ? end_block_pattern : end_block_pattern.source;
|
|
17406
|
+
this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, "g");
|
|
17407
|
+
this.__directive_pattern = / (\w+)[:](\w+)/g;
|
|
17408
|
+
this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, "g");
|
|
17409
|
+
}
|
|
17410
|
+
Directives.prototype.get_directives = function(text) {
|
|
17411
|
+
if (!text.match(this.__directives_block_pattern)) {
|
|
17412
|
+
return null;
|
|
17413
|
+
}
|
|
17414
|
+
var directives = {};
|
|
17415
|
+
this.__directive_pattern.lastIndex = 0;
|
|
17416
|
+
var directive_match = this.__directive_pattern.exec(text);
|
|
17417
|
+
while (directive_match) {
|
|
17418
|
+
directives[directive_match[1]] = directive_match[2];
|
|
17419
|
+
directive_match = this.__directive_pattern.exec(text);
|
|
17420
|
+
}
|
|
17421
|
+
return directives;
|
|
17422
|
+
};
|
|
17423
|
+
Directives.prototype.readIgnored = function(input) {
|
|
17424
|
+
return input.readUntilAfter(this.__directives_end_ignore_pattern);
|
|
17425
|
+
};
|
|
17426
|
+
module.exports.Directives = Directives;
|
|
17427
|
+
}
|
|
17428
|
+
});
|
|
17429
|
+
|
|
17430
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/templatablepattern.js
|
|
17431
|
+
var require_templatablepattern = __commonJS({
|
|
17432
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/core/templatablepattern.js"(exports, module) {
|
|
17433
|
+
init_define_process();
|
|
17434
|
+
var Pattern = require_pattern().Pattern;
|
|
17435
|
+
var template_names = {
|
|
17436
|
+
django: false,
|
|
17437
|
+
erb: false,
|
|
17438
|
+
handlebars: false,
|
|
17439
|
+
php: false,
|
|
17440
|
+
smarty: false
|
|
17441
|
+
};
|
|
17442
|
+
function TemplatablePattern(input_scanner, parent) {
|
|
17443
|
+
Pattern.call(this, input_scanner, parent);
|
|
17444
|
+
this.__template_pattern = null;
|
|
17445
|
+
this._disabled = Object.assign({}, template_names);
|
|
17446
|
+
this._excluded = Object.assign({}, template_names);
|
|
17447
|
+
if (parent) {
|
|
17448
|
+
this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
|
|
17449
|
+
this._excluded = Object.assign(this._excluded, parent._excluded);
|
|
17450
|
+
this._disabled = Object.assign(this._disabled, parent._disabled);
|
|
17451
|
+
}
|
|
17452
|
+
var pattern = new Pattern(input_scanner);
|
|
17453
|
+
this.__patterns = {
|
|
17454
|
+
handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
|
|
17455
|
+
handlebars_unescaped: pattern.starting_with(/{{{/).until_after(/}}}/),
|
|
17456
|
+
handlebars: pattern.starting_with(/{{/).until_after(/}}/),
|
|
17457
|
+
php: pattern.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),
|
|
17458
|
+
erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
|
|
17459
|
+
// django coflicts with handlebars a bit.
|
|
17460
|
+
django: pattern.starting_with(/{%/).until_after(/%}/),
|
|
17461
|
+
django_value: pattern.starting_with(/{{/).until_after(/}}/),
|
|
17462
|
+
django_comment: pattern.starting_with(/{#/).until_after(/#}/),
|
|
17463
|
+
smarty: pattern.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),
|
|
17464
|
+
smarty_comment: pattern.starting_with(/{\*/).until_after(/\*}/),
|
|
17465
|
+
smarty_literal: pattern.starting_with(/{literal}/).until_after(/{\/literal}/)
|
|
17466
|
+
};
|
|
17467
|
+
}
|
|
17468
|
+
TemplatablePattern.prototype = new Pattern();
|
|
17469
|
+
TemplatablePattern.prototype._create = function() {
|
|
17470
|
+
return new TemplatablePattern(this._input, this);
|
|
17471
|
+
};
|
|
17472
|
+
TemplatablePattern.prototype._update = function() {
|
|
17473
|
+
this.__set_templated_pattern();
|
|
17474
|
+
};
|
|
17475
|
+
TemplatablePattern.prototype.disable = function(language) {
|
|
17476
|
+
var result = this._create();
|
|
17477
|
+
result._disabled[language] = true;
|
|
17478
|
+
result._update();
|
|
17479
|
+
return result;
|
|
17480
|
+
};
|
|
17481
|
+
TemplatablePattern.prototype.read_options = function(options) {
|
|
17482
|
+
var result = this._create();
|
|
17483
|
+
for (var language in template_names) {
|
|
17484
|
+
result._disabled[language] = options.templating.indexOf(language) === -1;
|
|
17485
|
+
}
|
|
17486
|
+
result._update();
|
|
17487
|
+
return result;
|
|
17488
|
+
};
|
|
17489
|
+
TemplatablePattern.prototype.exclude = function(language) {
|
|
17490
|
+
var result = this._create();
|
|
17491
|
+
result._excluded[language] = true;
|
|
17492
|
+
result._update();
|
|
17493
|
+
return result;
|
|
17494
|
+
};
|
|
17495
|
+
TemplatablePattern.prototype.read = function() {
|
|
17496
|
+
var result = "";
|
|
17497
|
+
if (this._match_pattern) {
|
|
17498
|
+
result = this._input.read(this._starting_pattern);
|
|
17499
|
+
} else {
|
|
17500
|
+
result = this._input.read(this._starting_pattern, this.__template_pattern);
|
|
17501
|
+
}
|
|
17502
|
+
var next = this._read_template();
|
|
17503
|
+
while (next) {
|
|
17504
|
+
if (this._match_pattern) {
|
|
17505
|
+
next += this._input.read(this._match_pattern);
|
|
17506
|
+
} else {
|
|
17507
|
+
next += this._input.readUntil(this.__template_pattern);
|
|
17508
|
+
}
|
|
17509
|
+
result += next;
|
|
17510
|
+
next = this._read_template();
|
|
17511
|
+
}
|
|
17512
|
+
if (this._until_after) {
|
|
17513
|
+
result += this._input.readUntilAfter(this._until_pattern);
|
|
17514
|
+
}
|
|
17515
|
+
return result;
|
|
17516
|
+
};
|
|
17517
|
+
TemplatablePattern.prototype.__set_templated_pattern = function() {
|
|
17518
|
+
var items = [];
|
|
17519
|
+
if (!this._disabled.php) {
|
|
17520
|
+
items.push(this.__patterns.php._starting_pattern.source);
|
|
17521
|
+
}
|
|
17522
|
+
if (!this._disabled.handlebars) {
|
|
17523
|
+
items.push(this.__patterns.handlebars._starting_pattern.source);
|
|
17524
|
+
}
|
|
17525
|
+
if (!this._disabled.erb) {
|
|
17526
|
+
items.push(this.__patterns.erb._starting_pattern.source);
|
|
17527
|
+
}
|
|
17528
|
+
if (!this._disabled.django) {
|
|
17529
|
+
items.push(this.__patterns.django._starting_pattern.source);
|
|
17530
|
+
items.push(this.__patterns.django_value._starting_pattern.source);
|
|
17531
|
+
items.push(this.__patterns.django_comment._starting_pattern.source);
|
|
17532
|
+
}
|
|
17533
|
+
if (!this._disabled.smarty) {
|
|
17534
|
+
items.push(this.__patterns.smarty._starting_pattern.source);
|
|
17535
|
+
}
|
|
17536
|
+
if (this._until_pattern) {
|
|
17537
|
+
items.push(this._until_pattern.source);
|
|
17538
|
+
}
|
|
17539
|
+
this.__template_pattern = this._input.get_regexp("(?:" + items.join("|") + ")");
|
|
17540
|
+
};
|
|
17541
|
+
TemplatablePattern.prototype._read_template = function() {
|
|
17542
|
+
var resulting_string = "";
|
|
17543
|
+
var c = this._input.peek();
|
|
17544
|
+
if (c === "<") {
|
|
17545
|
+
var peek1 = this._input.peek(1);
|
|
17546
|
+
if (!this._disabled.php && !this._excluded.php && peek1 === "?") {
|
|
17547
|
+
resulting_string = resulting_string || this.__patterns.php.read();
|
|
17548
|
+
}
|
|
17549
|
+
if (!this._disabled.erb && !this._excluded.erb && peek1 === "%") {
|
|
17550
|
+
resulting_string = resulting_string || this.__patterns.erb.read();
|
|
17551
|
+
}
|
|
17552
|
+
} else if (c === "{") {
|
|
17553
|
+
if (!this._disabled.handlebars && !this._excluded.handlebars) {
|
|
17554
|
+
resulting_string = resulting_string || this.__patterns.handlebars_comment.read();
|
|
17555
|
+
resulting_string = resulting_string || this.__patterns.handlebars_unescaped.read();
|
|
17556
|
+
resulting_string = resulting_string || this.__patterns.handlebars.read();
|
|
17557
|
+
}
|
|
17558
|
+
if (!this._disabled.django) {
|
|
17559
|
+
if (!this._excluded.django && !this._excluded.handlebars) {
|
|
17560
|
+
resulting_string = resulting_string || this.__patterns.django_value.read();
|
|
17561
|
+
}
|
|
17562
|
+
if (!this._excluded.django) {
|
|
17563
|
+
resulting_string = resulting_string || this.__patterns.django_comment.read();
|
|
17564
|
+
resulting_string = resulting_string || this.__patterns.django.read();
|
|
17565
|
+
}
|
|
17566
|
+
}
|
|
17567
|
+
if (!this._disabled.smarty) {
|
|
17568
|
+
if (this._disabled.django && this._disabled.handlebars) {
|
|
17569
|
+
resulting_string = resulting_string || this.__patterns.smarty_comment.read();
|
|
17570
|
+
resulting_string = resulting_string || this.__patterns.smarty_literal.read();
|
|
17571
|
+
resulting_string = resulting_string || this.__patterns.smarty.read();
|
|
17572
|
+
}
|
|
17573
|
+
}
|
|
17574
|
+
}
|
|
17575
|
+
return resulting_string;
|
|
17576
|
+
};
|
|
17577
|
+
module.exports.TemplatablePattern = TemplatablePattern;
|
|
17578
|
+
}
|
|
17579
|
+
});
|
|
17580
|
+
|
|
17581
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/tokenizer.js
|
|
17582
|
+
var require_tokenizer2 = __commonJS({
|
|
17583
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/tokenizer.js"(exports, module) {
|
|
17584
|
+
init_define_process();
|
|
17585
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
17586
|
+
var BaseTokenizer = require_tokenizer().Tokenizer;
|
|
17587
|
+
var BASETOKEN = require_tokenizer().TOKEN;
|
|
17588
|
+
var Directives = require_directives().Directives;
|
|
17589
|
+
var acorn = require_acorn();
|
|
17590
|
+
var Pattern = require_pattern().Pattern;
|
|
17591
|
+
var TemplatablePattern = require_templatablepattern().TemplatablePattern;
|
|
17592
|
+
function in_array(what, arr) {
|
|
17593
|
+
return arr.indexOf(what) !== -1;
|
|
17594
|
+
}
|
|
17595
|
+
var TOKEN = {
|
|
17596
|
+
START_EXPR: "TK_START_EXPR",
|
|
17597
|
+
END_EXPR: "TK_END_EXPR",
|
|
17598
|
+
START_BLOCK: "TK_START_BLOCK",
|
|
17599
|
+
END_BLOCK: "TK_END_BLOCK",
|
|
17600
|
+
WORD: "TK_WORD",
|
|
17601
|
+
RESERVED: "TK_RESERVED",
|
|
17602
|
+
SEMICOLON: "TK_SEMICOLON",
|
|
17603
|
+
STRING: "TK_STRING",
|
|
17604
|
+
EQUALS: "TK_EQUALS",
|
|
17605
|
+
OPERATOR: "TK_OPERATOR",
|
|
17606
|
+
COMMA: "TK_COMMA",
|
|
17607
|
+
BLOCK_COMMENT: "TK_BLOCK_COMMENT",
|
|
17608
|
+
COMMENT: "TK_COMMENT",
|
|
17609
|
+
DOT: "TK_DOT",
|
|
17610
|
+
UNKNOWN: "TK_UNKNOWN",
|
|
17611
|
+
START: BASETOKEN.START,
|
|
17612
|
+
RAW: BASETOKEN.RAW,
|
|
17613
|
+
EOF: BASETOKEN.EOF
|
|
17614
|
+
};
|
|
17615
|
+
var directives_core = new Directives(/\/\*/, /\*\//);
|
|
17616
|
+
var number_pattern = /0[xX][0123456789abcdefABCDEF_]*n?|0[oO][01234567_]*n?|0[bB][01_]*n?|\d[\d_]*n|(?:\.\d[\d_]*|\d[\d_]*\.?[\d_]*)(?:[eE][+-]?[\d_]+)?/;
|
|
17617
|
+
var digit = /[0-9]/;
|
|
17618
|
+
var dot_pattern = /[^\d\.]/;
|
|
17619
|
+
var positionable_operators = ">>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" ");
|
|
17620
|
+
var punct = ">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |";
|
|
17621
|
+
punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
|
|
17622
|
+
punct = "\\?\\.(?!\\d) " + punct;
|
|
17623
|
+
punct = punct.replace(/ /g, "|");
|
|
17624
|
+
var punct_pattern = new RegExp(punct);
|
|
17625
|
+
var line_starters = "continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(",");
|
|
17626
|
+
var reserved_words = line_starters.concat(["do", "in", "of", "else", "get", "set", "new", "catch", "finally", "typeof", "yield", "async", "await", "from", "as", "class", "extends"]);
|
|
17627
|
+
var reserved_word_pattern = new RegExp("^(?:" + reserved_words.join("|") + ")$");
|
|
17628
|
+
var in_html_comment;
|
|
17629
|
+
var Tokenizer = function(input_string, options) {
|
|
17630
|
+
BaseTokenizer.call(this, input_string, options);
|
|
17631
|
+
this._patterns.whitespace = this._patterns.whitespace.matching(
|
|
17632
|
+
/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
|
|
17633
|
+
/\u2028\u2029/.source
|
|
17634
|
+
);
|
|
17635
|
+
var pattern_reader = new Pattern(this._input);
|
|
17636
|
+
var templatable = new TemplatablePattern(this._input).read_options(this._options);
|
|
17637
|
+
this.__patterns = {
|
|
17638
|
+
template: templatable,
|
|
17639
|
+
identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
|
|
17640
|
+
number: pattern_reader.matching(number_pattern),
|
|
17641
|
+
punct: pattern_reader.matching(punct_pattern),
|
|
17642
|
+
// comment ends just before nearest linefeed or end of file
|
|
17643
|
+
comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
|
|
17644
|
+
// /* ... */ comment ends with nearest */ or end of file
|
|
17645
|
+
block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
|
|
17646
|
+
html_comment_start: pattern_reader.matching(/<!--/),
|
|
17647
|
+
html_comment_end: pattern_reader.matching(/-->/),
|
|
17648
|
+
include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
|
|
17649
|
+
shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
|
|
17650
|
+
xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/),
|
|
17651
|
+
single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
|
|
17652
|
+
double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
|
|
17653
|
+
template_text: templatable.until(/[`\\$]/),
|
|
17654
|
+
template_expression: templatable.until(/[`}\\]/)
|
|
17655
|
+
};
|
|
17656
|
+
};
|
|
17657
|
+
Tokenizer.prototype = new BaseTokenizer();
|
|
17658
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
17659
|
+
return current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.BLOCK_COMMENT || current_token.type === TOKEN.UNKNOWN;
|
|
17660
|
+
};
|
|
17661
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
17662
|
+
return current_token.type === TOKEN.START_BLOCK || current_token.type === TOKEN.START_EXPR;
|
|
17663
|
+
};
|
|
17664
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
17665
|
+
return (current_token.type === TOKEN.END_BLOCK || current_token.type === TOKEN.END_EXPR) && (open_token && (current_token.text === "]" && open_token.text === "[" || current_token.text === ")" && open_token.text === "(" || current_token.text === "}" && open_token.text === "{"));
|
|
17666
|
+
};
|
|
17667
|
+
Tokenizer.prototype._reset = function() {
|
|
17668
|
+
in_html_comment = false;
|
|
17669
|
+
};
|
|
17670
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
17671
|
+
var token = null;
|
|
17672
|
+
this._readWhitespace();
|
|
17673
|
+
var c = this._input.peek();
|
|
17674
|
+
if (c === null) {
|
|
17675
|
+
return this._create_token(TOKEN.EOF, "");
|
|
17676
|
+
}
|
|
17677
|
+
token = token || this._read_non_javascript(c);
|
|
17678
|
+
token = token || this._read_string(c);
|
|
17679
|
+
token = token || this._read_word(previous_token);
|
|
17680
|
+
token = token || this._read_singles(c);
|
|
17681
|
+
token = token || this._read_comment(c);
|
|
17682
|
+
token = token || this._read_regexp(c, previous_token);
|
|
17683
|
+
token = token || this._read_xml(c, previous_token);
|
|
17684
|
+
token = token || this._read_punctuation();
|
|
17685
|
+
token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
|
|
17686
|
+
return token;
|
|
17687
|
+
};
|
|
17688
|
+
Tokenizer.prototype._read_word = function(previous_token) {
|
|
17689
|
+
var resulting_string;
|
|
17690
|
+
resulting_string = this.__patterns.identifier.read();
|
|
17691
|
+
if (resulting_string !== "") {
|
|
17692
|
+
resulting_string = resulting_string.replace(acorn.allLineBreaks, "\n");
|
|
17693
|
+
if (!(previous_token.type === TOKEN.DOT || previous_token.type === TOKEN.RESERVED && (previous_token.text === "set" || previous_token.text === "get")) && reserved_word_pattern.test(resulting_string)) {
|
|
17694
|
+
if ((resulting_string === "in" || resulting_string === "of") && (previous_token.type === TOKEN.WORD || previous_token.type === TOKEN.STRING)) {
|
|
17695
|
+
return this._create_token(TOKEN.OPERATOR, resulting_string);
|
|
17696
|
+
}
|
|
17697
|
+
return this._create_token(TOKEN.RESERVED, resulting_string);
|
|
17698
|
+
}
|
|
17699
|
+
return this._create_token(TOKEN.WORD, resulting_string);
|
|
17700
|
+
}
|
|
17701
|
+
resulting_string = this.__patterns.number.read();
|
|
17702
|
+
if (resulting_string !== "") {
|
|
17703
|
+
return this._create_token(TOKEN.WORD, resulting_string);
|
|
17704
|
+
}
|
|
17705
|
+
};
|
|
17706
|
+
Tokenizer.prototype._read_singles = function(c) {
|
|
17707
|
+
var token = null;
|
|
17708
|
+
if (c === "(" || c === "[") {
|
|
17709
|
+
token = this._create_token(TOKEN.START_EXPR, c);
|
|
17710
|
+
} else if (c === ")" || c === "]") {
|
|
17711
|
+
token = this._create_token(TOKEN.END_EXPR, c);
|
|
17712
|
+
} else if (c === "{") {
|
|
17713
|
+
token = this._create_token(TOKEN.START_BLOCK, c);
|
|
17714
|
+
} else if (c === "}") {
|
|
17715
|
+
token = this._create_token(TOKEN.END_BLOCK, c);
|
|
17716
|
+
} else if (c === ";") {
|
|
17717
|
+
token = this._create_token(TOKEN.SEMICOLON, c);
|
|
17718
|
+
} else if (c === "." && dot_pattern.test(this._input.peek(1))) {
|
|
17719
|
+
token = this._create_token(TOKEN.DOT, c);
|
|
17720
|
+
} else if (c === ",") {
|
|
17721
|
+
token = this._create_token(TOKEN.COMMA, c);
|
|
17722
|
+
}
|
|
17723
|
+
if (token) {
|
|
17724
|
+
this._input.next();
|
|
17725
|
+
}
|
|
17726
|
+
return token;
|
|
17727
|
+
};
|
|
17728
|
+
Tokenizer.prototype._read_punctuation = function() {
|
|
17729
|
+
var resulting_string = this.__patterns.punct.read();
|
|
17730
|
+
if (resulting_string !== "") {
|
|
17731
|
+
if (resulting_string === "=") {
|
|
17732
|
+
return this._create_token(TOKEN.EQUALS, resulting_string);
|
|
17733
|
+
} else if (resulting_string === "?.") {
|
|
17734
|
+
return this._create_token(TOKEN.DOT, resulting_string);
|
|
17735
|
+
} else {
|
|
17736
|
+
return this._create_token(TOKEN.OPERATOR, resulting_string);
|
|
17737
|
+
}
|
|
17738
|
+
}
|
|
17739
|
+
};
|
|
17740
|
+
Tokenizer.prototype._read_non_javascript = function(c) {
|
|
17741
|
+
var resulting_string = "";
|
|
17742
|
+
if (c === "#") {
|
|
17743
|
+
if (this._is_first_token()) {
|
|
17744
|
+
resulting_string = this.__patterns.shebang.read();
|
|
17745
|
+
if (resulting_string) {
|
|
17746
|
+
return this._create_token(TOKEN.UNKNOWN, resulting_string.trim() + "\n");
|
|
17747
|
+
}
|
|
17748
|
+
}
|
|
17749
|
+
resulting_string = this.__patterns.include.read();
|
|
17750
|
+
if (resulting_string) {
|
|
17751
|
+
return this._create_token(TOKEN.UNKNOWN, resulting_string.trim() + "\n");
|
|
17752
|
+
}
|
|
17753
|
+
c = this._input.next();
|
|
17754
|
+
var sharp = "#";
|
|
17755
|
+
if (this._input.hasNext() && this._input.testChar(digit)) {
|
|
17756
|
+
do {
|
|
17757
|
+
c = this._input.next();
|
|
17758
|
+
sharp += c;
|
|
17759
|
+
} while (this._input.hasNext() && c !== "#" && c !== "=");
|
|
17760
|
+
if (c === "#") ; else if (this._input.peek() === "[" && this._input.peek(1) === "]") {
|
|
17761
|
+
sharp += "[]";
|
|
17762
|
+
this._input.next();
|
|
17763
|
+
this._input.next();
|
|
17764
|
+
} else if (this._input.peek() === "{" && this._input.peek(1) === "}") {
|
|
17765
|
+
sharp += "{}";
|
|
17766
|
+
this._input.next();
|
|
17767
|
+
this._input.next();
|
|
17768
|
+
}
|
|
17769
|
+
return this._create_token(TOKEN.WORD, sharp);
|
|
17770
|
+
}
|
|
17771
|
+
this._input.back();
|
|
17772
|
+
} else if (c === "<" && this._is_first_token()) {
|
|
17773
|
+
resulting_string = this.__patterns.html_comment_start.read();
|
|
17774
|
+
if (resulting_string) {
|
|
17775
|
+
while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
|
|
17776
|
+
resulting_string += this._input.next();
|
|
17777
|
+
}
|
|
17778
|
+
in_html_comment = true;
|
|
17779
|
+
return this._create_token(TOKEN.COMMENT, resulting_string);
|
|
17780
|
+
}
|
|
17781
|
+
} else if (in_html_comment && c === "-") {
|
|
17782
|
+
resulting_string = this.__patterns.html_comment_end.read();
|
|
17783
|
+
if (resulting_string) {
|
|
17784
|
+
in_html_comment = false;
|
|
17785
|
+
return this._create_token(TOKEN.COMMENT, resulting_string);
|
|
17786
|
+
}
|
|
17787
|
+
}
|
|
17788
|
+
return null;
|
|
17789
|
+
};
|
|
17790
|
+
Tokenizer.prototype._read_comment = function(c) {
|
|
17791
|
+
var token = null;
|
|
17792
|
+
if (c === "/") {
|
|
17793
|
+
var comment = "";
|
|
17794
|
+
if (this._input.peek(1) === "*") {
|
|
17795
|
+
comment = this.__patterns.block_comment.read();
|
|
17796
|
+
var directives = directives_core.get_directives(comment);
|
|
17797
|
+
if (directives && directives.ignore === "start") {
|
|
17798
|
+
comment += directives_core.readIgnored(this._input);
|
|
17799
|
+
}
|
|
17800
|
+
comment = comment.replace(acorn.allLineBreaks, "\n");
|
|
17801
|
+
token = this._create_token(TOKEN.BLOCK_COMMENT, comment);
|
|
17802
|
+
token.directives = directives;
|
|
17803
|
+
} else if (this._input.peek(1) === "/") {
|
|
17804
|
+
comment = this.__patterns.comment.read();
|
|
17805
|
+
token = this._create_token(TOKEN.COMMENT, comment);
|
|
17806
|
+
}
|
|
17807
|
+
}
|
|
17808
|
+
return token;
|
|
17809
|
+
};
|
|
17810
|
+
Tokenizer.prototype._read_string = function(c) {
|
|
17811
|
+
if (c === "`" || c === "'" || c === '"') {
|
|
17812
|
+
var resulting_string = this._input.next();
|
|
17813
|
+
this.has_char_escapes = false;
|
|
17814
|
+
if (c === "`") {
|
|
17815
|
+
resulting_string += this._read_string_recursive("`", true, "${");
|
|
17816
|
+
} else {
|
|
17817
|
+
resulting_string += this._read_string_recursive(c);
|
|
17818
|
+
}
|
|
17819
|
+
if (this.has_char_escapes && this._options.unescape_strings) {
|
|
17820
|
+
resulting_string = unescape_string(resulting_string);
|
|
17821
|
+
}
|
|
17822
|
+
if (this._input.peek() === c) {
|
|
17823
|
+
resulting_string += this._input.next();
|
|
17824
|
+
}
|
|
17825
|
+
resulting_string = resulting_string.replace(acorn.allLineBreaks, "\n");
|
|
17826
|
+
return this._create_token(TOKEN.STRING, resulting_string);
|
|
17827
|
+
}
|
|
17828
|
+
return null;
|
|
17829
|
+
};
|
|
17830
|
+
Tokenizer.prototype._allow_regexp_or_xml = function(previous_token) {
|
|
17831
|
+
return previous_token.type === TOKEN.RESERVED && in_array(previous_token.text, ["return", "case", "throw", "else", "do", "typeof", "yield"]) || previous_token.type === TOKEN.END_EXPR && previous_token.text === ")" && previous_token.opened.previous.type === TOKEN.RESERVED && in_array(previous_token.opened.previous.text, ["if", "while", "for"]) || in_array(previous_token.type, [
|
|
17832
|
+
TOKEN.COMMENT,
|
|
17833
|
+
TOKEN.START_EXPR,
|
|
17834
|
+
TOKEN.START_BLOCK,
|
|
17835
|
+
TOKEN.START,
|
|
17836
|
+
TOKEN.END_BLOCK,
|
|
17837
|
+
TOKEN.OPERATOR,
|
|
17838
|
+
TOKEN.EQUALS,
|
|
17839
|
+
TOKEN.EOF,
|
|
17840
|
+
TOKEN.SEMICOLON,
|
|
17841
|
+
TOKEN.COMMA
|
|
17842
|
+
]);
|
|
17843
|
+
};
|
|
17844
|
+
Tokenizer.prototype._read_regexp = function(c, previous_token) {
|
|
17845
|
+
if (c === "/" && this._allow_regexp_or_xml(previous_token)) {
|
|
17846
|
+
var resulting_string = this._input.next();
|
|
17847
|
+
var esc = false;
|
|
17848
|
+
var in_char_class = false;
|
|
17849
|
+
while (this._input.hasNext() && ((esc || in_char_class || this._input.peek() !== c) && !this._input.testChar(acorn.newline))) {
|
|
17850
|
+
resulting_string += this._input.peek();
|
|
17851
|
+
if (!esc) {
|
|
17852
|
+
esc = this._input.peek() === "\\";
|
|
17853
|
+
if (this._input.peek() === "[") {
|
|
17854
|
+
in_char_class = true;
|
|
17855
|
+
} else if (this._input.peek() === "]") {
|
|
17856
|
+
in_char_class = false;
|
|
17857
|
+
}
|
|
17858
|
+
} else {
|
|
17859
|
+
esc = false;
|
|
17860
|
+
}
|
|
17861
|
+
this._input.next();
|
|
17862
|
+
}
|
|
17863
|
+
if (this._input.peek() === c) {
|
|
17864
|
+
resulting_string += this._input.next();
|
|
17865
|
+
resulting_string += this._input.read(acorn.identifier);
|
|
17866
|
+
}
|
|
17867
|
+
return this._create_token(TOKEN.STRING, resulting_string);
|
|
17868
|
+
}
|
|
17869
|
+
return null;
|
|
17870
|
+
};
|
|
17871
|
+
Tokenizer.prototype._read_xml = function(c, previous_token) {
|
|
17872
|
+
if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
|
|
17873
|
+
var xmlStr = "";
|
|
17874
|
+
var match = this.__patterns.xml.read_match();
|
|
17875
|
+
if (match) {
|
|
17876
|
+
var rootTag = match[2].replace(/^{\s+/, "{").replace(/\s+}$/, "}");
|
|
17877
|
+
var isCurlyRoot = rootTag.indexOf("{") === 0;
|
|
17878
|
+
var depth = 0;
|
|
17879
|
+
while (match) {
|
|
17880
|
+
var isEndTag = !!match[1];
|
|
17881
|
+
var tagName = match[2];
|
|
17882
|
+
var isSingletonTag = !!match[match.length - 1] || tagName.slice(0, 8) === "![CDATA[";
|
|
17883
|
+
if (!isSingletonTag && (tagName === rootTag || isCurlyRoot && tagName.replace(/^{\s+/, "{").replace(/\s+}$/, "}"))) {
|
|
17884
|
+
if (isEndTag) {
|
|
17885
|
+
--depth;
|
|
17886
|
+
} else {
|
|
17887
|
+
++depth;
|
|
17888
|
+
}
|
|
17889
|
+
}
|
|
17890
|
+
xmlStr += match[0];
|
|
17891
|
+
if (depth <= 0) {
|
|
17892
|
+
break;
|
|
17893
|
+
}
|
|
17894
|
+
match = this.__patterns.xml.read_match();
|
|
17895
|
+
}
|
|
17896
|
+
if (!match) {
|
|
17897
|
+
xmlStr += this._input.match(/[\s\S]*/g)[0];
|
|
17898
|
+
}
|
|
17899
|
+
xmlStr = xmlStr.replace(acorn.allLineBreaks, "\n");
|
|
17900
|
+
return this._create_token(TOKEN.STRING, xmlStr);
|
|
17901
|
+
}
|
|
17902
|
+
}
|
|
17903
|
+
return null;
|
|
17904
|
+
};
|
|
17905
|
+
function unescape_string(s) {
|
|
17906
|
+
var out = "", escaped = 0;
|
|
17907
|
+
var input_scan = new InputScanner(s);
|
|
17908
|
+
var matched = null;
|
|
17909
|
+
while (input_scan.hasNext()) {
|
|
17910
|
+
matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
|
|
17911
|
+
if (matched) {
|
|
17912
|
+
out += matched[0];
|
|
17913
|
+
}
|
|
17914
|
+
if (input_scan.peek() === "\\") {
|
|
17915
|
+
input_scan.next();
|
|
17916
|
+
if (input_scan.peek() === "x") {
|
|
17917
|
+
matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
|
|
17918
|
+
} else if (input_scan.peek() === "u") {
|
|
17919
|
+
matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
|
|
17920
|
+
} else {
|
|
17921
|
+
out += "\\";
|
|
17922
|
+
if (input_scan.hasNext()) {
|
|
17923
|
+
out += input_scan.next();
|
|
17924
|
+
}
|
|
17925
|
+
continue;
|
|
17926
|
+
}
|
|
17927
|
+
if (!matched) {
|
|
17928
|
+
return s;
|
|
17929
|
+
}
|
|
17930
|
+
escaped = parseInt(matched[1], 16);
|
|
17931
|
+
if (escaped > 126 && escaped <= 255 && matched[0].indexOf("x") === 0) {
|
|
17932
|
+
return s;
|
|
17933
|
+
} else if (escaped >= 0 && escaped < 32) {
|
|
17934
|
+
out += "\\" + matched[0];
|
|
17935
|
+
continue;
|
|
17936
|
+
} else if (escaped === 34 || escaped === 39 || escaped === 92) {
|
|
17937
|
+
out += "\\" + String.fromCharCode(escaped);
|
|
17938
|
+
} else {
|
|
17939
|
+
out += String.fromCharCode(escaped);
|
|
17940
|
+
}
|
|
17941
|
+
}
|
|
17942
|
+
}
|
|
17943
|
+
return out;
|
|
17944
|
+
}
|
|
17945
|
+
Tokenizer.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
|
|
17946
|
+
var current_char;
|
|
17947
|
+
var pattern;
|
|
17948
|
+
if (delimiter === "'") {
|
|
17949
|
+
pattern = this.__patterns.single_quote;
|
|
17950
|
+
} else if (delimiter === '"') {
|
|
17951
|
+
pattern = this.__patterns.double_quote;
|
|
17952
|
+
} else if (delimiter === "`") {
|
|
17953
|
+
pattern = this.__patterns.template_text;
|
|
17954
|
+
} else if (delimiter === "}") {
|
|
17955
|
+
pattern = this.__patterns.template_expression;
|
|
17956
|
+
}
|
|
17957
|
+
var resulting_string = pattern.read();
|
|
17958
|
+
var next = "";
|
|
17959
|
+
while (this._input.hasNext()) {
|
|
17960
|
+
next = this._input.next();
|
|
17961
|
+
if (next === delimiter || !allow_unescaped_newlines && acorn.newline.test(next)) {
|
|
17962
|
+
this._input.back();
|
|
17963
|
+
break;
|
|
17964
|
+
} else if (next === "\\" && this._input.hasNext()) {
|
|
17965
|
+
current_char = this._input.peek();
|
|
17966
|
+
if (current_char === "x" || current_char === "u") {
|
|
17967
|
+
this.has_char_escapes = true;
|
|
17968
|
+
} else if (current_char === "\r" && this._input.peek(1) === "\n") {
|
|
17969
|
+
this._input.next();
|
|
17970
|
+
}
|
|
17971
|
+
next += this._input.next();
|
|
17972
|
+
} else if (start_sub) {
|
|
17973
|
+
if (start_sub === "${" && next === "$" && this._input.peek() === "{") {
|
|
17974
|
+
next += this._input.next();
|
|
17975
|
+
}
|
|
17976
|
+
if (start_sub === next) {
|
|
17977
|
+
if (delimiter === "`") {
|
|
17978
|
+
next += this._read_string_recursive("}", allow_unescaped_newlines, "`");
|
|
17979
|
+
} else {
|
|
17980
|
+
next += this._read_string_recursive("`", allow_unescaped_newlines, "${");
|
|
17981
|
+
}
|
|
17982
|
+
if (this._input.hasNext()) {
|
|
17983
|
+
next += this._input.next();
|
|
17984
|
+
}
|
|
17985
|
+
}
|
|
17986
|
+
}
|
|
17987
|
+
next += pattern.read();
|
|
17988
|
+
resulting_string += next;
|
|
17989
|
+
}
|
|
17990
|
+
return resulting_string;
|
|
17991
|
+
};
|
|
17992
|
+
module.exports.Tokenizer = Tokenizer;
|
|
17993
|
+
module.exports.TOKEN = TOKEN;
|
|
17994
|
+
module.exports.positionable_operators = positionable_operators.slice();
|
|
17995
|
+
module.exports.line_starters = line_starters.slice();
|
|
17996
|
+
}
|
|
17997
|
+
});
|
|
17998
|
+
|
|
17999
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/beautifier.js
|
|
18000
|
+
var require_beautifier = __commonJS({
|
|
18001
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/beautifier.js"(exports, module) {
|
|
18002
|
+
init_define_process();
|
|
18003
|
+
var Output = require_output().Output;
|
|
18004
|
+
var Token = require_token().Token;
|
|
18005
|
+
var acorn = require_acorn();
|
|
18006
|
+
var Options = require_options2().Options;
|
|
18007
|
+
var Tokenizer = require_tokenizer2().Tokenizer;
|
|
18008
|
+
var line_starters = require_tokenizer2().line_starters;
|
|
18009
|
+
var positionable_operators = require_tokenizer2().positionable_operators;
|
|
18010
|
+
var TOKEN = require_tokenizer2().TOKEN;
|
|
18011
|
+
function in_array(what, arr) {
|
|
18012
|
+
return arr.indexOf(what) !== -1;
|
|
18013
|
+
}
|
|
18014
|
+
function ltrim(s) {
|
|
18015
|
+
return s.replace(/^\s+/g, "");
|
|
18016
|
+
}
|
|
18017
|
+
function generateMapFromStrings(list) {
|
|
18018
|
+
var result = {};
|
|
18019
|
+
for (var x = 0; x < list.length; x++) {
|
|
18020
|
+
result[list[x].replace(/-/g, "_")] = list[x];
|
|
18021
|
+
}
|
|
18022
|
+
return result;
|
|
18023
|
+
}
|
|
18024
|
+
function reserved_word(token, word) {
|
|
18025
|
+
return token && token.type === TOKEN.RESERVED && token.text === word;
|
|
18026
|
+
}
|
|
18027
|
+
function reserved_array(token, words) {
|
|
18028
|
+
return token && token.type === TOKEN.RESERVED && in_array(token.text, words);
|
|
18029
|
+
}
|
|
18030
|
+
var special_words = ["case", "return", "do", "if", "throw", "else", "await", "break", "continue", "async"];
|
|
18031
|
+
var validPositionValues = ["before-newline", "after-newline", "preserve-newline"];
|
|
18032
|
+
var OPERATOR_POSITION = generateMapFromStrings(validPositionValues);
|
|
18033
|
+
var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
|
|
18034
|
+
var MODE = {
|
|
18035
|
+
BlockStatement: "BlockStatement",
|
|
18036
|
+
// 'BLOCK'
|
|
18037
|
+
Statement: "Statement",
|
|
18038
|
+
// 'STATEMENT'
|
|
18039
|
+
ObjectLiteral: "ObjectLiteral",
|
|
18040
|
+
// 'OBJECT',
|
|
18041
|
+
ArrayLiteral: "ArrayLiteral",
|
|
18042
|
+
//'[EXPRESSION]',
|
|
18043
|
+
ForInitializer: "ForInitializer",
|
|
18044
|
+
//'(FOR-EXPRESSION)',
|
|
18045
|
+
Conditional: "Conditional",
|
|
18046
|
+
//'(COND-EXPRESSION)',
|
|
18047
|
+
Expression: "Expression"
|
|
18048
|
+
//'(EXPRESSION)'
|
|
18049
|
+
};
|
|
18050
|
+
function remove_redundant_indentation(output, frame) {
|
|
18051
|
+
if (frame.multiline_frame || frame.mode === MODE.ForInitializer || frame.mode === MODE.Conditional) {
|
|
18052
|
+
return;
|
|
18053
|
+
}
|
|
18054
|
+
output.remove_indent(frame.start_line_index);
|
|
18055
|
+
}
|
|
18056
|
+
function split_linebreaks(s) {
|
|
18057
|
+
s = s.replace(acorn.allLineBreaks, "\n");
|
|
18058
|
+
var out = [], idx = s.indexOf("\n");
|
|
18059
|
+
while (idx !== -1) {
|
|
18060
|
+
out.push(s.substring(0, idx));
|
|
18061
|
+
s = s.substring(idx + 1);
|
|
18062
|
+
idx = s.indexOf("\n");
|
|
18063
|
+
}
|
|
18064
|
+
if (s.length) {
|
|
18065
|
+
out.push(s);
|
|
18066
|
+
}
|
|
18067
|
+
return out;
|
|
18068
|
+
}
|
|
18069
|
+
function is_array(mode) {
|
|
18070
|
+
return mode === MODE.ArrayLiteral;
|
|
18071
|
+
}
|
|
18072
|
+
function is_expression(mode) {
|
|
18073
|
+
return in_array(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
|
|
18074
|
+
}
|
|
18075
|
+
function all_lines_start_with(lines, c) {
|
|
18076
|
+
for (var i = 0; i < lines.length; i++) {
|
|
18077
|
+
var line = lines[i].trim();
|
|
18078
|
+
if (line.charAt(0) !== c) {
|
|
18079
|
+
return false;
|
|
18080
|
+
}
|
|
18081
|
+
}
|
|
18082
|
+
return true;
|
|
18083
|
+
}
|
|
18084
|
+
function each_line_matches_indent(lines, indent) {
|
|
18085
|
+
var i = 0, len = lines.length, line;
|
|
18086
|
+
for (; i < len; i++) {
|
|
18087
|
+
line = lines[i];
|
|
18088
|
+
if (line && line.indexOf(indent) !== 0) {
|
|
18089
|
+
return false;
|
|
18090
|
+
}
|
|
18091
|
+
}
|
|
18092
|
+
return true;
|
|
18093
|
+
}
|
|
18094
|
+
function Beautifier(source_text, options) {
|
|
18095
|
+
options = options || {};
|
|
18096
|
+
this._source_text = source_text || "";
|
|
18097
|
+
this._output = null;
|
|
18098
|
+
this._tokens = null;
|
|
18099
|
+
this._last_last_text = null;
|
|
18100
|
+
this._flags = null;
|
|
18101
|
+
this._previous_flags = null;
|
|
18102
|
+
this._flag_store = null;
|
|
18103
|
+
this._options = new Options(options);
|
|
18104
|
+
}
|
|
18105
|
+
Beautifier.prototype.create_flags = function(flags_base, mode) {
|
|
18106
|
+
var next_indent_level = 0;
|
|
18107
|
+
if (flags_base) {
|
|
18108
|
+
next_indent_level = flags_base.indentation_level;
|
|
18109
|
+
if (!this._output.just_added_newline() && flags_base.line_indent_level > next_indent_level) {
|
|
18110
|
+
next_indent_level = flags_base.line_indent_level;
|
|
18111
|
+
}
|
|
18112
|
+
}
|
|
18113
|
+
var next_flags = {
|
|
18114
|
+
mode,
|
|
18115
|
+
parent: flags_base,
|
|
18116
|
+
last_token: flags_base ? flags_base.last_token : new Token(TOKEN.START_BLOCK, ""),
|
|
18117
|
+
// last token text
|
|
18118
|
+
last_word: flags_base ? flags_base.last_word : "",
|
|
18119
|
+
// last TOKEN.WORD passed
|
|
18120
|
+
declaration_statement: false,
|
|
18121
|
+
declaration_assignment: false,
|
|
18122
|
+
multiline_frame: false,
|
|
18123
|
+
inline_frame: false,
|
|
18124
|
+
if_block: false,
|
|
18125
|
+
else_block: false,
|
|
18126
|
+
class_start_block: false,
|
|
18127
|
+
// class A { INSIDE HERE } or class B extends C { INSIDE HERE }
|
|
18128
|
+
do_block: false,
|
|
18129
|
+
do_while: false,
|
|
18130
|
+
import_block: false,
|
|
18131
|
+
in_case_statement: false,
|
|
18132
|
+
// switch(..){ INSIDE HERE }
|
|
18133
|
+
in_case: false,
|
|
18134
|
+
// we're on the exact line with "case 0:"
|
|
18135
|
+
case_body: false,
|
|
18136
|
+
// the indented case-action block
|
|
18137
|
+
case_block: false,
|
|
18138
|
+
// the indented case-action block is wrapped with {}
|
|
18139
|
+
indentation_level: next_indent_level,
|
|
18140
|
+
alignment: 0,
|
|
18141
|
+
line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
|
|
18142
|
+
start_line_index: this._output.get_line_number(),
|
|
18143
|
+
ternary_depth: 0
|
|
18144
|
+
};
|
|
18145
|
+
return next_flags;
|
|
18146
|
+
};
|
|
18147
|
+
Beautifier.prototype._reset = function(source_text) {
|
|
18148
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
18149
|
+
this._last_last_text = "";
|
|
18150
|
+
this._output = new Output(this._options, baseIndentString);
|
|
18151
|
+
this._output.raw = this._options.test_output_raw;
|
|
18152
|
+
this._flag_store = [];
|
|
18153
|
+
this.set_mode(MODE.BlockStatement);
|
|
18154
|
+
var tokenizer = new Tokenizer(source_text, this._options);
|
|
18155
|
+
this._tokens = tokenizer.tokenize();
|
|
18156
|
+
return source_text;
|
|
18157
|
+
};
|
|
18158
|
+
Beautifier.prototype.beautify = function() {
|
|
18159
|
+
if (this._options.disabled) {
|
|
18160
|
+
return this._source_text;
|
|
18161
|
+
}
|
|
18162
|
+
var sweet_code;
|
|
18163
|
+
var source_text = this._reset(this._source_text);
|
|
18164
|
+
var eol = this._options.eol;
|
|
18165
|
+
if (this._options.eol === "auto") {
|
|
18166
|
+
eol = "\n";
|
|
18167
|
+
if (source_text && acorn.lineBreak.test(source_text || "")) {
|
|
18168
|
+
eol = source_text.match(acorn.lineBreak)[0];
|
|
18169
|
+
}
|
|
18170
|
+
}
|
|
18171
|
+
var current_token = this._tokens.next();
|
|
18172
|
+
while (current_token) {
|
|
18173
|
+
this.handle_token(current_token);
|
|
18174
|
+
this._last_last_text = this._flags.last_token.text;
|
|
18175
|
+
this._flags.last_token = current_token;
|
|
18176
|
+
current_token = this._tokens.next();
|
|
18177
|
+
}
|
|
18178
|
+
sweet_code = this._output.get_code(eol);
|
|
18179
|
+
return sweet_code;
|
|
18180
|
+
};
|
|
18181
|
+
Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
|
|
18182
|
+
if (current_token.type === TOKEN.START_EXPR) {
|
|
18183
|
+
this.handle_start_expr(current_token);
|
|
18184
|
+
} else if (current_token.type === TOKEN.END_EXPR) {
|
|
18185
|
+
this.handle_end_expr(current_token);
|
|
18186
|
+
} else if (current_token.type === TOKEN.START_BLOCK) {
|
|
18187
|
+
this.handle_start_block(current_token);
|
|
18188
|
+
} else if (current_token.type === TOKEN.END_BLOCK) {
|
|
18189
|
+
this.handle_end_block(current_token);
|
|
18190
|
+
} else if (current_token.type === TOKEN.WORD) {
|
|
18191
|
+
this.handle_word(current_token);
|
|
18192
|
+
} else if (current_token.type === TOKEN.RESERVED) {
|
|
18193
|
+
this.handle_word(current_token);
|
|
18194
|
+
} else if (current_token.type === TOKEN.SEMICOLON) {
|
|
18195
|
+
this.handle_semicolon(current_token);
|
|
18196
|
+
} else if (current_token.type === TOKEN.STRING) {
|
|
18197
|
+
this.handle_string(current_token);
|
|
18198
|
+
} else if (current_token.type === TOKEN.EQUALS) {
|
|
18199
|
+
this.handle_equals(current_token);
|
|
18200
|
+
} else if (current_token.type === TOKEN.OPERATOR) {
|
|
18201
|
+
this.handle_operator(current_token);
|
|
18202
|
+
} else if (current_token.type === TOKEN.COMMA) {
|
|
18203
|
+
this.handle_comma(current_token);
|
|
18204
|
+
} else if (current_token.type === TOKEN.BLOCK_COMMENT) {
|
|
18205
|
+
this.handle_block_comment(current_token, preserve_statement_flags);
|
|
18206
|
+
} else if (current_token.type === TOKEN.COMMENT) {
|
|
18207
|
+
this.handle_comment(current_token, preserve_statement_flags);
|
|
18208
|
+
} else if (current_token.type === TOKEN.DOT) {
|
|
18209
|
+
this.handle_dot(current_token);
|
|
18210
|
+
} else if (current_token.type === TOKEN.EOF) {
|
|
18211
|
+
this.handle_eof(current_token);
|
|
18212
|
+
} else if (current_token.type === TOKEN.UNKNOWN) {
|
|
18213
|
+
this.handle_unknown(current_token, preserve_statement_flags);
|
|
18214
|
+
} else {
|
|
18215
|
+
this.handle_unknown(current_token, preserve_statement_flags);
|
|
18216
|
+
}
|
|
18217
|
+
};
|
|
18218
|
+
Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
|
|
18219
|
+
var newlines = current_token.newlines;
|
|
18220
|
+
var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
|
|
18221
|
+
if (current_token.comments_before) {
|
|
18222
|
+
var comment_token = current_token.comments_before.next();
|
|
18223
|
+
while (comment_token) {
|
|
18224
|
+
this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
|
|
18225
|
+
this.handle_token(comment_token, preserve_statement_flags);
|
|
18226
|
+
comment_token = current_token.comments_before.next();
|
|
18227
|
+
}
|
|
18228
|
+
}
|
|
18229
|
+
if (keep_whitespace) {
|
|
18230
|
+
for (var i = 0; i < newlines; i += 1) {
|
|
18231
|
+
this.print_newline(i > 0, preserve_statement_flags);
|
|
18232
|
+
}
|
|
18233
|
+
} else {
|
|
18234
|
+
if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
|
|
18235
|
+
newlines = this._options.max_preserve_newlines;
|
|
18236
|
+
}
|
|
18237
|
+
if (this._options.preserve_newlines) {
|
|
18238
|
+
if (newlines > 1) {
|
|
18239
|
+
this.print_newline(false, preserve_statement_flags);
|
|
18240
|
+
for (var j = 1; j < newlines; j += 1) {
|
|
18241
|
+
this.print_newline(true, preserve_statement_flags);
|
|
18242
|
+
}
|
|
18243
|
+
}
|
|
18244
|
+
}
|
|
18245
|
+
}
|
|
18246
|
+
};
|
|
18247
|
+
var newline_restricted_tokens = ["async", "break", "continue", "return", "throw", "yield"];
|
|
18248
|
+
Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
|
|
18249
|
+
force_linewrap = force_linewrap === void 0 ? false : force_linewrap;
|
|
18250
|
+
if (this._output.just_added_newline()) {
|
|
18251
|
+
return;
|
|
18252
|
+
}
|
|
18253
|
+
var shouldPreserveOrForce = this._options.preserve_newlines && current_token.newlines || force_linewrap;
|
|
18254
|
+
var operatorLogicApplies = in_array(this._flags.last_token.text, positionable_operators) || in_array(current_token.text, positionable_operators);
|
|
18255
|
+
if (operatorLogicApplies) {
|
|
18256
|
+
var shouldPrintOperatorNewline = in_array(this._flags.last_token.text, positionable_operators) && in_array(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE) || in_array(current_token.text, positionable_operators);
|
|
18257
|
+
shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
|
|
18258
|
+
}
|
|
18259
|
+
if (shouldPreserveOrForce) {
|
|
18260
|
+
this.print_newline(false, true);
|
|
18261
|
+
} else if (this._options.wrap_line_length) {
|
|
18262
|
+
if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
|
|
18263
|
+
return;
|
|
18264
|
+
}
|
|
18265
|
+
this._output.set_wrap_point();
|
|
18266
|
+
}
|
|
18267
|
+
};
|
|
18268
|
+
Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
|
|
18269
|
+
if (!preserve_statement_flags) {
|
|
18270
|
+
if (this._flags.last_token.text !== ";" && this._flags.last_token.text !== "," && this._flags.last_token.text !== "=" && (this._flags.last_token.type !== TOKEN.OPERATOR || this._flags.last_token.text === "--" || this._flags.last_token.text === "++")) {
|
|
18271
|
+
var next_token = this._tokens.peek();
|
|
18272
|
+
while (this._flags.mode === MODE.Statement && !(this._flags.if_block && reserved_word(next_token, "else")) && !this._flags.do_block) {
|
|
18273
|
+
this.restore_mode();
|
|
18274
|
+
}
|
|
18275
|
+
}
|
|
18276
|
+
}
|
|
18277
|
+
if (this._output.add_new_line(force_newline)) {
|
|
18278
|
+
this._flags.multiline_frame = true;
|
|
18279
|
+
}
|
|
18280
|
+
};
|
|
18281
|
+
Beautifier.prototype.print_token_line_indentation = function(current_token) {
|
|
18282
|
+
if (this._output.just_added_newline()) {
|
|
18283
|
+
if (this._options.keep_array_indentation && current_token.newlines && (current_token.text === "[" || is_array(this._flags.mode))) {
|
|
18284
|
+
this._output.current_line.set_indent(-1);
|
|
18285
|
+
this._output.current_line.push(current_token.whitespace_before);
|
|
18286
|
+
this._output.space_before_token = false;
|
|
18287
|
+
} else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
|
|
18288
|
+
this._flags.line_indent_level = this._flags.indentation_level;
|
|
18289
|
+
}
|
|
18290
|
+
}
|
|
18291
|
+
};
|
|
18292
|
+
Beautifier.prototype.print_token = function(current_token) {
|
|
18293
|
+
if (this._output.raw) {
|
|
18294
|
+
this._output.add_raw_token(current_token);
|
|
18295
|
+
return;
|
|
18296
|
+
}
|
|
18297
|
+
if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN.COMMA && this._output.just_added_newline()) {
|
|
18298
|
+
if (this._output.previous_line.last() === ",") {
|
|
18299
|
+
var popped = this._output.previous_line.pop();
|
|
18300
|
+
if (this._output.previous_line.is_empty()) {
|
|
18301
|
+
this._output.previous_line.push(popped);
|
|
18302
|
+
this._output.trim(true);
|
|
18303
|
+
this._output.current_line.pop();
|
|
18304
|
+
this._output.trim();
|
|
18305
|
+
}
|
|
18306
|
+
this.print_token_line_indentation(current_token);
|
|
18307
|
+
this._output.add_token(",");
|
|
18308
|
+
this._output.space_before_token = true;
|
|
18309
|
+
}
|
|
18310
|
+
}
|
|
18311
|
+
this.print_token_line_indentation(current_token);
|
|
18312
|
+
this._output.non_breaking_space = true;
|
|
18313
|
+
this._output.add_token(current_token.text);
|
|
18314
|
+
if (this._output.previous_token_wrapped) {
|
|
18315
|
+
this._flags.multiline_frame = true;
|
|
18316
|
+
}
|
|
18317
|
+
};
|
|
18318
|
+
Beautifier.prototype.indent = function() {
|
|
18319
|
+
this._flags.indentation_level += 1;
|
|
18320
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
18321
|
+
};
|
|
18322
|
+
Beautifier.prototype.deindent = function() {
|
|
18323
|
+
if (this._flags.indentation_level > 0 && (!this._flags.parent || this._flags.indentation_level > this._flags.parent.indentation_level)) {
|
|
18324
|
+
this._flags.indentation_level -= 1;
|
|
18325
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
18326
|
+
}
|
|
18327
|
+
};
|
|
18328
|
+
Beautifier.prototype.set_mode = function(mode) {
|
|
18329
|
+
if (this._flags) {
|
|
18330
|
+
this._flag_store.push(this._flags);
|
|
18331
|
+
this._previous_flags = this._flags;
|
|
18332
|
+
} else {
|
|
18333
|
+
this._previous_flags = this.create_flags(null, mode);
|
|
18334
|
+
}
|
|
18335
|
+
this._flags = this.create_flags(this._previous_flags, mode);
|
|
18336
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
18337
|
+
};
|
|
18338
|
+
Beautifier.prototype.restore_mode = function() {
|
|
18339
|
+
if (this._flag_store.length > 0) {
|
|
18340
|
+
this._previous_flags = this._flags;
|
|
18341
|
+
this._flags = this._flag_store.pop();
|
|
18342
|
+
if (this._previous_flags.mode === MODE.Statement) {
|
|
18343
|
+
remove_redundant_indentation(this._output, this._previous_flags);
|
|
18344
|
+
}
|
|
18345
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
18346
|
+
}
|
|
18347
|
+
};
|
|
18348
|
+
Beautifier.prototype.start_of_object_property = function() {
|
|
18349
|
+
return this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement && (this._flags.last_token.text === ":" && this._flags.ternary_depth === 0 || reserved_array(this._flags.last_token, ["get", "set"]));
|
|
18350
|
+
};
|
|
18351
|
+
Beautifier.prototype.start_of_statement = function(current_token) {
|
|
18352
|
+
var start = false;
|
|
18353
|
+
start = start || reserved_array(this._flags.last_token, ["var", "let", "const"]) && current_token.type === TOKEN.WORD;
|
|
18354
|
+
start = start || reserved_word(this._flags.last_token, "do");
|
|
18355
|
+
start = start || !(this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement) && reserved_array(this._flags.last_token, newline_restricted_tokens) && !current_token.newlines;
|
|
18356
|
+
start = start || reserved_word(this._flags.last_token, "else") && !(reserved_word(current_token, "if") && !current_token.comments_before);
|
|
18357
|
+
start = start || this._flags.last_token.type === TOKEN.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional);
|
|
18358
|
+
start = start || this._flags.last_token.type === TOKEN.WORD && this._flags.mode === MODE.BlockStatement && !this._flags.in_case && !(current_token.text === "--" || current_token.text === "++") && this._last_last_text !== "function" && current_token.type !== TOKEN.WORD && current_token.type !== TOKEN.RESERVED;
|
|
18359
|
+
start = start || this._flags.mode === MODE.ObjectLiteral && (this._flags.last_token.text === ":" && this._flags.ternary_depth === 0 || reserved_array(this._flags.last_token, ["get", "set"]));
|
|
18360
|
+
if (start) {
|
|
18361
|
+
this.set_mode(MODE.Statement);
|
|
18362
|
+
this.indent();
|
|
18363
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
18364
|
+
if (!this.start_of_object_property()) {
|
|
18365
|
+
this.allow_wrap_or_preserved_newline(
|
|
18366
|
+
current_token,
|
|
18367
|
+
reserved_array(current_token, ["do", "for", "if", "while"])
|
|
18368
|
+
);
|
|
18369
|
+
}
|
|
18370
|
+
return true;
|
|
18371
|
+
}
|
|
18372
|
+
return false;
|
|
18373
|
+
};
|
|
18374
|
+
Beautifier.prototype.handle_start_expr = function(current_token) {
|
|
18375
|
+
if (!this.start_of_statement(current_token)) {
|
|
18376
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18377
|
+
}
|
|
18378
|
+
var next_mode = MODE.Expression;
|
|
18379
|
+
if (current_token.text === "[") {
|
|
18380
|
+
if (this._flags.last_token.type === TOKEN.WORD || this._flags.last_token.text === ")") {
|
|
18381
|
+
if (reserved_array(this._flags.last_token, line_starters)) {
|
|
18382
|
+
this._output.space_before_token = true;
|
|
18383
|
+
}
|
|
18384
|
+
this.print_token(current_token);
|
|
18385
|
+
this.set_mode(next_mode);
|
|
18386
|
+
this.indent();
|
|
18387
|
+
if (this._options.space_in_paren) {
|
|
18388
|
+
this._output.space_before_token = true;
|
|
18389
|
+
}
|
|
18390
|
+
return;
|
|
18391
|
+
}
|
|
18392
|
+
next_mode = MODE.ArrayLiteral;
|
|
18393
|
+
if (is_array(this._flags.mode)) {
|
|
18394
|
+
if (this._flags.last_token.text === "[" || this._flags.last_token.text === "," && (this._last_last_text === "]" || this._last_last_text === "}")) {
|
|
18395
|
+
if (!this._options.keep_array_indentation) {
|
|
18396
|
+
this.print_newline();
|
|
18397
|
+
}
|
|
18398
|
+
}
|
|
18399
|
+
}
|
|
18400
|
+
if (!in_array(this._flags.last_token.type, [TOKEN.START_EXPR, TOKEN.END_EXPR, TOKEN.WORD, TOKEN.OPERATOR, TOKEN.DOT])) {
|
|
18401
|
+
this._output.space_before_token = true;
|
|
18402
|
+
}
|
|
18403
|
+
} else {
|
|
18404
|
+
if (this._flags.last_token.type === TOKEN.RESERVED) {
|
|
18405
|
+
if (this._flags.last_token.text === "for") {
|
|
18406
|
+
this._output.space_before_token = this._options.space_before_conditional;
|
|
18407
|
+
next_mode = MODE.ForInitializer;
|
|
18408
|
+
} else if (in_array(this._flags.last_token.text, ["if", "while", "switch"])) {
|
|
18409
|
+
this._output.space_before_token = this._options.space_before_conditional;
|
|
18410
|
+
next_mode = MODE.Conditional;
|
|
18411
|
+
} else if (in_array(this._flags.last_word, ["await", "async"])) {
|
|
18412
|
+
this._output.space_before_token = true;
|
|
18413
|
+
} else if (this._flags.last_token.text === "import" && current_token.whitespace_before === "") {
|
|
18414
|
+
this._output.space_before_token = false;
|
|
18415
|
+
} else if (in_array(this._flags.last_token.text, line_starters) || this._flags.last_token.text === "catch") {
|
|
18416
|
+
this._output.space_before_token = true;
|
|
18417
|
+
}
|
|
18418
|
+
} else if (this._flags.last_token.type === TOKEN.EQUALS || this._flags.last_token.type === TOKEN.OPERATOR) {
|
|
18419
|
+
if (!this.start_of_object_property()) {
|
|
18420
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18421
|
+
}
|
|
18422
|
+
} else if (this._flags.last_token.type === TOKEN.WORD) {
|
|
18423
|
+
this._output.space_before_token = false;
|
|
18424
|
+
var peek_back_two = this._tokens.peek(-3);
|
|
18425
|
+
if (this._options.space_after_named_function && peek_back_two) {
|
|
18426
|
+
var peek_back_three = this._tokens.peek(-4);
|
|
18427
|
+
if (reserved_array(peek_back_two, ["async", "function"]) || peek_back_two.text === "*" && reserved_array(peek_back_three, ["async", "function"])) {
|
|
18428
|
+
this._output.space_before_token = true;
|
|
18429
|
+
} else if (this._flags.mode === MODE.ObjectLiteral) {
|
|
18430
|
+
if (peek_back_two.text === "{" || peek_back_two.text === "," || peek_back_two.text === "*" && (peek_back_three.text === "{" || peek_back_three.text === ",")) {
|
|
18431
|
+
this._output.space_before_token = true;
|
|
18432
|
+
}
|
|
18433
|
+
} else if (this._flags.parent && this._flags.parent.class_start_block) {
|
|
18434
|
+
this._output.space_before_token = true;
|
|
18435
|
+
}
|
|
18436
|
+
}
|
|
18437
|
+
} else {
|
|
18438
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18439
|
+
}
|
|
18440
|
+
if (this._flags.last_token.type === TOKEN.RESERVED && (this._flags.last_word === "function" || this._flags.last_word === "typeof") || this._flags.last_token.text === "*" && (in_array(this._last_last_text, ["function", "yield"]) || this._flags.mode === MODE.ObjectLiteral && in_array(this._last_last_text, ["{", ","]))) {
|
|
18441
|
+
this._output.space_before_token = this._options.space_after_anon_function;
|
|
18442
|
+
}
|
|
18443
|
+
}
|
|
18444
|
+
if (this._flags.last_token.text === ";" || this._flags.last_token.type === TOKEN.START_BLOCK) {
|
|
18445
|
+
this.print_newline();
|
|
18446
|
+
} else if (this._flags.last_token.type === TOKEN.END_EXPR || this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.END_BLOCK || this._flags.last_token.text === "." || this._flags.last_token.type === TOKEN.COMMA) {
|
|
18447
|
+
this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
|
|
18448
|
+
}
|
|
18449
|
+
this.print_token(current_token);
|
|
18450
|
+
this.set_mode(next_mode);
|
|
18451
|
+
if (this._options.space_in_paren) {
|
|
18452
|
+
this._output.space_before_token = true;
|
|
18453
|
+
}
|
|
18454
|
+
this.indent();
|
|
18455
|
+
};
|
|
18456
|
+
Beautifier.prototype.handle_end_expr = function(current_token) {
|
|
18457
|
+
while (this._flags.mode === MODE.Statement) {
|
|
18458
|
+
this.restore_mode();
|
|
18459
|
+
}
|
|
18460
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18461
|
+
if (this._flags.multiline_frame) {
|
|
18462
|
+
this.allow_wrap_or_preserved_newline(
|
|
18463
|
+
current_token,
|
|
18464
|
+
current_token.text === "]" && is_array(this._flags.mode) && !this._options.keep_array_indentation
|
|
18465
|
+
);
|
|
18466
|
+
}
|
|
18467
|
+
if (this._options.space_in_paren) {
|
|
18468
|
+
if (this._flags.last_token.type === TOKEN.START_EXPR && !this._options.space_in_empty_paren) {
|
|
18469
|
+
this._output.trim();
|
|
18470
|
+
this._output.space_before_token = false;
|
|
18471
|
+
} else {
|
|
18472
|
+
this._output.space_before_token = true;
|
|
18473
|
+
}
|
|
18474
|
+
}
|
|
18475
|
+
this.deindent();
|
|
18476
|
+
this.print_token(current_token);
|
|
18477
|
+
this.restore_mode();
|
|
18478
|
+
remove_redundant_indentation(this._output, this._previous_flags);
|
|
18479
|
+
if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
|
|
18480
|
+
this._previous_flags.mode = MODE.Expression;
|
|
18481
|
+
this._flags.do_block = false;
|
|
18482
|
+
this._flags.do_while = false;
|
|
18483
|
+
}
|
|
18484
|
+
};
|
|
18485
|
+
Beautifier.prototype.handle_start_block = function(current_token) {
|
|
18486
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18487
|
+
var next_token = this._tokens.peek();
|
|
18488
|
+
var second_token = this._tokens.peek(1);
|
|
18489
|
+
if (this._flags.last_word === "switch" && this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
18490
|
+
this.set_mode(MODE.BlockStatement);
|
|
18491
|
+
this._flags.in_case_statement = true;
|
|
18492
|
+
} else if (this._flags.case_body) {
|
|
18493
|
+
this.set_mode(MODE.BlockStatement);
|
|
18494
|
+
} else if (second_token && (in_array(second_token.text, [":", ","]) && in_array(next_token.type, [TOKEN.STRING, TOKEN.WORD, TOKEN.RESERVED]) || in_array(next_token.text, ["get", "set", "..."]) && in_array(second_token.type, [TOKEN.WORD, TOKEN.RESERVED]))) {
|
|
18495
|
+
if (in_array(this._last_last_text, ["class", "interface"]) && !in_array(second_token.text, [":", ","])) {
|
|
18496
|
+
this.set_mode(MODE.BlockStatement);
|
|
18497
|
+
} else {
|
|
18498
|
+
this.set_mode(MODE.ObjectLiteral);
|
|
18499
|
+
}
|
|
18500
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === "=>") {
|
|
18501
|
+
this.set_mode(MODE.BlockStatement);
|
|
18502
|
+
} else if (in_array(this._flags.last_token.type, [TOKEN.EQUALS, TOKEN.START_EXPR, TOKEN.COMMA, TOKEN.OPERATOR]) || reserved_array(this._flags.last_token, ["return", "throw", "import", "default"])) {
|
|
18503
|
+
this.set_mode(MODE.ObjectLiteral);
|
|
18504
|
+
} else {
|
|
18505
|
+
this.set_mode(MODE.BlockStatement);
|
|
18506
|
+
}
|
|
18507
|
+
if (this._flags.last_token) {
|
|
18508
|
+
if (reserved_array(this._flags.last_token.previous, ["class", "extends"])) {
|
|
18509
|
+
this._flags.class_start_block = true;
|
|
18510
|
+
}
|
|
18511
|
+
}
|
|
18512
|
+
var empty_braces = !next_token.comments_before && next_token.text === "}";
|
|
18513
|
+
var empty_anonymous_function = empty_braces && this._flags.last_word === "function" && this._flags.last_token.type === TOKEN.END_EXPR;
|
|
18514
|
+
if (this._options.brace_preserve_inline) {
|
|
18515
|
+
var index = 0;
|
|
18516
|
+
var check_token = null;
|
|
18517
|
+
this._flags.inline_frame = true;
|
|
18518
|
+
do {
|
|
18519
|
+
index += 1;
|
|
18520
|
+
check_token = this._tokens.peek(index - 1);
|
|
18521
|
+
if (check_token.newlines) {
|
|
18522
|
+
this._flags.inline_frame = false;
|
|
18523
|
+
break;
|
|
18524
|
+
}
|
|
18525
|
+
} while (check_token.type !== TOKEN.EOF && !(check_token.type === TOKEN.END_BLOCK && check_token.opened === current_token));
|
|
18526
|
+
}
|
|
18527
|
+
if ((this._options.brace_style === "expand" || this._options.brace_style === "none" && current_token.newlines) && !this._flags.inline_frame) {
|
|
18528
|
+
if (this._flags.last_token.type !== TOKEN.OPERATOR && (empty_anonymous_function || this._flags.last_token.type === TOKEN.EQUALS || reserved_array(this._flags.last_token, special_words) && this._flags.last_token.text !== "else")) {
|
|
18529
|
+
this._output.space_before_token = true;
|
|
18530
|
+
} else {
|
|
18531
|
+
this.print_newline(false, true);
|
|
18532
|
+
}
|
|
18533
|
+
} else {
|
|
18534
|
+
if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.COMMA)) {
|
|
18535
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._options.space_in_paren) {
|
|
18536
|
+
this._output.space_before_token = true;
|
|
18537
|
+
}
|
|
18538
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR && this._flags.inline_frame) {
|
|
18539
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18540
|
+
this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
|
|
18541
|
+
this._flags.multiline_frame = false;
|
|
18542
|
+
}
|
|
18543
|
+
}
|
|
18544
|
+
if (this._flags.last_token.type !== TOKEN.OPERATOR && this._flags.last_token.type !== TOKEN.START_EXPR) {
|
|
18545
|
+
if (this._flags.last_token.type === TOKEN.START_BLOCK && !this._flags.inline_frame) {
|
|
18546
|
+
this.print_newline();
|
|
18547
|
+
} else {
|
|
18548
|
+
this._output.space_before_token = true;
|
|
18549
|
+
}
|
|
18550
|
+
}
|
|
18551
|
+
}
|
|
18552
|
+
this.print_token(current_token);
|
|
18553
|
+
this.indent();
|
|
18554
|
+
if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
|
|
18555
|
+
this.print_newline();
|
|
18556
|
+
}
|
|
18557
|
+
};
|
|
18558
|
+
Beautifier.prototype.handle_end_block = function(current_token) {
|
|
18559
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18560
|
+
while (this._flags.mode === MODE.Statement) {
|
|
18561
|
+
this.restore_mode();
|
|
18562
|
+
}
|
|
18563
|
+
var empty_braces = this._flags.last_token.type === TOKEN.START_BLOCK;
|
|
18564
|
+
if (this._flags.inline_frame && !empty_braces) {
|
|
18565
|
+
this._output.space_before_token = true;
|
|
18566
|
+
} else if (this._options.brace_style === "expand") {
|
|
18567
|
+
if (!empty_braces) {
|
|
18568
|
+
this.print_newline();
|
|
18569
|
+
}
|
|
18570
|
+
} else {
|
|
18571
|
+
if (!empty_braces) {
|
|
18572
|
+
if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
|
|
18573
|
+
this._options.keep_array_indentation = false;
|
|
18574
|
+
this.print_newline();
|
|
18575
|
+
this._options.keep_array_indentation = true;
|
|
18576
|
+
} else {
|
|
18577
|
+
this.print_newline();
|
|
18578
|
+
}
|
|
18579
|
+
}
|
|
18580
|
+
}
|
|
18581
|
+
this.restore_mode();
|
|
18582
|
+
this.print_token(current_token);
|
|
18583
|
+
};
|
|
18584
|
+
Beautifier.prototype.handle_word = function(current_token) {
|
|
18585
|
+
if (current_token.type === TOKEN.RESERVED) {
|
|
18586
|
+
if (in_array(current_token.text, ["set", "get"]) && this._flags.mode !== MODE.ObjectLiteral) {
|
|
18587
|
+
current_token.type = TOKEN.WORD;
|
|
18588
|
+
} else if (current_token.text === "import" && in_array(this._tokens.peek().text, ["(", "."])) {
|
|
18589
|
+
current_token.type = TOKEN.WORD;
|
|
18590
|
+
} else if (in_array(current_token.text, ["as", "from"]) && !this._flags.import_block) {
|
|
18591
|
+
current_token.type = TOKEN.WORD;
|
|
18592
|
+
} else if (this._flags.mode === MODE.ObjectLiteral) {
|
|
18593
|
+
var next_token = this._tokens.peek();
|
|
18594
|
+
if (next_token.text === ":") {
|
|
18595
|
+
current_token.type = TOKEN.WORD;
|
|
18596
|
+
}
|
|
18597
|
+
}
|
|
18598
|
+
}
|
|
18599
|
+
if (this.start_of_statement(current_token)) {
|
|
18600
|
+
if (reserved_array(this._flags.last_token, ["var", "let", "const"]) && current_token.type === TOKEN.WORD) {
|
|
18601
|
+
this._flags.declaration_statement = true;
|
|
18602
|
+
}
|
|
18603
|
+
} else if (current_token.newlines && !is_expression(this._flags.mode) && (this._flags.last_token.type !== TOKEN.OPERATOR || (this._flags.last_token.text === "--" || this._flags.last_token.text === "++")) && this._flags.last_token.type !== TOKEN.EQUALS && (this._options.preserve_newlines || !reserved_array(this._flags.last_token, ["var", "let", "const", "set", "get"]))) {
|
|
18604
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18605
|
+
this.print_newline();
|
|
18606
|
+
} else {
|
|
18607
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18608
|
+
}
|
|
18609
|
+
if (this._flags.do_block && !this._flags.do_while) {
|
|
18610
|
+
if (reserved_word(current_token, "while")) {
|
|
18611
|
+
this._output.space_before_token = true;
|
|
18612
|
+
this.print_token(current_token);
|
|
18613
|
+
this._output.space_before_token = true;
|
|
18614
|
+
this._flags.do_while = true;
|
|
18615
|
+
return;
|
|
18616
|
+
} else {
|
|
18617
|
+
this.print_newline();
|
|
18618
|
+
this._flags.do_block = false;
|
|
18619
|
+
}
|
|
18620
|
+
}
|
|
18621
|
+
if (this._flags.if_block) {
|
|
18622
|
+
if (!this._flags.else_block && reserved_word(current_token, "else")) {
|
|
18623
|
+
this._flags.else_block = true;
|
|
18624
|
+
} else {
|
|
18625
|
+
while (this._flags.mode === MODE.Statement) {
|
|
18626
|
+
this.restore_mode();
|
|
18627
|
+
}
|
|
18628
|
+
this._flags.if_block = false;
|
|
18629
|
+
this._flags.else_block = false;
|
|
18630
|
+
}
|
|
18631
|
+
}
|
|
18632
|
+
if (this._flags.in_case_statement && reserved_array(current_token, ["case", "default"])) {
|
|
18633
|
+
this.print_newline();
|
|
18634
|
+
if (!this._flags.case_block && (this._flags.case_body || this._options.jslint_happy)) {
|
|
18635
|
+
this.deindent();
|
|
18636
|
+
}
|
|
18637
|
+
this._flags.case_body = false;
|
|
18638
|
+
this.print_token(current_token);
|
|
18639
|
+
this._flags.in_case = true;
|
|
18640
|
+
return;
|
|
18641
|
+
}
|
|
18642
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.EQUALS || this._flags.last_token.type === TOKEN.OPERATOR) {
|
|
18643
|
+
if (!this.start_of_object_property()) {
|
|
18644
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18645
|
+
}
|
|
18646
|
+
}
|
|
18647
|
+
if (reserved_word(current_token, "function")) {
|
|
18648
|
+
if (in_array(this._flags.last_token.text, ["}", ";"]) || this._output.just_added_newline() && !(in_array(this._flags.last_token.text, ["(", "[", "{", ":", "=", ","]) || this._flags.last_token.type === TOKEN.OPERATOR)) {
|
|
18649
|
+
if (!this._output.just_added_blankline() && !current_token.comments_before) {
|
|
18650
|
+
this.print_newline();
|
|
18651
|
+
this.print_newline(true);
|
|
18652
|
+
}
|
|
18653
|
+
}
|
|
18654
|
+
if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD) {
|
|
18655
|
+
if (reserved_array(this._flags.last_token, ["get", "set", "new", "export"]) || reserved_array(this._flags.last_token, newline_restricted_tokens)) {
|
|
18656
|
+
this._output.space_before_token = true;
|
|
18657
|
+
} else if (reserved_word(this._flags.last_token, "default") && this._last_last_text === "export") {
|
|
18658
|
+
this._output.space_before_token = true;
|
|
18659
|
+
} else if (this._flags.last_token.text === "declare") {
|
|
18660
|
+
this._output.space_before_token = true;
|
|
18661
|
+
} else {
|
|
18662
|
+
this.print_newline();
|
|
18663
|
+
}
|
|
18664
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR || this._flags.last_token.text === "=") {
|
|
18665
|
+
this._output.space_before_token = true;
|
|
18666
|
+
} else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) ; else {
|
|
18667
|
+
this.print_newline();
|
|
18668
|
+
}
|
|
18669
|
+
this.print_token(current_token);
|
|
18670
|
+
this._flags.last_word = current_token.text;
|
|
18671
|
+
return;
|
|
18672
|
+
}
|
|
18673
|
+
var prefix = "NONE";
|
|
18674
|
+
if (this._flags.last_token.type === TOKEN.END_BLOCK) {
|
|
18675
|
+
if (this._previous_flags.inline_frame) {
|
|
18676
|
+
prefix = "SPACE";
|
|
18677
|
+
} else if (!reserved_array(current_token, ["else", "catch", "finally", "from"])) {
|
|
18678
|
+
prefix = "NEWLINE";
|
|
18679
|
+
} else {
|
|
18680
|
+
if (this._options.brace_style === "expand" || this._options.brace_style === "end-expand" || this._options.brace_style === "none" && current_token.newlines) {
|
|
18681
|
+
prefix = "NEWLINE";
|
|
18682
|
+
} else {
|
|
18683
|
+
prefix = "SPACE";
|
|
18684
|
+
this._output.space_before_token = true;
|
|
18685
|
+
}
|
|
18686
|
+
}
|
|
18687
|
+
} else if (this._flags.last_token.type === TOKEN.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
|
|
18688
|
+
prefix = "NEWLINE";
|
|
18689
|
+
} else if (this._flags.last_token.type === TOKEN.SEMICOLON && is_expression(this._flags.mode)) {
|
|
18690
|
+
prefix = "SPACE";
|
|
18691
|
+
} else if (this._flags.last_token.type === TOKEN.STRING) {
|
|
18692
|
+
prefix = "NEWLINE";
|
|
18693
|
+
} else if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD || this._flags.last_token.text === "*" && (in_array(this._last_last_text, ["function", "yield"]) || this._flags.mode === MODE.ObjectLiteral && in_array(this._last_last_text, ["{", ","]))) {
|
|
18694
|
+
prefix = "SPACE";
|
|
18695
|
+
} else if (this._flags.last_token.type === TOKEN.START_BLOCK) {
|
|
18696
|
+
if (this._flags.inline_frame) {
|
|
18697
|
+
prefix = "SPACE";
|
|
18698
|
+
} else {
|
|
18699
|
+
prefix = "NEWLINE";
|
|
18700
|
+
}
|
|
18701
|
+
} else if (this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
18702
|
+
this._output.space_before_token = true;
|
|
18703
|
+
prefix = "NEWLINE";
|
|
18704
|
+
}
|
|
18705
|
+
if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ")") {
|
|
18706
|
+
if (this._flags.inline_frame || this._flags.last_token.text === "else" || this._flags.last_token.text === "export") {
|
|
18707
|
+
prefix = "SPACE";
|
|
18708
|
+
} else {
|
|
18709
|
+
prefix = "NEWLINE";
|
|
18710
|
+
}
|
|
18711
|
+
}
|
|
18712
|
+
if (reserved_array(current_token, ["else", "catch", "finally"])) {
|
|
18713
|
+
if ((!(this._flags.last_token.type === TOKEN.END_BLOCK && this._previous_flags.mode === MODE.BlockStatement) || this._options.brace_style === "expand" || this._options.brace_style === "end-expand" || this._options.brace_style === "none" && current_token.newlines) && !this._flags.inline_frame) {
|
|
18714
|
+
this.print_newline();
|
|
18715
|
+
} else {
|
|
18716
|
+
this._output.trim(true);
|
|
18717
|
+
var line = this._output.current_line;
|
|
18718
|
+
if (line.last() !== "}") {
|
|
18719
|
+
this.print_newline();
|
|
18720
|
+
}
|
|
18721
|
+
this._output.space_before_token = true;
|
|
18722
|
+
}
|
|
18723
|
+
} else if (prefix === "NEWLINE") {
|
|
18724
|
+
if (reserved_array(this._flags.last_token, special_words)) {
|
|
18725
|
+
this._output.space_before_token = true;
|
|
18726
|
+
} else if (this._flags.last_token.text === "declare" && reserved_array(current_token, ["var", "let", "const"])) {
|
|
18727
|
+
this._output.space_before_token = true;
|
|
18728
|
+
} else if (this._flags.last_token.type !== TOKEN.END_EXPR) {
|
|
18729
|
+
if ((this._flags.last_token.type !== TOKEN.START_EXPR || !reserved_array(current_token, ["var", "let", "const"])) && this._flags.last_token.text !== ":") {
|
|
18730
|
+
if (reserved_word(current_token, "if") && reserved_word(current_token.previous, "else")) {
|
|
18731
|
+
this._output.space_before_token = true;
|
|
18732
|
+
} else {
|
|
18733
|
+
this.print_newline();
|
|
18734
|
+
}
|
|
18735
|
+
}
|
|
18736
|
+
} else if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ")") {
|
|
18737
|
+
this.print_newline();
|
|
18738
|
+
}
|
|
18739
|
+
} else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === "," && this._last_last_text === "}") {
|
|
18740
|
+
this.print_newline();
|
|
18741
|
+
} else if (prefix === "SPACE") {
|
|
18742
|
+
this._output.space_before_token = true;
|
|
18743
|
+
}
|
|
18744
|
+
if (current_token.previous && (current_token.previous.type === TOKEN.WORD || current_token.previous.type === TOKEN.RESERVED)) {
|
|
18745
|
+
this._output.space_before_token = true;
|
|
18746
|
+
}
|
|
18747
|
+
this.print_token(current_token);
|
|
18748
|
+
this._flags.last_word = current_token.text;
|
|
18749
|
+
if (current_token.type === TOKEN.RESERVED) {
|
|
18750
|
+
if (current_token.text === "do") {
|
|
18751
|
+
this._flags.do_block = true;
|
|
18752
|
+
} else if (current_token.text === "if") {
|
|
18753
|
+
this._flags.if_block = true;
|
|
18754
|
+
} else if (current_token.text === "import") {
|
|
18755
|
+
this._flags.import_block = true;
|
|
18756
|
+
} else if (this._flags.import_block && reserved_word(current_token, "from")) {
|
|
18757
|
+
this._flags.import_block = false;
|
|
18758
|
+
}
|
|
18759
|
+
}
|
|
18760
|
+
};
|
|
18761
|
+
Beautifier.prototype.handle_semicolon = function(current_token) {
|
|
18762
|
+
if (this.start_of_statement(current_token)) {
|
|
18763
|
+
this._output.space_before_token = false;
|
|
18764
|
+
} else {
|
|
18765
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18766
|
+
}
|
|
18767
|
+
var next_token = this._tokens.peek();
|
|
18768
|
+
while (this._flags.mode === MODE.Statement && !(this._flags.if_block && reserved_word(next_token, "else")) && !this._flags.do_block) {
|
|
18769
|
+
this.restore_mode();
|
|
18770
|
+
}
|
|
18771
|
+
if (this._flags.import_block) {
|
|
18772
|
+
this._flags.import_block = false;
|
|
18773
|
+
}
|
|
18774
|
+
this.print_token(current_token);
|
|
18775
|
+
};
|
|
18776
|
+
Beautifier.prototype.handle_string = function(current_token) {
|
|
18777
|
+
if (current_token.text.startsWith("`") && current_token.newlines === 0 && current_token.whitespace_before === "" && (current_token.previous.text === ")" || this._flags.last_token.type === TOKEN.WORD)) ; else if (this.start_of_statement(current_token)) {
|
|
18778
|
+
this._output.space_before_token = true;
|
|
18779
|
+
} else {
|
|
18780
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18781
|
+
if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD || this._flags.inline_frame) {
|
|
18782
|
+
this._output.space_before_token = true;
|
|
18783
|
+
} else if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.EQUALS || this._flags.last_token.type === TOKEN.OPERATOR) {
|
|
18784
|
+
if (!this.start_of_object_property()) {
|
|
18785
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18786
|
+
}
|
|
18787
|
+
} else if (current_token.text.startsWith("`") && this._flags.last_token.type === TOKEN.END_EXPR && (current_token.previous.text === "]" || current_token.previous.text === ")") && current_token.newlines === 0) {
|
|
18788
|
+
this._output.space_before_token = true;
|
|
18789
|
+
} else {
|
|
18790
|
+
this.print_newline();
|
|
18791
|
+
}
|
|
18792
|
+
}
|
|
18793
|
+
this.print_token(current_token);
|
|
18794
|
+
};
|
|
18795
|
+
Beautifier.prototype.handle_equals = function(current_token) {
|
|
18796
|
+
if (this.start_of_statement(current_token)) ; else {
|
|
18797
|
+
this.handle_whitespace_and_comments(current_token);
|
|
18798
|
+
}
|
|
18799
|
+
if (this._flags.declaration_statement) {
|
|
18800
|
+
this._flags.declaration_assignment = true;
|
|
18801
|
+
}
|
|
18802
|
+
this._output.space_before_token = true;
|
|
18803
|
+
this.print_token(current_token);
|
|
18804
|
+
this._output.space_before_token = true;
|
|
18805
|
+
};
|
|
18806
|
+
Beautifier.prototype.handle_comma = function(current_token) {
|
|
18807
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
18808
|
+
this.print_token(current_token);
|
|
18809
|
+
this._output.space_before_token = true;
|
|
18810
|
+
if (this._flags.declaration_statement) {
|
|
18811
|
+
if (is_expression(this._flags.parent.mode)) {
|
|
18812
|
+
this._flags.declaration_assignment = false;
|
|
18813
|
+
}
|
|
18814
|
+
if (this._flags.declaration_assignment) {
|
|
18815
|
+
this._flags.declaration_assignment = false;
|
|
18816
|
+
this.print_newline(false, true);
|
|
18817
|
+
} else if (this._options.comma_first) {
|
|
18818
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18819
|
+
}
|
|
18820
|
+
} else if (this._flags.mode === MODE.ObjectLiteral || this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral) {
|
|
18821
|
+
if (this._flags.mode === MODE.Statement) {
|
|
18822
|
+
this.restore_mode();
|
|
18823
|
+
}
|
|
18824
|
+
if (!this._flags.inline_frame) {
|
|
18825
|
+
this.print_newline();
|
|
18826
|
+
}
|
|
18827
|
+
} else if (this._options.comma_first) {
|
|
18828
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18829
|
+
}
|
|
18830
|
+
};
|
|
18831
|
+
Beautifier.prototype.handle_operator = function(current_token) {
|
|
18832
|
+
var isGeneratorAsterisk = current_token.text === "*" && (reserved_array(this._flags.last_token, ["function", "yield"]) || in_array(this._flags.last_token.type, [TOKEN.START_BLOCK, TOKEN.COMMA, TOKEN.END_BLOCK, TOKEN.SEMICOLON]));
|
|
18833
|
+
var isUnary = in_array(current_token.text, ["-", "+"]) && (in_array(this._flags.last_token.type, [TOKEN.START_BLOCK, TOKEN.START_EXPR, TOKEN.EQUALS, TOKEN.OPERATOR]) || in_array(this._flags.last_token.text, line_starters) || this._flags.last_token.text === ",");
|
|
18834
|
+
if (this.start_of_statement(current_token)) ; else {
|
|
18835
|
+
var preserve_statement_flags = !isGeneratorAsterisk;
|
|
18836
|
+
this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
|
|
18837
|
+
}
|
|
18838
|
+
if (current_token.text === "*" && this._flags.last_token.type === TOKEN.DOT) {
|
|
18839
|
+
this.print_token(current_token);
|
|
18840
|
+
return;
|
|
18841
|
+
}
|
|
18842
|
+
if (current_token.text === "::") {
|
|
18843
|
+
this.print_token(current_token);
|
|
18844
|
+
return;
|
|
18845
|
+
}
|
|
18846
|
+
if (this._flags.last_token.type === TOKEN.OPERATOR && in_array(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
|
|
18847
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18848
|
+
}
|
|
18849
|
+
if (current_token.text === ":" && this._flags.in_case) {
|
|
18850
|
+
this.print_token(current_token);
|
|
18851
|
+
this._flags.in_case = false;
|
|
18852
|
+
this._flags.case_body = true;
|
|
18853
|
+
if (this._tokens.peek().type !== TOKEN.START_BLOCK) {
|
|
18854
|
+
this.indent();
|
|
18855
|
+
this.print_newline();
|
|
18856
|
+
this._flags.case_block = false;
|
|
18857
|
+
} else {
|
|
18858
|
+
this._flags.case_block = true;
|
|
18859
|
+
this._output.space_before_token = true;
|
|
18860
|
+
}
|
|
18861
|
+
return;
|
|
18862
|
+
}
|
|
18863
|
+
var space_before = true;
|
|
18864
|
+
var space_after = true;
|
|
18865
|
+
var in_ternary = false;
|
|
18866
|
+
if (current_token.text === ":") {
|
|
18867
|
+
if (this._flags.ternary_depth === 0) {
|
|
18868
|
+
space_before = false;
|
|
18869
|
+
} else {
|
|
18870
|
+
this._flags.ternary_depth -= 1;
|
|
18871
|
+
in_ternary = true;
|
|
18872
|
+
}
|
|
18873
|
+
} else if (current_token.text === "?") {
|
|
18874
|
+
this._flags.ternary_depth += 1;
|
|
18875
|
+
}
|
|
18876
|
+
if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array(current_token.text, positionable_operators)) {
|
|
18877
|
+
var isColon = current_token.text === ":";
|
|
18878
|
+
var isTernaryColon = isColon && in_ternary;
|
|
18879
|
+
var isOtherColon = isColon && !in_ternary;
|
|
18880
|
+
switch (this._options.operator_position) {
|
|
18881
|
+
case OPERATOR_POSITION.before_newline:
|
|
18882
|
+
this._output.space_before_token = !isOtherColon;
|
|
18883
|
+
this.print_token(current_token);
|
|
18884
|
+
if (!isColon || isTernaryColon) {
|
|
18885
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18886
|
+
}
|
|
18887
|
+
this._output.space_before_token = true;
|
|
18888
|
+
return;
|
|
18889
|
+
case OPERATOR_POSITION.after_newline:
|
|
18890
|
+
this._output.space_before_token = true;
|
|
18891
|
+
if (!isColon || isTernaryColon) {
|
|
18892
|
+
if (this._tokens.peek().newlines) {
|
|
18893
|
+
this.print_newline(false, true);
|
|
18894
|
+
} else {
|
|
18895
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18896
|
+
}
|
|
18897
|
+
} else {
|
|
18898
|
+
this._output.space_before_token = false;
|
|
18899
|
+
}
|
|
18900
|
+
this.print_token(current_token);
|
|
18901
|
+
this._output.space_before_token = true;
|
|
18902
|
+
return;
|
|
18903
|
+
case OPERATOR_POSITION.preserve_newline:
|
|
18904
|
+
if (!isOtherColon) {
|
|
18905
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18906
|
+
}
|
|
18907
|
+
space_before = !(this._output.just_added_newline() || isOtherColon);
|
|
18908
|
+
this._output.space_before_token = space_before;
|
|
18909
|
+
this.print_token(current_token);
|
|
18910
|
+
this._output.space_before_token = true;
|
|
18911
|
+
return;
|
|
18912
|
+
}
|
|
18913
|
+
}
|
|
18914
|
+
if (isGeneratorAsterisk) {
|
|
18915
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18916
|
+
space_before = false;
|
|
18917
|
+
var next_token = this._tokens.peek();
|
|
18918
|
+
space_after = next_token && in_array(next_token.type, [TOKEN.WORD, TOKEN.RESERVED]);
|
|
18919
|
+
} else if (current_token.text === "...") {
|
|
18920
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18921
|
+
space_before = this._flags.last_token.type === TOKEN.START_BLOCK;
|
|
18922
|
+
space_after = false;
|
|
18923
|
+
} else if (in_array(current_token.text, ["--", "++", "!", "~"]) || isUnary) {
|
|
18924
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR) {
|
|
18925
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
18926
|
+
}
|
|
18927
|
+
space_before = false;
|
|
18928
|
+
space_after = false;
|
|
18929
|
+
if (current_token.newlines && (current_token.text === "--" || current_token.text === "++" || current_token.text === "~")) {
|
|
18930
|
+
var new_line_needed = reserved_array(this._flags.last_token, special_words) && current_token.newlines;
|
|
18931
|
+
if (new_line_needed && (this._previous_flags.if_block || this._previous_flags.else_block)) {
|
|
18932
|
+
this.restore_mode();
|
|
18933
|
+
}
|
|
18934
|
+
this.print_newline(new_line_needed, true);
|
|
18935
|
+
}
|
|
18936
|
+
if (this._flags.last_token.text === ";" && is_expression(this._flags.mode)) {
|
|
18937
|
+
space_before = true;
|
|
18938
|
+
}
|
|
18939
|
+
if (this._flags.last_token.type === TOKEN.RESERVED) {
|
|
18940
|
+
space_before = true;
|
|
18941
|
+
} else if (this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
18942
|
+
space_before = !(this._flags.last_token.text === "]" && (current_token.text === "--" || current_token.text === "++"));
|
|
18943
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR) {
|
|
18944
|
+
space_before = in_array(current_token.text, ["--", "-", "++", "+"]) && in_array(this._flags.last_token.text, ["--", "-", "++", "+"]);
|
|
18945
|
+
if (in_array(current_token.text, ["+", "-"]) && in_array(this._flags.last_token.text, ["--", "++"])) {
|
|
18946
|
+
space_after = true;
|
|
18947
|
+
}
|
|
18948
|
+
}
|
|
18949
|
+
if ((this._flags.mode === MODE.BlockStatement && !this._flags.inline_frame || this._flags.mode === MODE.Statement) && (this._flags.last_token.text === "{" || this._flags.last_token.text === ";")) {
|
|
18950
|
+
this.print_newline();
|
|
18951
|
+
}
|
|
18952
|
+
}
|
|
18953
|
+
this._output.space_before_token = this._output.space_before_token || space_before;
|
|
18954
|
+
this.print_token(current_token);
|
|
18955
|
+
this._output.space_before_token = space_after;
|
|
18956
|
+
};
|
|
18957
|
+
Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
|
|
18958
|
+
if (this._output.raw) {
|
|
18959
|
+
this._output.add_raw_token(current_token);
|
|
18960
|
+
if (current_token.directives && current_token.directives.preserve === "end") {
|
|
18961
|
+
this._output.raw = this._options.test_output_raw;
|
|
18962
|
+
}
|
|
18963
|
+
return;
|
|
18964
|
+
}
|
|
18965
|
+
if (current_token.directives) {
|
|
18966
|
+
this.print_newline(false, preserve_statement_flags);
|
|
18967
|
+
this.print_token(current_token);
|
|
18968
|
+
if (current_token.directives.preserve === "start") {
|
|
18969
|
+
this._output.raw = true;
|
|
18970
|
+
}
|
|
18971
|
+
this.print_newline(false, true);
|
|
18972
|
+
return;
|
|
18973
|
+
}
|
|
18974
|
+
if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
|
|
18975
|
+
this._output.space_before_token = true;
|
|
18976
|
+
this.print_token(current_token);
|
|
18977
|
+
this._output.space_before_token = true;
|
|
18978
|
+
return;
|
|
18979
|
+
} else {
|
|
18980
|
+
this.print_block_commment(current_token, preserve_statement_flags);
|
|
18981
|
+
}
|
|
18982
|
+
};
|
|
18983
|
+
Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
|
|
18984
|
+
var lines = split_linebreaks(current_token.text);
|
|
18985
|
+
var j;
|
|
18986
|
+
var javadoc = false;
|
|
18987
|
+
var starless = false;
|
|
18988
|
+
var lastIndent = current_token.whitespace_before;
|
|
18989
|
+
var lastIndentLength = lastIndent.length;
|
|
18990
|
+
this.print_newline(false, preserve_statement_flags);
|
|
18991
|
+
this.print_token_line_indentation(current_token);
|
|
18992
|
+
this._output.add_token(lines[0]);
|
|
18993
|
+
this.print_newline(false, preserve_statement_flags);
|
|
18994
|
+
if (lines.length > 1) {
|
|
18995
|
+
lines = lines.slice(1);
|
|
18996
|
+
javadoc = all_lines_start_with(lines, "*");
|
|
18997
|
+
starless = each_line_matches_indent(lines, lastIndent);
|
|
18998
|
+
if (javadoc) {
|
|
18999
|
+
this._flags.alignment = 1;
|
|
19000
|
+
}
|
|
19001
|
+
for (j = 0; j < lines.length; j++) {
|
|
19002
|
+
if (javadoc) {
|
|
19003
|
+
this.print_token_line_indentation(current_token);
|
|
19004
|
+
this._output.add_token(ltrim(lines[j]));
|
|
19005
|
+
} else if (starless && lines[j]) {
|
|
19006
|
+
this.print_token_line_indentation(current_token);
|
|
19007
|
+
this._output.add_token(lines[j].substring(lastIndentLength));
|
|
19008
|
+
} else {
|
|
19009
|
+
this._output.current_line.set_indent(-1);
|
|
19010
|
+
this._output.add_token(lines[j]);
|
|
19011
|
+
}
|
|
19012
|
+
this.print_newline(false, preserve_statement_flags);
|
|
19013
|
+
}
|
|
19014
|
+
this._flags.alignment = 0;
|
|
19015
|
+
}
|
|
19016
|
+
};
|
|
19017
|
+
Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
|
|
19018
|
+
if (current_token.newlines) {
|
|
19019
|
+
this.print_newline(false, preserve_statement_flags);
|
|
19020
|
+
} else {
|
|
19021
|
+
this._output.trim(true);
|
|
19022
|
+
}
|
|
19023
|
+
this._output.space_before_token = true;
|
|
19024
|
+
this.print_token(current_token);
|
|
19025
|
+
this.print_newline(false, preserve_statement_flags);
|
|
19026
|
+
};
|
|
19027
|
+
Beautifier.prototype.handle_dot = function(current_token) {
|
|
19028
|
+
if (this.start_of_statement(current_token)) ; else {
|
|
19029
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
19030
|
+
}
|
|
19031
|
+
if (this._flags.last_token.text.match("^[0-9]+$")) {
|
|
19032
|
+
this._output.space_before_token = true;
|
|
19033
|
+
}
|
|
19034
|
+
if (reserved_array(this._flags.last_token, special_words)) {
|
|
19035
|
+
this._output.space_before_token = false;
|
|
19036
|
+
} else {
|
|
19037
|
+
this.allow_wrap_or_preserved_newline(
|
|
19038
|
+
current_token,
|
|
19039
|
+
this._flags.last_token.text === ")" && this._options.break_chained_methods
|
|
19040
|
+
);
|
|
19041
|
+
}
|
|
19042
|
+
if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
|
|
19043
|
+
this.deindent();
|
|
19044
|
+
}
|
|
19045
|
+
this.print_token(current_token);
|
|
19046
|
+
};
|
|
19047
|
+
Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
|
|
19048
|
+
this.print_token(current_token);
|
|
19049
|
+
if (current_token.text[current_token.text.length - 1] === "\n") {
|
|
19050
|
+
this.print_newline(false, preserve_statement_flags);
|
|
19051
|
+
}
|
|
19052
|
+
};
|
|
19053
|
+
Beautifier.prototype.handle_eof = function(current_token) {
|
|
19054
|
+
while (this._flags.mode === MODE.Statement) {
|
|
19055
|
+
this.restore_mode();
|
|
19056
|
+
}
|
|
19057
|
+
this.handle_whitespace_and_comments(current_token);
|
|
19058
|
+
};
|
|
19059
|
+
module.exports.Beautifier = Beautifier;
|
|
19060
|
+
}
|
|
19061
|
+
});
|
|
19062
|
+
|
|
19063
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/index.js
|
|
19064
|
+
var require_javascript = __commonJS({
|
|
19065
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/javascript/index.js"(exports, module) {
|
|
19066
|
+
init_define_process();
|
|
19067
|
+
var Beautifier = require_beautifier().Beautifier;
|
|
19068
|
+
var Options = require_options2().Options;
|
|
19069
|
+
function js_beautify(js_source_text, options) {
|
|
19070
|
+
var beautifier = new Beautifier(js_source_text, options);
|
|
19071
|
+
return beautifier.beautify();
|
|
19072
|
+
}
|
|
19073
|
+
module.exports = js_beautify;
|
|
19074
|
+
module.exports.defaultOptions = function() {
|
|
19075
|
+
return new Options();
|
|
19076
|
+
};
|
|
19077
|
+
}
|
|
19078
|
+
});
|
|
19079
|
+
|
|
19080
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/css/options.js
|
|
19081
|
+
var require_options3 = __commonJS({
|
|
19082
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/css/options.js"(exports, module) {
|
|
19083
|
+
init_define_process();
|
|
19084
|
+
var BaseOptions = require_options().Options;
|
|
19085
|
+
function Options(options) {
|
|
19086
|
+
BaseOptions.call(this, options, "css");
|
|
19087
|
+
this.selector_separator_newline = this._get_boolean("selector_separator_newline", true);
|
|
19088
|
+
this.newline_between_rules = this._get_boolean("newline_between_rules", true);
|
|
19089
|
+
var space_around_selector_separator = this._get_boolean("space_around_selector_separator");
|
|
19090
|
+
this.space_around_combinator = this._get_boolean("space_around_combinator") || space_around_selector_separator;
|
|
19091
|
+
var brace_style_split = this._get_selection_list("brace_style", ["collapse", "expand", "end-expand", "none", "preserve-inline"]);
|
|
19092
|
+
this.brace_style = "collapse";
|
|
19093
|
+
for (var bs = 0; bs < brace_style_split.length; bs++) {
|
|
19094
|
+
if (brace_style_split[bs] !== "expand") {
|
|
19095
|
+
this.brace_style = "collapse";
|
|
19096
|
+
} else {
|
|
19097
|
+
this.brace_style = brace_style_split[bs];
|
|
19098
|
+
}
|
|
19099
|
+
}
|
|
19100
|
+
}
|
|
19101
|
+
Options.prototype = new BaseOptions();
|
|
19102
|
+
module.exports.Options = Options;
|
|
19103
|
+
}
|
|
19104
|
+
});
|
|
19105
|
+
|
|
19106
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/css/beautifier.js
|
|
19107
|
+
var require_beautifier2 = __commonJS({
|
|
19108
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/css/beautifier.js"(exports, module) {
|
|
19109
|
+
init_define_process();
|
|
19110
|
+
var Options = require_options3().Options;
|
|
19111
|
+
var Output = require_output().Output;
|
|
19112
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
19113
|
+
var Directives = require_directives().Directives;
|
|
19114
|
+
var directives_core = new Directives(/\/\*/, /\*\//);
|
|
19115
|
+
var lineBreak = /\r\n|[\r\n]/;
|
|
19116
|
+
var allLineBreaks = /\r\n|[\r\n]/g;
|
|
19117
|
+
var whitespaceChar = /\s/;
|
|
19118
|
+
var whitespacePattern = /(?:\s|\n)+/g;
|
|
19119
|
+
var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
|
|
19120
|
+
var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
|
|
19121
|
+
function Beautifier(source_text, options) {
|
|
19122
|
+
this._source_text = source_text || "";
|
|
19123
|
+
this._options = new Options(options);
|
|
19124
|
+
this._ch = null;
|
|
19125
|
+
this._input = null;
|
|
19126
|
+
this.NESTED_AT_RULE = {
|
|
19127
|
+
"@page": true,
|
|
19128
|
+
"@font-face": true,
|
|
19129
|
+
"@keyframes": true,
|
|
19130
|
+
// also in CONDITIONAL_GROUP_RULE below
|
|
19131
|
+
"@media": true,
|
|
19132
|
+
"@supports": true,
|
|
19133
|
+
"@document": true
|
|
19134
|
+
};
|
|
19135
|
+
this.CONDITIONAL_GROUP_RULE = {
|
|
19136
|
+
"@media": true,
|
|
19137
|
+
"@supports": true,
|
|
19138
|
+
"@document": true
|
|
19139
|
+
};
|
|
19140
|
+
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
|
|
19141
|
+
"grid-template-areas",
|
|
19142
|
+
"grid-template"
|
|
19143
|
+
];
|
|
19144
|
+
}
|
|
19145
|
+
Beautifier.prototype.eatString = function(endChars) {
|
|
19146
|
+
var result = "";
|
|
19147
|
+
this._ch = this._input.next();
|
|
19148
|
+
while (this._ch) {
|
|
19149
|
+
result += this._ch;
|
|
19150
|
+
if (this._ch === "\\") {
|
|
19151
|
+
result += this._input.next();
|
|
19152
|
+
} else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
|
|
19153
|
+
break;
|
|
19154
|
+
}
|
|
19155
|
+
this._ch = this._input.next();
|
|
19156
|
+
}
|
|
19157
|
+
return result;
|
|
19158
|
+
};
|
|
19159
|
+
Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
|
|
19160
|
+
var result = whitespaceChar.test(this._input.peek());
|
|
19161
|
+
var newline_count = 0;
|
|
19162
|
+
while (whitespaceChar.test(this._input.peek())) {
|
|
19163
|
+
this._ch = this._input.next();
|
|
19164
|
+
if (allowAtLeastOneNewLine && this._ch === "\n") {
|
|
19165
|
+
if (newline_count === 0 || newline_count < this._options.max_preserve_newlines) {
|
|
19166
|
+
newline_count++;
|
|
19167
|
+
this._output.add_new_line(true);
|
|
19168
|
+
}
|
|
19169
|
+
}
|
|
19170
|
+
}
|
|
19171
|
+
return result;
|
|
19172
|
+
};
|
|
19173
|
+
Beautifier.prototype.foundNestedPseudoClass = function() {
|
|
19174
|
+
var openParen = 0;
|
|
19175
|
+
var i = 1;
|
|
19176
|
+
var ch = this._input.peek(i);
|
|
19177
|
+
while (ch) {
|
|
19178
|
+
if (ch === "{") {
|
|
19179
|
+
return true;
|
|
19180
|
+
} else if (ch === "(") {
|
|
19181
|
+
openParen += 1;
|
|
19182
|
+
} else if (ch === ")") {
|
|
19183
|
+
if (openParen === 0) {
|
|
19184
|
+
return false;
|
|
19185
|
+
}
|
|
19186
|
+
openParen -= 1;
|
|
19187
|
+
} else if (ch === ";" || ch === "}") {
|
|
19188
|
+
return false;
|
|
19189
|
+
}
|
|
19190
|
+
i++;
|
|
19191
|
+
ch = this._input.peek(i);
|
|
19192
|
+
}
|
|
19193
|
+
return false;
|
|
19194
|
+
};
|
|
19195
|
+
Beautifier.prototype.print_string = function(output_string) {
|
|
19196
|
+
this._output.set_indent(this._indentLevel);
|
|
19197
|
+
this._output.non_breaking_space = true;
|
|
19198
|
+
this._output.add_token(output_string);
|
|
19199
|
+
};
|
|
19200
|
+
Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) {
|
|
19201
|
+
if (isAfterSpace) {
|
|
19202
|
+
this._output.space_before_token = true;
|
|
19203
|
+
}
|
|
19204
|
+
};
|
|
19205
|
+
Beautifier.prototype.indent = function() {
|
|
19206
|
+
this._indentLevel++;
|
|
19207
|
+
};
|
|
19208
|
+
Beautifier.prototype.outdent = function() {
|
|
19209
|
+
if (this._indentLevel > 0) {
|
|
19210
|
+
this._indentLevel--;
|
|
19211
|
+
}
|
|
19212
|
+
};
|
|
19213
|
+
Beautifier.prototype.beautify = function() {
|
|
19214
|
+
if (this._options.disabled) {
|
|
19215
|
+
return this._source_text;
|
|
19216
|
+
}
|
|
19217
|
+
var source_text = this._source_text;
|
|
19218
|
+
var eol = this._options.eol;
|
|
19219
|
+
if (eol === "auto") {
|
|
19220
|
+
eol = "\n";
|
|
19221
|
+
if (source_text && lineBreak.test(source_text || "")) {
|
|
19222
|
+
eol = source_text.match(lineBreak)[0];
|
|
19223
|
+
}
|
|
19224
|
+
}
|
|
19225
|
+
source_text = source_text.replace(allLineBreaks, "\n");
|
|
19226
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
19227
|
+
this._output = new Output(this._options, baseIndentString);
|
|
19228
|
+
this._input = new InputScanner(source_text);
|
|
19229
|
+
this._indentLevel = 0;
|
|
19230
|
+
this._nestedLevel = 0;
|
|
19231
|
+
this._ch = null;
|
|
19232
|
+
var parenLevel = 0;
|
|
19233
|
+
var insideRule = false;
|
|
19234
|
+
var insidePropertyValue = false;
|
|
19235
|
+
var enteringConditionalGroup = false;
|
|
19236
|
+
var insideAtExtend = false;
|
|
19237
|
+
var insideAtImport = false;
|
|
19238
|
+
var insideScssMap = false;
|
|
19239
|
+
var topCharacter = this._ch;
|
|
19240
|
+
var insideNonSemiColonValues = false;
|
|
19241
|
+
var whitespace;
|
|
19242
|
+
var isAfterSpace;
|
|
19243
|
+
var previous_ch;
|
|
19244
|
+
while (true) {
|
|
19245
|
+
whitespace = this._input.read(whitespacePattern);
|
|
19246
|
+
isAfterSpace = whitespace !== "";
|
|
19247
|
+
previous_ch = topCharacter;
|
|
19248
|
+
this._ch = this._input.next();
|
|
19249
|
+
if (this._ch === "\\" && this._input.hasNext()) {
|
|
19250
|
+
this._ch += this._input.next();
|
|
19251
|
+
}
|
|
19252
|
+
topCharacter = this._ch;
|
|
19253
|
+
if (!this._ch) {
|
|
19254
|
+
break;
|
|
19255
|
+
} else if (this._ch === "/" && this._input.peek() === "*") {
|
|
19256
|
+
this._output.add_new_line();
|
|
19257
|
+
this._input.back();
|
|
19258
|
+
var comment = this._input.read(block_comment_pattern);
|
|
19259
|
+
var directives = directives_core.get_directives(comment);
|
|
19260
|
+
if (directives && directives.ignore === "start") {
|
|
19261
|
+
comment += directives_core.readIgnored(this._input);
|
|
19262
|
+
}
|
|
19263
|
+
this.print_string(comment);
|
|
19264
|
+
this.eatWhitespace(true);
|
|
19265
|
+
this._output.add_new_line();
|
|
19266
|
+
} else if (this._ch === "/" && this._input.peek() === "/") {
|
|
19267
|
+
this._output.space_before_token = true;
|
|
19268
|
+
this._input.back();
|
|
19269
|
+
this.print_string(this._input.read(comment_pattern));
|
|
19270
|
+
this.eatWhitespace(true);
|
|
19271
|
+
} else if (this._ch === "@" || this._ch === "$") {
|
|
19272
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
19273
|
+
if (this._input.peek() === "{") {
|
|
19274
|
+
this.print_string(this._ch + this.eatString("}"));
|
|
19275
|
+
} else {
|
|
19276
|
+
this.print_string(this._ch);
|
|
19277
|
+
var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
|
|
19278
|
+
if (variableOrRule.match(/[ :]$/)) {
|
|
19279
|
+
variableOrRule = this.eatString(": ").replace(/\s$/, "");
|
|
19280
|
+
this.print_string(variableOrRule);
|
|
19281
|
+
this._output.space_before_token = true;
|
|
19282
|
+
}
|
|
19283
|
+
variableOrRule = variableOrRule.replace(/\s$/, "");
|
|
19284
|
+
if (variableOrRule === "extend") {
|
|
19285
|
+
insideAtExtend = true;
|
|
19286
|
+
} else if (variableOrRule === "import") {
|
|
19287
|
+
insideAtImport = true;
|
|
19288
|
+
}
|
|
19289
|
+
if (variableOrRule in this.NESTED_AT_RULE) {
|
|
19290
|
+
this._nestedLevel += 1;
|
|
19291
|
+
if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
|
|
19292
|
+
enteringConditionalGroup = true;
|
|
19293
|
+
}
|
|
19294
|
+
} else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(":") !== -1) {
|
|
19295
|
+
insidePropertyValue = true;
|
|
19296
|
+
this.indent();
|
|
19297
|
+
}
|
|
19298
|
+
}
|
|
19299
|
+
} else if (this._ch === "#" && this._input.peek() === "{") {
|
|
19300
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
19301
|
+
this.print_string(this._ch + this.eatString("}"));
|
|
19302
|
+
} else if (this._ch === "{") {
|
|
19303
|
+
if (insidePropertyValue) {
|
|
19304
|
+
insidePropertyValue = false;
|
|
19305
|
+
this.outdent();
|
|
19306
|
+
}
|
|
19307
|
+
if (enteringConditionalGroup) {
|
|
19308
|
+
enteringConditionalGroup = false;
|
|
19309
|
+
insideRule = this._indentLevel >= this._nestedLevel;
|
|
19310
|
+
} else {
|
|
19311
|
+
insideRule = this._indentLevel >= this._nestedLevel - 1;
|
|
19312
|
+
}
|
|
19313
|
+
if (this._options.newline_between_rules && insideRule) {
|
|
19314
|
+
if (this._output.previous_line && this._output.previous_line.item(-1) !== "{") {
|
|
19315
|
+
this._output.ensure_empty_line_above("/", ",");
|
|
19316
|
+
}
|
|
19317
|
+
}
|
|
19318
|
+
this._output.space_before_token = true;
|
|
19319
|
+
if (this._options.brace_style === "expand") {
|
|
19320
|
+
this._output.add_new_line();
|
|
19321
|
+
this.print_string(this._ch);
|
|
19322
|
+
this.indent();
|
|
19323
|
+
this._output.set_indent(this._indentLevel);
|
|
19324
|
+
} else {
|
|
19325
|
+
if (previous_ch === "(") {
|
|
19326
|
+
this._output.space_before_token = false;
|
|
19327
|
+
} else if (previous_ch !== ",") {
|
|
19328
|
+
this.indent();
|
|
19329
|
+
}
|
|
19330
|
+
this.print_string(this._ch);
|
|
19331
|
+
}
|
|
19332
|
+
this.eatWhitespace(true);
|
|
19333
|
+
this._output.add_new_line();
|
|
19334
|
+
} else if (this._ch === "}") {
|
|
19335
|
+
this.outdent();
|
|
19336
|
+
this._output.add_new_line();
|
|
19337
|
+
if (previous_ch === "{") {
|
|
19338
|
+
this._output.trim(true);
|
|
19339
|
+
}
|
|
19340
|
+
insideAtImport = false;
|
|
19341
|
+
insideAtExtend = false;
|
|
19342
|
+
if (insidePropertyValue) {
|
|
19343
|
+
this.outdent();
|
|
19344
|
+
insidePropertyValue = false;
|
|
19345
|
+
}
|
|
19346
|
+
this.print_string(this._ch);
|
|
19347
|
+
insideRule = false;
|
|
19348
|
+
if (this._nestedLevel) {
|
|
19349
|
+
this._nestedLevel--;
|
|
19350
|
+
}
|
|
19351
|
+
this.eatWhitespace(true);
|
|
19352
|
+
this._output.add_new_line();
|
|
19353
|
+
if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
|
|
19354
|
+
if (this._input.peek() !== "}") {
|
|
19355
|
+
this._output.add_new_line(true);
|
|
19356
|
+
}
|
|
19357
|
+
}
|
|
19358
|
+
if (this._input.peek() === ")") {
|
|
19359
|
+
this._output.trim(true);
|
|
19360
|
+
if (this._options.brace_style === "expand") {
|
|
19361
|
+
this._output.add_new_line(true);
|
|
19362
|
+
}
|
|
19363
|
+
}
|
|
19364
|
+
} else if (this._ch === ":") {
|
|
19365
|
+
for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
|
|
19366
|
+
if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
|
|
19367
|
+
insideNonSemiColonValues = true;
|
|
19368
|
+
break;
|
|
19369
|
+
}
|
|
19370
|
+
}
|
|
19371
|
+
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
|
|
19372
|
+
this.print_string(":");
|
|
19373
|
+
if (!insidePropertyValue) {
|
|
19374
|
+
insidePropertyValue = true;
|
|
19375
|
+
this._output.space_before_token = true;
|
|
19376
|
+
this.eatWhitespace(true);
|
|
19377
|
+
this.indent();
|
|
19378
|
+
}
|
|
19379
|
+
} else {
|
|
19380
|
+
if (this._input.lookBack(" ")) {
|
|
19381
|
+
this._output.space_before_token = true;
|
|
19382
|
+
}
|
|
19383
|
+
if (this._input.peek() === ":") {
|
|
19384
|
+
this._ch = this._input.next();
|
|
19385
|
+
this.print_string("::");
|
|
19386
|
+
} else {
|
|
19387
|
+
this.print_string(":");
|
|
19388
|
+
}
|
|
19389
|
+
}
|
|
19390
|
+
} else if (this._ch === '"' || this._ch === "'") {
|
|
19391
|
+
var preserveQuoteSpace = previous_ch === '"' || previous_ch === "'";
|
|
19392
|
+
this.preserveSingleSpace(preserveQuoteSpace || isAfterSpace);
|
|
19393
|
+
this.print_string(this._ch + this.eatString(this._ch));
|
|
19394
|
+
this.eatWhitespace(true);
|
|
19395
|
+
} else if (this._ch === ";") {
|
|
19396
|
+
insideNonSemiColonValues = false;
|
|
19397
|
+
if (parenLevel === 0) {
|
|
19398
|
+
if (insidePropertyValue) {
|
|
19399
|
+
this.outdent();
|
|
19400
|
+
insidePropertyValue = false;
|
|
19401
|
+
}
|
|
19402
|
+
insideAtExtend = false;
|
|
19403
|
+
insideAtImport = false;
|
|
19404
|
+
this.print_string(this._ch);
|
|
19405
|
+
this.eatWhitespace(true);
|
|
19406
|
+
if (this._input.peek() !== "/") {
|
|
19407
|
+
this._output.add_new_line();
|
|
19408
|
+
}
|
|
19409
|
+
} else {
|
|
19410
|
+
this.print_string(this._ch);
|
|
19411
|
+
this.eatWhitespace(true);
|
|
19412
|
+
this._output.space_before_token = true;
|
|
19413
|
+
}
|
|
19414
|
+
} else if (this._ch === "(") {
|
|
19415
|
+
if (this._input.lookBack("url")) {
|
|
19416
|
+
this.print_string(this._ch);
|
|
19417
|
+
this.eatWhitespace();
|
|
19418
|
+
parenLevel++;
|
|
19419
|
+
this.indent();
|
|
19420
|
+
this._ch = this._input.next();
|
|
19421
|
+
if (this._ch === ")" || this._ch === '"' || this._ch === "'") {
|
|
19422
|
+
this._input.back();
|
|
19423
|
+
} else if (this._ch) {
|
|
19424
|
+
this.print_string(this._ch + this.eatString(")"));
|
|
19425
|
+
if (parenLevel) {
|
|
19426
|
+
parenLevel--;
|
|
19427
|
+
this.outdent();
|
|
19428
|
+
}
|
|
19429
|
+
}
|
|
19430
|
+
} else {
|
|
19431
|
+
var space_needed = false;
|
|
19432
|
+
if (this._input.lookBack("with")) {
|
|
19433
|
+
space_needed = true;
|
|
19434
|
+
}
|
|
19435
|
+
this.preserveSingleSpace(isAfterSpace || space_needed);
|
|
19436
|
+
this.print_string(this._ch);
|
|
19437
|
+
if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
|
|
19438
|
+
this._output.add_new_line();
|
|
19439
|
+
insideScssMap = true;
|
|
19440
|
+
} else {
|
|
19441
|
+
this.eatWhitespace();
|
|
19442
|
+
parenLevel++;
|
|
19443
|
+
this.indent();
|
|
19444
|
+
}
|
|
19445
|
+
}
|
|
19446
|
+
} else if (this._ch === ")") {
|
|
19447
|
+
if (parenLevel) {
|
|
19448
|
+
parenLevel--;
|
|
19449
|
+
this.outdent();
|
|
19450
|
+
}
|
|
19451
|
+
if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
|
|
19452
|
+
insideScssMap = false;
|
|
19453
|
+
this.outdent();
|
|
19454
|
+
this._output.add_new_line();
|
|
19455
|
+
}
|
|
19456
|
+
this.print_string(this._ch);
|
|
19457
|
+
} else if (this._ch === ",") {
|
|
19458
|
+
this.print_string(this._ch);
|
|
19459
|
+
this.eatWhitespace(true);
|
|
19460
|
+
if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
|
|
19461
|
+
this._output.add_new_line();
|
|
19462
|
+
} else {
|
|
19463
|
+
this._output.space_before_token = true;
|
|
19464
|
+
}
|
|
19465
|
+
} else if ((this._ch === ">" || this._ch === "+" || this._ch === "~") && !insidePropertyValue && parenLevel === 0) {
|
|
19466
|
+
if (this._options.space_around_combinator) {
|
|
19467
|
+
this._output.space_before_token = true;
|
|
19468
|
+
this.print_string(this._ch);
|
|
19469
|
+
this._output.space_before_token = true;
|
|
19470
|
+
} else {
|
|
19471
|
+
this.print_string(this._ch);
|
|
19472
|
+
this.eatWhitespace();
|
|
19473
|
+
if (this._ch && whitespaceChar.test(this._ch)) {
|
|
19474
|
+
this._ch = "";
|
|
19475
|
+
}
|
|
19476
|
+
}
|
|
19477
|
+
} else if (this._ch === "]") {
|
|
19478
|
+
this.print_string(this._ch);
|
|
19479
|
+
} else if (this._ch === "[") {
|
|
19480
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
19481
|
+
this.print_string(this._ch);
|
|
19482
|
+
} else if (this._ch === "=") {
|
|
19483
|
+
this.eatWhitespace();
|
|
19484
|
+
this.print_string("=");
|
|
19485
|
+
if (whitespaceChar.test(this._ch)) {
|
|
19486
|
+
this._ch = "";
|
|
19487
|
+
}
|
|
19488
|
+
} else if (this._ch === "!" && !this._input.lookBack("\\")) {
|
|
19489
|
+
this._output.space_before_token = true;
|
|
19490
|
+
this.print_string(this._ch);
|
|
19491
|
+
} else {
|
|
19492
|
+
var preserveAfterSpace = previous_ch === '"' || previous_ch === "'";
|
|
19493
|
+
this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
|
|
19494
|
+
this.print_string(this._ch);
|
|
19495
|
+
if (!this._output.just_added_newline() && this._input.peek() === "\n" && insideNonSemiColonValues) {
|
|
19496
|
+
this._output.add_new_line();
|
|
19497
|
+
}
|
|
19498
|
+
}
|
|
19499
|
+
}
|
|
19500
|
+
var sweetCode = this._output.get_code(eol);
|
|
19501
|
+
return sweetCode;
|
|
19502
|
+
};
|
|
19503
|
+
module.exports.Beautifier = Beautifier;
|
|
19504
|
+
}
|
|
19505
|
+
});
|
|
19506
|
+
|
|
19507
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/css/index.js
|
|
19508
|
+
var require_css = __commonJS({
|
|
19509
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/css/index.js"(exports, module) {
|
|
19510
|
+
init_define_process();
|
|
19511
|
+
var Beautifier = require_beautifier2().Beautifier;
|
|
19512
|
+
var Options = require_options3().Options;
|
|
19513
|
+
function css_beautify(source_text, options) {
|
|
19514
|
+
var beautifier = new Beautifier(source_text, options);
|
|
19515
|
+
return beautifier.beautify();
|
|
19516
|
+
}
|
|
19517
|
+
module.exports = css_beautify;
|
|
19518
|
+
module.exports.defaultOptions = function() {
|
|
19519
|
+
return new Options();
|
|
19520
|
+
};
|
|
19521
|
+
}
|
|
19522
|
+
});
|
|
19523
|
+
|
|
19524
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/html/options.js
|
|
19525
|
+
var require_options4 = __commonJS({
|
|
19526
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/html/options.js"(exports, module) {
|
|
19527
|
+
init_define_process();
|
|
19528
|
+
var BaseOptions = require_options().Options;
|
|
19529
|
+
function Options(options) {
|
|
19530
|
+
BaseOptions.call(this, options, "html");
|
|
19531
|
+
if (this.templating.length === 1 && this.templating[0] === "auto") {
|
|
19532
|
+
this.templating = ["django", "erb", "handlebars", "php"];
|
|
19533
|
+
}
|
|
19534
|
+
this.indent_inner_html = this._get_boolean("indent_inner_html");
|
|
19535
|
+
this.indent_body_inner_html = this._get_boolean("indent_body_inner_html", true);
|
|
19536
|
+
this.indent_head_inner_html = this._get_boolean("indent_head_inner_html", true);
|
|
19537
|
+
this.indent_handlebars = this._get_boolean("indent_handlebars", true);
|
|
19538
|
+
this.wrap_attributes = this._get_selection(
|
|
19539
|
+
"wrap_attributes",
|
|
19540
|
+
["auto", "force", "force-aligned", "force-expand-multiline", "aligned-multiple", "preserve", "preserve-aligned"]
|
|
19541
|
+
);
|
|
19542
|
+
this.wrap_attributes_indent_size = this._get_number("wrap_attributes_indent_size", this.indent_size);
|
|
19543
|
+
this.extra_liners = this._get_array("extra_liners", ["head", "body", "/html"]);
|
|
19544
|
+
this.inline = this._get_array("inline", [
|
|
19545
|
+
"a",
|
|
19546
|
+
"abbr",
|
|
19547
|
+
"area",
|
|
19548
|
+
"audio",
|
|
19549
|
+
"b",
|
|
19550
|
+
"bdi",
|
|
19551
|
+
"bdo",
|
|
19552
|
+
"br",
|
|
19553
|
+
"button",
|
|
19554
|
+
"canvas",
|
|
19555
|
+
"cite",
|
|
19556
|
+
"code",
|
|
19557
|
+
"data",
|
|
19558
|
+
"datalist",
|
|
19559
|
+
"del",
|
|
19560
|
+
"dfn",
|
|
19561
|
+
"em",
|
|
19562
|
+
"embed",
|
|
19563
|
+
"i",
|
|
19564
|
+
"iframe",
|
|
19565
|
+
"img",
|
|
19566
|
+
"input",
|
|
19567
|
+
"ins",
|
|
19568
|
+
"kbd",
|
|
19569
|
+
"keygen",
|
|
19570
|
+
"label",
|
|
19571
|
+
"map",
|
|
19572
|
+
"mark",
|
|
19573
|
+
"math",
|
|
19574
|
+
"meter",
|
|
19575
|
+
"noscript",
|
|
19576
|
+
"object",
|
|
19577
|
+
"output",
|
|
19578
|
+
"progress",
|
|
19579
|
+
"q",
|
|
19580
|
+
"ruby",
|
|
19581
|
+
"s",
|
|
19582
|
+
"samp",
|
|
19583
|
+
/* 'script', */
|
|
19584
|
+
"select",
|
|
19585
|
+
"small",
|
|
19586
|
+
"span",
|
|
19587
|
+
"strong",
|
|
19588
|
+
"sub",
|
|
19589
|
+
"sup",
|
|
19590
|
+
"svg",
|
|
19591
|
+
"template",
|
|
19592
|
+
"textarea",
|
|
19593
|
+
"time",
|
|
19594
|
+
"u",
|
|
19595
|
+
"var",
|
|
19596
|
+
"video",
|
|
19597
|
+
"wbr",
|
|
19598
|
+
"text",
|
|
19599
|
+
// obsolete inline tags
|
|
19600
|
+
"acronym",
|
|
19601
|
+
"big",
|
|
19602
|
+
"strike",
|
|
19603
|
+
"tt"
|
|
19604
|
+
]);
|
|
19605
|
+
this.void_elements = this._get_array("void_elements", [
|
|
19606
|
+
// HTLM void elements - aka self-closing tags - aka singletons
|
|
19607
|
+
// https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
|
|
19608
|
+
"area",
|
|
19609
|
+
"base",
|
|
19610
|
+
"br",
|
|
19611
|
+
"col",
|
|
19612
|
+
"embed",
|
|
19613
|
+
"hr",
|
|
19614
|
+
"img",
|
|
19615
|
+
"input",
|
|
19616
|
+
"keygen",
|
|
19617
|
+
"link",
|
|
19618
|
+
"menuitem",
|
|
19619
|
+
"meta",
|
|
19620
|
+
"param",
|
|
19621
|
+
"source",
|
|
19622
|
+
"track",
|
|
19623
|
+
"wbr",
|
|
19624
|
+
// NOTE: Optional tags are too complex for a simple list
|
|
19625
|
+
// they are hard coded in _do_optional_end_element
|
|
19626
|
+
// Doctype and xml elements
|
|
19627
|
+
"!doctype",
|
|
19628
|
+
"?xml",
|
|
19629
|
+
// obsolete tags
|
|
19630
|
+
// basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
|
|
19631
|
+
// isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
|
|
19632
|
+
"basefont",
|
|
19633
|
+
"isindex"
|
|
19634
|
+
]);
|
|
19635
|
+
this.unformatted = this._get_array("unformatted", []);
|
|
19636
|
+
this.content_unformatted = this._get_array("content_unformatted", [
|
|
19637
|
+
"pre",
|
|
19638
|
+
"textarea"
|
|
19639
|
+
]);
|
|
19640
|
+
this.unformatted_content_delimiter = this._get_characters("unformatted_content_delimiter");
|
|
19641
|
+
this.indent_scripts = this._get_selection("indent_scripts", ["normal", "keep", "separate"]);
|
|
19642
|
+
}
|
|
19643
|
+
Options.prototype = new BaseOptions();
|
|
19644
|
+
module.exports.Options = Options;
|
|
19645
|
+
}
|
|
19646
|
+
});
|
|
19647
|
+
|
|
19648
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/html/tokenizer.js
|
|
19649
|
+
var require_tokenizer3 = __commonJS({
|
|
19650
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/html/tokenizer.js"(exports, module) {
|
|
19651
|
+
init_define_process();
|
|
19652
|
+
var BaseTokenizer = require_tokenizer().Tokenizer;
|
|
19653
|
+
var BASETOKEN = require_tokenizer().TOKEN;
|
|
19654
|
+
var Directives = require_directives().Directives;
|
|
19655
|
+
var TemplatablePattern = require_templatablepattern().TemplatablePattern;
|
|
19656
|
+
var Pattern = require_pattern().Pattern;
|
|
19657
|
+
var TOKEN = {
|
|
19658
|
+
TAG_OPEN: "TK_TAG_OPEN",
|
|
19659
|
+
TAG_CLOSE: "TK_TAG_CLOSE",
|
|
19660
|
+
ATTRIBUTE: "TK_ATTRIBUTE",
|
|
19661
|
+
EQUALS: "TK_EQUALS",
|
|
19662
|
+
VALUE: "TK_VALUE",
|
|
19663
|
+
COMMENT: "TK_COMMENT",
|
|
19664
|
+
TEXT: "TK_TEXT",
|
|
19665
|
+
UNKNOWN: "TK_UNKNOWN",
|
|
19666
|
+
START: BASETOKEN.START,
|
|
19667
|
+
RAW: BASETOKEN.RAW,
|
|
19668
|
+
EOF: BASETOKEN.EOF
|
|
19669
|
+
};
|
|
19670
|
+
var directives_core = new Directives(/<\!--/, /-->/);
|
|
19671
|
+
var Tokenizer = function(input_string, options) {
|
|
19672
|
+
BaseTokenizer.call(this, input_string, options);
|
|
19673
|
+
this._current_tag_name = "";
|
|
19674
|
+
var templatable_reader = new TemplatablePattern(this._input).read_options(this._options);
|
|
19675
|
+
var pattern_reader = new Pattern(this._input);
|
|
19676
|
+
this.__patterns = {
|
|
19677
|
+
word: templatable_reader.until(/[\n\r\t <]/),
|
|
19678
|
+
single_quote: templatable_reader.until_after(/'/),
|
|
19679
|
+
double_quote: templatable_reader.until_after(/"/),
|
|
19680
|
+
attribute: templatable_reader.until(/[\n\r\t =>]|\/>/),
|
|
19681
|
+
element_name: templatable_reader.until(/[\n\r\t >\/]/),
|
|
19682
|
+
handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
|
|
19683
|
+
handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
|
|
19684
|
+
handlebars_open: pattern_reader.until(/[\n\r\t }]/),
|
|
19685
|
+
handlebars_raw_close: pattern_reader.until(/}}/),
|
|
19686
|
+
comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
|
|
19687
|
+
cdata: pattern_reader.starting_with(/<!\[CDATA\[/).until_after(/]]>/),
|
|
19688
|
+
// https://en.wikipedia.org/wiki/Conditional_comment
|
|
19689
|
+
conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
|
|
19690
|
+
processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
|
|
19691
|
+
};
|
|
19692
|
+
if (this._options.indent_handlebars) {
|
|
19693
|
+
this.__patterns.word = this.__patterns.word.exclude("handlebars");
|
|
19694
|
+
}
|
|
19695
|
+
this._unformatted_content_delimiter = null;
|
|
19696
|
+
if (this._options.unformatted_content_delimiter) {
|
|
19697
|
+
var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
|
|
19698
|
+
this.__patterns.unformatted_content_delimiter = pattern_reader.matching(literal_regexp).until_after(literal_regexp);
|
|
19699
|
+
}
|
|
19700
|
+
};
|
|
19701
|
+
Tokenizer.prototype = new BaseTokenizer();
|
|
19702
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
19703
|
+
return false;
|
|
19704
|
+
};
|
|
19705
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
19706
|
+
return current_token.type === TOKEN.TAG_OPEN;
|
|
19707
|
+
};
|
|
19708
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
19709
|
+
return current_token.type === TOKEN.TAG_CLOSE && (open_token && ((current_token.text === ">" || current_token.text === "/>") && open_token.text[0] === "<" || current_token.text === "}}" && open_token.text[0] === "{" && open_token.text[1] === "{"));
|
|
19710
|
+
};
|
|
19711
|
+
Tokenizer.prototype._reset = function() {
|
|
19712
|
+
this._current_tag_name = "";
|
|
19713
|
+
};
|
|
19714
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
19715
|
+
var token = null;
|
|
19716
|
+
this._readWhitespace();
|
|
19717
|
+
var c = this._input.peek();
|
|
19718
|
+
if (c === null) {
|
|
19719
|
+
return this._create_token(TOKEN.EOF, "");
|
|
19720
|
+
}
|
|
19721
|
+
token = token || this._read_open_handlebars(c, open_token);
|
|
19722
|
+
token = token || this._read_attribute(c, previous_token, open_token);
|
|
19723
|
+
token = token || this._read_close(c, open_token);
|
|
19724
|
+
token = token || this._read_raw_content(c, previous_token, open_token);
|
|
19725
|
+
token = token || this._read_content_word(c);
|
|
19726
|
+
token = token || this._read_comment_or_cdata(c);
|
|
19727
|
+
token = token || this._read_processing(c);
|
|
19728
|
+
token = token || this._read_open(c, open_token);
|
|
19729
|
+
token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
|
|
19730
|
+
return token;
|
|
19731
|
+
};
|
|
19732
|
+
Tokenizer.prototype._read_comment_or_cdata = function(c) {
|
|
19733
|
+
var token = null;
|
|
19734
|
+
var resulting_string = null;
|
|
19735
|
+
var directives = null;
|
|
19736
|
+
if (c === "<") {
|
|
19737
|
+
var peek1 = this._input.peek(1);
|
|
19738
|
+
if (peek1 === "!") {
|
|
19739
|
+
resulting_string = this.__patterns.comment.read();
|
|
19740
|
+
if (resulting_string) {
|
|
19741
|
+
directives = directives_core.get_directives(resulting_string);
|
|
19742
|
+
if (directives && directives.ignore === "start") {
|
|
19743
|
+
resulting_string += directives_core.readIgnored(this._input);
|
|
19744
|
+
}
|
|
19745
|
+
} else {
|
|
19746
|
+
resulting_string = this.__patterns.cdata.read();
|
|
19747
|
+
}
|
|
19748
|
+
}
|
|
19749
|
+
if (resulting_string) {
|
|
19750
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
19751
|
+
token.directives = directives;
|
|
19752
|
+
}
|
|
19753
|
+
}
|
|
19754
|
+
return token;
|
|
19755
|
+
};
|
|
19756
|
+
Tokenizer.prototype._read_processing = function(c) {
|
|
19757
|
+
var token = null;
|
|
19758
|
+
var resulting_string = null;
|
|
19759
|
+
var directives = null;
|
|
19760
|
+
if (c === "<") {
|
|
19761
|
+
var peek1 = this._input.peek(1);
|
|
19762
|
+
if (peek1 === "!" || peek1 === "?") {
|
|
19763
|
+
resulting_string = this.__patterns.conditional_comment.read();
|
|
19764
|
+
resulting_string = resulting_string || this.__patterns.processing.read();
|
|
19765
|
+
}
|
|
19766
|
+
if (resulting_string) {
|
|
19767
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
19768
|
+
token.directives = directives;
|
|
19769
|
+
}
|
|
19770
|
+
}
|
|
19771
|
+
return token;
|
|
19772
|
+
};
|
|
19773
|
+
Tokenizer.prototype._read_open = function(c, open_token) {
|
|
19774
|
+
var resulting_string = null;
|
|
19775
|
+
var token = null;
|
|
19776
|
+
if (!open_token) {
|
|
19777
|
+
if (c === "<") {
|
|
19778
|
+
resulting_string = this._input.next();
|
|
19779
|
+
if (this._input.peek() === "/") {
|
|
19780
|
+
resulting_string += this._input.next();
|
|
19781
|
+
}
|
|
19782
|
+
resulting_string += this.__patterns.element_name.read();
|
|
19783
|
+
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
|
|
19784
|
+
}
|
|
19785
|
+
}
|
|
19786
|
+
return token;
|
|
19787
|
+
};
|
|
19788
|
+
Tokenizer.prototype._read_open_handlebars = function(c, open_token) {
|
|
19789
|
+
var resulting_string = null;
|
|
19790
|
+
var token = null;
|
|
19791
|
+
if (!open_token) {
|
|
19792
|
+
if (this._options.indent_handlebars && c === "{" && this._input.peek(1) === "{") {
|
|
19793
|
+
if (this._input.peek(2) === "!") {
|
|
19794
|
+
resulting_string = this.__patterns.handlebars_comment.read();
|
|
19795
|
+
resulting_string = resulting_string || this.__patterns.handlebars.read();
|
|
19796
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
19797
|
+
} else {
|
|
19798
|
+
resulting_string = this.__patterns.handlebars_open.read();
|
|
19799
|
+
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
|
|
19800
|
+
}
|
|
19801
|
+
}
|
|
19802
|
+
}
|
|
19803
|
+
return token;
|
|
19804
|
+
};
|
|
19805
|
+
Tokenizer.prototype._read_close = function(c, open_token) {
|
|
19806
|
+
var resulting_string = null;
|
|
19807
|
+
var token = null;
|
|
19808
|
+
if (open_token) {
|
|
19809
|
+
if (open_token.text[0] === "<" && (c === ">" || c === "/" && this._input.peek(1) === ">")) {
|
|
19810
|
+
resulting_string = this._input.next();
|
|
19811
|
+
if (c === "/") {
|
|
19812
|
+
resulting_string += this._input.next();
|
|
19813
|
+
}
|
|
19814
|
+
token = this._create_token(TOKEN.TAG_CLOSE, resulting_string);
|
|
19815
|
+
} else if (open_token.text[0] === "{" && c === "}" && this._input.peek(1) === "}") {
|
|
19816
|
+
this._input.next();
|
|
19817
|
+
this._input.next();
|
|
19818
|
+
token = this._create_token(TOKEN.TAG_CLOSE, "}}");
|
|
19819
|
+
}
|
|
19820
|
+
}
|
|
19821
|
+
return token;
|
|
19822
|
+
};
|
|
19823
|
+
Tokenizer.prototype._read_attribute = function(c, previous_token, open_token) {
|
|
19824
|
+
var token = null;
|
|
19825
|
+
var resulting_string = "";
|
|
19826
|
+
if (open_token && open_token.text[0] === "<") {
|
|
19827
|
+
if (c === "=") {
|
|
19828
|
+
token = this._create_token(TOKEN.EQUALS, this._input.next());
|
|
19829
|
+
} else if (c === '"' || c === "'") {
|
|
19830
|
+
var content = this._input.next();
|
|
19831
|
+
if (c === '"') {
|
|
19832
|
+
content += this.__patterns.double_quote.read();
|
|
19833
|
+
} else {
|
|
19834
|
+
content += this.__patterns.single_quote.read();
|
|
19835
|
+
}
|
|
19836
|
+
token = this._create_token(TOKEN.VALUE, content);
|
|
19837
|
+
} else {
|
|
19838
|
+
resulting_string = this.__patterns.attribute.read();
|
|
19839
|
+
if (resulting_string) {
|
|
19840
|
+
if (previous_token.type === TOKEN.EQUALS) {
|
|
19841
|
+
token = this._create_token(TOKEN.VALUE, resulting_string);
|
|
19842
|
+
} else {
|
|
19843
|
+
token = this._create_token(TOKEN.ATTRIBUTE, resulting_string);
|
|
19844
|
+
}
|
|
19845
|
+
}
|
|
19846
|
+
}
|
|
19847
|
+
}
|
|
19848
|
+
return token;
|
|
19849
|
+
};
|
|
19850
|
+
Tokenizer.prototype._is_content_unformatted = function(tag_name) {
|
|
19851
|
+
return this._options.void_elements.indexOf(tag_name) === -1 && (this._options.content_unformatted.indexOf(tag_name) !== -1 || this._options.unformatted.indexOf(tag_name) !== -1);
|
|
19852
|
+
};
|
|
19853
|
+
Tokenizer.prototype._read_raw_content = function(c, previous_token, open_token) {
|
|
19854
|
+
var resulting_string = "";
|
|
19855
|
+
if (open_token && open_token.text[0] === "{") {
|
|
19856
|
+
resulting_string = this.__patterns.handlebars_raw_close.read();
|
|
19857
|
+
} else if (previous_token.type === TOKEN.TAG_CLOSE && previous_token.opened.text[0] === "<" && previous_token.text[0] !== "/") {
|
|
19858
|
+
var tag_name = previous_token.opened.text.substr(1).toLowerCase();
|
|
19859
|
+
if (tag_name === "script" || tag_name === "style") {
|
|
19860
|
+
var token = this._read_comment_or_cdata(c);
|
|
19861
|
+
if (token) {
|
|
19862
|
+
token.type = TOKEN.TEXT;
|
|
19863
|
+
return token;
|
|
19864
|
+
}
|
|
19865
|
+
resulting_string = this._input.readUntil(new RegExp("</" + tag_name + "[\\n\\r\\t ]*?>", "ig"));
|
|
19866
|
+
} else if (this._is_content_unformatted(tag_name)) {
|
|
19867
|
+
resulting_string = this._input.readUntil(new RegExp("</" + tag_name + "[\\n\\r\\t ]*?>", "ig"));
|
|
19868
|
+
}
|
|
19869
|
+
}
|
|
19870
|
+
if (resulting_string) {
|
|
19871
|
+
return this._create_token(TOKEN.TEXT, resulting_string);
|
|
19872
|
+
}
|
|
19873
|
+
return null;
|
|
19874
|
+
};
|
|
19875
|
+
Tokenizer.prototype._read_content_word = function(c) {
|
|
19876
|
+
var resulting_string = "";
|
|
19877
|
+
if (this._options.unformatted_content_delimiter) {
|
|
19878
|
+
if (c === this._options.unformatted_content_delimiter[0]) {
|
|
19879
|
+
resulting_string = this.__patterns.unformatted_content_delimiter.read();
|
|
19880
|
+
}
|
|
19881
|
+
}
|
|
19882
|
+
if (!resulting_string) {
|
|
19883
|
+
resulting_string = this.__patterns.word.read();
|
|
19884
|
+
}
|
|
19885
|
+
if (resulting_string) {
|
|
19886
|
+
return this._create_token(TOKEN.TEXT, resulting_string);
|
|
19887
|
+
}
|
|
19888
|
+
};
|
|
19889
|
+
module.exports.Tokenizer = Tokenizer;
|
|
19890
|
+
module.exports.TOKEN = TOKEN;
|
|
19891
|
+
}
|
|
19892
|
+
});
|
|
19893
|
+
|
|
19894
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/html/beautifier.js
|
|
19895
|
+
var require_beautifier3 = __commonJS({
|
|
19896
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/html/beautifier.js"(exports, module) {
|
|
19897
|
+
init_define_process();
|
|
19898
|
+
var Options = require_options4().Options;
|
|
19899
|
+
var Output = require_output().Output;
|
|
19900
|
+
var Tokenizer = require_tokenizer3().Tokenizer;
|
|
19901
|
+
var TOKEN = require_tokenizer3().TOKEN;
|
|
19902
|
+
var lineBreak = /\r\n|[\r\n]/;
|
|
19903
|
+
var allLineBreaks = /\r\n|[\r\n]/g;
|
|
19904
|
+
var Printer = function(options, base_indent_string) {
|
|
19905
|
+
this.indent_level = 0;
|
|
19906
|
+
this.alignment_size = 0;
|
|
19907
|
+
this.max_preserve_newlines = options.max_preserve_newlines;
|
|
19908
|
+
this.preserve_newlines = options.preserve_newlines;
|
|
19909
|
+
this._output = new Output(options, base_indent_string);
|
|
19910
|
+
};
|
|
19911
|
+
Printer.prototype.current_line_has_match = function(pattern) {
|
|
19912
|
+
return this._output.current_line.has_match(pattern);
|
|
19913
|
+
};
|
|
19914
|
+
Printer.prototype.set_space_before_token = function(value, non_breaking) {
|
|
19915
|
+
this._output.space_before_token = value;
|
|
19916
|
+
this._output.non_breaking_space = non_breaking;
|
|
19917
|
+
};
|
|
19918
|
+
Printer.prototype.set_wrap_point = function() {
|
|
19919
|
+
this._output.set_indent(this.indent_level, this.alignment_size);
|
|
19920
|
+
this._output.set_wrap_point();
|
|
19921
|
+
};
|
|
19922
|
+
Printer.prototype.add_raw_token = function(token) {
|
|
19923
|
+
this._output.add_raw_token(token);
|
|
19924
|
+
};
|
|
19925
|
+
Printer.prototype.print_preserved_newlines = function(raw_token) {
|
|
19926
|
+
var newlines = 0;
|
|
19927
|
+
if (raw_token.type !== TOKEN.TEXT && raw_token.previous.type !== TOKEN.TEXT) {
|
|
19928
|
+
newlines = raw_token.newlines ? 1 : 0;
|
|
19929
|
+
}
|
|
19930
|
+
if (this.preserve_newlines) {
|
|
19931
|
+
newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
|
|
19932
|
+
}
|
|
19933
|
+
for (var n = 0; n < newlines; n++) {
|
|
19934
|
+
this.print_newline(n > 0);
|
|
19935
|
+
}
|
|
19936
|
+
return newlines !== 0;
|
|
19937
|
+
};
|
|
19938
|
+
Printer.prototype.traverse_whitespace = function(raw_token) {
|
|
19939
|
+
if (raw_token.whitespace_before || raw_token.newlines) {
|
|
19940
|
+
if (!this.print_preserved_newlines(raw_token)) {
|
|
19941
|
+
this._output.space_before_token = true;
|
|
19942
|
+
}
|
|
19943
|
+
return true;
|
|
19944
|
+
}
|
|
19945
|
+
return false;
|
|
19946
|
+
};
|
|
19947
|
+
Printer.prototype.previous_token_wrapped = function() {
|
|
19948
|
+
return this._output.previous_token_wrapped;
|
|
19949
|
+
};
|
|
19950
|
+
Printer.prototype.print_newline = function(force) {
|
|
19951
|
+
this._output.add_new_line(force);
|
|
19952
|
+
};
|
|
19953
|
+
Printer.prototype.print_token = function(token) {
|
|
19954
|
+
if (token.text) {
|
|
19955
|
+
this._output.set_indent(this.indent_level, this.alignment_size);
|
|
19956
|
+
this._output.add_token(token.text);
|
|
19957
|
+
}
|
|
19958
|
+
};
|
|
19959
|
+
Printer.prototype.indent = function() {
|
|
19960
|
+
this.indent_level++;
|
|
19961
|
+
};
|
|
19962
|
+
Printer.prototype.get_full_indent = function(level) {
|
|
19963
|
+
level = this.indent_level + (level || 0);
|
|
19964
|
+
if (level < 1) {
|
|
19965
|
+
return "";
|
|
19966
|
+
}
|
|
19967
|
+
return this._output.get_indent_string(level);
|
|
19968
|
+
};
|
|
19969
|
+
var get_type_attribute = function(start_token) {
|
|
19970
|
+
var result = null;
|
|
19971
|
+
var raw_token = start_token.next;
|
|
19972
|
+
while (raw_token.type !== TOKEN.EOF && start_token.closed !== raw_token) {
|
|
19973
|
+
if (raw_token.type === TOKEN.ATTRIBUTE && raw_token.text === "type") {
|
|
19974
|
+
if (raw_token.next && raw_token.next.type === TOKEN.EQUALS && raw_token.next.next && raw_token.next.next.type === TOKEN.VALUE) {
|
|
19975
|
+
result = raw_token.next.next.text;
|
|
19976
|
+
}
|
|
19977
|
+
break;
|
|
19978
|
+
}
|
|
19979
|
+
raw_token = raw_token.next;
|
|
19980
|
+
}
|
|
19981
|
+
return result;
|
|
19982
|
+
};
|
|
19983
|
+
var get_custom_beautifier_name = function(tag_check, raw_token) {
|
|
19984
|
+
var typeAttribute = null;
|
|
19985
|
+
var result = null;
|
|
19986
|
+
if (!raw_token.closed) {
|
|
19987
|
+
return null;
|
|
19988
|
+
}
|
|
19989
|
+
if (tag_check === "script") {
|
|
19990
|
+
typeAttribute = "text/javascript";
|
|
19991
|
+
} else if (tag_check === "style") {
|
|
19992
|
+
typeAttribute = "text/css";
|
|
19993
|
+
}
|
|
19994
|
+
typeAttribute = get_type_attribute(raw_token) || typeAttribute;
|
|
19995
|
+
if (typeAttribute.search("text/css") > -1) {
|
|
19996
|
+
result = "css";
|
|
19997
|
+
} else if (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
|
|
19998
|
+
result = "javascript";
|
|
19999
|
+
} else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
|
|
20000
|
+
result = "html";
|
|
20001
|
+
} else if (typeAttribute.search(/test\/null/) > -1) {
|
|
20002
|
+
result = "null";
|
|
20003
|
+
}
|
|
20004
|
+
return result;
|
|
20005
|
+
};
|
|
20006
|
+
function in_array(what, arr) {
|
|
20007
|
+
return arr.indexOf(what) !== -1;
|
|
20008
|
+
}
|
|
20009
|
+
function TagFrame(parent, parser_token, indent_level) {
|
|
20010
|
+
this.parent = parent || null;
|
|
20011
|
+
this.tag = parser_token ? parser_token.tag_name : "";
|
|
20012
|
+
this.indent_level = indent_level || 0;
|
|
20013
|
+
this.parser_token = parser_token || null;
|
|
20014
|
+
}
|
|
20015
|
+
function TagStack(printer) {
|
|
20016
|
+
this._printer = printer;
|
|
20017
|
+
this._current_frame = null;
|
|
20018
|
+
}
|
|
20019
|
+
TagStack.prototype.get_parser_token = function() {
|
|
20020
|
+
return this._current_frame ? this._current_frame.parser_token : null;
|
|
20021
|
+
};
|
|
20022
|
+
TagStack.prototype.record_tag = function(parser_token) {
|
|
20023
|
+
var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
|
|
20024
|
+
this._current_frame = new_frame;
|
|
20025
|
+
};
|
|
20026
|
+
TagStack.prototype._try_pop_frame = function(frame) {
|
|
20027
|
+
var parser_token = null;
|
|
20028
|
+
if (frame) {
|
|
20029
|
+
parser_token = frame.parser_token;
|
|
20030
|
+
this._printer.indent_level = frame.indent_level;
|
|
20031
|
+
this._current_frame = frame.parent;
|
|
20032
|
+
}
|
|
20033
|
+
return parser_token;
|
|
20034
|
+
};
|
|
20035
|
+
TagStack.prototype._get_frame = function(tag_list, stop_list) {
|
|
20036
|
+
var frame = this._current_frame;
|
|
20037
|
+
while (frame) {
|
|
20038
|
+
if (tag_list.indexOf(frame.tag) !== -1) {
|
|
20039
|
+
break;
|
|
20040
|
+
} else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
|
|
20041
|
+
frame = null;
|
|
20042
|
+
break;
|
|
20043
|
+
}
|
|
20044
|
+
frame = frame.parent;
|
|
20045
|
+
}
|
|
20046
|
+
return frame;
|
|
20047
|
+
};
|
|
20048
|
+
TagStack.prototype.try_pop = function(tag, stop_list) {
|
|
20049
|
+
var frame = this._get_frame([tag], stop_list);
|
|
20050
|
+
return this._try_pop_frame(frame);
|
|
20051
|
+
};
|
|
20052
|
+
TagStack.prototype.indent_to_tag = function(tag_list) {
|
|
20053
|
+
var frame = this._get_frame(tag_list);
|
|
20054
|
+
if (frame) {
|
|
20055
|
+
this._printer.indent_level = frame.indent_level;
|
|
20056
|
+
}
|
|
20057
|
+
};
|
|
20058
|
+
function Beautifier(source_text, options, js_beautify, css_beautify) {
|
|
20059
|
+
this._source_text = source_text || "";
|
|
20060
|
+
options = options || {};
|
|
20061
|
+
this._js_beautify = js_beautify;
|
|
20062
|
+
this._css_beautify = css_beautify;
|
|
20063
|
+
this._tag_stack = null;
|
|
20064
|
+
var optionHtml = new Options(options, "html");
|
|
20065
|
+
this._options = optionHtml;
|
|
20066
|
+
this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, "force".length) === "force";
|
|
20067
|
+
this._is_wrap_attributes_force_expand_multiline = this._options.wrap_attributes === "force-expand-multiline";
|
|
20068
|
+
this._is_wrap_attributes_force_aligned = this._options.wrap_attributes === "force-aligned";
|
|
20069
|
+
this._is_wrap_attributes_aligned_multiple = this._options.wrap_attributes === "aligned-multiple";
|
|
20070
|
+
this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, "preserve".length) === "preserve";
|
|
20071
|
+
this._is_wrap_attributes_preserve_aligned = this._options.wrap_attributes === "preserve-aligned";
|
|
20072
|
+
}
|
|
20073
|
+
Beautifier.prototype.beautify = function() {
|
|
20074
|
+
if (this._options.disabled) {
|
|
20075
|
+
return this._source_text;
|
|
20076
|
+
}
|
|
20077
|
+
var source_text = this._source_text;
|
|
20078
|
+
var eol = this._options.eol;
|
|
20079
|
+
if (this._options.eol === "auto") {
|
|
20080
|
+
eol = "\n";
|
|
20081
|
+
if (source_text && lineBreak.test(source_text)) {
|
|
20082
|
+
eol = source_text.match(lineBreak)[0];
|
|
20083
|
+
}
|
|
20084
|
+
}
|
|
20085
|
+
source_text = source_text.replace(allLineBreaks, "\n");
|
|
20086
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
20087
|
+
var last_token = {
|
|
20088
|
+
text: "",
|
|
20089
|
+
type: ""
|
|
20090
|
+
};
|
|
20091
|
+
var last_tag_token = new TagOpenParserToken();
|
|
20092
|
+
var printer = new Printer(this._options, baseIndentString);
|
|
20093
|
+
var tokens = new Tokenizer(source_text, this._options).tokenize();
|
|
20094
|
+
this._tag_stack = new TagStack(printer);
|
|
20095
|
+
var parser_token = null;
|
|
20096
|
+
var raw_token = tokens.next();
|
|
20097
|
+
while (raw_token.type !== TOKEN.EOF) {
|
|
20098
|
+
if (raw_token.type === TOKEN.TAG_OPEN || raw_token.type === TOKEN.COMMENT) {
|
|
20099
|
+
parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token);
|
|
20100
|
+
last_tag_token = parser_token;
|
|
20101
|
+
} else if (raw_token.type === TOKEN.ATTRIBUTE || raw_token.type === TOKEN.EQUALS || raw_token.type === TOKEN.VALUE || raw_token.type === TOKEN.TEXT && !last_tag_token.tag_complete) {
|
|
20102
|
+
parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens);
|
|
20103
|
+
} else if (raw_token.type === TOKEN.TAG_CLOSE) {
|
|
20104
|
+
parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
|
|
20105
|
+
} else if (raw_token.type === TOKEN.TEXT) {
|
|
20106
|
+
parser_token = this._handle_text(printer, raw_token, last_tag_token);
|
|
20107
|
+
} else {
|
|
20108
|
+
printer.add_raw_token(raw_token);
|
|
20109
|
+
}
|
|
20110
|
+
last_token = parser_token;
|
|
20111
|
+
raw_token = tokens.next();
|
|
20112
|
+
}
|
|
20113
|
+
var sweet_code = printer._output.get_code(eol);
|
|
20114
|
+
return sweet_code;
|
|
20115
|
+
};
|
|
20116
|
+
Beautifier.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
|
|
20117
|
+
var parser_token = {
|
|
20118
|
+
text: raw_token.text,
|
|
20119
|
+
type: raw_token.type
|
|
20120
|
+
};
|
|
20121
|
+
printer.alignment_size = 0;
|
|
20122
|
+
last_tag_token.tag_complete = true;
|
|
20123
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
20124
|
+
if (last_tag_token.is_unformatted) {
|
|
20125
|
+
printer.add_raw_token(raw_token);
|
|
20126
|
+
} else {
|
|
20127
|
+
if (last_tag_token.tag_start_char === "<") {
|
|
20128
|
+
printer.set_space_before_token(raw_token.text[0] === "/", true);
|
|
20129
|
+
if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
|
|
20130
|
+
printer.print_newline(false);
|
|
20131
|
+
}
|
|
20132
|
+
}
|
|
20133
|
+
printer.print_token(raw_token);
|
|
20134
|
+
}
|
|
20135
|
+
if (last_tag_token.indent_content && !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
|
|
20136
|
+
printer.indent();
|
|
20137
|
+
last_tag_token.indent_content = false;
|
|
20138
|
+
}
|
|
20139
|
+
if (!last_tag_token.is_inline_element && !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
|
|
20140
|
+
printer.set_wrap_point();
|
|
20141
|
+
}
|
|
20142
|
+
return parser_token;
|
|
20143
|
+
};
|
|
20144
|
+
Beautifier.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) {
|
|
20145
|
+
var wrapped = last_tag_token.has_wrapped_attrs;
|
|
20146
|
+
var parser_token = {
|
|
20147
|
+
text: raw_token.text,
|
|
20148
|
+
type: raw_token.type
|
|
20149
|
+
};
|
|
20150
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
20151
|
+
if (last_tag_token.is_unformatted) {
|
|
20152
|
+
printer.add_raw_token(raw_token);
|
|
20153
|
+
} else if (last_tag_token.tag_start_char === "{" && raw_token.type === TOKEN.TEXT) {
|
|
20154
|
+
if (printer.print_preserved_newlines(raw_token)) {
|
|
20155
|
+
raw_token.newlines = 0;
|
|
20156
|
+
printer.add_raw_token(raw_token);
|
|
20157
|
+
} else {
|
|
20158
|
+
printer.print_token(raw_token);
|
|
20159
|
+
}
|
|
20160
|
+
} else {
|
|
20161
|
+
if (raw_token.type === TOKEN.ATTRIBUTE) {
|
|
20162
|
+
printer.set_space_before_token(true);
|
|
20163
|
+
last_tag_token.attr_count += 1;
|
|
20164
|
+
} else if (raw_token.type === TOKEN.EQUALS) {
|
|
20165
|
+
printer.set_space_before_token(false);
|
|
20166
|
+
} else if (raw_token.type === TOKEN.VALUE && raw_token.previous.type === TOKEN.EQUALS) {
|
|
20167
|
+
printer.set_space_before_token(false);
|
|
20168
|
+
}
|
|
20169
|
+
if (raw_token.type === TOKEN.ATTRIBUTE && last_tag_token.tag_start_char === "<") {
|
|
20170
|
+
if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
|
|
20171
|
+
printer.traverse_whitespace(raw_token);
|
|
20172
|
+
wrapped = wrapped || raw_token.newlines !== 0;
|
|
20173
|
+
}
|
|
20174
|
+
if (this._is_wrap_attributes_force) {
|
|
20175
|
+
var force_attr_wrap = last_tag_token.attr_count > 1;
|
|
20176
|
+
if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) {
|
|
20177
|
+
var is_only_attribute = true;
|
|
20178
|
+
var peek_index = 0;
|
|
20179
|
+
var peek_token;
|
|
20180
|
+
do {
|
|
20181
|
+
peek_token = tokens.peek(peek_index);
|
|
20182
|
+
if (peek_token.type === TOKEN.ATTRIBUTE) {
|
|
20183
|
+
is_only_attribute = false;
|
|
20184
|
+
break;
|
|
20185
|
+
}
|
|
20186
|
+
peek_index += 1;
|
|
20187
|
+
} while (peek_index < 4 && peek_token.type !== TOKEN.EOF && peek_token.type !== TOKEN.TAG_CLOSE);
|
|
20188
|
+
force_attr_wrap = !is_only_attribute;
|
|
20189
|
+
}
|
|
20190
|
+
if (force_attr_wrap) {
|
|
20191
|
+
printer.print_newline(false);
|
|
20192
|
+
wrapped = true;
|
|
20193
|
+
}
|
|
20194
|
+
}
|
|
20195
|
+
}
|
|
20196
|
+
printer.print_token(raw_token);
|
|
20197
|
+
wrapped = wrapped || printer.previous_token_wrapped();
|
|
20198
|
+
last_tag_token.has_wrapped_attrs = wrapped;
|
|
20199
|
+
}
|
|
20200
|
+
return parser_token;
|
|
20201
|
+
};
|
|
20202
|
+
Beautifier.prototype._handle_text = function(printer, raw_token, last_tag_token) {
|
|
20203
|
+
var parser_token = {
|
|
20204
|
+
text: raw_token.text,
|
|
20205
|
+
type: "TK_CONTENT"
|
|
20206
|
+
};
|
|
20207
|
+
if (last_tag_token.custom_beautifier_name) {
|
|
20208
|
+
this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
|
|
20209
|
+
} else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
|
|
20210
|
+
printer.add_raw_token(raw_token);
|
|
20211
|
+
} else {
|
|
20212
|
+
printer.traverse_whitespace(raw_token);
|
|
20213
|
+
printer.print_token(raw_token);
|
|
20214
|
+
}
|
|
20215
|
+
return parser_token;
|
|
20216
|
+
};
|
|
20217
|
+
Beautifier.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
|
|
20218
|
+
var local = this;
|
|
20219
|
+
if (raw_token.text !== "") {
|
|
20220
|
+
var text = raw_token.text, _beautifier, script_indent_level = 1, pre = "", post = "";
|
|
20221
|
+
if (last_tag_token.custom_beautifier_name === "javascript" && typeof this._js_beautify === "function") {
|
|
20222
|
+
_beautifier = this._js_beautify;
|
|
20223
|
+
} else if (last_tag_token.custom_beautifier_name === "css" && typeof this._css_beautify === "function") {
|
|
20224
|
+
_beautifier = this._css_beautify;
|
|
20225
|
+
} else if (last_tag_token.custom_beautifier_name === "html") {
|
|
20226
|
+
_beautifier = function(html_source, options) {
|
|
20227
|
+
var beautifier = new Beautifier(html_source, options, local._js_beautify, local._css_beautify);
|
|
20228
|
+
return beautifier.beautify();
|
|
20229
|
+
};
|
|
20230
|
+
}
|
|
20231
|
+
if (this._options.indent_scripts === "keep") {
|
|
20232
|
+
script_indent_level = 0;
|
|
20233
|
+
} else if (this._options.indent_scripts === "separate") {
|
|
20234
|
+
script_indent_level = -printer.indent_level;
|
|
20235
|
+
}
|
|
20236
|
+
var indentation = printer.get_full_indent(script_indent_level);
|
|
20237
|
+
text = text.replace(/\n[ \t]*$/, "");
|
|
20238
|
+
if (last_tag_token.custom_beautifier_name !== "html" && text[0] === "<" && text.match(/^(<!--|<!\[CDATA\[)/)) {
|
|
20239
|
+
var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
|
|
20240
|
+
if (!matched) {
|
|
20241
|
+
printer.add_raw_token(raw_token);
|
|
20242
|
+
return;
|
|
20243
|
+
}
|
|
20244
|
+
pre = indentation + matched[1] + "\n";
|
|
20245
|
+
text = matched[4];
|
|
20246
|
+
if (matched[5]) {
|
|
20247
|
+
post = indentation + matched[5];
|
|
20248
|
+
}
|
|
20249
|
+
text = text.replace(/\n[ \t]*$/, "");
|
|
20250
|
+
if (matched[2] || matched[3].indexOf("\n") !== -1) {
|
|
20251
|
+
matched = matched[3].match(/[ \t]+$/);
|
|
20252
|
+
if (matched) {
|
|
20253
|
+
raw_token.whitespace_before = matched[0];
|
|
20254
|
+
}
|
|
20255
|
+
}
|
|
20256
|
+
}
|
|
20257
|
+
if (text) {
|
|
20258
|
+
if (_beautifier) {
|
|
20259
|
+
var Child_options = function() {
|
|
20260
|
+
this.eol = "\n";
|
|
20261
|
+
};
|
|
20262
|
+
Child_options.prototype = this._options.raw_options;
|
|
20263
|
+
var child_options = new Child_options();
|
|
20264
|
+
text = _beautifier(indentation + text, child_options);
|
|
20265
|
+
} else {
|
|
20266
|
+
var white = raw_token.whitespace_before;
|
|
20267
|
+
if (white) {
|
|
20268
|
+
text = text.replace(new RegExp("\n(" + white + ")?", "g"), "\n");
|
|
20269
|
+
}
|
|
20270
|
+
text = indentation + text.replace(/\n/g, "\n" + indentation);
|
|
20271
|
+
}
|
|
20272
|
+
}
|
|
20273
|
+
if (pre) {
|
|
20274
|
+
if (!text) {
|
|
20275
|
+
text = pre + post;
|
|
20276
|
+
} else {
|
|
20277
|
+
text = pre + text + "\n" + post;
|
|
20278
|
+
}
|
|
20279
|
+
}
|
|
20280
|
+
printer.print_newline(false);
|
|
20281
|
+
if (text) {
|
|
20282
|
+
raw_token.text = text;
|
|
20283
|
+
raw_token.whitespace_before = "";
|
|
20284
|
+
raw_token.newlines = 0;
|
|
20285
|
+
printer.add_raw_token(raw_token);
|
|
20286
|
+
printer.print_newline(true);
|
|
20287
|
+
}
|
|
20288
|
+
}
|
|
20289
|
+
};
|
|
20290
|
+
Beautifier.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) {
|
|
20291
|
+
var parser_token = this._get_tag_open_token(raw_token);
|
|
20292
|
+
if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) && !last_tag_token.is_empty_element && raw_token.type === TOKEN.TAG_OPEN && raw_token.text.indexOf("</") === 0) {
|
|
20293
|
+
printer.add_raw_token(raw_token);
|
|
20294
|
+
parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
|
|
20295
|
+
} else {
|
|
20296
|
+
printer.traverse_whitespace(raw_token);
|
|
20297
|
+
this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
|
|
20298
|
+
if (!parser_token.is_inline_element) {
|
|
20299
|
+
printer.set_wrap_point();
|
|
20300
|
+
}
|
|
20301
|
+
printer.print_token(raw_token);
|
|
20302
|
+
}
|
|
20303
|
+
if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
|
|
20304
|
+
parser_token.alignment_size = raw_token.text.length + 1;
|
|
20305
|
+
}
|
|
20306
|
+
if (!parser_token.tag_complete && !parser_token.is_unformatted) {
|
|
20307
|
+
printer.alignment_size = parser_token.alignment_size;
|
|
20308
|
+
}
|
|
20309
|
+
return parser_token;
|
|
20310
|
+
};
|
|
20311
|
+
var TagOpenParserToken = function(parent, raw_token) {
|
|
20312
|
+
this.parent = parent || null;
|
|
20313
|
+
this.text = "";
|
|
20314
|
+
this.type = "TK_TAG_OPEN";
|
|
20315
|
+
this.tag_name = "";
|
|
20316
|
+
this.is_inline_element = false;
|
|
20317
|
+
this.is_unformatted = false;
|
|
20318
|
+
this.is_content_unformatted = false;
|
|
20319
|
+
this.is_empty_element = false;
|
|
20320
|
+
this.is_start_tag = false;
|
|
20321
|
+
this.is_end_tag = false;
|
|
20322
|
+
this.indent_content = false;
|
|
20323
|
+
this.multiline_content = false;
|
|
20324
|
+
this.custom_beautifier_name = null;
|
|
20325
|
+
this.start_tag_token = null;
|
|
20326
|
+
this.attr_count = 0;
|
|
20327
|
+
this.has_wrapped_attrs = false;
|
|
20328
|
+
this.alignment_size = 0;
|
|
20329
|
+
this.tag_complete = false;
|
|
20330
|
+
this.tag_start_char = "";
|
|
20331
|
+
this.tag_check = "";
|
|
20332
|
+
if (!raw_token) {
|
|
20333
|
+
this.tag_complete = true;
|
|
20334
|
+
} else {
|
|
20335
|
+
var tag_check_match;
|
|
20336
|
+
this.tag_start_char = raw_token.text[0];
|
|
20337
|
+
this.text = raw_token.text;
|
|
20338
|
+
if (this.tag_start_char === "<") {
|
|
20339
|
+
tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
|
|
20340
|
+
this.tag_check = tag_check_match ? tag_check_match[1] : "";
|
|
20341
|
+
} else {
|
|
20342
|
+
tag_check_match = raw_token.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/);
|
|
20343
|
+
this.tag_check = tag_check_match ? tag_check_match[1] : "";
|
|
20344
|
+
if ((raw_token.text.startsWith("{{#>") || raw_token.text.startsWith("{{~#>")) && this.tag_check[0] === ">") {
|
|
20345
|
+
if (this.tag_check === ">" && raw_token.next !== null) {
|
|
20346
|
+
this.tag_check = raw_token.next.text.split(" ")[0];
|
|
20347
|
+
} else {
|
|
20348
|
+
this.tag_check = raw_token.text.split(">")[1];
|
|
20349
|
+
}
|
|
20350
|
+
}
|
|
20351
|
+
}
|
|
20352
|
+
this.tag_check = this.tag_check.toLowerCase();
|
|
20353
|
+
if (raw_token.type === TOKEN.COMMENT) {
|
|
20354
|
+
this.tag_complete = true;
|
|
20355
|
+
}
|
|
20356
|
+
this.is_start_tag = this.tag_check.charAt(0) !== "/";
|
|
20357
|
+
this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
|
|
20358
|
+
this.is_end_tag = !this.is_start_tag || raw_token.closed && raw_token.closed.text === "/>";
|
|
20359
|
+
var handlebar_starts = 2;
|
|
20360
|
+
if (this.tag_start_char === "{" && this.text.length >= 3) {
|
|
20361
|
+
if (this.text.charAt(2) === "~") {
|
|
20362
|
+
handlebar_starts = 3;
|
|
20363
|
+
}
|
|
20364
|
+
}
|
|
20365
|
+
this.is_end_tag = this.is_end_tag || this.tag_start_char === "{" && (this.text.length < 3 || /[^#\^]/.test(this.text.charAt(handlebar_starts)));
|
|
20366
|
+
}
|
|
20367
|
+
};
|
|
20368
|
+
Beautifier.prototype._get_tag_open_token = function(raw_token) {
|
|
20369
|
+
var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
|
|
20370
|
+
parser_token.alignment_size = this._options.wrap_attributes_indent_size;
|
|
20371
|
+
parser_token.is_end_tag = parser_token.is_end_tag || in_array(parser_token.tag_check, this._options.void_elements);
|
|
20372
|
+
parser_token.is_empty_element = parser_token.tag_complete || parser_token.is_start_tag && parser_token.is_end_tag;
|
|
20373
|
+
parser_token.is_unformatted = !parser_token.tag_complete && in_array(parser_token.tag_check, this._options.unformatted);
|
|
20374
|
+
parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array(parser_token.tag_check, this._options.content_unformatted);
|
|
20375
|
+
parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || parser_token.tag_name.includes("-") || parser_token.tag_start_char === "{";
|
|
20376
|
+
return parser_token;
|
|
20377
|
+
};
|
|
20378
|
+
Beautifier.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
|
|
20379
|
+
if (!parser_token.is_empty_element) {
|
|
20380
|
+
if (parser_token.is_end_tag) {
|
|
20381
|
+
parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
|
|
20382
|
+
} else {
|
|
20383
|
+
if (this._do_optional_end_element(parser_token)) {
|
|
20384
|
+
if (!parser_token.is_inline_element) {
|
|
20385
|
+
printer.print_newline(false);
|
|
20386
|
+
}
|
|
20387
|
+
}
|
|
20388
|
+
this._tag_stack.record_tag(parser_token);
|
|
20389
|
+
if ((parser_token.tag_name === "script" || parser_token.tag_name === "style") && !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
|
|
20390
|
+
parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
|
|
20391
|
+
}
|
|
20392
|
+
}
|
|
20393
|
+
}
|
|
20394
|
+
if (in_array(parser_token.tag_check, this._options.extra_liners)) {
|
|
20395
|
+
printer.print_newline(false);
|
|
20396
|
+
if (!printer._output.just_added_blankline()) {
|
|
20397
|
+
printer.print_newline(true);
|
|
20398
|
+
}
|
|
20399
|
+
}
|
|
20400
|
+
if (parser_token.is_empty_element) {
|
|
20401
|
+
if (parser_token.tag_start_char === "{" && parser_token.tag_check === "else") {
|
|
20402
|
+
this._tag_stack.indent_to_tag(["if", "unless", "each"]);
|
|
20403
|
+
parser_token.indent_content = true;
|
|
20404
|
+
var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
|
|
20405
|
+
if (!foundIfOnCurrentLine) {
|
|
20406
|
+
printer.print_newline(false);
|
|
20407
|
+
}
|
|
20408
|
+
}
|
|
20409
|
+
if (parser_token.tag_name === "!--" && last_token.type === TOKEN.TAG_CLOSE && last_tag_token.is_end_tag && parser_token.text.indexOf("\n") === -1) ; else {
|
|
20410
|
+
if (!(parser_token.is_inline_element || parser_token.is_unformatted)) {
|
|
20411
|
+
printer.print_newline(false);
|
|
20412
|
+
}
|
|
20413
|
+
this._calcluate_parent_multiline(printer, parser_token);
|
|
20414
|
+
}
|
|
20415
|
+
} else if (parser_token.is_end_tag) {
|
|
20416
|
+
var do_end_expand = false;
|
|
20417
|
+
do_end_expand = parser_token.start_tag_token && parser_token.start_tag_token.multiline_content;
|
|
20418
|
+
do_end_expand = do_end_expand || !parser_token.is_inline_element && !(last_tag_token.is_inline_element || last_tag_token.is_unformatted) && !(last_token.type === TOKEN.TAG_CLOSE && parser_token.start_tag_token === last_tag_token) && last_token.type !== "TK_CONTENT";
|
|
20419
|
+
if (parser_token.is_content_unformatted || parser_token.is_unformatted) {
|
|
20420
|
+
do_end_expand = false;
|
|
20421
|
+
}
|
|
20422
|
+
if (do_end_expand) {
|
|
20423
|
+
printer.print_newline(false);
|
|
20424
|
+
}
|
|
20425
|
+
} else {
|
|
20426
|
+
parser_token.indent_content = !parser_token.custom_beautifier_name;
|
|
20427
|
+
if (parser_token.tag_start_char === "<") {
|
|
20428
|
+
if (parser_token.tag_name === "html") {
|
|
20429
|
+
parser_token.indent_content = this._options.indent_inner_html;
|
|
20430
|
+
} else if (parser_token.tag_name === "head") {
|
|
20431
|
+
parser_token.indent_content = this._options.indent_head_inner_html;
|
|
20432
|
+
} else if (parser_token.tag_name === "body") {
|
|
20433
|
+
parser_token.indent_content = this._options.indent_body_inner_html;
|
|
20434
|
+
}
|
|
20435
|
+
}
|
|
20436
|
+
if (!(parser_token.is_inline_element || parser_token.is_unformatted) && (last_token.type !== "TK_CONTENT" || parser_token.is_content_unformatted)) {
|
|
20437
|
+
printer.print_newline(false);
|
|
20438
|
+
}
|
|
20439
|
+
this._calcluate_parent_multiline(printer, parser_token);
|
|
20440
|
+
}
|
|
20441
|
+
};
|
|
20442
|
+
Beautifier.prototype._calcluate_parent_multiline = function(printer, parser_token) {
|
|
20443
|
+
if (parser_token.parent && printer._output.just_added_newline() && !((parser_token.is_inline_element || parser_token.is_unformatted) && parser_token.parent.is_inline_element)) {
|
|
20444
|
+
parser_token.parent.multiline_content = true;
|
|
20445
|
+
}
|
|
20446
|
+
};
|
|
20447
|
+
var p_closers = ["address", "article", "aside", "blockquote", "details", "div", "dl", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hr", "main", "nav", "ol", "p", "pre", "section", "table", "ul"];
|
|
20448
|
+
var p_parent_excludes = ["a", "audio", "del", "ins", "map", "noscript", "video"];
|
|
20449
|
+
Beautifier.prototype._do_optional_end_element = function(parser_token) {
|
|
20450
|
+
var result = null;
|
|
20451
|
+
if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
|
|
20452
|
+
return;
|
|
20453
|
+
}
|
|
20454
|
+
if (parser_token.tag_name === "body") {
|
|
20455
|
+
result = result || this._tag_stack.try_pop("head");
|
|
20456
|
+
} else if (parser_token.tag_name === "li") {
|
|
20457
|
+
result = result || this._tag_stack.try_pop("li", ["ol", "ul"]);
|
|
20458
|
+
} else if (parser_token.tag_name === "dd" || parser_token.tag_name === "dt") {
|
|
20459
|
+
result = result || this._tag_stack.try_pop("dt", ["dl"]);
|
|
20460
|
+
result = result || this._tag_stack.try_pop("dd", ["dl"]);
|
|
20461
|
+
} else if (parser_token.parent.tag_name === "p" && p_closers.indexOf(parser_token.tag_name) !== -1) {
|
|
20462
|
+
var p_parent = parser_token.parent.parent;
|
|
20463
|
+
if (!p_parent || p_parent_excludes.indexOf(p_parent.tag_name) === -1) {
|
|
20464
|
+
result = result || this._tag_stack.try_pop("p");
|
|
20465
|
+
}
|
|
20466
|
+
} else if (parser_token.tag_name === "rp" || parser_token.tag_name === "rt") {
|
|
20467
|
+
result = result || this._tag_stack.try_pop("rt", ["ruby", "rtc"]);
|
|
20468
|
+
result = result || this._tag_stack.try_pop("rp", ["ruby", "rtc"]);
|
|
20469
|
+
} else if (parser_token.tag_name === "optgroup") {
|
|
20470
|
+
result = result || this._tag_stack.try_pop("optgroup", ["select"]);
|
|
20471
|
+
} else if (parser_token.tag_name === "option") {
|
|
20472
|
+
result = result || this._tag_stack.try_pop("option", ["select", "datalist", "optgroup"]);
|
|
20473
|
+
} else if (parser_token.tag_name === "colgroup") {
|
|
20474
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
20475
|
+
} else if (parser_token.tag_name === "thead") {
|
|
20476
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
20477
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
20478
|
+
} else if (parser_token.tag_name === "tbody" || parser_token.tag_name === "tfoot") {
|
|
20479
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
20480
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
20481
|
+
result = result || this._tag_stack.try_pop("thead", ["table"]);
|
|
20482
|
+
result = result || this._tag_stack.try_pop("tbody", ["table"]);
|
|
20483
|
+
} else if (parser_token.tag_name === "tr") {
|
|
20484
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
20485
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
20486
|
+
result = result || this._tag_stack.try_pop("tr", ["table", "thead", "tbody", "tfoot"]);
|
|
20487
|
+
} else if (parser_token.tag_name === "th" || parser_token.tag_name === "td") {
|
|
20488
|
+
result = result || this._tag_stack.try_pop("td", ["table", "thead", "tbody", "tfoot", "tr"]);
|
|
20489
|
+
result = result || this._tag_stack.try_pop("th", ["table", "thead", "tbody", "tfoot", "tr"]);
|
|
20490
|
+
}
|
|
20491
|
+
parser_token.parent = this._tag_stack.get_parser_token();
|
|
20492
|
+
return result;
|
|
20493
|
+
};
|
|
20494
|
+
module.exports.Beautifier = Beautifier;
|
|
20495
|
+
}
|
|
20496
|
+
});
|
|
20497
|
+
|
|
20498
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/html/index.js
|
|
20499
|
+
var require_html = __commonJS({
|
|
20500
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/html/index.js"(exports, module) {
|
|
20501
|
+
init_define_process();
|
|
20502
|
+
var Beautifier = require_beautifier3().Beautifier;
|
|
20503
|
+
var Options = require_options4().Options;
|
|
20504
|
+
function style_html(html_source, options, js_beautify, css_beautify) {
|
|
20505
|
+
var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify);
|
|
20506
|
+
return beautifier.beautify();
|
|
20507
|
+
}
|
|
20508
|
+
module.exports = style_html;
|
|
20509
|
+
module.exports.defaultOptions = function() {
|
|
20510
|
+
return new Options();
|
|
20511
|
+
};
|
|
20512
|
+
}
|
|
20513
|
+
});
|
|
20514
|
+
|
|
20515
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/index.js
|
|
20516
|
+
var require_src2 = __commonJS({
|
|
20517
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/src/index.js"(exports, module) {
|
|
20518
|
+
init_define_process();
|
|
20519
|
+
var js_beautify = require_javascript();
|
|
20520
|
+
var css_beautify = require_css();
|
|
20521
|
+
var html_beautify = require_html();
|
|
20522
|
+
function style_html(html_source, options, js, css) {
|
|
20523
|
+
js = js || js_beautify;
|
|
20524
|
+
css = css || css_beautify;
|
|
20525
|
+
return html_beautify(html_source, options, js, css);
|
|
20526
|
+
}
|
|
20527
|
+
style_html.defaultOptions = html_beautify.defaultOptions;
|
|
20528
|
+
module.exports.js = js_beautify;
|
|
20529
|
+
module.exports.css = css_beautify;
|
|
20530
|
+
module.exports.html = style_html;
|
|
20531
|
+
}
|
|
20532
|
+
});
|
|
20533
|
+
|
|
20534
|
+
// ../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/index.js
|
|
20535
|
+
var require_js = __commonJS({
|
|
20536
|
+
"../../node_modules/.pnpm/js-beautify@1.14.7/node_modules/js-beautify/js/index.js"(exports, module) {
|
|
20537
|
+
init_define_process();
|
|
20538
|
+
function get_beautify(js_beautify, css_beautify, html_beautify) {
|
|
20539
|
+
var beautify2 = function(src, config) {
|
|
20540
|
+
return js_beautify.js_beautify(src, config);
|
|
20541
|
+
};
|
|
20542
|
+
beautify2.js = js_beautify.js_beautify;
|
|
20543
|
+
beautify2.css = css_beautify.css_beautify;
|
|
20544
|
+
beautify2.html = html_beautify.html_beautify;
|
|
20545
|
+
beautify2.js_beautify = js_beautify.js_beautify;
|
|
20546
|
+
beautify2.css_beautify = css_beautify.css_beautify;
|
|
20547
|
+
beautify2.html_beautify = html_beautify.html_beautify;
|
|
20548
|
+
return beautify2;
|
|
20549
|
+
}
|
|
20550
|
+
if (typeof define === "function" && define.amd) {
|
|
20551
|
+
define([
|
|
20552
|
+
"./lib/beautify",
|
|
20553
|
+
"./lib/beautify-css",
|
|
20554
|
+
"./lib/beautify-html"
|
|
20555
|
+
], function(js_beautify, css_beautify, html_beautify) {
|
|
20556
|
+
return get_beautify(js_beautify, css_beautify, html_beautify);
|
|
20557
|
+
});
|
|
20558
|
+
} else {
|
|
20559
|
+
(function(mod) {
|
|
20560
|
+
var beautifier = require_src2();
|
|
20561
|
+
beautifier.js_beautify = beautifier.js;
|
|
20562
|
+
beautifier.css_beautify = beautifier.css;
|
|
20563
|
+
beautifier.html_beautify = beautifier.html;
|
|
20564
|
+
mod.exports = get_beautify(beautifier, beautifier, beautifier);
|
|
20565
|
+
})(module);
|
|
20566
|
+
}
|
|
20567
|
+
}
|
|
20568
|
+
});
|
|
20569
|
+
|
|
16451
20570
|
// ../../node_modules/.pnpm/lodash.uniq@4.5.0/node_modules/lodash.uniq/index.js
|
|
16452
20571
|
var require_lodash = __commonJS({
|
|
16453
20572
|
"../../node_modules/.pnpm/lodash.uniq@4.5.0/node_modules/lodash.uniq/index.js"(exports, module) {
|
|
@@ -17018,6 +21137,22 @@ var kubb = (function (exports) {
|
|
|
17018
21137
|
}
|
|
17019
21138
|
};
|
|
17020
21139
|
|
|
21140
|
+
// src/utils/format.ts
|
|
21141
|
+
init_define_process();
|
|
21142
|
+
var import_js_beautify = __toESM(require_js());
|
|
21143
|
+
var formatOptions = {
|
|
21144
|
+
indent_size: 1,
|
|
21145
|
+
indent_char: " ",
|
|
21146
|
+
max_preserve_newlines: 5,
|
|
21147
|
+
preserve_newlines: true,
|
|
21148
|
+
brace_style: "collapse",
|
|
21149
|
+
space_before_conditional: true,
|
|
21150
|
+
wrap_line_length: 160
|
|
21151
|
+
};
|
|
21152
|
+
var format = (source) => {
|
|
21153
|
+
return (0, import_js_beautify.default)(source, formatOptions);
|
|
21154
|
+
};
|
|
21155
|
+
|
|
17021
21156
|
// src/plugin.ts
|
|
17022
21157
|
function createPlugin(factory) {
|
|
17023
21158
|
return (options) => {
|
|
@@ -17217,7 +21352,7 @@ var kubb = (function (exports) {
|
|
|
17217
21352
|
});
|
|
17218
21353
|
return count;
|
|
17219
21354
|
}
|
|
17220
|
-
getSource(file) {
|
|
21355
|
+
getSource(file, options = { format: true }) {
|
|
17221
21356
|
if (!file.fileName.endsWith(".ts")) {
|
|
17222
21357
|
return file.source;
|
|
17223
21358
|
}
|
|
@@ -17241,9 +21376,16 @@ import ${curr.isTypeOnly ? "type " : ""}{ ${curr.name.join(", ")} } from "${curr
|
|
|
17241
21376
|
import ${curr.isTypeOnly ? "type " : ""}${curr.name} from "${curr.path}";`;
|
|
17242
21377
|
}, "");
|
|
17243
21378
|
if (importSource) {
|
|
21379
|
+
if (options.format) {
|
|
21380
|
+
return format(`${importSource}
|
|
21381
|
+
${file.source}`);
|
|
21382
|
+
}
|
|
17244
21383
|
return `${importSource}
|
|
17245
21384
|
${file.source}`;
|
|
17246
21385
|
}
|
|
21386
|
+
if (options.format) {
|
|
21387
|
+
return format(file.source);
|
|
21388
|
+
}
|
|
17247
21389
|
return file.source;
|
|
17248
21390
|
}
|
|
17249
21391
|
get files() {
|
|
@@ -17727,6 +21869,7 @@ ${curr.source}`,
|
|
|
17727
21869
|
exports.createPluginCache = createPluginCache;
|
|
17728
21870
|
exports.default = src_default;
|
|
17729
21871
|
exports.defineConfig = defineConfig;
|
|
21872
|
+
exports.format = format;
|
|
17730
21873
|
exports.getPathMode = getPathMode;
|
|
17731
21874
|
exports.getRelativePath = getRelativePath;
|
|
17732
21875
|
exports.hooks = hooks;
|