unplugin-env 0.1.5 → 0.1.6
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/{chunk-2KZLPXSE.js → chunk-5IZPPKKA.js} +4134 -2
- package/dist/{chunk-QAX3K5V3.js → chunk-T3FDATSR.js} +1 -1
- package/dist/{chunk-5EP4GEYR.js → chunk-YLYGXRIS.js} +1 -1
- package/dist/esbuild.cjs +4134 -2
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +4134 -2
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +4134 -2
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +4134 -2
- package/dist/rollup.js +1 -1
- package/dist/vite.cjs +4134 -2
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +4134 -2
- package/dist/webpack.js +2 -2
- package/package.json +8 -6
|
@@ -21585,6 +21585,4105 @@ var require_lib = __commonJS({
|
|
|
21585
21585
|
}
|
|
21586
21586
|
});
|
|
21587
21587
|
|
|
21588
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/output.js
|
|
21589
|
+
var require_output = __commonJS({
|
|
21590
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/output.js"(exports, module2) {
|
|
21591
|
+
"use strict";
|
|
21592
|
+
function OutputLine(parent) {
|
|
21593
|
+
this.__parent = parent;
|
|
21594
|
+
this.__character_count = 0;
|
|
21595
|
+
this.__indent_count = -1;
|
|
21596
|
+
this.__alignment_count = 0;
|
|
21597
|
+
this.__wrap_point_index = 0;
|
|
21598
|
+
this.__wrap_point_character_count = 0;
|
|
21599
|
+
this.__wrap_point_indent_count = -1;
|
|
21600
|
+
this.__wrap_point_alignment_count = 0;
|
|
21601
|
+
this.__items = [];
|
|
21602
|
+
}
|
|
21603
|
+
OutputLine.prototype.clone_empty = function() {
|
|
21604
|
+
var line = new OutputLine(this.__parent);
|
|
21605
|
+
line.set_indent(this.__indent_count, this.__alignment_count);
|
|
21606
|
+
return line;
|
|
21607
|
+
};
|
|
21608
|
+
OutputLine.prototype.item = function(index) {
|
|
21609
|
+
if (index < 0) {
|
|
21610
|
+
return this.__items[this.__items.length + index];
|
|
21611
|
+
} else {
|
|
21612
|
+
return this.__items[index];
|
|
21613
|
+
}
|
|
21614
|
+
};
|
|
21615
|
+
OutputLine.prototype.has_match = function(pattern) {
|
|
21616
|
+
for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
|
|
21617
|
+
if (this.__items[lastCheckedOutput].match(pattern)) {
|
|
21618
|
+
return true;
|
|
21619
|
+
}
|
|
21620
|
+
}
|
|
21621
|
+
return false;
|
|
21622
|
+
};
|
|
21623
|
+
OutputLine.prototype.set_indent = function(indent, alignment) {
|
|
21624
|
+
if (this.is_empty()) {
|
|
21625
|
+
this.__indent_count = indent || 0;
|
|
21626
|
+
this.__alignment_count = alignment || 0;
|
|
21627
|
+
this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
|
|
21628
|
+
}
|
|
21629
|
+
};
|
|
21630
|
+
OutputLine.prototype._set_wrap_point = function() {
|
|
21631
|
+
if (this.__parent.wrap_line_length) {
|
|
21632
|
+
this.__wrap_point_index = this.__items.length;
|
|
21633
|
+
this.__wrap_point_character_count = this.__character_count;
|
|
21634
|
+
this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
|
|
21635
|
+
this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
|
|
21636
|
+
}
|
|
21637
|
+
};
|
|
21638
|
+
OutputLine.prototype._should_wrap = function() {
|
|
21639
|
+
return this.__wrap_point_index && this.__character_count > this.__parent.wrap_line_length && this.__wrap_point_character_count > this.__parent.next_line.__character_count;
|
|
21640
|
+
};
|
|
21641
|
+
OutputLine.prototype._allow_wrap = function() {
|
|
21642
|
+
if (this._should_wrap()) {
|
|
21643
|
+
this.__parent.add_new_line();
|
|
21644
|
+
var next = this.__parent.current_line;
|
|
21645
|
+
next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
|
|
21646
|
+
next.__items = this.__items.slice(this.__wrap_point_index);
|
|
21647
|
+
this.__items = this.__items.slice(0, this.__wrap_point_index);
|
|
21648
|
+
next.__character_count += this.__character_count - this.__wrap_point_character_count;
|
|
21649
|
+
this.__character_count = this.__wrap_point_character_count;
|
|
21650
|
+
if (next.__items[0] === " ") {
|
|
21651
|
+
next.__items.splice(0, 1);
|
|
21652
|
+
next.__character_count -= 1;
|
|
21653
|
+
}
|
|
21654
|
+
return true;
|
|
21655
|
+
}
|
|
21656
|
+
return false;
|
|
21657
|
+
};
|
|
21658
|
+
OutputLine.prototype.is_empty = function() {
|
|
21659
|
+
return this.__items.length === 0;
|
|
21660
|
+
};
|
|
21661
|
+
OutputLine.prototype.last = function() {
|
|
21662
|
+
if (!this.is_empty()) {
|
|
21663
|
+
return this.__items[this.__items.length - 1];
|
|
21664
|
+
} else {
|
|
21665
|
+
return null;
|
|
21666
|
+
}
|
|
21667
|
+
};
|
|
21668
|
+
OutputLine.prototype.push = function(item) {
|
|
21669
|
+
this.__items.push(item);
|
|
21670
|
+
var last_newline_index = item.lastIndexOf("\n");
|
|
21671
|
+
if (last_newline_index !== -1) {
|
|
21672
|
+
this.__character_count = item.length - last_newline_index;
|
|
21673
|
+
} else {
|
|
21674
|
+
this.__character_count += item.length;
|
|
21675
|
+
}
|
|
21676
|
+
};
|
|
21677
|
+
OutputLine.prototype.pop = function() {
|
|
21678
|
+
var item = null;
|
|
21679
|
+
if (!this.is_empty()) {
|
|
21680
|
+
item = this.__items.pop();
|
|
21681
|
+
this.__character_count -= item.length;
|
|
21682
|
+
}
|
|
21683
|
+
return item;
|
|
21684
|
+
};
|
|
21685
|
+
OutputLine.prototype._remove_indent = function() {
|
|
21686
|
+
if (this.__indent_count > 0) {
|
|
21687
|
+
this.__indent_count -= 1;
|
|
21688
|
+
this.__character_count -= this.__parent.indent_size;
|
|
21689
|
+
}
|
|
21690
|
+
};
|
|
21691
|
+
OutputLine.prototype._remove_wrap_indent = function() {
|
|
21692
|
+
if (this.__wrap_point_indent_count > 0) {
|
|
21693
|
+
this.__wrap_point_indent_count -= 1;
|
|
21694
|
+
}
|
|
21695
|
+
};
|
|
21696
|
+
OutputLine.prototype.trim = function() {
|
|
21697
|
+
while (this.last() === " ") {
|
|
21698
|
+
this.__items.pop();
|
|
21699
|
+
this.__character_count -= 1;
|
|
21700
|
+
}
|
|
21701
|
+
};
|
|
21702
|
+
OutputLine.prototype.toString = function() {
|
|
21703
|
+
var result = "";
|
|
21704
|
+
if (this.is_empty()) {
|
|
21705
|
+
if (this.__parent.indent_empty_lines) {
|
|
21706
|
+
result = this.__parent.get_indent_string(this.__indent_count);
|
|
21707
|
+
}
|
|
21708
|
+
} else {
|
|
21709
|
+
result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
|
|
21710
|
+
result += this.__items.join("");
|
|
21711
|
+
}
|
|
21712
|
+
return result;
|
|
21713
|
+
};
|
|
21714
|
+
function IndentStringCache(options, baseIndentString) {
|
|
21715
|
+
this.__cache = [""];
|
|
21716
|
+
this.__indent_size = options.indent_size;
|
|
21717
|
+
this.__indent_string = options.indent_char;
|
|
21718
|
+
if (!options.indent_with_tabs) {
|
|
21719
|
+
this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
|
|
21720
|
+
}
|
|
21721
|
+
baseIndentString = baseIndentString || "";
|
|
21722
|
+
if (options.indent_level > 0) {
|
|
21723
|
+
baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
|
|
21724
|
+
}
|
|
21725
|
+
this.__base_string = baseIndentString;
|
|
21726
|
+
this.__base_string_length = baseIndentString.length;
|
|
21727
|
+
}
|
|
21728
|
+
IndentStringCache.prototype.get_indent_size = function(indent, column) {
|
|
21729
|
+
var result = this.__base_string_length;
|
|
21730
|
+
column = column || 0;
|
|
21731
|
+
if (indent < 0) {
|
|
21732
|
+
result = 0;
|
|
21733
|
+
}
|
|
21734
|
+
result += indent * this.__indent_size;
|
|
21735
|
+
result += column;
|
|
21736
|
+
return result;
|
|
21737
|
+
};
|
|
21738
|
+
IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
|
|
21739
|
+
var result = this.__base_string;
|
|
21740
|
+
column = column || 0;
|
|
21741
|
+
if (indent_level < 0) {
|
|
21742
|
+
indent_level = 0;
|
|
21743
|
+
result = "";
|
|
21744
|
+
}
|
|
21745
|
+
column += indent_level * this.__indent_size;
|
|
21746
|
+
this.__ensure_cache(column);
|
|
21747
|
+
result += this.__cache[column];
|
|
21748
|
+
return result;
|
|
21749
|
+
};
|
|
21750
|
+
IndentStringCache.prototype.__ensure_cache = function(column) {
|
|
21751
|
+
while (column >= this.__cache.length) {
|
|
21752
|
+
this.__add_column();
|
|
21753
|
+
}
|
|
21754
|
+
};
|
|
21755
|
+
IndentStringCache.prototype.__add_column = function() {
|
|
21756
|
+
var column = this.__cache.length;
|
|
21757
|
+
var indent = 0;
|
|
21758
|
+
var result = "";
|
|
21759
|
+
if (this.__indent_size && column >= this.__indent_size) {
|
|
21760
|
+
indent = Math.floor(column / this.__indent_size);
|
|
21761
|
+
column -= indent * this.__indent_size;
|
|
21762
|
+
result = new Array(indent + 1).join(this.__indent_string);
|
|
21763
|
+
}
|
|
21764
|
+
if (column) {
|
|
21765
|
+
result += new Array(column + 1).join(" ");
|
|
21766
|
+
}
|
|
21767
|
+
this.__cache.push(result);
|
|
21768
|
+
};
|
|
21769
|
+
function Output(options, baseIndentString) {
|
|
21770
|
+
this.__indent_cache = new IndentStringCache(options, baseIndentString);
|
|
21771
|
+
this.raw = false;
|
|
21772
|
+
this._end_with_newline = options.end_with_newline;
|
|
21773
|
+
this.indent_size = options.indent_size;
|
|
21774
|
+
this.wrap_line_length = options.wrap_line_length;
|
|
21775
|
+
this.indent_empty_lines = options.indent_empty_lines;
|
|
21776
|
+
this.__lines = [];
|
|
21777
|
+
this.previous_line = null;
|
|
21778
|
+
this.current_line = null;
|
|
21779
|
+
this.next_line = new OutputLine(this);
|
|
21780
|
+
this.space_before_token = false;
|
|
21781
|
+
this.non_breaking_space = false;
|
|
21782
|
+
this.previous_token_wrapped = false;
|
|
21783
|
+
this.__add_outputline();
|
|
21784
|
+
}
|
|
21785
|
+
Output.prototype.__add_outputline = function() {
|
|
21786
|
+
this.previous_line = this.current_line;
|
|
21787
|
+
this.current_line = this.next_line.clone_empty();
|
|
21788
|
+
this.__lines.push(this.current_line);
|
|
21789
|
+
};
|
|
21790
|
+
Output.prototype.get_line_number = function() {
|
|
21791
|
+
return this.__lines.length;
|
|
21792
|
+
};
|
|
21793
|
+
Output.prototype.get_indent_string = function(indent, column) {
|
|
21794
|
+
return this.__indent_cache.get_indent_string(indent, column);
|
|
21795
|
+
};
|
|
21796
|
+
Output.prototype.get_indent_size = function(indent, column) {
|
|
21797
|
+
return this.__indent_cache.get_indent_size(indent, column);
|
|
21798
|
+
};
|
|
21799
|
+
Output.prototype.is_empty = function() {
|
|
21800
|
+
return !this.previous_line && this.current_line.is_empty();
|
|
21801
|
+
};
|
|
21802
|
+
Output.prototype.add_new_line = function(force_newline) {
|
|
21803
|
+
if (this.is_empty() || !force_newline && this.just_added_newline()) {
|
|
21804
|
+
return false;
|
|
21805
|
+
}
|
|
21806
|
+
if (!this.raw) {
|
|
21807
|
+
this.__add_outputline();
|
|
21808
|
+
}
|
|
21809
|
+
return true;
|
|
21810
|
+
};
|
|
21811
|
+
Output.prototype.get_code = function(eol) {
|
|
21812
|
+
this.trim(true);
|
|
21813
|
+
var last_item = this.current_line.pop();
|
|
21814
|
+
if (last_item) {
|
|
21815
|
+
if (last_item[last_item.length - 1] === "\n") {
|
|
21816
|
+
last_item = last_item.replace(/\n+$/g, "");
|
|
21817
|
+
}
|
|
21818
|
+
this.current_line.push(last_item);
|
|
21819
|
+
}
|
|
21820
|
+
if (this._end_with_newline) {
|
|
21821
|
+
this.__add_outputline();
|
|
21822
|
+
}
|
|
21823
|
+
var sweet_code = this.__lines.join("\n");
|
|
21824
|
+
if (eol !== "\n") {
|
|
21825
|
+
sweet_code = sweet_code.replace(/[\n]/g, eol);
|
|
21826
|
+
}
|
|
21827
|
+
return sweet_code;
|
|
21828
|
+
};
|
|
21829
|
+
Output.prototype.set_wrap_point = function() {
|
|
21830
|
+
this.current_line._set_wrap_point();
|
|
21831
|
+
};
|
|
21832
|
+
Output.prototype.set_indent = function(indent, alignment) {
|
|
21833
|
+
indent = indent || 0;
|
|
21834
|
+
alignment = alignment || 0;
|
|
21835
|
+
this.next_line.set_indent(indent, alignment);
|
|
21836
|
+
if (this.__lines.length > 1) {
|
|
21837
|
+
this.current_line.set_indent(indent, alignment);
|
|
21838
|
+
return true;
|
|
21839
|
+
}
|
|
21840
|
+
this.current_line.set_indent();
|
|
21841
|
+
return false;
|
|
21842
|
+
};
|
|
21843
|
+
Output.prototype.add_raw_token = function(token) {
|
|
21844
|
+
for (var x = 0; x < token.newlines; x++) {
|
|
21845
|
+
this.__add_outputline();
|
|
21846
|
+
}
|
|
21847
|
+
this.current_line.set_indent(-1);
|
|
21848
|
+
this.current_line.push(token.whitespace_before);
|
|
21849
|
+
this.current_line.push(token.text);
|
|
21850
|
+
this.space_before_token = false;
|
|
21851
|
+
this.non_breaking_space = false;
|
|
21852
|
+
this.previous_token_wrapped = false;
|
|
21853
|
+
};
|
|
21854
|
+
Output.prototype.add_token = function(printable_token) {
|
|
21855
|
+
this.__add_space_before_token();
|
|
21856
|
+
this.current_line.push(printable_token);
|
|
21857
|
+
this.space_before_token = false;
|
|
21858
|
+
this.non_breaking_space = false;
|
|
21859
|
+
this.previous_token_wrapped = this.current_line._allow_wrap();
|
|
21860
|
+
};
|
|
21861
|
+
Output.prototype.__add_space_before_token = function() {
|
|
21862
|
+
if (this.space_before_token && !this.just_added_newline()) {
|
|
21863
|
+
if (!this.non_breaking_space) {
|
|
21864
|
+
this.set_wrap_point();
|
|
21865
|
+
}
|
|
21866
|
+
this.current_line.push(" ");
|
|
21867
|
+
}
|
|
21868
|
+
};
|
|
21869
|
+
Output.prototype.remove_indent = function(index) {
|
|
21870
|
+
var output_length = this.__lines.length;
|
|
21871
|
+
while (index < output_length) {
|
|
21872
|
+
this.__lines[index]._remove_indent();
|
|
21873
|
+
index++;
|
|
21874
|
+
}
|
|
21875
|
+
this.current_line._remove_wrap_indent();
|
|
21876
|
+
};
|
|
21877
|
+
Output.prototype.trim = function(eat_newlines) {
|
|
21878
|
+
eat_newlines = eat_newlines === void 0 ? false : eat_newlines;
|
|
21879
|
+
this.current_line.trim();
|
|
21880
|
+
while (eat_newlines && this.__lines.length > 1 && this.current_line.is_empty()) {
|
|
21881
|
+
this.__lines.pop();
|
|
21882
|
+
this.current_line = this.__lines[this.__lines.length - 1];
|
|
21883
|
+
this.current_line.trim();
|
|
21884
|
+
}
|
|
21885
|
+
this.previous_line = this.__lines.length > 1 ? this.__lines[this.__lines.length - 2] : null;
|
|
21886
|
+
};
|
|
21887
|
+
Output.prototype.just_added_newline = function() {
|
|
21888
|
+
return this.current_line.is_empty();
|
|
21889
|
+
};
|
|
21890
|
+
Output.prototype.just_added_blankline = function() {
|
|
21891
|
+
return this.is_empty() || this.current_line.is_empty() && this.previous_line.is_empty();
|
|
21892
|
+
};
|
|
21893
|
+
Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
|
|
21894
|
+
var index = this.__lines.length - 2;
|
|
21895
|
+
while (index >= 0) {
|
|
21896
|
+
var potentialEmptyLine = this.__lines[index];
|
|
21897
|
+
if (potentialEmptyLine.is_empty()) {
|
|
21898
|
+
break;
|
|
21899
|
+
} else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 && potentialEmptyLine.item(-1) !== ends_with) {
|
|
21900
|
+
this.__lines.splice(index + 1, 0, new OutputLine(this));
|
|
21901
|
+
this.previous_line = this.__lines[this.__lines.length - 2];
|
|
21902
|
+
break;
|
|
21903
|
+
}
|
|
21904
|
+
index--;
|
|
21905
|
+
}
|
|
21906
|
+
};
|
|
21907
|
+
module2.exports.Output = Output;
|
|
21908
|
+
}
|
|
21909
|
+
});
|
|
21910
|
+
|
|
21911
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/token.js
|
|
21912
|
+
var require_token = __commonJS({
|
|
21913
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/token.js"(exports, module2) {
|
|
21914
|
+
"use strict";
|
|
21915
|
+
function Token(type, text, newlines, whitespace_before) {
|
|
21916
|
+
this.type = type;
|
|
21917
|
+
this.text = text;
|
|
21918
|
+
this.comments_before = null;
|
|
21919
|
+
this.newlines = newlines || 0;
|
|
21920
|
+
this.whitespace_before = whitespace_before || "";
|
|
21921
|
+
this.parent = null;
|
|
21922
|
+
this.next = null;
|
|
21923
|
+
this.previous = null;
|
|
21924
|
+
this.opened = null;
|
|
21925
|
+
this.closed = null;
|
|
21926
|
+
this.directives = null;
|
|
21927
|
+
}
|
|
21928
|
+
module2.exports.Token = Token;
|
|
21929
|
+
}
|
|
21930
|
+
});
|
|
21931
|
+
|
|
21932
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/acorn.js
|
|
21933
|
+
var require_acorn = __commonJS({
|
|
21934
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/acorn.js"(exports) {
|
|
21935
|
+
"use strict";
|
|
21936
|
+
var baseASCIIidentifierStartChars = "\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
|
|
21937
|
+
var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
|
|
21938
|
+
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";
|
|
21939
|
+
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";
|
|
21940
|
+
var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
|
|
21941
|
+
var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
|
|
21942
|
+
exports.identifier = new RegExp(identifierStart + identifierChars, "g");
|
|
21943
|
+
exports.identifierStart = new RegExp(identifierStart);
|
|
21944
|
+
exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
|
|
21945
|
+
exports.newline = /[\n\r\u2028\u2029]/;
|
|
21946
|
+
exports.lineBreak = new RegExp("\r\n|" + exports.newline.source);
|
|
21947
|
+
exports.allLineBreaks = new RegExp(exports.lineBreak.source, "g");
|
|
21948
|
+
}
|
|
21949
|
+
});
|
|
21950
|
+
|
|
21951
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/options.js
|
|
21952
|
+
var require_options = __commonJS({
|
|
21953
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/options.js"(exports, module2) {
|
|
21954
|
+
"use strict";
|
|
21955
|
+
function Options(options, merge_child_field) {
|
|
21956
|
+
this.raw_options = _mergeOpts(options, merge_child_field);
|
|
21957
|
+
this.disabled = this._get_boolean("disabled");
|
|
21958
|
+
this.eol = this._get_characters("eol", "auto");
|
|
21959
|
+
this.end_with_newline = this._get_boolean("end_with_newline");
|
|
21960
|
+
this.indent_size = this._get_number("indent_size", 4);
|
|
21961
|
+
this.indent_char = this._get_characters("indent_char", " ");
|
|
21962
|
+
this.indent_level = this._get_number("indent_level");
|
|
21963
|
+
this.preserve_newlines = this._get_boolean("preserve_newlines", true);
|
|
21964
|
+
this.max_preserve_newlines = this._get_number("max_preserve_newlines", 32786);
|
|
21965
|
+
if (!this.preserve_newlines) {
|
|
21966
|
+
this.max_preserve_newlines = 0;
|
|
21967
|
+
}
|
|
21968
|
+
this.indent_with_tabs = this._get_boolean("indent_with_tabs", this.indent_char === " ");
|
|
21969
|
+
if (this.indent_with_tabs) {
|
|
21970
|
+
this.indent_char = " ";
|
|
21971
|
+
if (this.indent_size === 1) {
|
|
21972
|
+
this.indent_size = 4;
|
|
21973
|
+
}
|
|
21974
|
+
}
|
|
21975
|
+
this.wrap_line_length = this._get_number("wrap_line_length", this._get_number("max_char"));
|
|
21976
|
+
this.indent_empty_lines = this._get_boolean("indent_empty_lines");
|
|
21977
|
+
this.templating = this._get_selection_list("templating", ["auto", "none", "django", "erb", "handlebars", "php", "smarty"], ["auto"]);
|
|
21978
|
+
}
|
|
21979
|
+
Options.prototype._get_array = function(name, default_value) {
|
|
21980
|
+
var option_value = this.raw_options[name];
|
|
21981
|
+
var result = default_value || [];
|
|
21982
|
+
if (typeof option_value === "object") {
|
|
21983
|
+
if (option_value !== null && typeof option_value.concat === "function") {
|
|
21984
|
+
result = option_value.concat();
|
|
21985
|
+
}
|
|
21986
|
+
} else if (typeof option_value === "string") {
|
|
21987
|
+
result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
|
|
21988
|
+
}
|
|
21989
|
+
return result;
|
|
21990
|
+
};
|
|
21991
|
+
Options.prototype._get_boolean = function(name, default_value) {
|
|
21992
|
+
var option_value = this.raw_options[name];
|
|
21993
|
+
var result = option_value === void 0 ? !!default_value : !!option_value;
|
|
21994
|
+
return result;
|
|
21995
|
+
};
|
|
21996
|
+
Options.prototype._get_characters = function(name, default_value) {
|
|
21997
|
+
var option_value = this.raw_options[name];
|
|
21998
|
+
var result = default_value || "";
|
|
21999
|
+
if (typeof option_value === "string") {
|
|
22000
|
+
result = option_value.replace(/\\r/, "\r").replace(/\\n/, "\n").replace(/\\t/, " ");
|
|
22001
|
+
}
|
|
22002
|
+
return result;
|
|
22003
|
+
};
|
|
22004
|
+
Options.prototype._get_number = function(name, default_value) {
|
|
22005
|
+
var option_value = this.raw_options[name];
|
|
22006
|
+
default_value = parseInt(default_value, 10);
|
|
22007
|
+
if (isNaN(default_value)) {
|
|
22008
|
+
default_value = 0;
|
|
22009
|
+
}
|
|
22010
|
+
var result = parseInt(option_value, 10);
|
|
22011
|
+
if (isNaN(result)) {
|
|
22012
|
+
result = default_value;
|
|
22013
|
+
}
|
|
22014
|
+
return result;
|
|
22015
|
+
};
|
|
22016
|
+
Options.prototype._get_selection = function(name, selection_list, default_value) {
|
|
22017
|
+
var result = this._get_selection_list(name, selection_list, default_value);
|
|
22018
|
+
if (result.length !== 1) {
|
|
22019
|
+
throw new Error(
|
|
22020
|
+
"Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" + selection_list + "\nYou passed in: '" + this.raw_options[name] + "'"
|
|
22021
|
+
);
|
|
22022
|
+
}
|
|
22023
|
+
return result[0];
|
|
22024
|
+
};
|
|
22025
|
+
Options.prototype._get_selection_list = function(name, selection_list, default_value) {
|
|
22026
|
+
if (!selection_list || selection_list.length === 0) {
|
|
22027
|
+
throw new Error("Selection list cannot be empty.");
|
|
22028
|
+
}
|
|
22029
|
+
default_value = default_value || [selection_list[0]];
|
|
22030
|
+
if (!this._is_valid_selection(default_value, selection_list)) {
|
|
22031
|
+
throw new Error("Invalid Default Value!");
|
|
22032
|
+
}
|
|
22033
|
+
var result = this._get_array(name, default_value);
|
|
22034
|
+
if (!this._is_valid_selection(result, selection_list)) {
|
|
22035
|
+
throw new Error(
|
|
22036
|
+
"Invalid Option Value: The option '" + name + "' can contain only the following values:\n" + selection_list + "\nYou passed in: '" + this.raw_options[name] + "'"
|
|
22037
|
+
);
|
|
22038
|
+
}
|
|
22039
|
+
return result;
|
|
22040
|
+
};
|
|
22041
|
+
Options.prototype._is_valid_selection = function(result, selection_list) {
|
|
22042
|
+
return result.length && selection_list.length && !result.some(function(item) {
|
|
22043
|
+
return selection_list.indexOf(item) === -1;
|
|
22044
|
+
});
|
|
22045
|
+
};
|
|
22046
|
+
function _mergeOpts(allOptions, childFieldName) {
|
|
22047
|
+
var finalOpts = {};
|
|
22048
|
+
allOptions = _normalizeOpts(allOptions);
|
|
22049
|
+
var name;
|
|
22050
|
+
for (name in allOptions) {
|
|
22051
|
+
if (name !== childFieldName) {
|
|
22052
|
+
finalOpts[name] = allOptions[name];
|
|
22053
|
+
}
|
|
22054
|
+
}
|
|
22055
|
+
if (childFieldName && allOptions[childFieldName]) {
|
|
22056
|
+
for (name in allOptions[childFieldName]) {
|
|
22057
|
+
finalOpts[name] = allOptions[childFieldName][name];
|
|
22058
|
+
}
|
|
22059
|
+
}
|
|
22060
|
+
return finalOpts;
|
|
22061
|
+
}
|
|
22062
|
+
function _normalizeOpts(options) {
|
|
22063
|
+
var convertedOpts = {};
|
|
22064
|
+
var key;
|
|
22065
|
+
for (key in options) {
|
|
22066
|
+
var newKey = key.replace(/-/g, "_");
|
|
22067
|
+
convertedOpts[newKey] = options[key];
|
|
22068
|
+
}
|
|
22069
|
+
return convertedOpts;
|
|
22070
|
+
}
|
|
22071
|
+
module2.exports.Options = Options;
|
|
22072
|
+
module2.exports.normalizeOpts = _normalizeOpts;
|
|
22073
|
+
module2.exports.mergeOpts = _mergeOpts;
|
|
22074
|
+
}
|
|
22075
|
+
});
|
|
22076
|
+
|
|
22077
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/options.js
|
|
22078
|
+
var require_options2 = __commonJS({
|
|
22079
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/options.js"(exports, module2) {
|
|
22080
|
+
"use strict";
|
|
22081
|
+
var BaseOptions = require_options().Options;
|
|
22082
|
+
var validPositionValues = ["before-newline", "after-newline", "preserve-newline"];
|
|
22083
|
+
function Options(options) {
|
|
22084
|
+
BaseOptions.call(this, options, "js");
|
|
22085
|
+
var raw_brace_style = this.raw_options.brace_style || null;
|
|
22086
|
+
if (raw_brace_style === "expand-strict") {
|
|
22087
|
+
this.raw_options.brace_style = "expand";
|
|
22088
|
+
} else if (raw_brace_style === "collapse-preserve-inline") {
|
|
22089
|
+
this.raw_options.brace_style = "collapse,preserve-inline";
|
|
22090
|
+
} else if (this.raw_options.braces_on_own_line !== void 0) {
|
|
22091
|
+
this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
|
|
22092
|
+
}
|
|
22093
|
+
var brace_style_split = this._get_selection_list("brace_style", ["collapse", "expand", "end-expand", "none", "preserve-inline"]);
|
|
22094
|
+
this.brace_preserve_inline = false;
|
|
22095
|
+
this.brace_style = "collapse";
|
|
22096
|
+
for (var bs = 0; bs < brace_style_split.length; bs++) {
|
|
22097
|
+
if (brace_style_split[bs] === "preserve-inline") {
|
|
22098
|
+
this.brace_preserve_inline = true;
|
|
22099
|
+
} else {
|
|
22100
|
+
this.brace_style = brace_style_split[bs];
|
|
22101
|
+
}
|
|
22102
|
+
}
|
|
22103
|
+
this.unindent_chained_methods = this._get_boolean("unindent_chained_methods");
|
|
22104
|
+
this.break_chained_methods = this._get_boolean("break_chained_methods");
|
|
22105
|
+
this.space_in_paren = this._get_boolean("space_in_paren");
|
|
22106
|
+
this.space_in_empty_paren = this._get_boolean("space_in_empty_paren");
|
|
22107
|
+
this.jslint_happy = this._get_boolean("jslint_happy");
|
|
22108
|
+
this.space_after_anon_function = this._get_boolean("space_after_anon_function");
|
|
22109
|
+
this.space_after_named_function = this._get_boolean("space_after_named_function");
|
|
22110
|
+
this.keep_array_indentation = this._get_boolean("keep_array_indentation");
|
|
22111
|
+
this.space_before_conditional = this._get_boolean("space_before_conditional", true);
|
|
22112
|
+
this.unescape_strings = this._get_boolean("unescape_strings");
|
|
22113
|
+
this.e4x = this._get_boolean("e4x");
|
|
22114
|
+
this.comma_first = this._get_boolean("comma_first");
|
|
22115
|
+
this.operator_position = this._get_selection("operator_position", validPositionValues);
|
|
22116
|
+
this.test_output_raw = this._get_boolean("test_output_raw");
|
|
22117
|
+
if (this.jslint_happy) {
|
|
22118
|
+
this.space_after_anon_function = true;
|
|
22119
|
+
}
|
|
22120
|
+
}
|
|
22121
|
+
Options.prototype = new BaseOptions();
|
|
22122
|
+
module2.exports.Options = Options;
|
|
22123
|
+
}
|
|
22124
|
+
});
|
|
22125
|
+
|
|
22126
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/inputscanner.js
|
|
22127
|
+
var require_inputscanner = __commonJS({
|
|
22128
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/inputscanner.js"(exports, module2) {
|
|
22129
|
+
"use strict";
|
|
22130
|
+
var regexp_has_sticky = RegExp.prototype.hasOwnProperty("sticky");
|
|
22131
|
+
function InputScanner(input_string) {
|
|
22132
|
+
this.__input = input_string || "";
|
|
22133
|
+
this.__input_length = this.__input.length;
|
|
22134
|
+
this.__position = 0;
|
|
22135
|
+
}
|
|
22136
|
+
InputScanner.prototype.restart = function() {
|
|
22137
|
+
this.__position = 0;
|
|
22138
|
+
};
|
|
22139
|
+
InputScanner.prototype.back = function() {
|
|
22140
|
+
if (this.__position > 0) {
|
|
22141
|
+
this.__position -= 1;
|
|
22142
|
+
}
|
|
22143
|
+
};
|
|
22144
|
+
InputScanner.prototype.hasNext = function() {
|
|
22145
|
+
return this.__position < this.__input_length;
|
|
22146
|
+
};
|
|
22147
|
+
InputScanner.prototype.next = function() {
|
|
22148
|
+
var val = null;
|
|
22149
|
+
if (this.hasNext()) {
|
|
22150
|
+
val = this.__input.charAt(this.__position);
|
|
22151
|
+
this.__position += 1;
|
|
22152
|
+
}
|
|
22153
|
+
return val;
|
|
22154
|
+
};
|
|
22155
|
+
InputScanner.prototype.peek = function(index) {
|
|
22156
|
+
var val = null;
|
|
22157
|
+
index = index || 0;
|
|
22158
|
+
index += this.__position;
|
|
22159
|
+
if (index >= 0 && index < this.__input_length) {
|
|
22160
|
+
val = this.__input.charAt(index);
|
|
22161
|
+
}
|
|
22162
|
+
return val;
|
|
22163
|
+
};
|
|
22164
|
+
InputScanner.prototype.__match = function(pattern, index) {
|
|
22165
|
+
pattern.lastIndex = index;
|
|
22166
|
+
var pattern_match = pattern.exec(this.__input);
|
|
22167
|
+
if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
|
|
22168
|
+
if (pattern_match.index !== index) {
|
|
22169
|
+
pattern_match = null;
|
|
22170
|
+
}
|
|
22171
|
+
}
|
|
22172
|
+
return pattern_match;
|
|
22173
|
+
};
|
|
22174
|
+
InputScanner.prototype.test = function(pattern, index) {
|
|
22175
|
+
index = index || 0;
|
|
22176
|
+
index += this.__position;
|
|
22177
|
+
if (index >= 0 && index < this.__input_length) {
|
|
22178
|
+
return !!this.__match(pattern, index);
|
|
22179
|
+
} else {
|
|
22180
|
+
return false;
|
|
22181
|
+
}
|
|
22182
|
+
};
|
|
22183
|
+
InputScanner.prototype.testChar = function(pattern, index) {
|
|
22184
|
+
var val = this.peek(index);
|
|
22185
|
+
pattern.lastIndex = 0;
|
|
22186
|
+
return val !== null && pattern.test(val);
|
|
22187
|
+
};
|
|
22188
|
+
InputScanner.prototype.match = function(pattern) {
|
|
22189
|
+
var pattern_match = this.__match(pattern, this.__position);
|
|
22190
|
+
if (pattern_match) {
|
|
22191
|
+
this.__position += pattern_match[0].length;
|
|
22192
|
+
} else {
|
|
22193
|
+
pattern_match = null;
|
|
22194
|
+
}
|
|
22195
|
+
return pattern_match;
|
|
22196
|
+
};
|
|
22197
|
+
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
|
|
22198
|
+
var val = "";
|
|
22199
|
+
var match;
|
|
22200
|
+
if (starting_pattern) {
|
|
22201
|
+
match = this.match(starting_pattern);
|
|
22202
|
+
if (match) {
|
|
22203
|
+
val += match[0];
|
|
22204
|
+
}
|
|
22205
|
+
}
|
|
22206
|
+
if (until_pattern && (match || !starting_pattern)) {
|
|
22207
|
+
val += this.readUntil(until_pattern, until_after);
|
|
22208
|
+
}
|
|
22209
|
+
return val;
|
|
22210
|
+
};
|
|
22211
|
+
InputScanner.prototype.readUntil = function(pattern, until_after) {
|
|
22212
|
+
var val = "";
|
|
22213
|
+
var match_index = this.__position;
|
|
22214
|
+
pattern.lastIndex = this.__position;
|
|
22215
|
+
var pattern_match = pattern.exec(this.__input);
|
|
22216
|
+
if (pattern_match) {
|
|
22217
|
+
match_index = pattern_match.index;
|
|
22218
|
+
if (until_after) {
|
|
22219
|
+
match_index += pattern_match[0].length;
|
|
22220
|
+
}
|
|
22221
|
+
} else {
|
|
22222
|
+
match_index = this.__input_length;
|
|
22223
|
+
}
|
|
22224
|
+
val = this.__input.substring(this.__position, match_index);
|
|
22225
|
+
this.__position = match_index;
|
|
22226
|
+
return val;
|
|
22227
|
+
};
|
|
22228
|
+
InputScanner.prototype.readUntilAfter = function(pattern) {
|
|
22229
|
+
return this.readUntil(pattern, true);
|
|
22230
|
+
};
|
|
22231
|
+
InputScanner.prototype.get_regexp = function(pattern, match_from) {
|
|
22232
|
+
var result = null;
|
|
22233
|
+
var flags = "g";
|
|
22234
|
+
if (match_from && regexp_has_sticky) {
|
|
22235
|
+
flags = "y";
|
|
22236
|
+
}
|
|
22237
|
+
if (typeof pattern === "string" && pattern !== "") {
|
|
22238
|
+
result = new RegExp(pattern, flags);
|
|
22239
|
+
} else if (pattern) {
|
|
22240
|
+
result = new RegExp(pattern.source, flags);
|
|
22241
|
+
}
|
|
22242
|
+
return result;
|
|
22243
|
+
};
|
|
22244
|
+
InputScanner.prototype.get_literal_regexp = function(literal_string) {
|
|
22245
|
+
return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
|
|
22246
|
+
};
|
|
22247
|
+
InputScanner.prototype.peekUntilAfter = function(pattern) {
|
|
22248
|
+
var start = this.__position;
|
|
22249
|
+
var val = this.readUntilAfter(pattern);
|
|
22250
|
+
this.__position = start;
|
|
22251
|
+
return val;
|
|
22252
|
+
};
|
|
22253
|
+
InputScanner.prototype.lookBack = function(testVal) {
|
|
22254
|
+
var start = this.__position - 1;
|
|
22255
|
+
return start >= testVal.length && this.__input.substring(start - testVal.length, start).toLowerCase() === testVal;
|
|
22256
|
+
};
|
|
22257
|
+
module2.exports.InputScanner = InputScanner;
|
|
22258
|
+
}
|
|
22259
|
+
});
|
|
22260
|
+
|
|
22261
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/tokenstream.js
|
|
22262
|
+
var require_tokenstream = __commonJS({
|
|
22263
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/tokenstream.js"(exports, module2) {
|
|
22264
|
+
"use strict";
|
|
22265
|
+
function TokenStream(parent_token) {
|
|
22266
|
+
this.__tokens = [];
|
|
22267
|
+
this.__tokens_length = this.__tokens.length;
|
|
22268
|
+
this.__position = 0;
|
|
22269
|
+
this.__parent_token = parent_token;
|
|
22270
|
+
}
|
|
22271
|
+
TokenStream.prototype.restart = function() {
|
|
22272
|
+
this.__position = 0;
|
|
22273
|
+
};
|
|
22274
|
+
TokenStream.prototype.isEmpty = function() {
|
|
22275
|
+
return this.__tokens_length === 0;
|
|
22276
|
+
};
|
|
22277
|
+
TokenStream.prototype.hasNext = function() {
|
|
22278
|
+
return this.__position < this.__tokens_length;
|
|
22279
|
+
};
|
|
22280
|
+
TokenStream.prototype.next = function() {
|
|
22281
|
+
var val = null;
|
|
22282
|
+
if (this.hasNext()) {
|
|
22283
|
+
val = this.__tokens[this.__position];
|
|
22284
|
+
this.__position += 1;
|
|
22285
|
+
}
|
|
22286
|
+
return val;
|
|
22287
|
+
};
|
|
22288
|
+
TokenStream.prototype.peek = function(index) {
|
|
22289
|
+
var val = null;
|
|
22290
|
+
index = index || 0;
|
|
22291
|
+
index += this.__position;
|
|
22292
|
+
if (index >= 0 && index < this.__tokens_length) {
|
|
22293
|
+
val = this.__tokens[index];
|
|
22294
|
+
}
|
|
22295
|
+
return val;
|
|
22296
|
+
};
|
|
22297
|
+
TokenStream.prototype.add = function(token) {
|
|
22298
|
+
if (this.__parent_token) {
|
|
22299
|
+
token.parent = this.__parent_token;
|
|
22300
|
+
}
|
|
22301
|
+
this.__tokens.push(token);
|
|
22302
|
+
this.__tokens_length += 1;
|
|
22303
|
+
};
|
|
22304
|
+
module2.exports.TokenStream = TokenStream;
|
|
22305
|
+
}
|
|
22306
|
+
});
|
|
22307
|
+
|
|
22308
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/pattern.js
|
|
22309
|
+
var require_pattern2 = __commonJS({
|
|
22310
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/pattern.js"(exports, module2) {
|
|
22311
|
+
"use strict";
|
|
22312
|
+
function Pattern(input_scanner, parent) {
|
|
22313
|
+
this._input = input_scanner;
|
|
22314
|
+
this._starting_pattern = null;
|
|
22315
|
+
this._match_pattern = null;
|
|
22316
|
+
this._until_pattern = null;
|
|
22317
|
+
this._until_after = false;
|
|
22318
|
+
if (parent) {
|
|
22319
|
+
this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
|
|
22320
|
+
this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
|
|
22321
|
+
this._until_pattern = this._input.get_regexp(parent._until_pattern);
|
|
22322
|
+
this._until_after = parent._until_after;
|
|
22323
|
+
}
|
|
22324
|
+
}
|
|
22325
|
+
Pattern.prototype.read = function() {
|
|
22326
|
+
var result = this._input.read(this._starting_pattern);
|
|
22327
|
+
if (!this._starting_pattern || result) {
|
|
22328
|
+
result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
|
|
22329
|
+
}
|
|
22330
|
+
return result;
|
|
22331
|
+
};
|
|
22332
|
+
Pattern.prototype.read_match = function() {
|
|
22333
|
+
return this._input.match(this._match_pattern);
|
|
22334
|
+
};
|
|
22335
|
+
Pattern.prototype.until_after = function(pattern) {
|
|
22336
|
+
var result = this._create();
|
|
22337
|
+
result._until_after = true;
|
|
22338
|
+
result._until_pattern = this._input.get_regexp(pattern);
|
|
22339
|
+
result._update();
|
|
22340
|
+
return result;
|
|
22341
|
+
};
|
|
22342
|
+
Pattern.prototype.until = function(pattern) {
|
|
22343
|
+
var result = this._create();
|
|
22344
|
+
result._until_after = false;
|
|
22345
|
+
result._until_pattern = this._input.get_regexp(pattern);
|
|
22346
|
+
result._update();
|
|
22347
|
+
return result;
|
|
22348
|
+
};
|
|
22349
|
+
Pattern.prototype.starting_with = function(pattern) {
|
|
22350
|
+
var result = this._create();
|
|
22351
|
+
result._starting_pattern = this._input.get_regexp(pattern, true);
|
|
22352
|
+
result._update();
|
|
22353
|
+
return result;
|
|
22354
|
+
};
|
|
22355
|
+
Pattern.prototype.matching = function(pattern) {
|
|
22356
|
+
var result = this._create();
|
|
22357
|
+
result._match_pattern = this._input.get_regexp(pattern, true);
|
|
22358
|
+
result._update();
|
|
22359
|
+
return result;
|
|
22360
|
+
};
|
|
22361
|
+
Pattern.prototype._create = function() {
|
|
22362
|
+
return new Pattern(this._input, this);
|
|
22363
|
+
};
|
|
22364
|
+
Pattern.prototype._update = function() {
|
|
22365
|
+
};
|
|
22366
|
+
module2.exports.Pattern = Pattern;
|
|
22367
|
+
}
|
|
22368
|
+
});
|
|
22369
|
+
|
|
22370
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/whitespacepattern.js
|
|
22371
|
+
var require_whitespacepattern = __commonJS({
|
|
22372
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/whitespacepattern.js"(exports, module2) {
|
|
22373
|
+
"use strict";
|
|
22374
|
+
var Pattern = require_pattern2().Pattern;
|
|
22375
|
+
function WhitespacePattern(input_scanner, parent) {
|
|
22376
|
+
Pattern.call(this, input_scanner, parent);
|
|
22377
|
+
if (parent) {
|
|
22378
|
+
this._line_regexp = this._input.get_regexp(parent._line_regexp);
|
|
22379
|
+
} else {
|
|
22380
|
+
this.__set_whitespace_patterns("", "");
|
|
22381
|
+
}
|
|
22382
|
+
this.newline_count = 0;
|
|
22383
|
+
this.whitespace_before_token = "";
|
|
22384
|
+
}
|
|
22385
|
+
WhitespacePattern.prototype = new Pattern();
|
|
22386
|
+
WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
|
|
22387
|
+
whitespace_chars += "\\t ";
|
|
22388
|
+
newline_chars += "\\n\\r";
|
|
22389
|
+
this._match_pattern = this._input.get_regexp(
|
|
22390
|
+
"[" + whitespace_chars + newline_chars + "]+",
|
|
22391
|
+
true
|
|
22392
|
+
);
|
|
22393
|
+
this._newline_regexp = this._input.get_regexp(
|
|
22394
|
+
"\\r\\n|[" + newline_chars + "]"
|
|
22395
|
+
);
|
|
22396
|
+
};
|
|
22397
|
+
WhitespacePattern.prototype.read = function() {
|
|
22398
|
+
this.newline_count = 0;
|
|
22399
|
+
this.whitespace_before_token = "";
|
|
22400
|
+
var resulting_string = this._input.read(this._match_pattern);
|
|
22401
|
+
if (resulting_string === " ") {
|
|
22402
|
+
this.whitespace_before_token = " ";
|
|
22403
|
+
} else if (resulting_string) {
|
|
22404
|
+
var matches = this.__split(this._newline_regexp, resulting_string);
|
|
22405
|
+
this.newline_count = matches.length - 1;
|
|
22406
|
+
this.whitespace_before_token = matches[this.newline_count];
|
|
22407
|
+
}
|
|
22408
|
+
return resulting_string;
|
|
22409
|
+
};
|
|
22410
|
+
WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
|
|
22411
|
+
var result = this._create();
|
|
22412
|
+
result.__set_whitespace_patterns(whitespace_chars, newline_chars);
|
|
22413
|
+
result._update();
|
|
22414
|
+
return result;
|
|
22415
|
+
};
|
|
22416
|
+
WhitespacePattern.prototype._create = function() {
|
|
22417
|
+
return new WhitespacePattern(this._input, this);
|
|
22418
|
+
};
|
|
22419
|
+
WhitespacePattern.prototype.__split = function(regexp, input_string) {
|
|
22420
|
+
regexp.lastIndex = 0;
|
|
22421
|
+
var start_index = 0;
|
|
22422
|
+
var result = [];
|
|
22423
|
+
var next_match = regexp.exec(input_string);
|
|
22424
|
+
while (next_match) {
|
|
22425
|
+
result.push(input_string.substring(start_index, next_match.index));
|
|
22426
|
+
start_index = next_match.index + next_match[0].length;
|
|
22427
|
+
next_match = regexp.exec(input_string);
|
|
22428
|
+
}
|
|
22429
|
+
if (start_index < input_string.length) {
|
|
22430
|
+
result.push(input_string.substring(start_index, input_string.length));
|
|
22431
|
+
} else {
|
|
22432
|
+
result.push("");
|
|
22433
|
+
}
|
|
22434
|
+
return result;
|
|
22435
|
+
};
|
|
22436
|
+
module2.exports.WhitespacePattern = WhitespacePattern;
|
|
22437
|
+
}
|
|
22438
|
+
});
|
|
22439
|
+
|
|
22440
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/tokenizer.js
|
|
22441
|
+
var require_tokenizer = __commonJS({
|
|
22442
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/tokenizer.js"(exports, module2) {
|
|
22443
|
+
"use strict";
|
|
22444
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
22445
|
+
var Token = require_token().Token;
|
|
22446
|
+
var TokenStream = require_tokenstream().TokenStream;
|
|
22447
|
+
var WhitespacePattern = require_whitespacepattern().WhitespacePattern;
|
|
22448
|
+
var TOKEN = {
|
|
22449
|
+
START: "TK_START",
|
|
22450
|
+
RAW: "TK_RAW",
|
|
22451
|
+
EOF: "TK_EOF"
|
|
22452
|
+
};
|
|
22453
|
+
var Tokenizer = function(input_string, options) {
|
|
22454
|
+
this._input = new InputScanner(input_string);
|
|
22455
|
+
this._options = options || {};
|
|
22456
|
+
this.__tokens = null;
|
|
22457
|
+
this._patterns = {};
|
|
22458
|
+
this._patterns.whitespace = new WhitespacePattern(this._input);
|
|
22459
|
+
};
|
|
22460
|
+
Tokenizer.prototype.tokenize = function() {
|
|
22461
|
+
this._input.restart();
|
|
22462
|
+
this.__tokens = new TokenStream();
|
|
22463
|
+
this._reset();
|
|
22464
|
+
var current;
|
|
22465
|
+
var previous = new Token(TOKEN.START, "");
|
|
22466
|
+
var open_token = null;
|
|
22467
|
+
var open_stack = [];
|
|
22468
|
+
var comments = new TokenStream();
|
|
22469
|
+
while (previous.type !== TOKEN.EOF) {
|
|
22470
|
+
current = this._get_next_token(previous, open_token);
|
|
22471
|
+
while (this._is_comment(current)) {
|
|
22472
|
+
comments.add(current);
|
|
22473
|
+
current = this._get_next_token(previous, open_token);
|
|
22474
|
+
}
|
|
22475
|
+
if (!comments.isEmpty()) {
|
|
22476
|
+
current.comments_before = comments;
|
|
22477
|
+
comments = new TokenStream();
|
|
22478
|
+
}
|
|
22479
|
+
current.parent = open_token;
|
|
22480
|
+
if (this._is_opening(current)) {
|
|
22481
|
+
open_stack.push(open_token);
|
|
22482
|
+
open_token = current;
|
|
22483
|
+
} else if (open_token && this._is_closing(current, open_token)) {
|
|
22484
|
+
current.opened = open_token;
|
|
22485
|
+
open_token.closed = current;
|
|
22486
|
+
open_token = open_stack.pop();
|
|
22487
|
+
current.parent = open_token;
|
|
22488
|
+
}
|
|
22489
|
+
current.previous = previous;
|
|
22490
|
+
previous.next = current;
|
|
22491
|
+
this.__tokens.add(current);
|
|
22492
|
+
previous = current;
|
|
22493
|
+
}
|
|
22494
|
+
return this.__tokens;
|
|
22495
|
+
};
|
|
22496
|
+
Tokenizer.prototype._is_first_token = function() {
|
|
22497
|
+
return this.__tokens.isEmpty();
|
|
22498
|
+
};
|
|
22499
|
+
Tokenizer.prototype._reset = function() {
|
|
22500
|
+
};
|
|
22501
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
22502
|
+
this._readWhitespace();
|
|
22503
|
+
var resulting_string = this._input.read(/.+/g);
|
|
22504
|
+
if (resulting_string) {
|
|
22505
|
+
return this._create_token(TOKEN.RAW, resulting_string);
|
|
22506
|
+
} else {
|
|
22507
|
+
return this._create_token(TOKEN.EOF, "");
|
|
22508
|
+
}
|
|
22509
|
+
};
|
|
22510
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
22511
|
+
return false;
|
|
22512
|
+
};
|
|
22513
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
22514
|
+
return false;
|
|
22515
|
+
};
|
|
22516
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
22517
|
+
return false;
|
|
22518
|
+
};
|
|
22519
|
+
Tokenizer.prototype._create_token = function(type, text) {
|
|
22520
|
+
var token = new Token(
|
|
22521
|
+
type,
|
|
22522
|
+
text,
|
|
22523
|
+
this._patterns.whitespace.newline_count,
|
|
22524
|
+
this._patterns.whitespace.whitespace_before_token
|
|
22525
|
+
);
|
|
22526
|
+
return token;
|
|
22527
|
+
};
|
|
22528
|
+
Tokenizer.prototype._readWhitespace = function() {
|
|
22529
|
+
return this._patterns.whitespace.read();
|
|
22530
|
+
};
|
|
22531
|
+
module2.exports.Tokenizer = Tokenizer;
|
|
22532
|
+
module2.exports.TOKEN = TOKEN;
|
|
22533
|
+
}
|
|
22534
|
+
});
|
|
22535
|
+
|
|
22536
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/directives.js
|
|
22537
|
+
var require_directives = __commonJS({
|
|
22538
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/directives.js"(exports, module2) {
|
|
22539
|
+
"use strict";
|
|
22540
|
+
function Directives(start_block_pattern, end_block_pattern) {
|
|
22541
|
+
start_block_pattern = typeof start_block_pattern === "string" ? start_block_pattern : start_block_pattern.source;
|
|
22542
|
+
end_block_pattern = typeof end_block_pattern === "string" ? end_block_pattern : end_block_pattern.source;
|
|
22543
|
+
this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, "g");
|
|
22544
|
+
this.__directive_pattern = / (\w+)[:](\w+)/g;
|
|
22545
|
+
this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, "g");
|
|
22546
|
+
}
|
|
22547
|
+
Directives.prototype.get_directives = function(text) {
|
|
22548
|
+
if (!text.match(this.__directives_block_pattern)) {
|
|
22549
|
+
return null;
|
|
22550
|
+
}
|
|
22551
|
+
var directives = {};
|
|
22552
|
+
this.__directive_pattern.lastIndex = 0;
|
|
22553
|
+
var directive_match = this.__directive_pattern.exec(text);
|
|
22554
|
+
while (directive_match) {
|
|
22555
|
+
directives[directive_match[1]] = directive_match[2];
|
|
22556
|
+
directive_match = this.__directive_pattern.exec(text);
|
|
22557
|
+
}
|
|
22558
|
+
return directives;
|
|
22559
|
+
};
|
|
22560
|
+
Directives.prototype.readIgnored = function(input) {
|
|
22561
|
+
return input.readUntilAfter(this.__directives_end_ignore_pattern);
|
|
22562
|
+
};
|
|
22563
|
+
module2.exports.Directives = Directives;
|
|
22564
|
+
}
|
|
22565
|
+
});
|
|
22566
|
+
|
|
22567
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/templatablepattern.js
|
|
22568
|
+
var require_templatablepattern = __commonJS({
|
|
22569
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/core/templatablepattern.js"(exports, module2) {
|
|
22570
|
+
"use strict";
|
|
22571
|
+
var Pattern = require_pattern2().Pattern;
|
|
22572
|
+
var template_names = {
|
|
22573
|
+
django: false,
|
|
22574
|
+
erb: false,
|
|
22575
|
+
handlebars: false,
|
|
22576
|
+
php: false,
|
|
22577
|
+
smarty: false
|
|
22578
|
+
};
|
|
22579
|
+
function TemplatablePattern(input_scanner, parent) {
|
|
22580
|
+
Pattern.call(this, input_scanner, parent);
|
|
22581
|
+
this.__template_pattern = null;
|
|
22582
|
+
this._disabled = Object.assign({}, template_names);
|
|
22583
|
+
this._excluded = Object.assign({}, template_names);
|
|
22584
|
+
if (parent) {
|
|
22585
|
+
this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
|
|
22586
|
+
this._excluded = Object.assign(this._excluded, parent._excluded);
|
|
22587
|
+
this._disabled = Object.assign(this._disabled, parent._disabled);
|
|
22588
|
+
}
|
|
22589
|
+
var pattern = new Pattern(input_scanner);
|
|
22590
|
+
this.__patterns = {
|
|
22591
|
+
handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
|
|
22592
|
+
handlebars_unescaped: pattern.starting_with(/{{{/).until_after(/}}}/),
|
|
22593
|
+
handlebars: pattern.starting_with(/{{/).until_after(/}}/),
|
|
22594
|
+
php: pattern.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),
|
|
22595
|
+
erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
|
|
22596
|
+
// django coflicts with handlebars a bit.
|
|
22597
|
+
django: pattern.starting_with(/{%/).until_after(/%}/),
|
|
22598
|
+
django_value: pattern.starting_with(/{{/).until_after(/}}/),
|
|
22599
|
+
django_comment: pattern.starting_with(/{#/).until_after(/#}/),
|
|
22600
|
+
smarty: pattern.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),
|
|
22601
|
+
smarty_comment: pattern.starting_with(/{\*/).until_after(/\*}/),
|
|
22602
|
+
smarty_literal: pattern.starting_with(/{literal}/).until_after(/{\/literal}/)
|
|
22603
|
+
};
|
|
22604
|
+
}
|
|
22605
|
+
TemplatablePattern.prototype = new Pattern();
|
|
22606
|
+
TemplatablePattern.prototype._create = function() {
|
|
22607
|
+
return new TemplatablePattern(this._input, this);
|
|
22608
|
+
};
|
|
22609
|
+
TemplatablePattern.prototype._update = function() {
|
|
22610
|
+
this.__set_templated_pattern();
|
|
22611
|
+
};
|
|
22612
|
+
TemplatablePattern.prototype.disable = function(language) {
|
|
22613
|
+
var result = this._create();
|
|
22614
|
+
result._disabled[language] = true;
|
|
22615
|
+
result._update();
|
|
22616
|
+
return result;
|
|
22617
|
+
};
|
|
22618
|
+
TemplatablePattern.prototype.read_options = function(options) {
|
|
22619
|
+
var result = this._create();
|
|
22620
|
+
for (var language in template_names) {
|
|
22621
|
+
result._disabled[language] = options.templating.indexOf(language) === -1;
|
|
22622
|
+
}
|
|
22623
|
+
result._update();
|
|
22624
|
+
return result;
|
|
22625
|
+
};
|
|
22626
|
+
TemplatablePattern.prototype.exclude = function(language) {
|
|
22627
|
+
var result = this._create();
|
|
22628
|
+
result._excluded[language] = true;
|
|
22629
|
+
result._update();
|
|
22630
|
+
return result;
|
|
22631
|
+
};
|
|
22632
|
+
TemplatablePattern.prototype.read = function() {
|
|
22633
|
+
var result = "";
|
|
22634
|
+
if (this._match_pattern) {
|
|
22635
|
+
result = this._input.read(this._starting_pattern);
|
|
22636
|
+
} else {
|
|
22637
|
+
result = this._input.read(this._starting_pattern, this.__template_pattern);
|
|
22638
|
+
}
|
|
22639
|
+
var next = this._read_template();
|
|
22640
|
+
while (next) {
|
|
22641
|
+
if (this._match_pattern) {
|
|
22642
|
+
next += this._input.read(this._match_pattern);
|
|
22643
|
+
} else {
|
|
22644
|
+
next += this._input.readUntil(this.__template_pattern);
|
|
22645
|
+
}
|
|
22646
|
+
result += next;
|
|
22647
|
+
next = this._read_template();
|
|
22648
|
+
}
|
|
22649
|
+
if (this._until_after) {
|
|
22650
|
+
result += this._input.readUntilAfter(this._until_pattern);
|
|
22651
|
+
}
|
|
22652
|
+
return result;
|
|
22653
|
+
};
|
|
22654
|
+
TemplatablePattern.prototype.__set_templated_pattern = function() {
|
|
22655
|
+
var items = [];
|
|
22656
|
+
if (!this._disabled.php) {
|
|
22657
|
+
items.push(this.__patterns.php._starting_pattern.source);
|
|
22658
|
+
}
|
|
22659
|
+
if (!this._disabled.handlebars) {
|
|
22660
|
+
items.push(this.__patterns.handlebars._starting_pattern.source);
|
|
22661
|
+
}
|
|
22662
|
+
if (!this._disabled.erb) {
|
|
22663
|
+
items.push(this.__patterns.erb._starting_pattern.source);
|
|
22664
|
+
}
|
|
22665
|
+
if (!this._disabled.django) {
|
|
22666
|
+
items.push(this.__patterns.django._starting_pattern.source);
|
|
22667
|
+
items.push(this.__patterns.django_value._starting_pattern.source);
|
|
22668
|
+
items.push(this.__patterns.django_comment._starting_pattern.source);
|
|
22669
|
+
}
|
|
22670
|
+
if (!this._disabled.smarty) {
|
|
22671
|
+
items.push(this.__patterns.smarty._starting_pattern.source);
|
|
22672
|
+
}
|
|
22673
|
+
if (this._until_pattern) {
|
|
22674
|
+
items.push(this._until_pattern.source);
|
|
22675
|
+
}
|
|
22676
|
+
this.__template_pattern = this._input.get_regexp("(?:" + items.join("|") + ")");
|
|
22677
|
+
};
|
|
22678
|
+
TemplatablePattern.prototype._read_template = function() {
|
|
22679
|
+
var resulting_string = "";
|
|
22680
|
+
var c = this._input.peek();
|
|
22681
|
+
if (c === "<") {
|
|
22682
|
+
var peek1 = this._input.peek(1);
|
|
22683
|
+
if (!this._disabled.php && !this._excluded.php && peek1 === "?") {
|
|
22684
|
+
resulting_string = resulting_string || this.__patterns.php.read();
|
|
22685
|
+
}
|
|
22686
|
+
if (!this._disabled.erb && !this._excluded.erb && peek1 === "%") {
|
|
22687
|
+
resulting_string = resulting_string || this.__patterns.erb.read();
|
|
22688
|
+
}
|
|
22689
|
+
} else if (c === "{") {
|
|
22690
|
+
if (!this._disabled.handlebars && !this._excluded.handlebars) {
|
|
22691
|
+
resulting_string = resulting_string || this.__patterns.handlebars_comment.read();
|
|
22692
|
+
resulting_string = resulting_string || this.__patterns.handlebars_unescaped.read();
|
|
22693
|
+
resulting_string = resulting_string || this.__patterns.handlebars.read();
|
|
22694
|
+
}
|
|
22695
|
+
if (!this._disabled.django) {
|
|
22696
|
+
if (!this._excluded.django && !this._excluded.handlebars) {
|
|
22697
|
+
resulting_string = resulting_string || this.__patterns.django_value.read();
|
|
22698
|
+
}
|
|
22699
|
+
if (!this._excluded.django) {
|
|
22700
|
+
resulting_string = resulting_string || this.__patterns.django_comment.read();
|
|
22701
|
+
resulting_string = resulting_string || this.__patterns.django.read();
|
|
22702
|
+
}
|
|
22703
|
+
}
|
|
22704
|
+
if (!this._disabled.smarty) {
|
|
22705
|
+
if (this._disabled.django && this._disabled.handlebars) {
|
|
22706
|
+
resulting_string = resulting_string || this.__patterns.smarty_comment.read();
|
|
22707
|
+
resulting_string = resulting_string || this.__patterns.smarty_literal.read();
|
|
22708
|
+
resulting_string = resulting_string || this.__patterns.smarty.read();
|
|
22709
|
+
}
|
|
22710
|
+
}
|
|
22711
|
+
}
|
|
22712
|
+
return resulting_string;
|
|
22713
|
+
};
|
|
22714
|
+
module2.exports.TemplatablePattern = TemplatablePattern;
|
|
22715
|
+
}
|
|
22716
|
+
});
|
|
22717
|
+
|
|
22718
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/tokenizer.js
|
|
22719
|
+
var require_tokenizer2 = __commonJS({
|
|
22720
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/tokenizer.js"(exports, module2) {
|
|
22721
|
+
"use strict";
|
|
22722
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
22723
|
+
var BaseTokenizer = require_tokenizer().Tokenizer;
|
|
22724
|
+
var BASETOKEN = require_tokenizer().TOKEN;
|
|
22725
|
+
var Directives = require_directives().Directives;
|
|
22726
|
+
var acorn = require_acorn();
|
|
22727
|
+
var Pattern = require_pattern2().Pattern;
|
|
22728
|
+
var TemplatablePattern = require_templatablepattern().TemplatablePattern;
|
|
22729
|
+
function in_array(what, arr) {
|
|
22730
|
+
return arr.indexOf(what) !== -1;
|
|
22731
|
+
}
|
|
22732
|
+
var TOKEN = {
|
|
22733
|
+
START_EXPR: "TK_START_EXPR",
|
|
22734
|
+
END_EXPR: "TK_END_EXPR",
|
|
22735
|
+
START_BLOCK: "TK_START_BLOCK",
|
|
22736
|
+
END_BLOCK: "TK_END_BLOCK",
|
|
22737
|
+
WORD: "TK_WORD",
|
|
22738
|
+
RESERVED: "TK_RESERVED",
|
|
22739
|
+
SEMICOLON: "TK_SEMICOLON",
|
|
22740
|
+
STRING: "TK_STRING",
|
|
22741
|
+
EQUALS: "TK_EQUALS",
|
|
22742
|
+
OPERATOR: "TK_OPERATOR",
|
|
22743
|
+
COMMA: "TK_COMMA",
|
|
22744
|
+
BLOCK_COMMENT: "TK_BLOCK_COMMENT",
|
|
22745
|
+
COMMENT: "TK_COMMENT",
|
|
22746
|
+
DOT: "TK_DOT",
|
|
22747
|
+
UNKNOWN: "TK_UNKNOWN",
|
|
22748
|
+
START: BASETOKEN.START,
|
|
22749
|
+
RAW: BASETOKEN.RAW,
|
|
22750
|
+
EOF: BASETOKEN.EOF
|
|
22751
|
+
};
|
|
22752
|
+
var directives_core = new Directives(/\/\*/, /\*\//);
|
|
22753
|
+
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_]+)?/;
|
|
22754
|
+
var digit = /[0-9]/;
|
|
22755
|
+
var dot_pattern = /[^\d\.]/;
|
|
22756
|
+
var positionable_operators = ">>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" ");
|
|
22757
|
+
var punct = ">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |";
|
|
22758
|
+
punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
|
|
22759
|
+
punct = "\\?\\.(?!\\d) " + punct;
|
|
22760
|
+
punct = punct.replace(/ /g, "|");
|
|
22761
|
+
var punct_pattern = new RegExp(punct);
|
|
22762
|
+
var line_starters = "continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(",");
|
|
22763
|
+
var reserved_words = line_starters.concat(["do", "in", "of", "else", "get", "set", "new", "catch", "finally", "typeof", "yield", "async", "await", "from", "as"]);
|
|
22764
|
+
var reserved_word_pattern = new RegExp("^(?:" + reserved_words.join("|") + ")$");
|
|
22765
|
+
var in_html_comment;
|
|
22766
|
+
var Tokenizer = function(input_string, options) {
|
|
22767
|
+
BaseTokenizer.call(this, input_string, options);
|
|
22768
|
+
this._patterns.whitespace = this._patterns.whitespace.matching(
|
|
22769
|
+
/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
|
|
22770
|
+
/\u2028\u2029/.source
|
|
22771
|
+
);
|
|
22772
|
+
var pattern_reader = new Pattern(this._input);
|
|
22773
|
+
var templatable = new TemplatablePattern(this._input).read_options(this._options);
|
|
22774
|
+
this.__patterns = {
|
|
22775
|
+
template: templatable,
|
|
22776
|
+
identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
|
|
22777
|
+
number: pattern_reader.matching(number_pattern),
|
|
22778
|
+
punct: pattern_reader.matching(punct_pattern),
|
|
22779
|
+
// comment ends just before nearest linefeed or end of file
|
|
22780
|
+
comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
|
|
22781
|
+
// /* ... */ comment ends with nearest */ or end of file
|
|
22782
|
+
block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
|
|
22783
|
+
html_comment_start: pattern_reader.matching(/<!--/),
|
|
22784
|
+
html_comment_end: pattern_reader.matching(/-->/),
|
|
22785
|
+
include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
|
|
22786
|
+
shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
|
|
22787
|
+
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*>/),
|
|
22788
|
+
single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
|
|
22789
|
+
double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
|
|
22790
|
+
template_text: templatable.until(/[`\\$]/),
|
|
22791
|
+
template_expression: templatable.until(/[`}\\]/)
|
|
22792
|
+
};
|
|
22793
|
+
};
|
|
22794
|
+
Tokenizer.prototype = new BaseTokenizer();
|
|
22795
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
22796
|
+
return current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.BLOCK_COMMENT || current_token.type === TOKEN.UNKNOWN;
|
|
22797
|
+
};
|
|
22798
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
22799
|
+
return current_token.type === TOKEN.START_BLOCK || current_token.type === TOKEN.START_EXPR;
|
|
22800
|
+
};
|
|
22801
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
22802
|
+
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 === "{"));
|
|
22803
|
+
};
|
|
22804
|
+
Tokenizer.prototype._reset = function() {
|
|
22805
|
+
in_html_comment = false;
|
|
22806
|
+
};
|
|
22807
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
22808
|
+
var token = null;
|
|
22809
|
+
this._readWhitespace();
|
|
22810
|
+
var c = this._input.peek();
|
|
22811
|
+
if (c === null) {
|
|
22812
|
+
return this._create_token(TOKEN.EOF, "");
|
|
22813
|
+
}
|
|
22814
|
+
token = token || this._read_non_javascript(c);
|
|
22815
|
+
token = token || this._read_string(c);
|
|
22816
|
+
token = token || this._read_word(previous_token);
|
|
22817
|
+
token = token || this._read_singles(c);
|
|
22818
|
+
token = token || this._read_comment(c);
|
|
22819
|
+
token = token || this._read_regexp(c, previous_token);
|
|
22820
|
+
token = token || this._read_xml(c, previous_token);
|
|
22821
|
+
token = token || this._read_punctuation();
|
|
22822
|
+
token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
|
|
22823
|
+
return token;
|
|
22824
|
+
};
|
|
22825
|
+
Tokenizer.prototype._read_word = function(previous_token) {
|
|
22826
|
+
var resulting_string;
|
|
22827
|
+
resulting_string = this.__patterns.identifier.read();
|
|
22828
|
+
if (resulting_string !== "") {
|
|
22829
|
+
resulting_string = resulting_string.replace(acorn.allLineBreaks, "\n");
|
|
22830
|
+
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)) {
|
|
22831
|
+
if (resulting_string === "in" || resulting_string === "of") {
|
|
22832
|
+
return this._create_token(TOKEN.OPERATOR, resulting_string);
|
|
22833
|
+
}
|
|
22834
|
+
return this._create_token(TOKEN.RESERVED, resulting_string);
|
|
22835
|
+
}
|
|
22836
|
+
return this._create_token(TOKEN.WORD, resulting_string);
|
|
22837
|
+
}
|
|
22838
|
+
resulting_string = this.__patterns.number.read();
|
|
22839
|
+
if (resulting_string !== "") {
|
|
22840
|
+
return this._create_token(TOKEN.WORD, resulting_string);
|
|
22841
|
+
}
|
|
22842
|
+
};
|
|
22843
|
+
Tokenizer.prototype._read_singles = function(c) {
|
|
22844
|
+
var token = null;
|
|
22845
|
+
if (c === "(" || c === "[") {
|
|
22846
|
+
token = this._create_token(TOKEN.START_EXPR, c);
|
|
22847
|
+
} else if (c === ")" || c === "]") {
|
|
22848
|
+
token = this._create_token(TOKEN.END_EXPR, c);
|
|
22849
|
+
} else if (c === "{") {
|
|
22850
|
+
token = this._create_token(TOKEN.START_BLOCK, c);
|
|
22851
|
+
} else if (c === "}") {
|
|
22852
|
+
token = this._create_token(TOKEN.END_BLOCK, c);
|
|
22853
|
+
} else if (c === ";") {
|
|
22854
|
+
token = this._create_token(TOKEN.SEMICOLON, c);
|
|
22855
|
+
} else if (c === "." && dot_pattern.test(this._input.peek(1))) {
|
|
22856
|
+
token = this._create_token(TOKEN.DOT, c);
|
|
22857
|
+
} else if (c === ",") {
|
|
22858
|
+
token = this._create_token(TOKEN.COMMA, c);
|
|
22859
|
+
}
|
|
22860
|
+
if (token) {
|
|
22861
|
+
this._input.next();
|
|
22862
|
+
}
|
|
22863
|
+
return token;
|
|
22864
|
+
};
|
|
22865
|
+
Tokenizer.prototype._read_punctuation = function() {
|
|
22866
|
+
var resulting_string = this.__patterns.punct.read();
|
|
22867
|
+
if (resulting_string !== "") {
|
|
22868
|
+
if (resulting_string === "=") {
|
|
22869
|
+
return this._create_token(TOKEN.EQUALS, resulting_string);
|
|
22870
|
+
} else if (resulting_string === "?.") {
|
|
22871
|
+
return this._create_token(TOKEN.DOT, resulting_string);
|
|
22872
|
+
} else {
|
|
22873
|
+
return this._create_token(TOKEN.OPERATOR, resulting_string);
|
|
22874
|
+
}
|
|
22875
|
+
}
|
|
22876
|
+
};
|
|
22877
|
+
Tokenizer.prototype._read_non_javascript = function(c) {
|
|
22878
|
+
var resulting_string = "";
|
|
22879
|
+
if (c === "#") {
|
|
22880
|
+
if (this._is_first_token()) {
|
|
22881
|
+
resulting_string = this.__patterns.shebang.read();
|
|
22882
|
+
if (resulting_string) {
|
|
22883
|
+
return this._create_token(TOKEN.UNKNOWN, resulting_string.trim() + "\n");
|
|
22884
|
+
}
|
|
22885
|
+
}
|
|
22886
|
+
resulting_string = this.__patterns.include.read();
|
|
22887
|
+
if (resulting_string) {
|
|
22888
|
+
return this._create_token(TOKEN.UNKNOWN, resulting_string.trim() + "\n");
|
|
22889
|
+
}
|
|
22890
|
+
c = this._input.next();
|
|
22891
|
+
var sharp = "#";
|
|
22892
|
+
if (this._input.hasNext() && this._input.testChar(digit)) {
|
|
22893
|
+
do {
|
|
22894
|
+
c = this._input.next();
|
|
22895
|
+
sharp += c;
|
|
22896
|
+
} while (this._input.hasNext() && c !== "#" && c !== "=");
|
|
22897
|
+
if (c === "#") {
|
|
22898
|
+
} else if (this._input.peek() === "[" && this._input.peek(1) === "]") {
|
|
22899
|
+
sharp += "[]";
|
|
22900
|
+
this._input.next();
|
|
22901
|
+
this._input.next();
|
|
22902
|
+
} else if (this._input.peek() === "{" && this._input.peek(1) === "}") {
|
|
22903
|
+
sharp += "{}";
|
|
22904
|
+
this._input.next();
|
|
22905
|
+
this._input.next();
|
|
22906
|
+
}
|
|
22907
|
+
return this._create_token(TOKEN.WORD, sharp);
|
|
22908
|
+
}
|
|
22909
|
+
this._input.back();
|
|
22910
|
+
} else if (c === "<" && this._is_first_token()) {
|
|
22911
|
+
resulting_string = this.__patterns.html_comment_start.read();
|
|
22912
|
+
if (resulting_string) {
|
|
22913
|
+
while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
|
|
22914
|
+
resulting_string += this._input.next();
|
|
22915
|
+
}
|
|
22916
|
+
in_html_comment = true;
|
|
22917
|
+
return this._create_token(TOKEN.COMMENT, resulting_string);
|
|
22918
|
+
}
|
|
22919
|
+
} else if (in_html_comment && c === "-") {
|
|
22920
|
+
resulting_string = this.__patterns.html_comment_end.read();
|
|
22921
|
+
if (resulting_string) {
|
|
22922
|
+
in_html_comment = false;
|
|
22923
|
+
return this._create_token(TOKEN.COMMENT, resulting_string);
|
|
22924
|
+
}
|
|
22925
|
+
}
|
|
22926
|
+
return null;
|
|
22927
|
+
};
|
|
22928
|
+
Tokenizer.prototype._read_comment = function(c) {
|
|
22929
|
+
var token = null;
|
|
22930
|
+
if (c === "/") {
|
|
22931
|
+
var comment = "";
|
|
22932
|
+
if (this._input.peek(1) === "*") {
|
|
22933
|
+
comment = this.__patterns.block_comment.read();
|
|
22934
|
+
var directives = directives_core.get_directives(comment);
|
|
22935
|
+
if (directives && directives.ignore === "start") {
|
|
22936
|
+
comment += directives_core.readIgnored(this._input);
|
|
22937
|
+
}
|
|
22938
|
+
comment = comment.replace(acorn.allLineBreaks, "\n");
|
|
22939
|
+
token = this._create_token(TOKEN.BLOCK_COMMENT, comment);
|
|
22940
|
+
token.directives = directives;
|
|
22941
|
+
} else if (this._input.peek(1) === "/") {
|
|
22942
|
+
comment = this.__patterns.comment.read();
|
|
22943
|
+
token = this._create_token(TOKEN.COMMENT, comment);
|
|
22944
|
+
}
|
|
22945
|
+
}
|
|
22946
|
+
return token;
|
|
22947
|
+
};
|
|
22948
|
+
Tokenizer.prototype._read_string = function(c) {
|
|
22949
|
+
if (c === "`" || c === "'" || c === '"') {
|
|
22950
|
+
var resulting_string = this._input.next();
|
|
22951
|
+
this.has_char_escapes = false;
|
|
22952
|
+
if (c === "`") {
|
|
22953
|
+
resulting_string += this._read_string_recursive("`", true, "${");
|
|
22954
|
+
} else {
|
|
22955
|
+
resulting_string += this._read_string_recursive(c);
|
|
22956
|
+
}
|
|
22957
|
+
if (this.has_char_escapes && this._options.unescape_strings) {
|
|
22958
|
+
resulting_string = unescape_string(resulting_string);
|
|
22959
|
+
}
|
|
22960
|
+
if (this._input.peek() === c) {
|
|
22961
|
+
resulting_string += this._input.next();
|
|
22962
|
+
}
|
|
22963
|
+
resulting_string = resulting_string.replace(acorn.allLineBreaks, "\n");
|
|
22964
|
+
return this._create_token(TOKEN.STRING, resulting_string);
|
|
22965
|
+
}
|
|
22966
|
+
return null;
|
|
22967
|
+
};
|
|
22968
|
+
Tokenizer.prototype._allow_regexp_or_xml = function(previous_token) {
|
|
22969
|
+
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, [
|
|
22970
|
+
TOKEN.COMMENT,
|
|
22971
|
+
TOKEN.START_EXPR,
|
|
22972
|
+
TOKEN.START_BLOCK,
|
|
22973
|
+
TOKEN.START,
|
|
22974
|
+
TOKEN.END_BLOCK,
|
|
22975
|
+
TOKEN.OPERATOR,
|
|
22976
|
+
TOKEN.EQUALS,
|
|
22977
|
+
TOKEN.EOF,
|
|
22978
|
+
TOKEN.SEMICOLON,
|
|
22979
|
+
TOKEN.COMMA
|
|
22980
|
+
]);
|
|
22981
|
+
};
|
|
22982
|
+
Tokenizer.prototype._read_regexp = function(c, previous_token) {
|
|
22983
|
+
if (c === "/" && this._allow_regexp_or_xml(previous_token)) {
|
|
22984
|
+
var resulting_string = this._input.next();
|
|
22985
|
+
var esc = false;
|
|
22986
|
+
var in_char_class = false;
|
|
22987
|
+
while (this._input.hasNext() && ((esc || in_char_class || this._input.peek() !== c) && !this._input.testChar(acorn.newline))) {
|
|
22988
|
+
resulting_string += this._input.peek();
|
|
22989
|
+
if (!esc) {
|
|
22990
|
+
esc = this._input.peek() === "\\";
|
|
22991
|
+
if (this._input.peek() === "[") {
|
|
22992
|
+
in_char_class = true;
|
|
22993
|
+
} else if (this._input.peek() === "]") {
|
|
22994
|
+
in_char_class = false;
|
|
22995
|
+
}
|
|
22996
|
+
} else {
|
|
22997
|
+
esc = false;
|
|
22998
|
+
}
|
|
22999
|
+
this._input.next();
|
|
23000
|
+
}
|
|
23001
|
+
if (this._input.peek() === c) {
|
|
23002
|
+
resulting_string += this._input.next();
|
|
23003
|
+
resulting_string += this._input.read(acorn.identifier);
|
|
23004
|
+
}
|
|
23005
|
+
return this._create_token(TOKEN.STRING, resulting_string);
|
|
23006
|
+
}
|
|
23007
|
+
return null;
|
|
23008
|
+
};
|
|
23009
|
+
Tokenizer.prototype._read_xml = function(c, previous_token) {
|
|
23010
|
+
if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
|
|
23011
|
+
var xmlStr = "";
|
|
23012
|
+
var match = this.__patterns.xml.read_match();
|
|
23013
|
+
if (match) {
|
|
23014
|
+
var rootTag = match[2].replace(/^{\s+/, "{").replace(/\s+}$/, "}");
|
|
23015
|
+
var isCurlyRoot = rootTag.indexOf("{") === 0;
|
|
23016
|
+
var depth = 0;
|
|
23017
|
+
while (match) {
|
|
23018
|
+
var isEndTag = !!match[1];
|
|
23019
|
+
var tagName = match[2];
|
|
23020
|
+
var isSingletonTag = !!match[match.length - 1] || tagName.slice(0, 8) === "![CDATA[";
|
|
23021
|
+
if (!isSingletonTag && (tagName === rootTag || isCurlyRoot && tagName.replace(/^{\s+/, "{").replace(/\s+}$/, "}"))) {
|
|
23022
|
+
if (isEndTag) {
|
|
23023
|
+
--depth;
|
|
23024
|
+
} else {
|
|
23025
|
+
++depth;
|
|
23026
|
+
}
|
|
23027
|
+
}
|
|
23028
|
+
xmlStr += match[0];
|
|
23029
|
+
if (depth <= 0) {
|
|
23030
|
+
break;
|
|
23031
|
+
}
|
|
23032
|
+
match = this.__patterns.xml.read_match();
|
|
23033
|
+
}
|
|
23034
|
+
if (!match) {
|
|
23035
|
+
xmlStr += this._input.match(/[\s\S]*/g)[0];
|
|
23036
|
+
}
|
|
23037
|
+
xmlStr = xmlStr.replace(acorn.allLineBreaks, "\n");
|
|
23038
|
+
return this._create_token(TOKEN.STRING, xmlStr);
|
|
23039
|
+
}
|
|
23040
|
+
}
|
|
23041
|
+
return null;
|
|
23042
|
+
};
|
|
23043
|
+
function unescape_string(s) {
|
|
23044
|
+
var out = "", escaped = 0;
|
|
23045
|
+
var input_scan = new InputScanner(s);
|
|
23046
|
+
var matched = null;
|
|
23047
|
+
while (input_scan.hasNext()) {
|
|
23048
|
+
matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
|
|
23049
|
+
if (matched) {
|
|
23050
|
+
out += matched[0];
|
|
23051
|
+
}
|
|
23052
|
+
if (input_scan.peek() === "\\") {
|
|
23053
|
+
input_scan.next();
|
|
23054
|
+
if (input_scan.peek() === "x") {
|
|
23055
|
+
matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
|
|
23056
|
+
} else if (input_scan.peek() === "u") {
|
|
23057
|
+
matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
|
|
23058
|
+
} else {
|
|
23059
|
+
out += "\\";
|
|
23060
|
+
if (input_scan.hasNext()) {
|
|
23061
|
+
out += input_scan.next();
|
|
23062
|
+
}
|
|
23063
|
+
continue;
|
|
23064
|
+
}
|
|
23065
|
+
if (!matched) {
|
|
23066
|
+
return s;
|
|
23067
|
+
}
|
|
23068
|
+
escaped = parseInt(matched[1], 16);
|
|
23069
|
+
if (escaped > 126 && escaped <= 255 && matched[0].indexOf("x") === 0) {
|
|
23070
|
+
return s;
|
|
23071
|
+
} else if (escaped >= 0 && escaped < 32) {
|
|
23072
|
+
out += "\\" + matched[0];
|
|
23073
|
+
continue;
|
|
23074
|
+
} else if (escaped === 34 || escaped === 39 || escaped === 92) {
|
|
23075
|
+
out += "\\" + String.fromCharCode(escaped);
|
|
23076
|
+
} else {
|
|
23077
|
+
out += String.fromCharCode(escaped);
|
|
23078
|
+
}
|
|
23079
|
+
}
|
|
23080
|
+
}
|
|
23081
|
+
return out;
|
|
23082
|
+
}
|
|
23083
|
+
Tokenizer.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
|
|
23084
|
+
var current_char;
|
|
23085
|
+
var pattern;
|
|
23086
|
+
if (delimiter === "'") {
|
|
23087
|
+
pattern = this.__patterns.single_quote;
|
|
23088
|
+
} else if (delimiter === '"') {
|
|
23089
|
+
pattern = this.__patterns.double_quote;
|
|
23090
|
+
} else if (delimiter === "`") {
|
|
23091
|
+
pattern = this.__patterns.template_text;
|
|
23092
|
+
} else if (delimiter === "}") {
|
|
23093
|
+
pattern = this.__patterns.template_expression;
|
|
23094
|
+
}
|
|
23095
|
+
var resulting_string = pattern.read();
|
|
23096
|
+
var next = "";
|
|
23097
|
+
while (this._input.hasNext()) {
|
|
23098
|
+
next = this._input.next();
|
|
23099
|
+
if (next === delimiter || !allow_unescaped_newlines && acorn.newline.test(next)) {
|
|
23100
|
+
this._input.back();
|
|
23101
|
+
break;
|
|
23102
|
+
} else if (next === "\\" && this._input.hasNext()) {
|
|
23103
|
+
current_char = this._input.peek();
|
|
23104
|
+
if (current_char === "x" || current_char === "u") {
|
|
23105
|
+
this.has_char_escapes = true;
|
|
23106
|
+
} else if (current_char === "\r" && this._input.peek(1) === "\n") {
|
|
23107
|
+
this._input.next();
|
|
23108
|
+
}
|
|
23109
|
+
next += this._input.next();
|
|
23110
|
+
} else if (start_sub) {
|
|
23111
|
+
if (start_sub === "${" && next === "$" && this._input.peek() === "{") {
|
|
23112
|
+
next += this._input.next();
|
|
23113
|
+
}
|
|
23114
|
+
if (start_sub === next) {
|
|
23115
|
+
if (delimiter === "`") {
|
|
23116
|
+
next += this._read_string_recursive("}", allow_unescaped_newlines, "`");
|
|
23117
|
+
} else {
|
|
23118
|
+
next += this._read_string_recursive("`", allow_unescaped_newlines, "${");
|
|
23119
|
+
}
|
|
23120
|
+
if (this._input.hasNext()) {
|
|
23121
|
+
next += this._input.next();
|
|
23122
|
+
}
|
|
23123
|
+
}
|
|
23124
|
+
}
|
|
23125
|
+
next += pattern.read();
|
|
23126
|
+
resulting_string += next;
|
|
23127
|
+
}
|
|
23128
|
+
return resulting_string;
|
|
23129
|
+
};
|
|
23130
|
+
module2.exports.Tokenizer = Tokenizer;
|
|
23131
|
+
module2.exports.TOKEN = TOKEN;
|
|
23132
|
+
module2.exports.positionable_operators = positionable_operators.slice();
|
|
23133
|
+
module2.exports.line_starters = line_starters.slice();
|
|
23134
|
+
}
|
|
23135
|
+
});
|
|
23136
|
+
|
|
23137
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/beautifier.js
|
|
23138
|
+
var require_beautifier = __commonJS({
|
|
23139
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/beautifier.js"(exports, module2) {
|
|
23140
|
+
"use strict";
|
|
23141
|
+
var Output = require_output().Output;
|
|
23142
|
+
var Token = require_token().Token;
|
|
23143
|
+
var acorn = require_acorn();
|
|
23144
|
+
var Options = require_options2().Options;
|
|
23145
|
+
var Tokenizer = require_tokenizer2().Tokenizer;
|
|
23146
|
+
var line_starters = require_tokenizer2().line_starters;
|
|
23147
|
+
var positionable_operators = require_tokenizer2().positionable_operators;
|
|
23148
|
+
var TOKEN = require_tokenizer2().TOKEN;
|
|
23149
|
+
function in_array(what, arr) {
|
|
23150
|
+
return arr.indexOf(what) !== -1;
|
|
23151
|
+
}
|
|
23152
|
+
function ltrim(s) {
|
|
23153
|
+
return s.replace(/^\s+/g, "");
|
|
23154
|
+
}
|
|
23155
|
+
function generateMapFromStrings(list) {
|
|
23156
|
+
var result = {};
|
|
23157
|
+
for (var x = 0; x < list.length; x++) {
|
|
23158
|
+
result[list[x].replace(/-/g, "_")] = list[x];
|
|
23159
|
+
}
|
|
23160
|
+
return result;
|
|
23161
|
+
}
|
|
23162
|
+
function reserved_word(token, word) {
|
|
23163
|
+
return token && token.type === TOKEN.RESERVED && token.text === word;
|
|
23164
|
+
}
|
|
23165
|
+
function reserved_array(token, words) {
|
|
23166
|
+
return token && token.type === TOKEN.RESERVED && in_array(token.text, words);
|
|
23167
|
+
}
|
|
23168
|
+
var special_words = ["case", "return", "do", "if", "throw", "else", "await", "break", "continue", "async"];
|
|
23169
|
+
var validPositionValues = ["before-newline", "after-newline", "preserve-newline"];
|
|
23170
|
+
var OPERATOR_POSITION = generateMapFromStrings(validPositionValues);
|
|
23171
|
+
var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
|
|
23172
|
+
var MODE = {
|
|
23173
|
+
BlockStatement: "BlockStatement",
|
|
23174
|
+
// 'BLOCK'
|
|
23175
|
+
Statement: "Statement",
|
|
23176
|
+
// 'STATEMENT'
|
|
23177
|
+
ObjectLiteral: "ObjectLiteral",
|
|
23178
|
+
// 'OBJECT',
|
|
23179
|
+
ArrayLiteral: "ArrayLiteral",
|
|
23180
|
+
//'[EXPRESSION]',
|
|
23181
|
+
ForInitializer: "ForInitializer",
|
|
23182
|
+
//'(FOR-EXPRESSION)',
|
|
23183
|
+
Conditional: "Conditional",
|
|
23184
|
+
//'(COND-EXPRESSION)',
|
|
23185
|
+
Expression: "Expression"
|
|
23186
|
+
//'(EXPRESSION)'
|
|
23187
|
+
};
|
|
23188
|
+
function remove_redundant_indentation(output, frame) {
|
|
23189
|
+
if (frame.multiline_frame || frame.mode === MODE.ForInitializer || frame.mode === MODE.Conditional) {
|
|
23190
|
+
return;
|
|
23191
|
+
}
|
|
23192
|
+
output.remove_indent(frame.start_line_index);
|
|
23193
|
+
}
|
|
23194
|
+
function split_linebreaks(s) {
|
|
23195
|
+
s = s.replace(acorn.allLineBreaks, "\n");
|
|
23196
|
+
var out = [], idx = s.indexOf("\n");
|
|
23197
|
+
while (idx !== -1) {
|
|
23198
|
+
out.push(s.substring(0, idx));
|
|
23199
|
+
s = s.substring(idx + 1);
|
|
23200
|
+
idx = s.indexOf("\n");
|
|
23201
|
+
}
|
|
23202
|
+
if (s.length) {
|
|
23203
|
+
out.push(s);
|
|
23204
|
+
}
|
|
23205
|
+
return out;
|
|
23206
|
+
}
|
|
23207
|
+
function is_array(mode) {
|
|
23208
|
+
return mode === MODE.ArrayLiteral;
|
|
23209
|
+
}
|
|
23210
|
+
function is_expression(mode) {
|
|
23211
|
+
return in_array(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
|
|
23212
|
+
}
|
|
23213
|
+
function all_lines_start_with(lines, c) {
|
|
23214
|
+
for (var i = 0; i < lines.length; i++) {
|
|
23215
|
+
var line = lines[i].trim();
|
|
23216
|
+
if (line.charAt(0) !== c) {
|
|
23217
|
+
return false;
|
|
23218
|
+
}
|
|
23219
|
+
}
|
|
23220
|
+
return true;
|
|
23221
|
+
}
|
|
23222
|
+
function each_line_matches_indent(lines, indent) {
|
|
23223
|
+
var i = 0, len = lines.length, line;
|
|
23224
|
+
for (; i < len; i++) {
|
|
23225
|
+
line = lines[i];
|
|
23226
|
+
if (line && line.indexOf(indent) !== 0) {
|
|
23227
|
+
return false;
|
|
23228
|
+
}
|
|
23229
|
+
}
|
|
23230
|
+
return true;
|
|
23231
|
+
}
|
|
23232
|
+
function Beautifier(source_text, options) {
|
|
23233
|
+
options = options || {};
|
|
23234
|
+
this._source_text = source_text || "";
|
|
23235
|
+
this._output = null;
|
|
23236
|
+
this._tokens = null;
|
|
23237
|
+
this._last_last_text = null;
|
|
23238
|
+
this._flags = null;
|
|
23239
|
+
this._previous_flags = null;
|
|
23240
|
+
this._flag_store = null;
|
|
23241
|
+
this._options = new Options(options);
|
|
23242
|
+
}
|
|
23243
|
+
Beautifier.prototype.create_flags = function(flags_base, mode) {
|
|
23244
|
+
var next_indent_level = 0;
|
|
23245
|
+
if (flags_base) {
|
|
23246
|
+
next_indent_level = flags_base.indentation_level;
|
|
23247
|
+
if (!this._output.just_added_newline() && flags_base.line_indent_level > next_indent_level) {
|
|
23248
|
+
next_indent_level = flags_base.line_indent_level;
|
|
23249
|
+
}
|
|
23250
|
+
}
|
|
23251
|
+
var next_flags = {
|
|
23252
|
+
mode,
|
|
23253
|
+
parent: flags_base,
|
|
23254
|
+
last_token: flags_base ? flags_base.last_token : new Token(TOKEN.START_BLOCK, ""),
|
|
23255
|
+
// last token text
|
|
23256
|
+
last_word: flags_base ? flags_base.last_word : "",
|
|
23257
|
+
// last TOKEN.WORD passed
|
|
23258
|
+
declaration_statement: false,
|
|
23259
|
+
declaration_assignment: false,
|
|
23260
|
+
multiline_frame: false,
|
|
23261
|
+
inline_frame: false,
|
|
23262
|
+
if_block: false,
|
|
23263
|
+
else_block: false,
|
|
23264
|
+
do_block: false,
|
|
23265
|
+
do_while: false,
|
|
23266
|
+
import_block: false,
|
|
23267
|
+
in_case_statement: false,
|
|
23268
|
+
// switch(..){ INSIDE HERE }
|
|
23269
|
+
in_case: false,
|
|
23270
|
+
// we're on the exact line with "case 0:"
|
|
23271
|
+
case_body: false,
|
|
23272
|
+
// the indented case-action block
|
|
23273
|
+
case_block: false,
|
|
23274
|
+
// the indented case-action block is wrapped with {}
|
|
23275
|
+
indentation_level: next_indent_level,
|
|
23276
|
+
alignment: 0,
|
|
23277
|
+
line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
|
|
23278
|
+
start_line_index: this._output.get_line_number(),
|
|
23279
|
+
ternary_depth: 0
|
|
23280
|
+
};
|
|
23281
|
+
return next_flags;
|
|
23282
|
+
};
|
|
23283
|
+
Beautifier.prototype._reset = function(source_text) {
|
|
23284
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
23285
|
+
this._last_last_text = "";
|
|
23286
|
+
this._output = new Output(this._options, baseIndentString);
|
|
23287
|
+
this._output.raw = this._options.test_output_raw;
|
|
23288
|
+
this._flag_store = [];
|
|
23289
|
+
this.set_mode(MODE.BlockStatement);
|
|
23290
|
+
var tokenizer = new Tokenizer(source_text, this._options);
|
|
23291
|
+
this._tokens = tokenizer.tokenize();
|
|
23292
|
+
return source_text;
|
|
23293
|
+
};
|
|
23294
|
+
Beautifier.prototype.beautify = function() {
|
|
23295
|
+
if (this._options.disabled) {
|
|
23296
|
+
return this._source_text;
|
|
23297
|
+
}
|
|
23298
|
+
var sweet_code;
|
|
23299
|
+
var source_text = this._reset(this._source_text);
|
|
23300
|
+
var eol = this._options.eol;
|
|
23301
|
+
if (this._options.eol === "auto") {
|
|
23302
|
+
eol = "\n";
|
|
23303
|
+
if (source_text && acorn.lineBreak.test(source_text || "")) {
|
|
23304
|
+
eol = source_text.match(acorn.lineBreak)[0];
|
|
23305
|
+
}
|
|
23306
|
+
}
|
|
23307
|
+
var current_token = this._tokens.next();
|
|
23308
|
+
while (current_token) {
|
|
23309
|
+
this.handle_token(current_token);
|
|
23310
|
+
this._last_last_text = this._flags.last_token.text;
|
|
23311
|
+
this._flags.last_token = current_token;
|
|
23312
|
+
current_token = this._tokens.next();
|
|
23313
|
+
}
|
|
23314
|
+
sweet_code = this._output.get_code(eol);
|
|
23315
|
+
return sweet_code;
|
|
23316
|
+
};
|
|
23317
|
+
Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
|
|
23318
|
+
if (current_token.type === TOKEN.START_EXPR) {
|
|
23319
|
+
this.handle_start_expr(current_token);
|
|
23320
|
+
} else if (current_token.type === TOKEN.END_EXPR) {
|
|
23321
|
+
this.handle_end_expr(current_token);
|
|
23322
|
+
} else if (current_token.type === TOKEN.START_BLOCK) {
|
|
23323
|
+
this.handle_start_block(current_token);
|
|
23324
|
+
} else if (current_token.type === TOKEN.END_BLOCK) {
|
|
23325
|
+
this.handle_end_block(current_token);
|
|
23326
|
+
} else if (current_token.type === TOKEN.WORD) {
|
|
23327
|
+
this.handle_word(current_token);
|
|
23328
|
+
} else if (current_token.type === TOKEN.RESERVED) {
|
|
23329
|
+
this.handle_word(current_token);
|
|
23330
|
+
} else if (current_token.type === TOKEN.SEMICOLON) {
|
|
23331
|
+
this.handle_semicolon(current_token);
|
|
23332
|
+
} else if (current_token.type === TOKEN.STRING) {
|
|
23333
|
+
this.handle_string(current_token);
|
|
23334
|
+
} else if (current_token.type === TOKEN.EQUALS) {
|
|
23335
|
+
this.handle_equals(current_token);
|
|
23336
|
+
} else if (current_token.type === TOKEN.OPERATOR) {
|
|
23337
|
+
this.handle_operator(current_token);
|
|
23338
|
+
} else if (current_token.type === TOKEN.COMMA) {
|
|
23339
|
+
this.handle_comma(current_token);
|
|
23340
|
+
} else if (current_token.type === TOKEN.BLOCK_COMMENT) {
|
|
23341
|
+
this.handle_block_comment(current_token, preserve_statement_flags);
|
|
23342
|
+
} else if (current_token.type === TOKEN.COMMENT) {
|
|
23343
|
+
this.handle_comment(current_token, preserve_statement_flags);
|
|
23344
|
+
} else if (current_token.type === TOKEN.DOT) {
|
|
23345
|
+
this.handle_dot(current_token);
|
|
23346
|
+
} else if (current_token.type === TOKEN.EOF) {
|
|
23347
|
+
this.handle_eof(current_token);
|
|
23348
|
+
} else if (current_token.type === TOKEN.UNKNOWN) {
|
|
23349
|
+
this.handle_unknown(current_token, preserve_statement_flags);
|
|
23350
|
+
} else {
|
|
23351
|
+
this.handle_unknown(current_token, preserve_statement_flags);
|
|
23352
|
+
}
|
|
23353
|
+
};
|
|
23354
|
+
Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
|
|
23355
|
+
var newlines = current_token.newlines;
|
|
23356
|
+
var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
|
|
23357
|
+
if (current_token.comments_before) {
|
|
23358
|
+
var comment_token = current_token.comments_before.next();
|
|
23359
|
+
while (comment_token) {
|
|
23360
|
+
this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
|
|
23361
|
+
this.handle_token(comment_token, preserve_statement_flags);
|
|
23362
|
+
comment_token = current_token.comments_before.next();
|
|
23363
|
+
}
|
|
23364
|
+
}
|
|
23365
|
+
if (keep_whitespace) {
|
|
23366
|
+
for (var i = 0; i < newlines; i += 1) {
|
|
23367
|
+
this.print_newline(i > 0, preserve_statement_flags);
|
|
23368
|
+
}
|
|
23369
|
+
} else {
|
|
23370
|
+
if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
|
|
23371
|
+
newlines = this._options.max_preserve_newlines;
|
|
23372
|
+
}
|
|
23373
|
+
if (this._options.preserve_newlines) {
|
|
23374
|
+
if (newlines > 1) {
|
|
23375
|
+
this.print_newline(false, preserve_statement_flags);
|
|
23376
|
+
for (var j = 1; j < newlines; j += 1) {
|
|
23377
|
+
this.print_newline(true, preserve_statement_flags);
|
|
23378
|
+
}
|
|
23379
|
+
}
|
|
23380
|
+
}
|
|
23381
|
+
}
|
|
23382
|
+
};
|
|
23383
|
+
var newline_restricted_tokens = ["async", "break", "continue", "return", "throw", "yield"];
|
|
23384
|
+
Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
|
|
23385
|
+
force_linewrap = force_linewrap === void 0 ? false : force_linewrap;
|
|
23386
|
+
if (this._output.just_added_newline()) {
|
|
23387
|
+
return;
|
|
23388
|
+
}
|
|
23389
|
+
var shouldPreserveOrForce = this._options.preserve_newlines && current_token.newlines || force_linewrap;
|
|
23390
|
+
var operatorLogicApplies = in_array(this._flags.last_token.text, positionable_operators) || in_array(current_token.text, positionable_operators);
|
|
23391
|
+
if (operatorLogicApplies) {
|
|
23392
|
+
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);
|
|
23393
|
+
shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
|
|
23394
|
+
}
|
|
23395
|
+
if (shouldPreserveOrForce) {
|
|
23396
|
+
this.print_newline(false, true);
|
|
23397
|
+
} else if (this._options.wrap_line_length) {
|
|
23398
|
+
if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
|
|
23399
|
+
return;
|
|
23400
|
+
}
|
|
23401
|
+
this._output.set_wrap_point();
|
|
23402
|
+
}
|
|
23403
|
+
};
|
|
23404
|
+
Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
|
|
23405
|
+
if (!preserve_statement_flags) {
|
|
23406
|
+
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 === "++")) {
|
|
23407
|
+
var next_token = this._tokens.peek();
|
|
23408
|
+
while (this._flags.mode === MODE.Statement && !(this._flags.if_block && reserved_word(next_token, "else")) && !this._flags.do_block) {
|
|
23409
|
+
this.restore_mode();
|
|
23410
|
+
}
|
|
23411
|
+
}
|
|
23412
|
+
}
|
|
23413
|
+
if (this._output.add_new_line(force_newline)) {
|
|
23414
|
+
this._flags.multiline_frame = true;
|
|
23415
|
+
}
|
|
23416
|
+
};
|
|
23417
|
+
Beautifier.prototype.print_token_line_indentation = function(current_token) {
|
|
23418
|
+
if (this._output.just_added_newline()) {
|
|
23419
|
+
if (this._options.keep_array_indentation && current_token.newlines && (current_token.text === "[" || is_array(this._flags.mode))) {
|
|
23420
|
+
this._output.current_line.set_indent(-1);
|
|
23421
|
+
this._output.current_line.push(current_token.whitespace_before);
|
|
23422
|
+
this._output.space_before_token = false;
|
|
23423
|
+
} else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
|
|
23424
|
+
this._flags.line_indent_level = this._flags.indentation_level;
|
|
23425
|
+
}
|
|
23426
|
+
}
|
|
23427
|
+
};
|
|
23428
|
+
Beautifier.prototype.print_token = function(current_token) {
|
|
23429
|
+
if (this._output.raw) {
|
|
23430
|
+
this._output.add_raw_token(current_token);
|
|
23431
|
+
return;
|
|
23432
|
+
}
|
|
23433
|
+
if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN.COMMA && this._output.just_added_newline()) {
|
|
23434
|
+
if (this._output.previous_line.last() === ",") {
|
|
23435
|
+
var popped = this._output.previous_line.pop();
|
|
23436
|
+
if (this._output.previous_line.is_empty()) {
|
|
23437
|
+
this._output.previous_line.push(popped);
|
|
23438
|
+
this._output.trim(true);
|
|
23439
|
+
this._output.current_line.pop();
|
|
23440
|
+
this._output.trim();
|
|
23441
|
+
}
|
|
23442
|
+
this.print_token_line_indentation(current_token);
|
|
23443
|
+
this._output.add_token(",");
|
|
23444
|
+
this._output.space_before_token = true;
|
|
23445
|
+
}
|
|
23446
|
+
}
|
|
23447
|
+
this.print_token_line_indentation(current_token);
|
|
23448
|
+
this._output.non_breaking_space = true;
|
|
23449
|
+
this._output.add_token(current_token.text);
|
|
23450
|
+
if (this._output.previous_token_wrapped) {
|
|
23451
|
+
this._flags.multiline_frame = true;
|
|
23452
|
+
}
|
|
23453
|
+
};
|
|
23454
|
+
Beautifier.prototype.indent = function() {
|
|
23455
|
+
this._flags.indentation_level += 1;
|
|
23456
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
23457
|
+
};
|
|
23458
|
+
Beautifier.prototype.deindent = function() {
|
|
23459
|
+
if (this._flags.indentation_level > 0 && (!this._flags.parent || this._flags.indentation_level > this._flags.parent.indentation_level)) {
|
|
23460
|
+
this._flags.indentation_level -= 1;
|
|
23461
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
23462
|
+
}
|
|
23463
|
+
};
|
|
23464
|
+
Beautifier.prototype.set_mode = function(mode) {
|
|
23465
|
+
if (this._flags) {
|
|
23466
|
+
this._flag_store.push(this._flags);
|
|
23467
|
+
this._previous_flags = this._flags;
|
|
23468
|
+
} else {
|
|
23469
|
+
this._previous_flags = this.create_flags(null, mode);
|
|
23470
|
+
}
|
|
23471
|
+
this._flags = this.create_flags(this._previous_flags, mode);
|
|
23472
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
23473
|
+
};
|
|
23474
|
+
Beautifier.prototype.restore_mode = function() {
|
|
23475
|
+
if (this._flag_store.length > 0) {
|
|
23476
|
+
this._previous_flags = this._flags;
|
|
23477
|
+
this._flags = this._flag_store.pop();
|
|
23478
|
+
if (this._previous_flags.mode === MODE.Statement) {
|
|
23479
|
+
remove_redundant_indentation(this._output, this._previous_flags);
|
|
23480
|
+
}
|
|
23481
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
23482
|
+
}
|
|
23483
|
+
};
|
|
23484
|
+
Beautifier.prototype.start_of_object_property = function() {
|
|
23485
|
+
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"]));
|
|
23486
|
+
};
|
|
23487
|
+
Beautifier.prototype.start_of_statement = function(current_token) {
|
|
23488
|
+
var start = false;
|
|
23489
|
+
start = start || reserved_array(this._flags.last_token, ["var", "let", "const"]) && current_token.type === TOKEN.WORD;
|
|
23490
|
+
start = start || reserved_word(this._flags.last_token, "do");
|
|
23491
|
+
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;
|
|
23492
|
+
start = start || reserved_word(this._flags.last_token, "else") && !(reserved_word(current_token, "if") && !current_token.comments_before);
|
|
23493
|
+
start = start || this._flags.last_token.type === TOKEN.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional);
|
|
23494
|
+
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;
|
|
23495
|
+
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"]));
|
|
23496
|
+
if (start) {
|
|
23497
|
+
this.set_mode(MODE.Statement);
|
|
23498
|
+
this.indent();
|
|
23499
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
23500
|
+
if (!this.start_of_object_property()) {
|
|
23501
|
+
this.allow_wrap_or_preserved_newline(
|
|
23502
|
+
current_token,
|
|
23503
|
+
reserved_array(current_token, ["do", "for", "if", "while"])
|
|
23504
|
+
);
|
|
23505
|
+
}
|
|
23506
|
+
return true;
|
|
23507
|
+
}
|
|
23508
|
+
return false;
|
|
23509
|
+
};
|
|
23510
|
+
Beautifier.prototype.handle_start_expr = function(current_token) {
|
|
23511
|
+
if (!this.start_of_statement(current_token)) {
|
|
23512
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23513
|
+
}
|
|
23514
|
+
var next_mode = MODE.Expression;
|
|
23515
|
+
if (current_token.text === "[") {
|
|
23516
|
+
if (this._flags.last_token.type === TOKEN.WORD || this._flags.last_token.text === ")") {
|
|
23517
|
+
if (reserved_array(this._flags.last_token, line_starters)) {
|
|
23518
|
+
this._output.space_before_token = true;
|
|
23519
|
+
}
|
|
23520
|
+
this.print_token(current_token);
|
|
23521
|
+
this.set_mode(next_mode);
|
|
23522
|
+
this.indent();
|
|
23523
|
+
if (this._options.space_in_paren) {
|
|
23524
|
+
this._output.space_before_token = true;
|
|
23525
|
+
}
|
|
23526
|
+
return;
|
|
23527
|
+
}
|
|
23528
|
+
next_mode = MODE.ArrayLiteral;
|
|
23529
|
+
if (is_array(this._flags.mode)) {
|
|
23530
|
+
if (this._flags.last_token.text === "[" || this._flags.last_token.text === "," && (this._last_last_text === "]" || this._last_last_text === "}")) {
|
|
23531
|
+
if (!this._options.keep_array_indentation) {
|
|
23532
|
+
this.print_newline();
|
|
23533
|
+
}
|
|
23534
|
+
}
|
|
23535
|
+
}
|
|
23536
|
+
if (!in_array(this._flags.last_token.type, [TOKEN.START_EXPR, TOKEN.END_EXPR, TOKEN.WORD, TOKEN.OPERATOR, TOKEN.DOT])) {
|
|
23537
|
+
this._output.space_before_token = true;
|
|
23538
|
+
}
|
|
23539
|
+
} else {
|
|
23540
|
+
if (this._flags.last_token.type === TOKEN.RESERVED) {
|
|
23541
|
+
if (this._flags.last_token.text === "for") {
|
|
23542
|
+
this._output.space_before_token = this._options.space_before_conditional;
|
|
23543
|
+
next_mode = MODE.ForInitializer;
|
|
23544
|
+
} else if (in_array(this._flags.last_token.text, ["if", "while", "switch"])) {
|
|
23545
|
+
this._output.space_before_token = this._options.space_before_conditional;
|
|
23546
|
+
next_mode = MODE.Conditional;
|
|
23547
|
+
} else if (in_array(this._flags.last_word, ["await", "async"])) {
|
|
23548
|
+
this._output.space_before_token = true;
|
|
23549
|
+
} else if (this._flags.last_token.text === "import" && current_token.whitespace_before === "") {
|
|
23550
|
+
this._output.space_before_token = false;
|
|
23551
|
+
} else if (in_array(this._flags.last_token.text, line_starters) || this._flags.last_token.text === "catch") {
|
|
23552
|
+
this._output.space_before_token = true;
|
|
23553
|
+
}
|
|
23554
|
+
} else if (this._flags.last_token.type === TOKEN.EQUALS || this._flags.last_token.type === TOKEN.OPERATOR) {
|
|
23555
|
+
if (!this.start_of_object_property()) {
|
|
23556
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
23557
|
+
}
|
|
23558
|
+
} else if (this._flags.last_token.type === TOKEN.WORD) {
|
|
23559
|
+
this._output.space_before_token = false;
|
|
23560
|
+
var peek_back_two = this._tokens.peek(-3);
|
|
23561
|
+
if (this._options.space_after_named_function && peek_back_two) {
|
|
23562
|
+
var peek_back_three = this._tokens.peek(-4);
|
|
23563
|
+
if (reserved_array(peek_back_two, ["async", "function"]) || peek_back_two.text === "*" && reserved_array(peek_back_three, ["async", "function"])) {
|
|
23564
|
+
this._output.space_before_token = true;
|
|
23565
|
+
} else if (this._flags.mode === MODE.ObjectLiteral) {
|
|
23566
|
+
if (peek_back_two.text === "{" || peek_back_two.text === "," || peek_back_two.text === "*" && (peek_back_three.text === "{" || peek_back_three.text === ",")) {
|
|
23567
|
+
this._output.space_before_token = true;
|
|
23568
|
+
}
|
|
23569
|
+
}
|
|
23570
|
+
}
|
|
23571
|
+
} else {
|
|
23572
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
23573
|
+
}
|
|
23574
|
+
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, ["{", ","]))) {
|
|
23575
|
+
this._output.space_before_token = this._options.space_after_anon_function;
|
|
23576
|
+
}
|
|
23577
|
+
}
|
|
23578
|
+
if (this._flags.last_token.text === ";" || this._flags.last_token.type === TOKEN.START_BLOCK) {
|
|
23579
|
+
this.print_newline();
|
|
23580
|
+
} 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) {
|
|
23581
|
+
this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
|
|
23582
|
+
}
|
|
23583
|
+
this.print_token(current_token);
|
|
23584
|
+
this.set_mode(next_mode);
|
|
23585
|
+
if (this._options.space_in_paren) {
|
|
23586
|
+
this._output.space_before_token = true;
|
|
23587
|
+
}
|
|
23588
|
+
this.indent();
|
|
23589
|
+
};
|
|
23590
|
+
Beautifier.prototype.handle_end_expr = function(current_token) {
|
|
23591
|
+
while (this._flags.mode === MODE.Statement) {
|
|
23592
|
+
this.restore_mode();
|
|
23593
|
+
}
|
|
23594
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23595
|
+
if (this._flags.multiline_frame) {
|
|
23596
|
+
this.allow_wrap_or_preserved_newline(
|
|
23597
|
+
current_token,
|
|
23598
|
+
current_token.text === "]" && is_array(this._flags.mode) && !this._options.keep_array_indentation
|
|
23599
|
+
);
|
|
23600
|
+
}
|
|
23601
|
+
if (this._options.space_in_paren) {
|
|
23602
|
+
if (this._flags.last_token.type === TOKEN.START_EXPR && !this._options.space_in_empty_paren) {
|
|
23603
|
+
this._output.trim();
|
|
23604
|
+
this._output.space_before_token = false;
|
|
23605
|
+
} else {
|
|
23606
|
+
this._output.space_before_token = true;
|
|
23607
|
+
}
|
|
23608
|
+
}
|
|
23609
|
+
this.deindent();
|
|
23610
|
+
this.print_token(current_token);
|
|
23611
|
+
this.restore_mode();
|
|
23612
|
+
remove_redundant_indentation(this._output, this._previous_flags);
|
|
23613
|
+
if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
|
|
23614
|
+
this._previous_flags.mode = MODE.Expression;
|
|
23615
|
+
this._flags.do_block = false;
|
|
23616
|
+
this._flags.do_while = false;
|
|
23617
|
+
}
|
|
23618
|
+
};
|
|
23619
|
+
Beautifier.prototype.handle_start_block = function(current_token) {
|
|
23620
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23621
|
+
var next_token = this._tokens.peek();
|
|
23622
|
+
var second_token = this._tokens.peek(1);
|
|
23623
|
+
if (this._flags.last_word === "switch" && this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
23624
|
+
this.set_mode(MODE.BlockStatement);
|
|
23625
|
+
this._flags.in_case_statement = true;
|
|
23626
|
+
} else if (this._flags.case_body) {
|
|
23627
|
+
this.set_mode(MODE.BlockStatement);
|
|
23628
|
+
} 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]))) {
|
|
23629
|
+
if (in_array(this._last_last_text, ["class", "interface"]) && !in_array(second_token.text, [":", ","])) {
|
|
23630
|
+
this.set_mode(MODE.BlockStatement);
|
|
23631
|
+
} else {
|
|
23632
|
+
this.set_mode(MODE.ObjectLiteral);
|
|
23633
|
+
}
|
|
23634
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === "=>") {
|
|
23635
|
+
this.set_mode(MODE.BlockStatement);
|
|
23636
|
+
} 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"])) {
|
|
23637
|
+
this.set_mode(MODE.ObjectLiteral);
|
|
23638
|
+
} else {
|
|
23639
|
+
this.set_mode(MODE.BlockStatement);
|
|
23640
|
+
}
|
|
23641
|
+
var empty_braces = !next_token.comments_before && next_token.text === "}";
|
|
23642
|
+
var empty_anonymous_function = empty_braces && this._flags.last_word === "function" && this._flags.last_token.type === TOKEN.END_EXPR;
|
|
23643
|
+
if (this._options.brace_preserve_inline) {
|
|
23644
|
+
var index = 0;
|
|
23645
|
+
var check_token = null;
|
|
23646
|
+
this._flags.inline_frame = true;
|
|
23647
|
+
do {
|
|
23648
|
+
index += 1;
|
|
23649
|
+
check_token = this._tokens.peek(index - 1);
|
|
23650
|
+
if (check_token.newlines) {
|
|
23651
|
+
this._flags.inline_frame = false;
|
|
23652
|
+
break;
|
|
23653
|
+
}
|
|
23654
|
+
} while (check_token.type !== TOKEN.EOF && !(check_token.type === TOKEN.END_BLOCK && check_token.opened === current_token));
|
|
23655
|
+
}
|
|
23656
|
+
if ((this._options.brace_style === "expand" || this._options.brace_style === "none" && current_token.newlines) && !this._flags.inline_frame) {
|
|
23657
|
+
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")) {
|
|
23658
|
+
this._output.space_before_token = true;
|
|
23659
|
+
} else {
|
|
23660
|
+
this.print_newline(false, true);
|
|
23661
|
+
}
|
|
23662
|
+
} else {
|
|
23663
|
+
if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.COMMA)) {
|
|
23664
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._options.space_in_paren) {
|
|
23665
|
+
this._output.space_before_token = true;
|
|
23666
|
+
}
|
|
23667
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR && this._flags.inline_frame) {
|
|
23668
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
23669
|
+
this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
|
|
23670
|
+
this._flags.multiline_frame = false;
|
|
23671
|
+
}
|
|
23672
|
+
}
|
|
23673
|
+
if (this._flags.last_token.type !== TOKEN.OPERATOR && this._flags.last_token.type !== TOKEN.START_EXPR) {
|
|
23674
|
+
if (this._flags.last_token.type === TOKEN.START_BLOCK && !this._flags.inline_frame) {
|
|
23675
|
+
this.print_newline();
|
|
23676
|
+
} else {
|
|
23677
|
+
this._output.space_before_token = true;
|
|
23678
|
+
}
|
|
23679
|
+
}
|
|
23680
|
+
}
|
|
23681
|
+
this.print_token(current_token);
|
|
23682
|
+
this.indent();
|
|
23683
|
+
if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
|
|
23684
|
+
this.print_newline();
|
|
23685
|
+
}
|
|
23686
|
+
};
|
|
23687
|
+
Beautifier.prototype.handle_end_block = function(current_token) {
|
|
23688
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23689
|
+
while (this._flags.mode === MODE.Statement) {
|
|
23690
|
+
this.restore_mode();
|
|
23691
|
+
}
|
|
23692
|
+
var empty_braces = this._flags.last_token.type === TOKEN.START_BLOCK;
|
|
23693
|
+
if (this._flags.inline_frame && !empty_braces) {
|
|
23694
|
+
this._output.space_before_token = true;
|
|
23695
|
+
} else if (this._options.brace_style === "expand") {
|
|
23696
|
+
if (!empty_braces) {
|
|
23697
|
+
this.print_newline();
|
|
23698
|
+
}
|
|
23699
|
+
} else {
|
|
23700
|
+
if (!empty_braces) {
|
|
23701
|
+
if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
|
|
23702
|
+
this._options.keep_array_indentation = false;
|
|
23703
|
+
this.print_newline();
|
|
23704
|
+
this._options.keep_array_indentation = true;
|
|
23705
|
+
} else {
|
|
23706
|
+
this.print_newline();
|
|
23707
|
+
}
|
|
23708
|
+
}
|
|
23709
|
+
}
|
|
23710
|
+
this.restore_mode();
|
|
23711
|
+
this.print_token(current_token);
|
|
23712
|
+
};
|
|
23713
|
+
Beautifier.prototype.handle_word = function(current_token) {
|
|
23714
|
+
if (current_token.type === TOKEN.RESERVED) {
|
|
23715
|
+
if (in_array(current_token.text, ["set", "get"]) && this._flags.mode !== MODE.ObjectLiteral) {
|
|
23716
|
+
current_token.type = TOKEN.WORD;
|
|
23717
|
+
} else if (current_token.text === "import" && in_array(this._tokens.peek().text, ["(", "."])) {
|
|
23718
|
+
current_token.type = TOKEN.WORD;
|
|
23719
|
+
} else if (in_array(current_token.text, ["as", "from"]) && !this._flags.import_block) {
|
|
23720
|
+
current_token.type = TOKEN.WORD;
|
|
23721
|
+
} else if (this._flags.mode === MODE.ObjectLiteral) {
|
|
23722
|
+
var next_token = this._tokens.peek();
|
|
23723
|
+
if (next_token.text === ":") {
|
|
23724
|
+
current_token.type = TOKEN.WORD;
|
|
23725
|
+
}
|
|
23726
|
+
}
|
|
23727
|
+
}
|
|
23728
|
+
if (this.start_of_statement(current_token)) {
|
|
23729
|
+
if (reserved_array(this._flags.last_token, ["var", "let", "const"]) && current_token.type === TOKEN.WORD) {
|
|
23730
|
+
this._flags.declaration_statement = true;
|
|
23731
|
+
}
|
|
23732
|
+
} 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"]))) {
|
|
23733
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23734
|
+
this.print_newline();
|
|
23735
|
+
} else {
|
|
23736
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23737
|
+
}
|
|
23738
|
+
if (this._flags.do_block && !this._flags.do_while) {
|
|
23739
|
+
if (reserved_word(current_token, "while")) {
|
|
23740
|
+
this._output.space_before_token = true;
|
|
23741
|
+
this.print_token(current_token);
|
|
23742
|
+
this._output.space_before_token = true;
|
|
23743
|
+
this._flags.do_while = true;
|
|
23744
|
+
return;
|
|
23745
|
+
} else {
|
|
23746
|
+
this.print_newline();
|
|
23747
|
+
this._flags.do_block = false;
|
|
23748
|
+
}
|
|
23749
|
+
}
|
|
23750
|
+
if (this._flags.if_block) {
|
|
23751
|
+
if (!this._flags.else_block && reserved_word(current_token, "else")) {
|
|
23752
|
+
this._flags.else_block = true;
|
|
23753
|
+
} else {
|
|
23754
|
+
while (this._flags.mode === MODE.Statement) {
|
|
23755
|
+
this.restore_mode();
|
|
23756
|
+
}
|
|
23757
|
+
this._flags.if_block = false;
|
|
23758
|
+
this._flags.else_block = false;
|
|
23759
|
+
}
|
|
23760
|
+
}
|
|
23761
|
+
if (this._flags.in_case_statement && reserved_array(current_token, ["case", "default"])) {
|
|
23762
|
+
this.print_newline();
|
|
23763
|
+
if (!this._flags.case_block && (this._flags.case_body || this._options.jslint_happy)) {
|
|
23764
|
+
this.deindent();
|
|
23765
|
+
}
|
|
23766
|
+
this._flags.case_body = false;
|
|
23767
|
+
this.print_token(current_token);
|
|
23768
|
+
this._flags.in_case = true;
|
|
23769
|
+
return;
|
|
23770
|
+
}
|
|
23771
|
+
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) {
|
|
23772
|
+
if (!this.start_of_object_property()) {
|
|
23773
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
23774
|
+
}
|
|
23775
|
+
}
|
|
23776
|
+
if (reserved_word(current_token, "function")) {
|
|
23777
|
+
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)) {
|
|
23778
|
+
if (!this._output.just_added_blankline() && !current_token.comments_before) {
|
|
23779
|
+
this.print_newline();
|
|
23780
|
+
this.print_newline(true);
|
|
23781
|
+
}
|
|
23782
|
+
}
|
|
23783
|
+
if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD) {
|
|
23784
|
+
if (reserved_array(this._flags.last_token, ["get", "set", "new", "export"]) || reserved_array(this._flags.last_token, newline_restricted_tokens)) {
|
|
23785
|
+
this._output.space_before_token = true;
|
|
23786
|
+
} else if (reserved_word(this._flags.last_token, "default") && this._last_last_text === "export") {
|
|
23787
|
+
this._output.space_before_token = true;
|
|
23788
|
+
} else if (this._flags.last_token.text === "declare") {
|
|
23789
|
+
this._output.space_before_token = true;
|
|
23790
|
+
} else {
|
|
23791
|
+
this.print_newline();
|
|
23792
|
+
}
|
|
23793
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR || this._flags.last_token.text === "=") {
|
|
23794
|
+
this._output.space_before_token = true;
|
|
23795
|
+
} else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) {
|
|
23796
|
+
} else {
|
|
23797
|
+
this.print_newline();
|
|
23798
|
+
}
|
|
23799
|
+
this.print_token(current_token);
|
|
23800
|
+
this._flags.last_word = current_token.text;
|
|
23801
|
+
return;
|
|
23802
|
+
}
|
|
23803
|
+
var prefix = "NONE";
|
|
23804
|
+
if (this._flags.last_token.type === TOKEN.END_BLOCK) {
|
|
23805
|
+
if (this._previous_flags.inline_frame) {
|
|
23806
|
+
prefix = "SPACE";
|
|
23807
|
+
} else if (!reserved_array(current_token, ["else", "catch", "finally", "from"])) {
|
|
23808
|
+
prefix = "NEWLINE";
|
|
23809
|
+
} else {
|
|
23810
|
+
if (this._options.brace_style === "expand" || this._options.brace_style === "end-expand" || this._options.brace_style === "none" && current_token.newlines) {
|
|
23811
|
+
prefix = "NEWLINE";
|
|
23812
|
+
} else {
|
|
23813
|
+
prefix = "SPACE";
|
|
23814
|
+
this._output.space_before_token = true;
|
|
23815
|
+
}
|
|
23816
|
+
}
|
|
23817
|
+
} else if (this._flags.last_token.type === TOKEN.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
|
|
23818
|
+
prefix = "NEWLINE";
|
|
23819
|
+
} else if (this._flags.last_token.type === TOKEN.SEMICOLON && is_expression(this._flags.mode)) {
|
|
23820
|
+
prefix = "SPACE";
|
|
23821
|
+
} else if (this._flags.last_token.type === TOKEN.STRING) {
|
|
23822
|
+
prefix = "NEWLINE";
|
|
23823
|
+
} 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, ["{", ","]))) {
|
|
23824
|
+
prefix = "SPACE";
|
|
23825
|
+
} else if (this._flags.last_token.type === TOKEN.START_BLOCK) {
|
|
23826
|
+
if (this._flags.inline_frame) {
|
|
23827
|
+
prefix = "SPACE";
|
|
23828
|
+
} else {
|
|
23829
|
+
prefix = "NEWLINE";
|
|
23830
|
+
}
|
|
23831
|
+
} else if (this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
23832
|
+
this._output.space_before_token = true;
|
|
23833
|
+
prefix = "NEWLINE";
|
|
23834
|
+
}
|
|
23835
|
+
if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ")") {
|
|
23836
|
+
if (this._flags.inline_frame || this._flags.last_token.text === "else" || this._flags.last_token.text === "export") {
|
|
23837
|
+
prefix = "SPACE";
|
|
23838
|
+
} else {
|
|
23839
|
+
prefix = "NEWLINE";
|
|
23840
|
+
}
|
|
23841
|
+
}
|
|
23842
|
+
if (reserved_array(current_token, ["else", "catch", "finally"])) {
|
|
23843
|
+
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) {
|
|
23844
|
+
this.print_newline();
|
|
23845
|
+
} else {
|
|
23846
|
+
this._output.trim(true);
|
|
23847
|
+
var line = this._output.current_line;
|
|
23848
|
+
if (line.last() !== "}") {
|
|
23849
|
+
this.print_newline();
|
|
23850
|
+
}
|
|
23851
|
+
this._output.space_before_token = true;
|
|
23852
|
+
}
|
|
23853
|
+
} else if (prefix === "NEWLINE") {
|
|
23854
|
+
if (reserved_array(this._flags.last_token, special_words)) {
|
|
23855
|
+
this._output.space_before_token = true;
|
|
23856
|
+
} else if (this._flags.last_token.text === "declare" && reserved_array(current_token, ["var", "let", "const"])) {
|
|
23857
|
+
this._output.space_before_token = true;
|
|
23858
|
+
} else if (this._flags.last_token.type !== TOKEN.END_EXPR) {
|
|
23859
|
+
if ((this._flags.last_token.type !== TOKEN.START_EXPR || !reserved_array(current_token, ["var", "let", "const"])) && this._flags.last_token.text !== ":") {
|
|
23860
|
+
if (reserved_word(current_token, "if") && reserved_word(current_token.previous, "else")) {
|
|
23861
|
+
this._output.space_before_token = true;
|
|
23862
|
+
} else {
|
|
23863
|
+
this.print_newline();
|
|
23864
|
+
}
|
|
23865
|
+
}
|
|
23866
|
+
} else if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ")") {
|
|
23867
|
+
this.print_newline();
|
|
23868
|
+
}
|
|
23869
|
+
} else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === "," && this._last_last_text === "}") {
|
|
23870
|
+
this.print_newline();
|
|
23871
|
+
} else if (prefix === "SPACE") {
|
|
23872
|
+
this._output.space_before_token = true;
|
|
23873
|
+
}
|
|
23874
|
+
if (current_token.previous && (current_token.previous.type === TOKEN.WORD || current_token.previous.type === TOKEN.RESERVED)) {
|
|
23875
|
+
this._output.space_before_token = true;
|
|
23876
|
+
}
|
|
23877
|
+
this.print_token(current_token);
|
|
23878
|
+
this._flags.last_word = current_token.text;
|
|
23879
|
+
if (current_token.type === TOKEN.RESERVED) {
|
|
23880
|
+
if (current_token.text === "do") {
|
|
23881
|
+
this._flags.do_block = true;
|
|
23882
|
+
} else if (current_token.text === "if") {
|
|
23883
|
+
this._flags.if_block = true;
|
|
23884
|
+
} else if (current_token.text === "import") {
|
|
23885
|
+
this._flags.import_block = true;
|
|
23886
|
+
} else if (this._flags.import_block && reserved_word(current_token, "from")) {
|
|
23887
|
+
this._flags.import_block = false;
|
|
23888
|
+
}
|
|
23889
|
+
}
|
|
23890
|
+
};
|
|
23891
|
+
Beautifier.prototype.handle_semicolon = function(current_token) {
|
|
23892
|
+
if (this.start_of_statement(current_token)) {
|
|
23893
|
+
this._output.space_before_token = false;
|
|
23894
|
+
} else {
|
|
23895
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23896
|
+
}
|
|
23897
|
+
var next_token = this._tokens.peek();
|
|
23898
|
+
while (this._flags.mode === MODE.Statement && !(this._flags.if_block && reserved_word(next_token, "else")) && !this._flags.do_block) {
|
|
23899
|
+
this.restore_mode();
|
|
23900
|
+
}
|
|
23901
|
+
if (this._flags.import_block) {
|
|
23902
|
+
this._flags.import_block = false;
|
|
23903
|
+
}
|
|
23904
|
+
this.print_token(current_token);
|
|
23905
|
+
};
|
|
23906
|
+
Beautifier.prototype.handle_string = function(current_token) {
|
|
23907
|
+
if (current_token.text.startsWith("`") && current_token.newlines === 0 && current_token.whitespace_before === "" && (current_token.previous.text === ")" || this._flags.last_token.type === TOKEN.WORD)) {
|
|
23908
|
+
} else if (this.start_of_statement(current_token)) {
|
|
23909
|
+
this._output.space_before_token = true;
|
|
23910
|
+
} else {
|
|
23911
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23912
|
+
if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD || this._flags.inline_frame) {
|
|
23913
|
+
this._output.space_before_token = true;
|
|
23914
|
+
} 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) {
|
|
23915
|
+
if (!this.start_of_object_property()) {
|
|
23916
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
23917
|
+
}
|
|
23918
|
+
} 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) {
|
|
23919
|
+
this._output.space_before_token = true;
|
|
23920
|
+
} else {
|
|
23921
|
+
this.print_newline();
|
|
23922
|
+
}
|
|
23923
|
+
}
|
|
23924
|
+
this.print_token(current_token);
|
|
23925
|
+
};
|
|
23926
|
+
Beautifier.prototype.handle_equals = function(current_token) {
|
|
23927
|
+
if (this.start_of_statement(current_token)) {
|
|
23928
|
+
} else {
|
|
23929
|
+
this.handle_whitespace_and_comments(current_token);
|
|
23930
|
+
}
|
|
23931
|
+
if (this._flags.declaration_statement) {
|
|
23932
|
+
this._flags.declaration_assignment = true;
|
|
23933
|
+
}
|
|
23934
|
+
this._output.space_before_token = true;
|
|
23935
|
+
this.print_token(current_token);
|
|
23936
|
+
this._output.space_before_token = true;
|
|
23937
|
+
};
|
|
23938
|
+
Beautifier.prototype.handle_comma = function(current_token) {
|
|
23939
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
23940
|
+
this.print_token(current_token);
|
|
23941
|
+
this._output.space_before_token = true;
|
|
23942
|
+
if (this._flags.declaration_statement) {
|
|
23943
|
+
if (is_expression(this._flags.parent.mode)) {
|
|
23944
|
+
this._flags.declaration_assignment = false;
|
|
23945
|
+
}
|
|
23946
|
+
if (this._flags.declaration_assignment) {
|
|
23947
|
+
this._flags.declaration_assignment = false;
|
|
23948
|
+
this.print_newline(false, true);
|
|
23949
|
+
} else if (this._options.comma_first) {
|
|
23950
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
23951
|
+
}
|
|
23952
|
+
} else if (this._flags.mode === MODE.ObjectLiteral || this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral) {
|
|
23953
|
+
if (this._flags.mode === MODE.Statement) {
|
|
23954
|
+
this.restore_mode();
|
|
23955
|
+
}
|
|
23956
|
+
if (!this._flags.inline_frame) {
|
|
23957
|
+
this.print_newline();
|
|
23958
|
+
}
|
|
23959
|
+
} else if (this._options.comma_first) {
|
|
23960
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
23961
|
+
}
|
|
23962
|
+
};
|
|
23963
|
+
Beautifier.prototype.handle_operator = function(current_token) {
|
|
23964
|
+
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]));
|
|
23965
|
+
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 === ",");
|
|
23966
|
+
if (this.start_of_statement(current_token)) {
|
|
23967
|
+
} else {
|
|
23968
|
+
var preserve_statement_flags = !isGeneratorAsterisk;
|
|
23969
|
+
this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
|
|
23970
|
+
}
|
|
23971
|
+
if (reserved_array(this._flags.last_token, special_words)) {
|
|
23972
|
+
this._output.space_before_token = true;
|
|
23973
|
+
this.print_token(current_token);
|
|
23974
|
+
return;
|
|
23975
|
+
}
|
|
23976
|
+
if (current_token.text === "*" && this._flags.last_token.type === TOKEN.DOT) {
|
|
23977
|
+
this.print_token(current_token);
|
|
23978
|
+
return;
|
|
23979
|
+
}
|
|
23980
|
+
if (current_token.text === "::") {
|
|
23981
|
+
this.print_token(current_token);
|
|
23982
|
+
return;
|
|
23983
|
+
}
|
|
23984
|
+
if (this._flags.last_token.type === TOKEN.OPERATOR && in_array(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
|
|
23985
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
23986
|
+
}
|
|
23987
|
+
if (current_token.text === ":" && this._flags.in_case) {
|
|
23988
|
+
this.print_token(current_token);
|
|
23989
|
+
this._flags.in_case = false;
|
|
23990
|
+
this._flags.case_body = true;
|
|
23991
|
+
if (this._tokens.peek().type !== TOKEN.START_BLOCK) {
|
|
23992
|
+
this.indent();
|
|
23993
|
+
this.print_newline();
|
|
23994
|
+
this._flags.case_block = false;
|
|
23995
|
+
} else {
|
|
23996
|
+
this._flags.case_block = true;
|
|
23997
|
+
this._output.space_before_token = true;
|
|
23998
|
+
}
|
|
23999
|
+
return;
|
|
24000
|
+
}
|
|
24001
|
+
var space_before = true;
|
|
24002
|
+
var space_after = true;
|
|
24003
|
+
var in_ternary = false;
|
|
24004
|
+
if (current_token.text === ":") {
|
|
24005
|
+
if (this._flags.ternary_depth === 0) {
|
|
24006
|
+
space_before = false;
|
|
24007
|
+
} else {
|
|
24008
|
+
this._flags.ternary_depth -= 1;
|
|
24009
|
+
in_ternary = true;
|
|
24010
|
+
}
|
|
24011
|
+
} else if (current_token.text === "?") {
|
|
24012
|
+
this._flags.ternary_depth += 1;
|
|
24013
|
+
}
|
|
24014
|
+
if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array(current_token.text, positionable_operators)) {
|
|
24015
|
+
var isColon = current_token.text === ":";
|
|
24016
|
+
var isTernaryColon = isColon && in_ternary;
|
|
24017
|
+
var isOtherColon = isColon && !in_ternary;
|
|
24018
|
+
switch (this._options.operator_position) {
|
|
24019
|
+
case OPERATOR_POSITION.before_newline:
|
|
24020
|
+
this._output.space_before_token = !isOtherColon;
|
|
24021
|
+
this.print_token(current_token);
|
|
24022
|
+
if (!isColon || isTernaryColon) {
|
|
24023
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
24024
|
+
}
|
|
24025
|
+
this._output.space_before_token = true;
|
|
24026
|
+
return;
|
|
24027
|
+
case OPERATOR_POSITION.after_newline:
|
|
24028
|
+
this._output.space_before_token = true;
|
|
24029
|
+
if (!isColon || isTernaryColon) {
|
|
24030
|
+
if (this._tokens.peek().newlines) {
|
|
24031
|
+
this.print_newline(false, true);
|
|
24032
|
+
} else {
|
|
24033
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
24034
|
+
}
|
|
24035
|
+
} else {
|
|
24036
|
+
this._output.space_before_token = false;
|
|
24037
|
+
}
|
|
24038
|
+
this.print_token(current_token);
|
|
24039
|
+
this._output.space_before_token = true;
|
|
24040
|
+
return;
|
|
24041
|
+
case OPERATOR_POSITION.preserve_newline:
|
|
24042
|
+
if (!isOtherColon) {
|
|
24043
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
24044
|
+
}
|
|
24045
|
+
space_before = !(this._output.just_added_newline() || isOtherColon);
|
|
24046
|
+
this._output.space_before_token = space_before;
|
|
24047
|
+
this.print_token(current_token);
|
|
24048
|
+
this._output.space_before_token = true;
|
|
24049
|
+
return;
|
|
24050
|
+
}
|
|
24051
|
+
}
|
|
24052
|
+
if (isGeneratorAsterisk) {
|
|
24053
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
24054
|
+
space_before = false;
|
|
24055
|
+
var next_token = this._tokens.peek();
|
|
24056
|
+
space_after = next_token && in_array(next_token.type, [TOKEN.WORD, TOKEN.RESERVED]);
|
|
24057
|
+
} else if (current_token.text === "...") {
|
|
24058
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
24059
|
+
space_before = this._flags.last_token.type === TOKEN.START_BLOCK;
|
|
24060
|
+
space_after = false;
|
|
24061
|
+
} else if (in_array(current_token.text, ["--", "++", "!", "~"]) || isUnary) {
|
|
24062
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR) {
|
|
24063
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
24064
|
+
}
|
|
24065
|
+
space_before = false;
|
|
24066
|
+
space_after = false;
|
|
24067
|
+
if (current_token.newlines && (current_token.text === "--" || current_token.text === "++" || current_token.text === "~")) {
|
|
24068
|
+
this.print_newline(false, true);
|
|
24069
|
+
}
|
|
24070
|
+
if (this._flags.last_token.text === ";" && is_expression(this._flags.mode)) {
|
|
24071
|
+
space_before = true;
|
|
24072
|
+
}
|
|
24073
|
+
if (this._flags.last_token.type === TOKEN.RESERVED) {
|
|
24074
|
+
space_before = true;
|
|
24075
|
+
} else if (this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
24076
|
+
space_before = !(this._flags.last_token.text === "]" && (current_token.text === "--" || current_token.text === "++"));
|
|
24077
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR) {
|
|
24078
|
+
space_before = in_array(current_token.text, ["--", "-", "++", "+"]) && in_array(this._flags.last_token.text, ["--", "-", "++", "+"]);
|
|
24079
|
+
if (in_array(current_token.text, ["+", "-"]) && in_array(this._flags.last_token.text, ["--", "++"])) {
|
|
24080
|
+
space_after = true;
|
|
24081
|
+
}
|
|
24082
|
+
}
|
|
24083
|
+
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 === ";")) {
|
|
24084
|
+
this.print_newline();
|
|
24085
|
+
}
|
|
24086
|
+
}
|
|
24087
|
+
this._output.space_before_token = this._output.space_before_token || space_before;
|
|
24088
|
+
this.print_token(current_token);
|
|
24089
|
+
this._output.space_before_token = space_after;
|
|
24090
|
+
};
|
|
24091
|
+
Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
|
|
24092
|
+
if (this._output.raw) {
|
|
24093
|
+
this._output.add_raw_token(current_token);
|
|
24094
|
+
if (current_token.directives && current_token.directives.preserve === "end") {
|
|
24095
|
+
this._output.raw = this._options.test_output_raw;
|
|
24096
|
+
}
|
|
24097
|
+
return;
|
|
24098
|
+
}
|
|
24099
|
+
if (current_token.directives) {
|
|
24100
|
+
this.print_newline(false, preserve_statement_flags);
|
|
24101
|
+
this.print_token(current_token);
|
|
24102
|
+
if (current_token.directives.preserve === "start") {
|
|
24103
|
+
this._output.raw = true;
|
|
24104
|
+
}
|
|
24105
|
+
this.print_newline(false, true);
|
|
24106
|
+
return;
|
|
24107
|
+
}
|
|
24108
|
+
if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
|
|
24109
|
+
this._output.space_before_token = true;
|
|
24110
|
+
this.print_token(current_token);
|
|
24111
|
+
this._output.space_before_token = true;
|
|
24112
|
+
return;
|
|
24113
|
+
} else {
|
|
24114
|
+
this.print_block_commment(current_token, preserve_statement_flags);
|
|
24115
|
+
}
|
|
24116
|
+
};
|
|
24117
|
+
Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
|
|
24118
|
+
var lines = split_linebreaks(current_token.text);
|
|
24119
|
+
var j;
|
|
24120
|
+
var javadoc = false;
|
|
24121
|
+
var starless = false;
|
|
24122
|
+
var lastIndent = current_token.whitespace_before;
|
|
24123
|
+
var lastIndentLength = lastIndent.length;
|
|
24124
|
+
this.print_newline(false, preserve_statement_flags);
|
|
24125
|
+
this.print_token_line_indentation(current_token);
|
|
24126
|
+
this._output.add_token(lines[0]);
|
|
24127
|
+
this.print_newline(false, preserve_statement_flags);
|
|
24128
|
+
if (lines.length > 1) {
|
|
24129
|
+
lines = lines.slice(1);
|
|
24130
|
+
javadoc = all_lines_start_with(lines, "*");
|
|
24131
|
+
starless = each_line_matches_indent(lines, lastIndent);
|
|
24132
|
+
if (javadoc) {
|
|
24133
|
+
this._flags.alignment = 1;
|
|
24134
|
+
}
|
|
24135
|
+
for (j = 0; j < lines.length; j++) {
|
|
24136
|
+
if (javadoc) {
|
|
24137
|
+
this.print_token_line_indentation(current_token);
|
|
24138
|
+
this._output.add_token(ltrim(lines[j]));
|
|
24139
|
+
} else if (starless && lines[j]) {
|
|
24140
|
+
this.print_token_line_indentation(current_token);
|
|
24141
|
+
this._output.add_token(lines[j].substring(lastIndentLength));
|
|
24142
|
+
} else {
|
|
24143
|
+
this._output.current_line.set_indent(-1);
|
|
24144
|
+
this._output.add_token(lines[j]);
|
|
24145
|
+
}
|
|
24146
|
+
this.print_newline(false, preserve_statement_flags);
|
|
24147
|
+
}
|
|
24148
|
+
this._flags.alignment = 0;
|
|
24149
|
+
}
|
|
24150
|
+
};
|
|
24151
|
+
Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
|
|
24152
|
+
if (current_token.newlines) {
|
|
24153
|
+
this.print_newline(false, preserve_statement_flags);
|
|
24154
|
+
} else {
|
|
24155
|
+
this._output.trim(true);
|
|
24156
|
+
}
|
|
24157
|
+
this._output.space_before_token = true;
|
|
24158
|
+
this.print_token(current_token);
|
|
24159
|
+
this.print_newline(false, preserve_statement_flags);
|
|
24160
|
+
};
|
|
24161
|
+
Beautifier.prototype.handle_dot = function(current_token) {
|
|
24162
|
+
if (this.start_of_statement(current_token)) {
|
|
24163
|
+
} else {
|
|
24164
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
24165
|
+
}
|
|
24166
|
+
if (reserved_array(this._flags.last_token, special_words)) {
|
|
24167
|
+
this._output.space_before_token = false;
|
|
24168
|
+
} else {
|
|
24169
|
+
this.allow_wrap_or_preserved_newline(
|
|
24170
|
+
current_token,
|
|
24171
|
+
this._flags.last_token.text === ")" && this._options.break_chained_methods
|
|
24172
|
+
);
|
|
24173
|
+
}
|
|
24174
|
+
if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
|
|
24175
|
+
this.deindent();
|
|
24176
|
+
}
|
|
24177
|
+
this.print_token(current_token);
|
|
24178
|
+
};
|
|
24179
|
+
Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
|
|
24180
|
+
this.print_token(current_token);
|
|
24181
|
+
if (current_token.text[current_token.text.length - 1] === "\n") {
|
|
24182
|
+
this.print_newline(false, preserve_statement_flags);
|
|
24183
|
+
}
|
|
24184
|
+
};
|
|
24185
|
+
Beautifier.prototype.handle_eof = function(current_token) {
|
|
24186
|
+
while (this._flags.mode === MODE.Statement) {
|
|
24187
|
+
this.restore_mode();
|
|
24188
|
+
}
|
|
24189
|
+
this.handle_whitespace_and_comments(current_token);
|
|
24190
|
+
};
|
|
24191
|
+
module2.exports.Beautifier = Beautifier;
|
|
24192
|
+
}
|
|
24193
|
+
});
|
|
24194
|
+
|
|
24195
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/index.js
|
|
24196
|
+
var require_javascript = __commonJS({
|
|
24197
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/javascript/index.js"(exports, module2) {
|
|
24198
|
+
"use strict";
|
|
24199
|
+
var Beautifier = require_beautifier().Beautifier;
|
|
24200
|
+
var Options = require_options2().Options;
|
|
24201
|
+
function js_beautify2(js_source_text, options) {
|
|
24202
|
+
var beautifier = new Beautifier(js_source_text, options);
|
|
24203
|
+
return beautifier.beautify();
|
|
24204
|
+
}
|
|
24205
|
+
module2.exports = js_beautify2;
|
|
24206
|
+
module2.exports.defaultOptions = function() {
|
|
24207
|
+
return new Options();
|
|
24208
|
+
};
|
|
24209
|
+
}
|
|
24210
|
+
});
|
|
24211
|
+
|
|
24212
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/css/options.js
|
|
24213
|
+
var require_options3 = __commonJS({
|
|
24214
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/css/options.js"(exports, module2) {
|
|
24215
|
+
"use strict";
|
|
24216
|
+
var BaseOptions = require_options().Options;
|
|
24217
|
+
function Options(options) {
|
|
24218
|
+
BaseOptions.call(this, options, "css");
|
|
24219
|
+
this.selector_separator_newline = this._get_boolean("selector_separator_newline", true);
|
|
24220
|
+
this.newline_between_rules = this._get_boolean("newline_between_rules", true);
|
|
24221
|
+
var space_around_selector_separator = this._get_boolean("space_around_selector_separator");
|
|
24222
|
+
this.space_around_combinator = this._get_boolean("space_around_combinator") || space_around_selector_separator;
|
|
24223
|
+
var brace_style_split = this._get_selection_list("brace_style", ["collapse", "expand", "end-expand", "none", "preserve-inline"]);
|
|
24224
|
+
this.brace_style = "collapse";
|
|
24225
|
+
for (var bs = 0; bs < brace_style_split.length; bs++) {
|
|
24226
|
+
if (brace_style_split[bs] !== "expand") {
|
|
24227
|
+
this.brace_style = "collapse";
|
|
24228
|
+
} else {
|
|
24229
|
+
this.brace_style = brace_style_split[bs];
|
|
24230
|
+
}
|
|
24231
|
+
}
|
|
24232
|
+
}
|
|
24233
|
+
Options.prototype = new BaseOptions();
|
|
24234
|
+
module2.exports.Options = Options;
|
|
24235
|
+
}
|
|
24236
|
+
});
|
|
24237
|
+
|
|
24238
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/css/beautifier.js
|
|
24239
|
+
var require_beautifier2 = __commonJS({
|
|
24240
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/css/beautifier.js"(exports, module2) {
|
|
24241
|
+
"use strict";
|
|
24242
|
+
var Options = require_options3().Options;
|
|
24243
|
+
var Output = require_output().Output;
|
|
24244
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
24245
|
+
var Directives = require_directives().Directives;
|
|
24246
|
+
var directives_core = new Directives(/\/\*/, /\*\//);
|
|
24247
|
+
var lineBreak = /\r\n|[\r\n]/;
|
|
24248
|
+
var allLineBreaks = /\r\n|[\r\n]/g;
|
|
24249
|
+
var whitespaceChar = /\s/;
|
|
24250
|
+
var whitespacePattern = /(?:\s|\n)+/g;
|
|
24251
|
+
var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
|
|
24252
|
+
var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
|
|
24253
|
+
function Beautifier(source_text, options) {
|
|
24254
|
+
this._source_text = source_text || "";
|
|
24255
|
+
this._options = new Options(options);
|
|
24256
|
+
this._ch = null;
|
|
24257
|
+
this._input = null;
|
|
24258
|
+
this.NESTED_AT_RULE = {
|
|
24259
|
+
"@page": true,
|
|
24260
|
+
"@font-face": true,
|
|
24261
|
+
"@keyframes": true,
|
|
24262
|
+
// also in CONDITIONAL_GROUP_RULE below
|
|
24263
|
+
"@media": true,
|
|
24264
|
+
"@supports": true,
|
|
24265
|
+
"@document": true
|
|
24266
|
+
};
|
|
24267
|
+
this.CONDITIONAL_GROUP_RULE = {
|
|
24268
|
+
"@media": true,
|
|
24269
|
+
"@supports": true,
|
|
24270
|
+
"@document": true
|
|
24271
|
+
};
|
|
24272
|
+
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
|
|
24273
|
+
"grid-template"
|
|
24274
|
+
];
|
|
24275
|
+
}
|
|
24276
|
+
Beautifier.prototype.eatString = function(endChars) {
|
|
24277
|
+
var result = "";
|
|
24278
|
+
this._ch = this._input.next();
|
|
24279
|
+
while (this._ch) {
|
|
24280
|
+
result += this._ch;
|
|
24281
|
+
if (this._ch === "\\") {
|
|
24282
|
+
result += this._input.next();
|
|
24283
|
+
} else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
|
|
24284
|
+
break;
|
|
24285
|
+
}
|
|
24286
|
+
this._ch = this._input.next();
|
|
24287
|
+
}
|
|
24288
|
+
return result;
|
|
24289
|
+
};
|
|
24290
|
+
Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
|
|
24291
|
+
var result = whitespaceChar.test(this._input.peek());
|
|
24292
|
+
var newline_count = 0;
|
|
24293
|
+
while (whitespaceChar.test(this._input.peek())) {
|
|
24294
|
+
this._ch = this._input.next();
|
|
24295
|
+
if (allowAtLeastOneNewLine && this._ch === "\n") {
|
|
24296
|
+
if (newline_count === 0 || newline_count < this._options.max_preserve_newlines) {
|
|
24297
|
+
newline_count++;
|
|
24298
|
+
this._output.add_new_line(true);
|
|
24299
|
+
}
|
|
24300
|
+
}
|
|
24301
|
+
}
|
|
24302
|
+
return result;
|
|
24303
|
+
};
|
|
24304
|
+
Beautifier.prototype.foundNestedPseudoClass = function() {
|
|
24305
|
+
var openParen = 0;
|
|
24306
|
+
var i = 1;
|
|
24307
|
+
var ch = this._input.peek(i);
|
|
24308
|
+
while (ch) {
|
|
24309
|
+
if (ch === "{") {
|
|
24310
|
+
return true;
|
|
24311
|
+
} else if (ch === "(") {
|
|
24312
|
+
openParen += 1;
|
|
24313
|
+
} else if (ch === ")") {
|
|
24314
|
+
if (openParen === 0) {
|
|
24315
|
+
return false;
|
|
24316
|
+
}
|
|
24317
|
+
openParen -= 1;
|
|
24318
|
+
} else if (ch === ";" || ch === "}") {
|
|
24319
|
+
return false;
|
|
24320
|
+
}
|
|
24321
|
+
i++;
|
|
24322
|
+
ch = this._input.peek(i);
|
|
24323
|
+
}
|
|
24324
|
+
return false;
|
|
24325
|
+
};
|
|
24326
|
+
Beautifier.prototype.print_string = function(output_string) {
|
|
24327
|
+
this._output.set_indent(this._indentLevel);
|
|
24328
|
+
this._output.non_breaking_space = true;
|
|
24329
|
+
this._output.add_token(output_string);
|
|
24330
|
+
};
|
|
24331
|
+
Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) {
|
|
24332
|
+
if (isAfterSpace) {
|
|
24333
|
+
this._output.space_before_token = true;
|
|
24334
|
+
}
|
|
24335
|
+
};
|
|
24336
|
+
Beautifier.prototype.indent = function() {
|
|
24337
|
+
this._indentLevel++;
|
|
24338
|
+
};
|
|
24339
|
+
Beautifier.prototype.outdent = function() {
|
|
24340
|
+
if (this._indentLevel > 0) {
|
|
24341
|
+
this._indentLevel--;
|
|
24342
|
+
}
|
|
24343
|
+
};
|
|
24344
|
+
Beautifier.prototype.beautify = function() {
|
|
24345
|
+
if (this._options.disabled) {
|
|
24346
|
+
return this._source_text;
|
|
24347
|
+
}
|
|
24348
|
+
var source_text = this._source_text;
|
|
24349
|
+
var eol = this._options.eol;
|
|
24350
|
+
if (eol === "auto") {
|
|
24351
|
+
eol = "\n";
|
|
24352
|
+
if (source_text && lineBreak.test(source_text || "")) {
|
|
24353
|
+
eol = source_text.match(lineBreak)[0];
|
|
24354
|
+
}
|
|
24355
|
+
}
|
|
24356
|
+
source_text = source_text.replace(allLineBreaks, "\n");
|
|
24357
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
24358
|
+
this._output = new Output(this._options, baseIndentString);
|
|
24359
|
+
this._input = new InputScanner(source_text);
|
|
24360
|
+
this._indentLevel = 0;
|
|
24361
|
+
this._nestedLevel = 0;
|
|
24362
|
+
this._ch = null;
|
|
24363
|
+
var parenLevel = 0;
|
|
24364
|
+
var insideRule = false;
|
|
24365
|
+
var insidePropertyValue = false;
|
|
24366
|
+
var enteringConditionalGroup = false;
|
|
24367
|
+
var insideAtExtend = false;
|
|
24368
|
+
var insideAtImport = false;
|
|
24369
|
+
var insideScssMap = false;
|
|
24370
|
+
var topCharacter = this._ch;
|
|
24371
|
+
var insideNonSemiColonValues = false;
|
|
24372
|
+
var whitespace;
|
|
24373
|
+
var isAfterSpace;
|
|
24374
|
+
var previous_ch;
|
|
24375
|
+
while (true) {
|
|
24376
|
+
whitespace = this._input.read(whitespacePattern);
|
|
24377
|
+
isAfterSpace = whitespace !== "";
|
|
24378
|
+
previous_ch = topCharacter;
|
|
24379
|
+
this._ch = this._input.next();
|
|
24380
|
+
if (this._ch === "\\" && this._input.hasNext()) {
|
|
24381
|
+
this._ch += this._input.next();
|
|
24382
|
+
}
|
|
24383
|
+
topCharacter = this._ch;
|
|
24384
|
+
if (!this._ch) {
|
|
24385
|
+
break;
|
|
24386
|
+
} else if (this._ch === "/" && this._input.peek() === "*") {
|
|
24387
|
+
this._output.add_new_line();
|
|
24388
|
+
this._input.back();
|
|
24389
|
+
var comment = this._input.read(block_comment_pattern);
|
|
24390
|
+
var directives = directives_core.get_directives(comment);
|
|
24391
|
+
if (directives && directives.ignore === "start") {
|
|
24392
|
+
comment += directives_core.readIgnored(this._input);
|
|
24393
|
+
}
|
|
24394
|
+
this.print_string(comment);
|
|
24395
|
+
this.eatWhitespace(true);
|
|
24396
|
+
this._output.add_new_line();
|
|
24397
|
+
} else if (this._ch === "/" && this._input.peek() === "/") {
|
|
24398
|
+
this._output.space_before_token = true;
|
|
24399
|
+
this._input.back();
|
|
24400
|
+
this.print_string(this._input.read(comment_pattern));
|
|
24401
|
+
this.eatWhitespace(true);
|
|
24402
|
+
} else if (this._ch === "@" || this._ch === "$") {
|
|
24403
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
24404
|
+
if (this._input.peek() === "{") {
|
|
24405
|
+
this.print_string(this._ch + this.eatString("}"));
|
|
24406
|
+
} else {
|
|
24407
|
+
this.print_string(this._ch);
|
|
24408
|
+
var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
|
|
24409
|
+
if (variableOrRule.match(/[ :]$/)) {
|
|
24410
|
+
variableOrRule = this.eatString(": ").replace(/\s$/, "");
|
|
24411
|
+
this.print_string(variableOrRule);
|
|
24412
|
+
this._output.space_before_token = true;
|
|
24413
|
+
}
|
|
24414
|
+
variableOrRule = variableOrRule.replace(/\s$/, "");
|
|
24415
|
+
if (variableOrRule === "extend") {
|
|
24416
|
+
insideAtExtend = true;
|
|
24417
|
+
} else if (variableOrRule === "import") {
|
|
24418
|
+
insideAtImport = true;
|
|
24419
|
+
}
|
|
24420
|
+
if (variableOrRule in this.NESTED_AT_RULE) {
|
|
24421
|
+
this._nestedLevel += 1;
|
|
24422
|
+
if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
|
|
24423
|
+
enteringConditionalGroup = true;
|
|
24424
|
+
}
|
|
24425
|
+
} else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(":") !== -1) {
|
|
24426
|
+
insidePropertyValue = true;
|
|
24427
|
+
this.indent();
|
|
24428
|
+
}
|
|
24429
|
+
}
|
|
24430
|
+
} else if (this._ch === "#" && this._input.peek() === "{") {
|
|
24431
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
24432
|
+
this.print_string(this._ch + this.eatString("}"));
|
|
24433
|
+
} else if (this._ch === "{") {
|
|
24434
|
+
if (insidePropertyValue) {
|
|
24435
|
+
insidePropertyValue = false;
|
|
24436
|
+
this.outdent();
|
|
24437
|
+
}
|
|
24438
|
+
if (enteringConditionalGroup) {
|
|
24439
|
+
enteringConditionalGroup = false;
|
|
24440
|
+
insideRule = this._indentLevel >= this._nestedLevel;
|
|
24441
|
+
} else {
|
|
24442
|
+
insideRule = this._indentLevel >= this._nestedLevel - 1;
|
|
24443
|
+
}
|
|
24444
|
+
if (this._options.newline_between_rules && insideRule) {
|
|
24445
|
+
if (this._output.previous_line && this._output.previous_line.item(-1) !== "{") {
|
|
24446
|
+
this._output.ensure_empty_line_above("/", ",");
|
|
24447
|
+
}
|
|
24448
|
+
}
|
|
24449
|
+
this._output.space_before_token = true;
|
|
24450
|
+
if (this._options.brace_style === "expand") {
|
|
24451
|
+
this._output.add_new_line();
|
|
24452
|
+
this.print_string(this._ch);
|
|
24453
|
+
this.indent();
|
|
24454
|
+
this._output.set_indent(this._indentLevel);
|
|
24455
|
+
} else {
|
|
24456
|
+
if (previous_ch === "(") {
|
|
24457
|
+
this._output.space_before_token = false;
|
|
24458
|
+
} else if (previous_ch !== ",") {
|
|
24459
|
+
this.indent();
|
|
24460
|
+
}
|
|
24461
|
+
this.print_string(this._ch);
|
|
24462
|
+
}
|
|
24463
|
+
this.eatWhitespace(true);
|
|
24464
|
+
this._output.add_new_line();
|
|
24465
|
+
} else if (this._ch === "}") {
|
|
24466
|
+
this.outdent();
|
|
24467
|
+
this._output.add_new_line();
|
|
24468
|
+
if (previous_ch === "{") {
|
|
24469
|
+
this._output.trim(true);
|
|
24470
|
+
}
|
|
24471
|
+
insideAtImport = false;
|
|
24472
|
+
insideAtExtend = false;
|
|
24473
|
+
if (insidePropertyValue) {
|
|
24474
|
+
this.outdent();
|
|
24475
|
+
insidePropertyValue = false;
|
|
24476
|
+
}
|
|
24477
|
+
this.print_string(this._ch);
|
|
24478
|
+
insideRule = false;
|
|
24479
|
+
if (this._nestedLevel) {
|
|
24480
|
+
this._nestedLevel--;
|
|
24481
|
+
}
|
|
24482
|
+
this.eatWhitespace(true);
|
|
24483
|
+
this._output.add_new_line();
|
|
24484
|
+
if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
|
|
24485
|
+
if (this._input.peek() !== "}") {
|
|
24486
|
+
this._output.add_new_line(true);
|
|
24487
|
+
}
|
|
24488
|
+
}
|
|
24489
|
+
if (this._input.peek() === ")") {
|
|
24490
|
+
this._output.trim(true);
|
|
24491
|
+
if (this._options.brace_style === "expand") {
|
|
24492
|
+
this._output.add_new_line(true);
|
|
24493
|
+
}
|
|
24494
|
+
}
|
|
24495
|
+
} else if (this._ch === ":") {
|
|
24496
|
+
for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
|
|
24497
|
+
if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
|
|
24498
|
+
insideNonSemiColonValues = true;
|
|
24499
|
+
break;
|
|
24500
|
+
}
|
|
24501
|
+
}
|
|
24502
|
+
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
|
|
24503
|
+
this.print_string(":");
|
|
24504
|
+
if (!insidePropertyValue) {
|
|
24505
|
+
insidePropertyValue = true;
|
|
24506
|
+
this._output.space_before_token = true;
|
|
24507
|
+
this.eatWhitespace(true);
|
|
24508
|
+
this.indent();
|
|
24509
|
+
}
|
|
24510
|
+
} else {
|
|
24511
|
+
if (this._input.lookBack(" ")) {
|
|
24512
|
+
this._output.space_before_token = true;
|
|
24513
|
+
}
|
|
24514
|
+
if (this._input.peek() === ":") {
|
|
24515
|
+
this._ch = this._input.next();
|
|
24516
|
+
this.print_string("::");
|
|
24517
|
+
} else {
|
|
24518
|
+
this.print_string(":");
|
|
24519
|
+
}
|
|
24520
|
+
}
|
|
24521
|
+
} else if (this._ch === '"' || this._ch === "'") {
|
|
24522
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
24523
|
+
this.print_string(this._ch + this.eatString(this._ch));
|
|
24524
|
+
this.eatWhitespace(true);
|
|
24525
|
+
} else if (this._ch === ";") {
|
|
24526
|
+
insideNonSemiColonValues = false;
|
|
24527
|
+
if (parenLevel === 0) {
|
|
24528
|
+
if (insidePropertyValue) {
|
|
24529
|
+
this.outdent();
|
|
24530
|
+
insidePropertyValue = false;
|
|
24531
|
+
}
|
|
24532
|
+
insideAtExtend = false;
|
|
24533
|
+
insideAtImport = false;
|
|
24534
|
+
this.print_string(this._ch);
|
|
24535
|
+
this.eatWhitespace(true);
|
|
24536
|
+
if (this._input.peek() !== "/") {
|
|
24537
|
+
this._output.add_new_line();
|
|
24538
|
+
}
|
|
24539
|
+
} else {
|
|
24540
|
+
this.print_string(this._ch);
|
|
24541
|
+
this.eatWhitespace(true);
|
|
24542
|
+
this._output.space_before_token = true;
|
|
24543
|
+
}
|
|
24544
|
+
} else if (this._ch === "(") {
|
|
24545
|
+
if (this._input.lookBack("url")) {
|
|
24546
|
+
this.print_string(this._ch);
|
|
24547
|
+
this.eatWhitespace();
|
|
24548
|
+
parenLevel++;
|
|
24549
|
+
this.indent();
|
|
24550
|
+
this._ch = this._input.next();
|
|
24551
|
+
if (this._ch === ")" || this._ch === '"' || this._ch === "'") {
|
|
24552
|
+
this._input.back();
|
|
24553
|
+
} else if (this._ch) {
|
|
24554
|
+
this.print_string(this._ch + this.eatString(")"));
|
|
24555
|
+
if (parenLevel) {
|
|
24556
|
+
parenLevel--;
|
|
24557
|
+
this.outdent();
|
|
24558
|
+
}
|
|
24559
|
+
}
|
|
24560
|
+
} else {
|
|
24561
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
24562
|
+
this.print_string(this._ch);
|
|
24563
|
+
if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
|
|
24564
|
+
this._output.add_new_line();
|
|
24565
|
+
insideScssMap = true;
|
|
24566
|
+
} else {
|
|
24567
|
+
this.eatWhitespace();
|
|
24568
|
+
parenLevel++;
|
|
24569
|
+
this.indent();
|
|
24570
|
+
}
|
|
24571
|
+
}
|
|
24572
|
+
} else if (this._ch === ")") {
|
|
24573
|
+
if (parenLevel) {
|
|
24574
|
+
parenLevel--;
|
|
24575
|
+
this.outdent();
|
|
24576
|
+
}
|
|
24577
|
+
if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
|
|
24578
|
+
insideScssMap = false;
|
|
24579
|
+
this.outdent();
|
|
24580
|
+
this._output.add_new_line();
|
|
24581
|
+
}
|
|
24582
|
+
this.print_string(this._ch);
|
|
24583
|
+
} else if (this._ch === ",") {
|
|
24584
|
+
this.print_string(this._ch);
|
|
24585
|
+
this.eatWhitespace(true);
|
|
24586
|
+
if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
|
|
24587
|
+
this._output.add_new_line();
|
|
24588
|
+
} else {
|
|
24589
|
+
this._output.space_before_token = true;
|
|
24590
|
+
}
|
|
24591
|
+
} else if ((this._ch === ">" || this._ch === "+" || this._ch === "~") && !insidePropertyValue && parenLevel === 0) {
|
|
24592
|
+
if (this._options.space_around_combinator) {
|
|
24593
|
+
this._output.space_before_token = true;
|
|
24594
|
+
this.print_string(this._ch);
|
|
24595
|
+
this._output.space_before_token = true;
|
|
24596
|
+
} else {
|
|
24597
|
+
this.print_string(this._ch);
|
|
24598
|
+
this.eatWhitespace();
|
|
24599
|
+
if (this._ch && whitespaceChar.test(this._ch)) {
|
|
24600
|
+
this._ch = "";
|
|
24601
|
+
}
|
|
24602
|
+
}
|
|
24603
|
+
} else if (this._ch === "]") {
|
|
24604
|
+
this.print_string(this._ch);
|
|
24605
|
+
} else if (this._ch === "[") {
|
|
24606
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
24607
|
+
this.print_string(this._ch);
|
|
24608
|
+
} else if (this._ch === "=") {
|
|
24609
|
+
this.eatWhitespace();
|
|
24610
|
+
this.print_string("=");
|
|
24611
|
+
if (whitespaceChar.test(this._ch)) {
|
|
24612
|
+
this._ch = "";
|
|
24613
|
+
}
|
|
24614
|
+
} else if (this._ch === "!" && !this._input.lookBack("\\")) {
|
|
24615
|
+
this.print_string(" ");
|
|
24616
|
+
this.print_string(this._ch);
|
|
24617
|
+
} else {
|
|
24618
|
+
var preserveAfterSpace = previous_ch === '"' || previous_ch === "'";
|
|
24619
|
+
this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
|
|
24620
|
+
this.print_string(this._ch);
|
|
24621
|
+
if (!this._output.just_added_newline() && this._input.peek() === "\n" && insideNonSemiColonValues) {
|
|
24622
|
+
this._output.add_new_line();
|
|
24623
|
+
}
|
|
24624
|
+
}
|
|
24625
|
+
}
|
|
24626
|
+
var sweetCode = this._output.get_code(eol);
|
|
24627
|
+
return sweetCode;
|
|
24628
|
+
};
|
|
24629
|
+
module2.exports.Beautifier = Beautifier;
|
|
24630
|
+
}
|
|
24631
|
+
});
|
|
24632
|
+
|
|
24633
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/css/index.js
|
|
24634
|
+
var require_css = __commonJS({
|
|
24635
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/css/index.js"(exports, module2) {
|
|
24636
|
+
"use strict";
|
|
24637
|
+
var Beautifier = require_beautifier2().Beautifier;
|
|
24638
|
+
var Options = require_options3().Options;
|
|
24639
|
+
function css_beautify(source_text, options) {
|
|
24640
|
+
var beautifier = new Beautifier(source_text, options);
|
|
24641
|
+
return beautifier.beautify();
|
|
24642
|
+
}
|
|
24643
|
+
module2.exports = css_beautify;
|
|
24644
|
+
module2.exports.defaultOptions = function() {
|
|
24645
|
+
return new Options();
|
|
24646
|
+
};
|
|
24647
|
+
}
|
|
24648
|
+
});
|
|
24649
|
+
|
|
24650
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/html/options.js
|
|
24651
|
+
var require_options4 = __commonJS({
|
|
24652
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/html/options.js"(exports, module2) {
|
|
24653
|
+
"use strict";
|
|
24654
|
+
var BaseOptions = require_options().Options;
|
|
24655
|
+
function Options(options) {
|
|
24656
|
+
BaseOptions.call(this, options, "html");
|
|
24657
|
+
if (this.templating.length === 1 && this.templating[0] === "auto") {
|
|
24658
|
+
this.templating = ["django", "erb", "handlebars", "php"];
|
|
24659
|
+
}
|
|
24660
|
+
this.indent_inner_html = this._get_boolean("indent_inner_html");
|
|
24661
|
+
this.indent_body_inner_html = this._get_boolean("indent_body_inner_html", true);
|
|
24662
|
+
this.indent_head_inner_html = this._get_boolean("indent_head_inner_html", true);
|
|
24663
|
+
this.indent_handlebars = this._get_boolean("indent_handlebars", true);
|
|
24664
|
+
this.wrap_attributes = this._get_selection(
|
|
24665
|
+
"wrap_attributes",
|
|
24666
|
+
["auto", "force", "force-aligned", "force-expand-multiline", "aligned-multiple", "preserve", "preserve-aligned"]
|
|
24667
|
+
);
|
|
24668
|
+
this.wrap_attributes_indent_size = this._get_number("wrap_attributes_indent_size", this.indent_size);
|
|
24669
|
+
this.extra_liners = this._get_array("extra_liners", ["head", "body", "/html"]);
|
|
24670
|
+
this.inline = this._get_array("inline", [
|
|
24671
|
+
"a",
|
|
24672
|
+
"abbr",
|
|
24673
|
+
"area",
|
|
24674
|
+
"audio",
|
|
24675
|
+
"b",
|
|
24676
|
+
"bdi",
|
|
24677
|
+
"bdo",
|
|
24678
|
+
"br",
|
|
24679
|
+
"button",
|
|
24680
|
+
"canvas",
|
|
24681
|
+
"cite",
|
|
24682
|
+
"code",
|
|
24683
|
+
"data",
|
|
24684
|
+
"datalist",
|
|
24685
|
+
"del",
|
|
24686
|
+
"dfn",
|
|
24687
|
+
"em",
|
|
24688
|
+
"embed",
|
|
24689
|
+
"i",
|
|
24690
|
+
"iframe",
|
|
24691
|
+
"img",
|
|
24692
|
+
"input",
|
|
24693
|
+
"ins",
|
|
24694
|
+
"kbd",
|
|
24695
|
+
"keygen",
|
|
24696
|
+
"label",
|
|
24697
|
+
"map",
|
|
24698
|
+
"mark",
|
|
24699
|
+
"math",
|
|
24700
|
+
"meter",
|
|
24701
|
+
"noscript",
|
|
24702
|
+
"object",
|
|
24703
|
+
"output",
|
|
24704
|
+
"progress",
|
|
24705
|
+
"q",
|
|
24706
|
+
"ruby",
|
|
24707
|
+
"s",
|
|
24708
|
+
"samp",
|
|
24709
|
+
/* 'script', */
|
|
24710
|
+
"select",
|
|
24711
|
+
"small",
|
|
24712
|
+
"span",
|
|
24713
|
+
"strong",
|
|
24714
|
+
"sub",
|
|
24715
|
+
"sup",
|
|
24716
|
+
"svg",
|
|
24717
|
+
"template",
|
|
24718
|
+
"textarea",
|
|
24719
|
+
"time",
|
|
24720
|
+
"u",
|
|
24721
|
+
"var",
|
|
24722
|
+
"video",
|
|
24723
|
+
"wbr",
|
|
24724
|
+
"text",
|
|
24725
|
+
// obsolete inline tags
|
|
24726
|
+
"acronym",
|
|
24727
|
+
"big",
|
|
24728
|
+
"strike",
|
|
24729
|
+
"tt"
|
|
24730
|
+
]);
|
|
24731
|
+
this.void_elements = this._get_array("void_elements", [
|
|
24732
|
+
// HTLM void elements - aka self-closing tags - aka singletons
|
|
24733
|
+
// https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
|
|
24734
|
+
"area",
|
|
24735
|
+
"base",
|
|
24736
|
+
"br",
|
|
24737
|
+
"col",
|
|
24738
|
+
"embed",
|
|
24739
|
+
"hr",
|
|
24740
|
+
"img",
|
|
24741
|
+
"input",
|
|
24742
|
+
"keygen",
|
|
24743
|
+
"link",
|
|
24744
|
+
"menuitem",
|
|
24745
|
+
"meta",
|
|
24746
|
+
"param",
|
|
24747
|
+
"source",
|
|
24748
|
+
"track",
|
|
24749
|
+
"wbr",
|
|
24750
|
+
// NOTE: Optional tags are too complex for a simple list
|
|
24751
|
+
// they are hard coded in _do_optional_end_element
|
|
24752
|
+
// Doctype and xml elements
|
|
24753
|
+
"!doctype",
|
|
24754
|
+
"?xml",
|
|
24755
|
+
// obsolete tags
|
|
24756
|
+
// basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
|
|
24757
|
+
// isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
|
|
24758
|
+
"basefont",
|
|
24759
|
+
"isindex"
|
|
24760
|
+
]);
|
|
24761
|
+
this.unformatted = this._get_array("unformatted", []);
|
|
24762
|
+
this.content_unformatted = this._get_array("content_unformatted", [
|
|
24763
|
+
"pre",
|
|
24764
|
+
"textarea"
|
|
24765
|
+
]);
|
|
24766
|
+
this.unformatted_content_delimiter = this._get_characters("unformatted_content_delimiter");
|
|
24767
|
+
this.indent_scripts = this._get_selection("indent_scripts", ["normal", "keep", "separate"]);
|
|
24768
|
+
}
|
|
24769
|
+
Options.prototype = new BaseOptions();
|
|
24770
|
+
module2.exports.Options = Options;
|
|
24771
|
+
}
|
|
24772
|
+
});
|
|
24773
|
+
|
|
24774
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/html/tokenizer.js
|
|
24775
|
+
var require_tokenizer3 = __commonJS({
|
|
24776
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/html/tokenizer.js"(exports, module2) {
|
|
24777
|
+
"use strict";
|
|
24778
|
+
var BaseTokenizer = require_tokenizer().Tokenizer;
|
|
24779
|
+
var BASETOKEN = require_tokenizer().TOKEN;
|
|
24780
|
+
var Directives = require_directives().Directives;
|
|
24781
|
+
var TemplatablePattern = require_templatablepattern().TemplatablePattern;
|
|
24782
|
+
var Pattern = require_pattern2().Pattern;
|
|
24783
|
+
var TOKEN = {
|
|
24784
|
+
TAG_OPEN: "TK_TAG_OPEN",
|
|
24785
|
+
TAG_CLOSE: "TK_TAG_CLOSE",
|
|
24786
|
+
ATTRIBUTE: "TK_ATTRIBUTE",
|
|
24787
|
+
EQUALS: "TK_EQUALS",
|
|
24788
|
+
VALUE: "TK_VALUE",
|
|
24789
|
+
COMMENT: "TK_COMMENT",
|
|
24790
|
+
TEXT: "TK_TEXT",
|
|
24791
|
+
UNKNOWN: "TK_UNKNOWN",
|
|
24792
|
+
START: BASETOKEN.START,
|
|
24793
|
+
RAW: BASETOKEN.RAW,
|
|
24794
|
+
EOF: BASETOKEN.EOF
|
|
24795
|
+
};
|
|
24796
|
+
var directives_core = new Directives(/<\!--/, /-->/);
|
|
24797
|
+
var Tokenizer = function(input_string, options) {
|
|
24798
|
+
BaseTokenizer.call(this, input_string, options);
|
|
24799
|
+
this._current_tag_name = "";
|
|
24800
|
+
var templatable_reader = new TemplatablePattern(this._input).read_options(this._options);
|
|
24801
|
+
var pattern_reader = new Pattern(this._input);
|
|
24802
|
+
this.__patterns = {
|
|
24803
|
+
word: templatable_reader.until(/[\n\r\t <]/),
|
|
24804
|
+
single_quote: templatable_reader.until_after(/'/),
|
|
24805
|
+
double_quote: templatable_reader.until_after(/"/),
|
|
24806
|
+
attribute: templatable_reader.until(/[\n\r\t =>]|\/>/),
|
|
24807
|
+
element_name: templatable_reader.until(/[\n\r\t >\/]/),
|
|
24808
|
+
handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
|
|
24809
|
+
handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
|
|
24810
|
+
handlebars_open: pattern_reader.until(/[\n\r\t }]/),
|
|
24811
|
+
handlebars_raw_close: pattern_reader.until(/}}/),
|
|
24812
|
+
comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
|
|
24813
|
+
cdata: pattern_reader.starting_with(/<!\[CDATA\[/).until_after(/]]>/),
|
|
24814
|
+
// https://en.wikipedia.org/wiki/Conditional_comment
|
|
24815
|
+
conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
|
|
24816
|
+
processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
|
|
24817
|
+
};
|
|
24818
|
+
if (this._options.indent_handlebars) {
|
|
24819
|
+
this.__patterns.word = this.__patterns.word.exclude("handlebars");
|
|
24820
|
+
}
|
|
24821
|
+
this._unformatted_content_delimiter = null;
|
|
24822
|
+
if (this._options.unformatted_content_delimiter) {
|
|
24823
|
+
var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
|
|
24824
|
+
this.__patterns.unformatted_content_delimiter = pattern_reader.matching(literal_regexp).until_after(literal_regexp);
|
|
24825
|
+
}
|
|
24826
|
+
};
|
|
24827
|
+
Tokenizer.prototype = new BaseTokenizer();
|
|
24828
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
24829
|
+
return false;
|
|
24830
|
+
};
|
|
24831
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
24832
|
+
return current_token.type === TOKEN.TAG_OPEN;
|
|
24833
|
+
};
|
|
24834
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
24835
|
+
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] === "{"));
|
|
24836
|
+
};
|
|
24837
|
+
Tokenizer.prototype._reset = function() {
|
|
24838
|
+
this._current_tag_name = "";
|
|
24839
|
+
};
|
|
24840
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
24841
|
+
var token = null;
|
|
24842
|
+
this._readWhitespace();
|
|
24843
|
+
var c = this._input.peek();
|
|
24844
|
+
if (c === null) {
|
|
24845
|
+
return this._create_token(TOKEN.EOF, "");
|
|
24846
|
+
}
|
|
24847
|
+
token = token || this._read_open_handlebars(c, open_token);
|
|
24848
|
+
token = token || this._read_attribute(c, previous_token, open_token);
|
|
24849
|
+
token = token || this._read_close(c, open_token);
|
|
24850
|
+
token = token || this._read_raw_content(c, previous_token, open_token);
|
|
24851
|
+
token = token || this._read_content_word(c);
|
|
24852
|
+
token = token || this._read_comment_or_cdata(c);
|
|
24853
|
+
token = token || this._read_processing(c);
|
|
24854
|
+
token = token || this._read_open(c, open_token);
|
|
24855
|
+
token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
|
|
24856
|
+
return token;
|
|
24857
|
+
};
|
|
24858
|
+
Tokenizer.prototype._read_comment_or_cdata = function(c) {
|
|
24859
|
+
var token = null;
|
|
24860
|
+
var resulting_string = null;
|
|
24861
|
+
var directives = null;
|
|
24862
|
+
if (c === "<") {
|
|
24863
|
+
var peek1 = this._input.peek(1);
|
|
24864
|
+
if (peek1 === "!") {
|
|
24865
|
+
resulting_string = this.__patterns.comment.read();
|
|
24866
|
+
if (resulting_string) {
|
|
24867
|
+
directives = directives_core.get_directives(resulting_string);
|
|
24868
|
+
if (directives && directives.ignore === "start") {
|
|
24869
|
+
resulting_string += directives_core.readIgnored(this._input);
|
|
24870
|
+
}
|
|
24871
|
+
} else {
|
|
24872
|
+
resulting_string = this.__patterns.cdata.read();
|
|
24873
|
+
}
|
|
24874
|
+
}
|
|
24875
|
+
if (resulting_string) {
|
|
24876
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
24877
|
+
token.directives = directives;
|
|
24878
|
+
}
|
|
24879
|
+
}
|
|
24880
|
+
return token;
|
|
24881
|
+
};
|
|
24882
|
+
Tokenizer.prototype._read_processing = function(c) {
|
|
24883
|
+
var token = null;
|
|
24884
|
+
var resulting_string = null;
|
|
24885
|
+
var directives = null;
|
|
24886
|
+
if (c === "<") {
|
|
24887
|
+
var peek1 = this._input.peek(1);
|
|
24888
|
+
if (peek1 === "!" || peek1 === "?") {
|
|
24889
|
+
resulting_string = this.__patterns.conditional_comment.read();
|
|
24890
|
+
resulting_string = resulting_string || this.__patterns.processing.read();
|
|
24891
|
+
}
|
|
24892
|
+
if (resulting_string) {
|
|
24893
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
24894
|
+
token.directives = directives;
|
|
24895
|
+
}
|
|
24896
|
+
}
|
|
24897
|
+
return token;
|
|
24898
|
+
};
|
|
24899
|
+
Tokenizer.prototype._read_open = function(c, open_token) {
|
|
24900
|
+
var resulting_string = null;
|
|
24901
|
+
var token = null;
|
|
24902
|
+
if (!open_token) {
|
|
24903
|
+
if (c === "<") {
|
|
24904
|
+
resulting_string = this._input.next();
|
|
24905
|
+
if (this._input.peek() === "/") {
|
|
24906
|
+
resulting_string += this._input.next();
|
|
24907
|
+
}
|
|
24908
|
+
resulting_string += this.__patterns.element_name.read();
|
|
24909
|
+
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
|
|
24910
|
+
}
|
|
24911
|
+
}
|
|
24912
|
+
return token;
|
|
24913
|
+
};
|
|
24914
|
+
Tokenizer.prototype._read_open_handlebars = function(c, open_token) {
|
|
24915
|
+
var resulting_string = null;
|
|
24916
|
+
var token = null;
|
|
24917
|
+
if (!open_token) {
|
|
24918
|
+
if (this._options.indent_handlebars && c === "{" && this._input.peek(1) === "{") {
|
|
24919
|
+
if (this._input.peek(2) === "!") {
|
|
24920
|
+
resulting_string = this.__patterns.handlebars_comment.read();
|
|
24921
|
+
resulting_string = resulting_string || this.__patterns.handlebars.read();
|
|
24922
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
24923
|
+
} else {
|
|
24924
|
+
resulting_string = this.__patterns.handlebars_open.read();
|
|
24925
|
+
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
|
|
24926
|
+
}
|
|
24927
|
+
}
|
|
24928
|
+
}
|
|
24929
|
+
return token;
|
|
24930
|
+
};
|
|
24931
|
+
Tokenizer.prototype._read_close = function(c, open_token) {
|
|
24932
|
+
var resulting_string = null;
|
|
24933
|
+
var token = null;
|
|
24934
|
+
if (open_token) {
|
|
24935
|
+
if (open_token.text[0] === "<" && (c === ">" || c === "/" && this._input.peek(1) === ">")) {
|
|
24936
|
+
resulting_string = this._input.next();
|
|
24937
|
+
if (c === "/") {
|
|
24938
|
+
resulting_string += this._input.next();
|
|
24939
|
+
}
|
|
24940
|
+
token = this._create_token(TOKEN.TAG_CLOSE, resulting_string);
|
|
24941
|
+
} else if (open_token.text[0] === "{" && c === "}" && this._input.peek(1) === "}") {
|
|
24942
|
+
this._input.next();
|
|
24943
|
+
this._input.next();
|
|
24944
|
+
token = this._create_token(TOKEN.TAG_CLOSE, "}}");
|
|
24945
|
+
}
|
|
24946
|
+
}
|
|
24947
|
+
return token;
|
|
24948
|
+
};
|
|
24949
|
+
Tokenizer.prototype._read_attribute = function(c, previous_token, open_token) {
|
|
24950
|
+
var token = null;
|
|
24951
|
+
var resulting_string = "";
|
|
24952
|
+
if (open_token && open_token.text[0] === "<") {
|
|
24953
|
+
if (c === "=") {
|
|
24954
|
+
token = this._create_token(TOKEN.EQUALS, this._input.next());
|
|
24955
|
+
} else if (c === '"' || c === "'") {
|
|
24956
|
+
var content = this._input.next();
|
|
24957
|
+
if (c === '"') {
|
|
24958
|
+
content += this.__patterns.double_quote.read();
|
|
24959
|
+
} else {
|
|
24960
|
+
content += this.__patterns.single_quote.read();
|
|
24961
|
+
}
|
|
24962
|
+
token = this._create_token(TOKEN.VALUE, content);
|
|
24963
|
+
} else {
|
|
24964
|
+
resulting_string = this.__patterns.attribute.read();
|
|
24965
|
+
if (resulting_string) {
|
|
24966
|
+
if (previous_token.type === TOKEN.EQUALS) {
|
|
24967
|
+
token = this._create_token(TOKEN.VALUE, resulting_string);
|
|
24968
|
+
} else {
|
|
24969
|
+
token = this._create_token(TOKEN.ATTRIBUTE, resulting_string);
|
|
24970
|
+
}
|
|
24971
|
+
}
|
|
24972
|
+
}
|
|
24973
|
+
}
|
|
24974
|
+
return token;
|
|
24975
|
+
};
|
|
24976
|
+
Tokenizer.prototype._is_content_unformatted = function(tag_name) {
|
|
24977
|
+
return this._options.void_elements.indexOf(tag_name) === -1 && (this._options.content_unformatted.indexOf(tag_name) !== -1 || this._options.unformatted.indexOf(tag_name) !== -1);
|
|
24978
|
+
};
|
|
24979
|
+
Tokenizer.prototype._read_raw_content = function(c, previous_token, open_token) {
|
|
24980
|
+
var resulting_string = "";
|
|
24981
|
+
if (open_token && open_token.text[0] === "{") {
|
|
24982
|
+
resulting_string = this.__patterns.handlebars_raw_close.read();
|
|
24983
|
+
} else if (previous_token.type === TOKEN.TAG_CLOSE && previous_token.opened.text[0] === "<" && previous_token.text[0] !== "/") {
|
|
24984
|
+
var tag_name = previous_token.opened.text.substr(1).toLowerCase();
|
|
24985
|
+
if (tag_name === "script" || tag_name === "style") {
|
|
24986
|
+
var token = this._read_comment_or_cdata(c);
|
|
24987
|
+
if (token) {
|
|
24988
|
+
token.type = TOKEN.TEXT;
|
|
24989
|
+
return token;
|
|
24990
|
+
}
|
|
24991
|
+
resulting_string = this._input.readUntil(new RegExp("</" + tag_name + "[\\n\\r\\t ]*?>", "ig"));
|
|
24992
|
+
} else if (this._is_content_unformatted(tag_name)) {
|
|
24993
|
+
resulting_string = this._input.readUntil(new RegExp("</" + tag_name + "[\\n\\r\\t ]*?>", "ig"));
|
|
24994
|
+
}
|
|
24995
|
+
}
|
|
24996
|
+
if (resulting_string) {
|
|
24997
|
+
return this._create_token(TOKEN.TEXT, resulting_string);
|
|
24998
|
+
}
|
|
24999
|
+
return null;
|
|
25000
|
+
};
|
|
25001
|
+
Tokenizer.prototype._read_content_word = function(c) {
|
|
25002
|
+
var resulting_string = "";
|
|
25003
|
+
if (this._options.unformatted_content_delimiter) {
|
|
25004
|
+
if (c === this._options.unformatted_content_delimiter[0]) {
|
|
25005
|
+
resulting_string = this.__patterns.unformatted_content_delimiter.read();
|
|
25006
|
+
}
|
|
25007
|
+
}
|
|
25008
|
+
if (!resulting_string) {
|
|
25009
|
+
resulting_string = this.__patterns.word.read();
|
|
25010
|
+
}
|
|
25011
|
+
if (resulting_string) {
|
|
25012
|
+
return this._create_token(TOKEN.TEXT, resulting_string);
|
|
25013
|
+
}
|
|
25014
|
+
};
|
|
25015
|
+
module2.exports.Tokenizer = Tokenizer;
|
|
25016
|
+
module2.exports.TOKEN = TOKEN;
|
|
25017
|
+
}
|
|
25018
|
+
});
|
|
25019
|
+
|
|
25020
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/html/beautifier.js
|
|
25021
|
+
var require_beautifier3 = __commonJS({
|
|
25022
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/html/beautifier.js"(exports, module2) {
|
|
25023
|
+
"use strict";
|
|
25024
|
+
var Options = require_options4().Options;
|
|
25025
|
+
var Output = require_output().Output;
|
|
25026
|
+
var Tokenizer = require_tokenizer3().Tokenizer;
|
|
25027
|
+
var TOKEN = require_tokenizer3().TOKEN;
|
|
25028
|
+
var lineBreak = /\r\n|[\r\n]/;
|
|
25029
|
+
var allLineBreaks = /\r\n|[\r\n]/g;
|
|
25030
|
+
var Printer3 = function(options, base_indent_string) {
|
|
25031
|
+
this.indent_level = 0;
|
|
25032
|
+
this.alignment_size = 0;
|
|
25033
|
+
this.max_preserve_newlines = options.max_preserve_newlines;
|
|
25034
|
+
this.preserve_newlines = options.preserve_newlines;
|
|
25035
|
+
this._output = new Output(options, base_indent_string);
|
|
25036
|
+
};
|
|
25037
|
+
Printer3.prototype.current_line_has_match = function(pattern) {
|
|
25038
|
+
return this._output.current_line.has_match(pattern);
|
|
25039
|
+
};
|
|
25040
|
+
Printer3.prototype.set_space_before_token = function(value, non_breaking) {
|
|
25041
|
+
this._output.space_before_token = value;
|
|
25042
|
+
this._output.non_breaking_space = non_breaking;
|
|
25043
|
+
};
|
|
25044
|
+
Printer3.prototype.set_wrap_point = function() {
|
|
25045
|
+
this._output.set_indent(this.indent_level, this.alignment_size);
|
|
25046
|
+
this._output.set_wrap_point();
|
|
25047
|
+
};
|
|
25048
|
+
Printer3.prototype.add_raw_token = function(token) {
|
|
25049
|
+
this._output.add_raw_token(token);
|
|
25050
|
+
};
|
|
25051
|
+
Printer3.prototype.print_preserved_newlines = function(raw_token) {
|
|
25052
|
+
var newlines = 0;
|
|
25053
|
+
if (raw_token.type !== TOKEN.TEXT && raw_token.previous.type !== TOKEN.TEXT) {
|
|
25054
|
+
newlines = raw_token.newlines ? 1 : 0;
|
|
25055
|
+
}
|
|
25056
|
+
if (this.preserve_newlines) {
|
|
25057
|
+
newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
|
|
25058
|
+
}
|
|
25059
|
+
for (var n2 = 0; n2 < newlines; n2++) {
|
|
25060
|
+
this.print_newline(n2 > 0);
|
|
25061
|
+
}
|
|
25062
|
+
return newlines !== 0;
|
|
25063
|
+
};
|
|
25064
|
+
Printer3.prototype.traverse_whitespace = function(raw_token) {
|
|
25065
|
+
if (raw_token.whitespace_before || raw_token.newlines) {
|
|
25066
|
+
if (!this.print_preserved_newlines(raw_token)) {
|
|
25067
|
+
this._output.space_before_token = true;
|
|
25068
|
+
}
|
|
25069
|
+
return true;
|
|
25070
|
+
}
|
|
25071
|
+
return false;
|
|
25072
|
+
};
|
|
25073
|
+
Printer3.prototype.previous_token_wrapped = function() {
|
|
25074
|
+
return this._output.previous_token_wrapped;
|
|
25075
|
+
};
|
|
25076
|
+
Printer3.prototype.print_newline = function(force) {
|
|
25077
|
+
this._output.add_new_line(force);
|
|
25078
|
+
};
|
|
25079
|
+
Printer3.prototype.print_token = function(token) {
|
|
25080
|
+
if (token.text) {
|
|
25081
|
+
this._output.set_indent(this.indent_level, this.alignment_size);
|
|
25082
|
+
this._output.add_token(token.text);
|
|
25083
|
+
}
|
|
25084
|
+
};
|
|
25085
|
+
Printer3.prototype.indent = function() {
|
|
25086
|
+
this.indent_level++;
|
|
25087
|
+
};
|
|
25088
|
+
Printer3.prototype.get_full_indent = function(level) {
|
|
25089
|
+
level = this.indent_level + (level || 0);
|
|
25090
|
+
if (level < 1) {
|
|
25091
|
+
return "";
|
|
25092
|
+
}
|
|
25093
|
+
return this._output.get_indent_string(level);
|
|
25094
|
+
};
|
|
25095
|
+
var get_type_attribute = function(start_token) {
|
|
25096
|
+
var result = null;
|
|
25097
|
+
var raw_token = start_token.next;
|
|
25098
|
+
while (raw_token.type !== TOKEN.EOF && start_token.closed !== raw_token) {
|
|
25099
|
+
if (raw_token.type === TOKEN.ATTRIBUTE && raw_token.text === "type") {
|
|
25100
|
+
if (raw_token.next && raw_token.next.type === TOKEN.EQUALS && raw_token.next.next && raw_token.next.next.type === TOKEN.VALUE) {
|
|
25101
|
+
result = raw_token.next.next.text;
|
|
25102
|
+
}
|
|
25103
|
+
break;
|
|
25104
|
+
}
|
|
25105
|
+
raw_token = raw_token.next;
|
|
25106
|
+
}
|
|
25107
|
+
return result;
|
|
25108
|
+
};
|
|
25109
|
+
var get_custom_beautifier_name = function(tag_check, raw_token) {
|
|
25110
|
+
var typeAttribute = null;
|
|
25111
|
+
var result = null;
|
|
25112
|
+
if (!raw_token.closed) {
|
|
25113
|
+
return null;
|
|
25114
|
+
}
|
|
25115
|
+
if (tag_check === "script") {
|
|
25116
|
+
typeAttribute = "text/javascript";
|
|
25117
|
+
} else if (tag_check === "style") {
|
|
25118
|
+
typeAttribute = "text/css";
|
|
25119
|
+
}
|
|
25120
|
+
typeAttribute = get_type_attribute(raw_token) || typeAttribute;
|
|
25121
|
+
if (typeAttribute.search("text/css") > -1) {
|
|
25122
|
+
result = "css";
|
|
25123
|
+
} else if (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
|
|
25124
|
+
result = "javascript";
|
|
25125
|
+
} else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
|
|
25126
|
+
result = "html";
|
|
25127
|
+
} else if (typeAttribute.search(/test\/null/) > -1) {
|
|
25128
|
+
result = "null";
|
|
25129
|
+
}
|
|
25130
|
+
return result;
|
|
25131
|
+
};
|
|
25132
|
+
function in_array(what, arr) {
|
|
25133
|
+
return arr.indexOf(what) !== -1;
|
|
25134
|
+
}
|
|
25135
|
+
function TagFrame(parent, parser_token, indent_level) {
|
|
25136
|
+
this.parent = parent || null;
|
|
25137
|
+
this.tag = parser_token ? parser_token.tag_name : "";
|
|
25138
|
+
this.indent_level = indent_level || 0;
|
|
25139
|
+
this.parser_token = parser_token || null;
|
|
25140
|
+
}
|
|
25141
|
+
function TagStack(printer) {
|
|
25142
|
+
this._printer = printer;
|
|
25143
|
+
this._current_frame = null;
|
|
25144
|
+
}
|
|
25145
|
+
TagStack.prototype.get_parser_token = function() {
|
|
25146
|
+
return this._current_frame ? this._current_frame.parser_token : null;
|
|
25147
|
+
};
|
|
25148
|
+
TagStack.prototype.record_tag = function(parser_token) {
|
|
25149
|
+
var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
|
|
25150
|
+
this._current_frame = new_frame;
|
|
25151
|
+
};
|
|
25152
|
+
TagStack.prototype._try_pop_frame = function(frame) {
|
|
25153
|
+
var parser_token = null;
|
|
25154
|
+
if (frame) {
|
|
25155
|
+
parser_token = frame.parser_token;
|
|
25156
|
+
this._printer.indent_level = frame.indent_level;
|
|
25157
|
+
this._current_frame = frame.parent;
|
|
25158
|
+
}
|
|
25159
|
+
return parser_token;
|
|
25160
|
+
};
|
|
25161
|
+
TagStack.prototype._get_frame = function(tag_list, stop_list) {
|
|
25162
|
+
var frame = this._current_frame;
|
|
25163
|
+
while (frame) {
|
|
25164
|
+
if (tag_list.indexOf(frame.tag) !== -1) {
|
|
25165
|
+
break;
|
|
25166
|
+
} else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
|
|
25167
|
+
frame = null;
|
|
25168
|
+
break;
|
|
25169
|
+
}
|
|
25170
|
+
frame = frame.parent;
|
|
25171
|
+
}
|
|
25172
|
+
return frame;
|
|
25173
|
+
};
|
|
25174
|
+
TagStack.prototype.try_pop = function(tag, stop_list) {
|
|
25175
|
+
var frame = this._get_frame([tag], stop_list);
|
|
25176
|
+
return this._try_pop_frame(frame);
|
|
25177
|
+
};
|
|
25178
|
+
TagStack.prototype.indent_to_tag = function(tag_list) {
|
|
25179
|
+
var frame = this._get_frame(tag_list);
|
|
25180
|
+
if (frame) {
|
|
25181
|
+
this._printer.indent_level = frame.indent_level;
|
|
25182
|
+
}
|
|
25183
|
+
};
|
|
25184
|
+
function Beautifier(source_text, options, js_beautify2, css_beautify) {
|
|
25185
|
+
this._source_text = source_text || "";
|
|
25186
|
+
options = options || {};
|
|
25187
|
+
this._js_beautify = js_beautify2;
|
|
25188
|
+
this._css_beautify = css_beautify;
|
|
25189
|
+
this._tag_stack = null;
|
|
25190
|
+
var optionHtml = new Options(options, "html");
|
|
25191
|
+
this._options = optionHtml;
|
|
25192
|
+
this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, "force".length) === "force";
|
|
25193
|
+
this._is_wrap_attributes_force_expand_multiline = this._options.wrap_attributes === "force-expand-multiline";
|
|
25194
|
+
this._is_wrap_attributes_force_aligned = this._options.wrap_attributes === "force-aligned";
|
|
25195
|
+
this._is_wrap_attributes_aligned_multiple = this._options.wrap_attributes === "aligned-multiple";
|
|
25196
|
+
this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, "preserve".length) === "preserve";
|
|
25197
|
+
this._is_wrap_attributes_preserve_aligned = this._options.wrap_attributes === "preserve-aligned";
|
|
25198
|
+
}
|
|
25199
|
+
Beautifier.prototype.beautify = function() {
|
|
25200
|
+
if (this._options.disabled) {
|
|
25201
|
+
return this._source_text;
|
|
25202
|
+
}
|
|
25203
|
+
var source_text = this._source_text;
|
|
25204
|
+
var eol = this._options.eol;
|
|
25205
|
+
if (this._options.eol === "auto") {
|
|
25206
|
+
eol = "\n";
|
|
25207
|
+
if (source_text && lineBreak.test(source_text)) {
|
|
25208
|
+
eol = source_text.match(lineBreak)[0];
|
|
25209
|
+
}
|
|
25210
|
+
}
|
|
25211
|
+
source_text = source_text.replace(allLineBreaks, "\n");
|
|
25212
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
25213
|
+
var last_token = {
|
|
25214
|
+
text: "",
|
|
25215
|
+
type: ""
|
|
25216
|
+
};
|
|
25217
|
+
var last_tag_token = new TagOpenParserToken();
|
|
25218
|
+
var printer = new Printer3(this._options, baseIndentString);
|
|
25219
|
+
var tokens = new Tokenizer(source_text, this._options).tokenize();
|
|
25220
|
+
this._tag_stack = new TagStack(printer);
|
|
25221
|
+
var parser_token = null;
|
|
25222
|
+
var raw_token = tokens.next();
|
|
25223
|
+
while (raw_token.type !== TOKEN.EOF) {
|
|
25224
|
+
if (raw_token.type === TOKEN.TAG_OPEN || raw_token.type === TOKEN.COMMENT) {
|
|
25225
|
+
parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token);
|
|
25226
|
+
last_tag_token = parser_token;
|
|
25227
|
+
} 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) {
|
|
25228
|
+
parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens);
|
|
25229
|
+
} else if (raw_token.type === TOKEN.TAG_CLOSE) {
|
|
25230
|
+
parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
|
|
25231
|
+
} else if (raw_token.type === TOKEN.TEXT) {
|
|
25232
|
+
parser_token = this._handle_text(printer, raw_token, last_tag_token);
|
|
25233
|
+
} else {
|
|
25234
|
+
printer.add_raw_token(raw_token);
|
|
25235
|
+
}
|
|
25236
|
+
last_token = parser_token;
|
|
25237
|
+
raw_token = tokens.next();
|
|
25238
|
+
}
|
|
25239
|
+
var sweet_code = printer._output.get_code(eol);
|
|
25240
|
+
return sweet_code;
|
|
25241
|
+
};
|
|
25242
|
+
Beautifier.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
|
|
25243
|
+
var parser_token = {
|
|
25244
|
+
text: raw_token.text,
|
|
25245
|
+
type: raw_token.type
|
|
25246
|
+
};
|
|
25247
|
+
printer.alignment_size = 0;
|
|
25248
|
+
last_tag_token.tag_complete = true;
|
|
25249
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
25250
|
+
if (last_tag_token.is_unformatted) {
|
|
25251
|
+
printer.add_raw_token(raw_token);
|
|
25252
|
+
} else {
|
|
25253
|
+
if (last_tag_token.tag_start_char === "<") {
|
|
25254
|
+
printer.set_space_before_token(raw_token.text[0] === "/", true);
|
|
25255
|
+
if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
|
|
25256
|
+
printer.print_newline(false);
|
|
25257
|
+
}
|
|
25258
|
+
}
|
|
25259
|
+
printer.print_token(raw_token);
|
|
25260
|
+
}
|
|
25261
|
+
if (last_tag_token.indent_content && !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
|
|
25262
|
+
printer.indent();
|
|
25263
|
+
last_tag_token.indent_content = false;
|
|
25264
|
+
}
|
|
25265
|
+
if (!last_tag_token.is_inline_element && !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
|
|
25266
|
+
printer.set_wrap_point();
|
|
25267
|
+
}
|
|
25268
|
+
return parser_token;
|
|
25269
|
+
};
|
|
25270
|
+
Beautifier.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) {
|
|
25271
|
+
var wrapped = last_tag_token.has_wrapped_attrs;
|
|
25272
|
+
var parser_token = {
|
|
25273
|
+
text: raw_token.text,
|
|
25274
|
+
type: raw_token.type
|
|
25275
|
+
};
|
|
25276
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
25277
|
+
if (last_tag_token.is_unformatted) {
|
|
25278
|
+
printer.add_raw_token(raw_token);
|
|
25279
|
+
} else if (last_tag_token.tag_start_char === "{" && raw_token.type === TOKEN.TEXT) {
|
|
25280
|
+
if (printer.print_preserved_newlines(raw_token)) {
|
|
25281
|
+
raw_token.newlines = 0;
|
|
25282
|
+
printer.add_raw_token(raw_token);
|
|
25283
|
+
} else {
|
|
25284
|
+
printer.print_token(raw_token);
|
|
25285
|
+
}
|
|
25286
|
+
} else {
|
|
25287
|
+
if (raw_token.type === TOKEN.ATTRIBUTE) {
|
|
25288
|
+
printer.set_space_before_token(true);
|
|
25289
|
+
last_tag_token.attr_count += 1;
|
|
25290
|
+
} else if (raw_token.type === TOKEN.EQUALS) {
|
|
25291
|
+
printer.set_space_before_token(false);
|
|
25292
|
+
} else if (raw_token.type === TOKEN.VALUE && raw_token.previous.type === TOKEN.EQUALS) {
|
|
25293
|
+
printer.set_space_before_token(false);
|
|
25294
|
+
}
|
|
25295
|
+
if (raw_token.type === TOKEN.ATTRIBUTE && last_tag_token.tag_start_char === "<") {
|
|
25296
|
+
if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
|
|
25297
|
+
printer.traverse_whitespace(raw_token);
|
|
25298
|
+
wrapped = wrapped || raw_token.newlines !== 0;
|
|
25299
|
+
}
|
|
25300
|
+
if (this._is_wrap_attributes_force) {
|
|
25301
|
+
var force_attr_wrap = last_tag_token.attr_count > 1;
|
|
25302
|
+
if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) {
|
|
25303
|
+
var is_only_attribute = true;
|
|
25304
|
+
var peek_index = 0;
|
|
25305
|
+
var peek_token;
|
|
25306
|
+
do {
|
|
25307
|
+
peek_token = tokens.peek(peek_index);
|
|
25308
|
+
if (peek_token.type === TOKEN.ATTRIBUTE) {
|
|
25309
|
+
is_only_attribute = false;
|
|
25310
|
+
break;
|
|
25311
|
+
}
|
|
25312
|
+
peek_index += 1;
|
|
25313
|
+
} while (peek_index < 4 && peek_token.type !== TOKEN.EOF && peek_token.type !== TOKEN.TAG_CLOSE);
|
|
25314
|
+
force_attr_wrap = !is_only_attribute;
|
|
25315
|
+
}
|
|
25316
|
+
if (force_attr_wrap) {
|
|
25317
|
+
printer.print_newline(false);
|
|
25318
|
+
wrapped = true;
|
|
25319
|
+
}
|
|
25320
|
+
}
|
|
25321
|
+
}
|
|
25322
|
+
printer.print_token(raw_token);
|
|
25323
|
+
wrapped = wrapped || printer.previous_token_wrapped();
|
|
25324
|
+
last_tag_token.has_wrapped_attrs = wrapped;
|
|
25325
|
+
}
|
|
25326
|
+
return parser_token;
|
|
25327
|
+
};
|
|
25328
|
+
Beautifier.prototype._handle_text = function(printer, raw_token, last_tag_token) {
|
|
25329
|
+
var parser_token = {
|
|
25330
|
+
text: raw_token.text,
|
|
25331
|
+
type: "TK_CONTENT"
|
|
25332
|
+
};
|
|
25333
|
+
if (last_tag_token.custom_beautifier_name) {
|
|
25334
|
+
this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
|
|
25335
|
+
} else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
|
|
25336
|
+
printer.add_raw_token(raw_token);
|
|
25337
|
+
} else {
|
|
25338
|
+
printer.traverse_whitespace(raw_token);
|
|
25339
|
+
printer.print_token(raw_token);
|
|
25340
|
+
}
|
|
25341
|
+
return parser_token;
|
|
25342
|
+
};
|
|
25343
|
+
Beautifier.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
|
|
25344
|
+
var local = this;
|
|
25345
|
+
if (raw_token.text !== "") {
|
|
25346
|
+
var text = raw_token.text, _beautifier, script_indent_level = 1, pre = "", post = "";
|
|
25347
|
+
if (last_tag_token.custom_beautifier_name === "javascript" && typeof this._js_beautify === "function") {
|
|
25348
|
+
_beautifier = this._js_beautify;
|
|
25349
|
+
} else if (last_tag_token.custom_beautifier_name === "css" && typeof this._css_beautify === "function") {
|
|
25350
|
+
_beautifier = this._css_beautify;
|
|
25351
|
+
} else if (last_tag_token.custom_beautifier_name === "html") {
|
|
25352
|
+
_beautifier = function(html_source, options) {
|
|
25353
|
+
var beautifier = new Beautifier(html_source, options, local._js_beautify, local._css_beautify);
|
|
25354
|
+
return beautifier.beautify();
|
|
25355
|
+
};
|
|
25356
|
+
}
|
|
25357
|
+
if (this._options.indent_scripts === "keep") {
|
|
25358
|
+
script_indent_level = 0;
|
|
25359
|
+
} else if (this._options.indent_scripts === "separate") {
|
|
25360
|
+
script_indent_level = -printer.indent_level;
|
|
25361
|
+
}
|
|
25362
|
+
var indentation = printer.get_full_indent(script_indent_level);
|
|
25363
|
+
text = text.replace(/\n[ \t]*$/, "");
|
|
25364
|
+
if (last_tag_token.custom_beautifier_name !== "html" && text[0] === "<" && text.match(/^(<!--|<!\[CDATA\[)/)) {
|
|
25365
|
+
var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
|
|
25366
|
+
if (!matched) {
|
|
25367
|
+
printer.add_raw_token(raw_token);
|
|
25368
|
+
return;
|
|
25369
|
+
}
|
|
25370
|
+
pre = indentation + matched[1] + "\n";
|
|
25371
|
+
text = matched[4];
|
|
25372
|
+
if (matched[5]) {
|
|
25373
|
+
post = indentation + matched[5];
|
|
25374
|
+
}
|
|
25375
|
+
text = text.replace(/\n[ \t]*$/, "");
|
|
25376
|
+
if (matched[2] || matched[3].indexOf("\n") !== -1) {
|
|
25377
|
+
matched = matched[3].match(/[ \t]+$/);
|
|
25378
|
+
if (matched) {
|
|
25379
|
+
raw_token.whitespace_before = matched[0];
|
|
25380
|
+
}
|
|
25381
|
+
}
|
|
25382
|
+
}
|
|
25383
|
+
if (text) {
|
|
25384
|
+
if (_beautifier) {
|
|
25385
|
+
var Child_options = function() {
|
|
25386
|
+
this.eol = "\n";
|
|
25387
|
+
};
|
|
25388
|
+
Child_options.prototype = this._options.raw_options;
|
|
25389
|
+
var child_options = new Child_options();
|
|
25390
|
+
text = _beautifier(indentation + text, child_options);
|
|
25391
|
+
} else {
|
|
25392
|
+
var white = raw_token.whitespace_before;
|
|
25393
|
+
if (white) {
|
|
25394
|
+
text = text.replace(new RegExp("\n(" + white + ")?", "g"), "\n");
|
|
25395
|
+
}
|
|
25396
|
+
text = indentation + text.replace(/\n/g, "\n" + indentation);
|
|
25397
|
+
}
|
|
25398
|
+
}
|
|
25399
|
+
if (pre) {
|
|
25400
|
+
if (!text) {
|
|
25401
|
+
text = pre + post;
|
|
25402
|
+
} else {
|
|
25403
|
+
text = pre + text + "\n" + post;
|
|
25404
|
+
}
|
|
25405
|
+
}
|
|
25406
|
+
printer.print_newline(false);
|
|
25407
|
+
if (text) {
|
|
25408
|
+
raw_token.text = text;
|
|
25409
|
+
raw_token.whitespace_before = "";
|
|
25410
|
+
raw_token.newlines = 0;
|
|
25411
|
+
printer.add_raw_token(raw_token);
|
|
25412
|
+
printer.print_newline(true);
|
|
25413
|
+
}
|
|
25414
|
+
}
|
|
25415
|
+
};
|
|
25416
|
+
Beautifier.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) {
|
|
25417
|
+
var parser_token = this._get_tag_open_token(raw_token);
|
|
25418
|
+
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) {
|
|
25419
|
+
printer.add_raw_token(raw_token);
|
|
25420
|
+
parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
|
|
25421
|
+
} else {
|
|
25422
|
+
printer.traverse_whitespace(raw_token);
|
|
25423
|
+
this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
|
|
25424
|
+
if (!parser_token.is_inline_element) {
|
|
25425
|
+
printer.set_wrap_point();
|
|
25426
|
+
}
|
|
25427
|
+
printer.print_token(raw_token);
|
|
25428
|
+
}
|
|
25429
|
+
if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
|
|
25430
|
+
parser_token.alignment_size = raw_token.text.length + 1;
|
|
25431
|
+
}
|
|
25432
|
+
if (!parser_token.tag_complete && !parser_token.is_unformatted) {
|
|
25433
|
+
printer.alignment_size = parser_token.alignment_size;
|
|
25434
|
+
}
|
|
25435
|
+
return parser_token;
|
|
25436
|
+
};
|
|
25437
|
+
var TagOpenParserToken = function(parent, raw_token) {
|
|
25438
|
+
this.parent = parent || null;
|
|
25439
|
+
this.text = "";
|
|
25440
|
+
this.type = "TK_TAG_OPEN";
|
|
25441
|
+
this.tag_name = "";
|
|
25442
|
+
this.is_inline_element = false;
|
|
25443
|
+
this.is_unformatted = false;
|
|
25444
|
+
this.is_content_unformatted = false;
|
|
25445
|
+
this.is_empty_element = false;
|
|
25446
|
+
this.is_start_tag = false;
|
|
25447
|
+
this.is_end_tag = false;
|
|
25448
|
+
this.indent_content = false;
|
|
25449
|
+
this.multiline_content = false;
|
|
25450
|
+
this.custom_beautifier_name = null;
|
|
25451
|
+
this.start_tag_token = null;
|
|
25452
|
+
this.attr_count = 0;
|
|
25453
|
+
this.has_wrapped_attrs = false;
|
|
25454
|
+
this.alignment_size = 0;
|
|
25455
|
+
this.tag_complete = false;
|
|
25456
|
+
this.tag_start_char = "";
|
|
25457
|
+
this.tag_check = "";
|
|
25458
|
+
if (!raw_token) {
|
|
25459
|
+
this.tag_complete = true;
|
|
25460
|
+
} else {
|
|
25461
|
+
var tag_check_match;
|
|
25462
|
+
this.tag_start_char = raw_token.text[0];
|
|
25463
|
+
this.text = raw_token.text;
|
|
25464
|
+
if (this.tag_start_char === "<") {
|
|
25465
|
+
tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
|
|
25466
|
+
this.tag_check = tag_check_match ? tag_check_match[1] : "";
|
|
25467
|
+
} else {
|
|
25468
|
+
tag_check_match = raw_token.text.match(/^{{(?:[\^]|#\*?)?([^\s}]+)/);
|
|
25469
|
+
this.tag_check = tag_check_match ? tag_check_match[1] : "";
|
|
25470
|
+
if (raw_token.text === "{{#>" && this.tag_check === ">" && raw_token.next !== null) {
|
|
25471
|
+
this.tag_check = raw_token.next.text.split(" ")[0];
|
|
25472
|
+
}
|
|
25473
|
+
}
|
|
25474
|
+
this.tag_check = this.tag_check.toLowerCase();
|
|
25475
|
+
if (raw_token.type === TOKEN.COMMENT) {
|
|
25476
|
+
this.tag_complete = true;
|
|
25477
|
+
}
|
|
25478
|
+
this.is_start_tag = this.tag_check.charAt(0) !== "/";
|
|
25479
|
+
this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
|
|
25480
|
+
this.is_end_tag = !this.is_start_tag || raw_token.closed && raw_token.closed.text === "/>";
|
|
25481
|
+
this.is_end_tag = this.is_end_tag || this.tag_start_char === "{" && (this.text.length < 3 || /[^#\^]/.test(this.text.charAt(2)));
|
|
25482
|
+
}
|
|
25483
|
+
};
|
|
25484
|
+
Beautifier.prototype._get_tag_open_token = function(raw_token) {
|
|
25485
|
+
var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
|
|
25486
|
+
parser_token.alignment_size = this._options.wrap_attributes_indent_size;
|
|
25487
|
+
parser_token.is_end_tag = parser_token.is_end_tag || in_array(parser_token.tag_check, this._options.void_elements);
|
|
25488
|
+
parser_token.is_empty_element = parser_token.tag_complete || parser_token.is_start_tag && parser_token.is_end_tag;
|
|
25489
|
+
parser_token.is_unformatted = !parser_token.tag_complete && in_array(parser_token.tag_check, this._options.unformatted);
|
|
25490
|
+
parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array(parser_token.tag_check, this._options.content_unformatted);
|
|
25491
|
+
parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || parser_token.tag_start_char === "{";
|
|
25492
|
+
return parser_token;
|
|
25493
|
+
};
|
|
25494
|
+
Beautifier.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
|
|
25495
|
+
if (!parser_token.is_empty_element) {
|
|
25496
|
+
if (parser_token.is_end_tag) {
|
|
25497
|
+
parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
|
|
25498
|
+
} else {
|
|
25499
|
+
if (this._do_optional_end_element(parser_token)) {
|
|
25500
|
+
if (!parser_token.is_inline_element) {
|
|
25501
|
+
printer.print_newline(false);
|
|
25502
|
+
}
|
|
25503
|
+
}
|
|
25504
|
+
this._tag_stack.record_tag(parser_token);
|
|
25505
|
+
if ((parser_token.tag_name === "script" || parser_token.tag_name === "style") && !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
|
|
25506
|
+
parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
|
|
25507
|
+
}
|
|
25508
|
+
}
|
|
25509
|
+
}
|
|
25510
|
+
if (in_array(parser_token.tag_check, this._options.extra_liners)) {
|
|
25511
|
+
printer.print_newline(false);
|
|
25512
|
+
if (!printer._output.just_added_blankline()) {
|
|
25513
|
+
printer.print_newline(true);
|
|
25514
|
+
}
|
|
25515
|
+
}
|
|
25516
|
+
if (parser_token.is_empty_element) {
|
|
25517
|
+
if (parser_token.tag_start_char === "{" && parser_token.tag_check === "else") {
|
|
25518
|
+
this._tag_stack.indent_to_tag(["if", "unless", "each"]);
|
|
25519
|
+
parser_token.indent_content = true;
|
|
25520
|
+
var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
|
|
25521
|
+
if (!foundIfOnCurrentLine) {
|
|
25522
|
+
printer.print_newline(false);
|
|
25523
|
+
}
|
|
25524
|
+
}
|
|
25525
|
+
if (parser_token.tag_name === "!--" && last_token.type === TOKEN.TAG_CLOSE && last_tag_token.is_end_tag && parser_token.text.indexOf("\n") === -1) {
|
|
25526
|
+
} else {
|
|
25527
|
+
if (!(parser_token.is_inline_element || parser_token.is_unformatted)) {
|
|
25528
|
+
printer.print_newline(false);
|
|
25529
|
+
}
|
|
25530
|
+
this._calcluate_parent_multiline(printer, parser_token);
|
|
25531
|
+
}
|
|
25532
|
+
} else if (parser_token.is_end_tag) {
|
|
25533
|
+
var do_end_expand = false;
|
|
25534
|
+
do_end_expand = parser_token.start_tag_token && parser_token.start_tag_token.multiline_content;
|
|
25535
|
+
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";
|
|
25536
|
+
if (parser_token.is_content_unformatted || parser_token.is_unformatted) {
|
|
25537
|
+
do_end_expand = false;
|
|
25538
|
+
}
|
|
25539
|
+
if (do_end_expand) {
|
|
25540
|
+
printer.print_newline(false);
|
|
25541
|
+
}
|
|
25542
|
+
} else {
|
|
25543
|
+
parser_token.indent_content = !parser_token.custom_beautifier_name;
|
|
25544
|
+
if (parser_token.tag_start_char === "<") {
|
|
25545
|
+
if (parser_token.tag_name === "html") {
|
|
25546
|
+
parser_token.indent_content = this._options.indent_inner_html;
|
|
25547
|
+
} else if (parser_token.tag_name === "head") {
|
|
25548
|
+
parser_token.indent_content = this._options.indent_head_inner_html;
|
|
25549
|
+
} else if (parser_token.tag_name === "body") {
|
|
25550
|
+
parser_token.indent_content = this._options.indent_body_inner_html;
|
|
25551
|
+
}
|
|
25552
|
+
}
|
|
25553
|
+
if (!(parser_token.is_inline_element || parser_token.is_unformatted) && (last_token.type !== "TK_CONTENT" || parser_token.is_content_unformatted)) {
|
|
25554
|
+
printer.print_newline(false);
|
|
25555
|
+
}
|
|
25556
|
+
this._calcluate_parent_multiline(printer, parser_token);
|
|
25557
|
+
}
|
|
25558
|
+
};
|
|
25559
|
+
Beautifier.prototype._calcluate_parent_multiline = function(printer, parser_token) {
|
|
25560
|
+
if (parser_token.parent && printer._output.just_added_newline() && !((parser_token.is_inline_element || parser_token.is_unformatted) && parser_token.parent.is_inline_element)) {
|
|
25561
|
+
parser_token.parent.multiline_content = true;
|
|
25562
|
+
}
|
|
25563
|
+
};
|
|
25564
|
+
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"];
|
|
25565
|
+
var p_parent_excludes = ["a", "audio", "del", "ins", "map", "noscript", "video"];
|
|
25566
|
+
Beautifier.prototype._do_optional_end_element = function(parser_token) {
|
|
25567
|
+
var result = null;
|
|
25568
|
+
if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
|
|
25569
|
+
return;
|
|
25570
|
+
}
|
|
25571
|
+
if (parser_token.tag_name === "body") {
|
|
25572
|
+
result = result || this._tag_stack.try_pop("head");
|
|
25573
|
+
} else if (parser_token.tag_name === "li") {
|
|
25574
|
+
result = result || this._tag_stack.try_pop("li", ["ol", "ul"]);
|
|
25575
|
+
} else if (parser_token.tag_name === "dd" || parser_token.tag_name === "dt") {
|
|
25576
|
+
result = result || this._tag_stack.try_pop("dt", ["dl"]);
|
|
25577
|
+
result = result || this._tag_stack.try_pop("dd", ["dl"]);
|
|
25578
|
+
} else if (parser_token.parent.tag_name === "p" && p_closers.indexOf(parser_token.tag_name) !== -1) {
|
|
25579
|
+
var p_parent = parser_token.parent.parent;
|
|
25580
|
+
if (!p_parent || p_parent_excludes.indexOf(p_parent.tag_name) === -1) {
|
|
25581
|
+
result = result || this._tag_stack.try_pop("p");
|
|
25582
|
+
}
|
|
25583
|
+
} else if (parser_token.tag_name === "rp" || parser_token.tag_name === "rt") {
|
|
25584
|
+
result = result || this._tag_stack.try_pop("rt", ["ruby", "rtc"]);
|
|
25585
|
+
result = result || this._tag_stack.try_pop("rp", ["ruby", "rtc"]);
|
|
25586
|
+
} else if (parser_token.tag_name === "optgroup") {
|
|
25587
|
+
result = result || this._tag_stack.try_pop("optgroup", ["select"]);
|
|
25588
|
+
} else if (parser_token.tag_name === "option") {
|
|
25589
|
+
result = result || this._tag_stack.try_pop("option", ["select", "datalist", "optgroup"]);
|
|
25590
|
+
} else if (parser_token.tag_name === "colgroup") {
|
|
25591
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
25592
|
+
} else if (parser_token.tag_name === "thead") {
|
|
25593
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
25594
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
25595
|
+
} else if (parser_token.tag_name === "tbody" || parser_token.tag_name === "tfoot") {
|
|
25596
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
25597
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
25598
|
+
result = result || this._tag_stack.try_pop("thead", ["table"]);
|
|
25599
|
+
result = result || this._tag_stack.try_pop("tbody", ["table"]);
|
|
25600
|
+
} else if (parser_token.tag_name === "tr") {
|
|
25601
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
25602
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
25603
|
+
result = result || this._tag_stack.try_pop("tr", ["table", "thead", "tbody", "tfoot"]);
|
|
25604
|
+
} else if (parser_token.tag_name === "th" || parser_token.tag_name === "td") {
|
|
25605
|
+
result = result || this._tag_stack.try_pop("td", ["table", "thead", "tbody", "tfoot", "tr"]);
|
|
25606
|
+
result = result || this._tag_stack.try_pop("th", ["table", "thead", "tbody", "tfoot", "tr"]);
|
|
25607
|
+
}
|
|
25608
|
+
parser_token.parent = this._tag_stack.get_parser_token();
|
|
25609
|
+
return result;
|
|
25610
|
+
};
|
|
25611
|
+
module2.exports.Beautifier = Beautifier;
|
|
25612
|
+
}
|
|
25613
|
+
});
|
|
25614
|
+
|
|
25615
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/html/index.js
|
|
25616
|
+
var require_html = __commonJS({
|
|
25617
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/html/index.js"(exports, module2) {
|
|
25618
|
+
"use strict";
|
|
25619
|
+
var Beautifier = require_beautifier3().Beautifier;
|
|
25620
|
+
var Options = require_options4().Options;
|
|
25621
|
+
function style_html(html_source, options, js_beautify2, css_beautify) {
|
|
25622
|
+
var beautifier = new Beautifier(html_source, options, js_beautify2, css_beautify);
|
|
25623
|
+
return beautifier.beautify();
|
|
25624
|
+
}
|
|
25625
|
+
module2.exports = style_html;
|
|
25626
|
+
module2.exports.defaultOptions = function() {
|
|
25627
|
+
return new Options();
|
|
25628
|
+
};
|
|
25629
|
+
}
|
|
25630
|
+
});
|
|
25631
|
+
|
|
25632
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/index.js
|
|
25633
|
+
var require_src = __commonJS({
|
|
25634
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/src/index.js"(exports, module2) {
|
|
25635
|
+
"use strict";
|
|
25636
|
+
var js_beautify2 = require_javascript();
|
|
25637
|
+
var css_beautify = require_css();
|
|
25638
|
+
var html_beautify = require_html();
|
|
25639
|
+
function style_html(html_source, options, js, css) {
|
|
25640
|
+
js = js || js_beautify2;
|
|
25641
|
+
css = css || css_beautify;
|
|
25642
|
+
return html_beautify(html_source, options, js, css);
|
|
25643
|
+
}
|
|
25644
|
+
style_html.defaultOptions = html_beautify.defaultOptions;
|
|
25645
|
+
module2.exports.js = js_beautify2;
|
|
25646
|
+
module2.exports.css = css_beautify;
|
|
25647
|
+
module2.exports.html = style_html;
|
|
25648
|
+
}
|
|
25649
|
+
});
|
|
25650
|
+
|
|
25651
|
+
// node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/index.js
|
|
25652
|
+
var require_js = __commonJS({
|
|
25653
|
+
"node_modules/.pnpm/js-beautify@1.14.3/node_modules/js-beautify/js/index.js"(exports, module2) {
|
|
25654
|
+
"use strict";
|
|
25655
|
+
function get_beautify(js_beautify2, css_beautify, html_beautify) {
|
|
25656
|
+
var beautify = function(src, config) {
|
|
25657
|
+
return js_beautify2.js_beautify(src, config);
|
|
25658
|
+
};
|
|
25659
|
+
beautify.js = js_beautify2.js_beautify;
|
|
25660
|
+
beautify.css = css_beautify.css_beautify;
|
|
25661
|
+
beautify.html = html_beautify.html_beautify;
|
|
25662
|
+
beautify.js_beautify = js_beautify2.js_beautify;
|
|
25663
|
+
beautify.css_beautify = css_beautify.css_beautify;
|
|
25664
|
+
beautify.html_beautify = html_beautify.html_beautify;
|
|
25665
|
+
return beautify;
|
|
25666
|
+
}
|
|
25667
|
+
if (typeof define === "function" && define.amd) {
|
|
25668
|
+
define([
|
|
25669
|
+
"./lib/beautify",
|
|
25670
|
+
"./lib/beautify-css",
|
|
25671
|
+
"./lib/beautify-html"
|
|
25672
|
+
], function(js_beautify2, css_beautify, html_beautify) {
|
|
25673
|
+
return get_beautify(js_beautify2, css_beautify, html_beautify);
|
|
25674
|
+
});
|
|
25675
|
+
} else {
|
|
25676
|
+
(function(mod) {
|
|
25677
|
+
var beautifier = require_src();
|
|
25678
|
+
beautifier.js_beautify = beautifier.js;
|
|
25679
|
+
beautifier.css_beautify = beautifier.css;
|
|
25680
|
+
beautifier.html_beautify = beautifier.html;
|
|
25681
|
+
mod.exports = get_beautify(beautifier, beautifier, beautifier);
|
|
25682
|
+
})(module2);
|
|
25683
|
+
}
|
|
25684
|
+
}
|
|
25685
|
+
});
|
|
25686
|
+
|
|
21588
25687
|
// src/index.ts
|
|
21589
25688
|
import { promises as fs3 } from "node:fs";
|
|
21590
25689
|
import process5 from "node:process";
|
|
@@ -21596,7 +25695,7 @@ import path, { resolve } from "node:path";
|
|
|
21596
25695
|
import { promises as fs } from "node:fs";
|
|
21597
25696
|
import process2 from "node:process";
|
|
21598
25697
|
|
|
21599
|
-
// node_modules/.pnpm/magicast@0.3.
|
|
25698
|
+
// node_modules/.pnpm/magicast@0.3.4/node_modules/magicast/dist/index.mjs
|
|
21600
25699
|
import { promises } from "node:fs";
|
|
21601
25700
|
var import_source_map_js = __toESM(require_source_map(), 1);
|
|
21602
25701
|
var babelParser = __toESM(require_lib(), 1);
|
|
@@ -30062,6 +34161,30 @@ function proxifyIdentifier(node) {
|
|
|
30062
34161
|
{}
|
|
30063
34162
|
);
|
|
30064
34163
|
}
|
|
34164
|
+
function proxifyLogicalExpression(node) {
|
|
34165
|
+
if (node.type !== "LogicalExpression") {
|
|
34166
|
+
throw new MagicastError("Not a logical expression");
|
|
34167
|
+
}
|
|
34168
|
+
return createProxy(
|
|
34169
|
+
node,
|
|
34170
|
+
{
|
|
34171
|
+
$type: "logicalExpression"
|
|
34172
|
+
},
|
|
34173
|
+
{}
|
|
34174
|
+
);
|
|
34175
|
+
}
|
|
34176
|
+
function proxifyMemberExpression(node) {
|
|
34177
|
+
if (node.type !== "MemberExpression") {
|
|
34178
|
+
throw new MagicastError("Not a member expression");
|
|
34179
|
+
}
|
|
34180
|
+
return createProxy(
|
|
34181
|
+
node,
|
|
34182
|
+
{
|
|
34183
|
+
$type: "memberExpression"
|
|
34184
|
+
},
|
|
34185
|
+
{}
|
|
34186
|
+
);
|
|
34187
|
+
}
|
|
30065
34188
|
var _cache = /* @__PURE__ */ new WeakMap();
|
|
30066
34189
|
function proxify(node, mod) {
|
|
30067
34190
|
if (LITERALS_TYPEOF.has(typeof node)) {
|
|
@@ -30099,6 +34222,14 @@ function proxify(node, mod) {
|
|
|
30099
34222
|
proxy = proxifyIdentifier(node);
|
|
30100
34223
|
break;
|
|
30101
34224
|
}
|
|
34225
|
+
case "LogicalExpression": {
|
|
34226
|
+
proxy = proxifyLogicalExpression(node);
|
|
34227
|
+
break;
|
|
34228
|
+
}
|
|
34229
|
+
case "MemberExpression": {
|
|
34230
|
+
proxy = proxifyMemberExpression(node);
|
|
34231
|
+
break;
|
|
34232
|
+
}
|
|
30102
34233
|
case "TSAsExpression":
|
|
30103
34234
|
case "TSSatisfiesExpression": {
|
|
30104
34235
|
proxy = proxify(node.expression, mod);
|
|
@@ -30340,6 +34471,7 @@ async function loadFile(filename, options = {}) {
|
|
|
30340
34471
|
}
|
|
30341
34472
|
|
|
30342
34473
|
// src/core/generate.ts
|
|
34474
|
+
var import_js_beautify = __toESM(require_js(), 1);
|
|
30343
34475
|
import { deepMerge } from "@antfu/utils";
|
|
30344
34476
|
async function generateScript(options, mode) {
|
|
30345
34477
|
const { dir, fileName, globalName, serve, build } = options.env;
|
|
@@ -30367,7 +34499,7 @@ async function generateScript(options, mode) {
|
|
|
30367
34499
|
const returnedTarget = deepMerge({}, source, target);
|
|
30368
34500
|
const versionInfo = await generateVersion(options, mode);
|
|
30369
34501
|
code = `window.${globalName}=${JSON.stringify(returnedTarget)};${versionInfo}`;
|
|
30370
|
-
const formatCode = code;
|
|
34502
|
+
const formatCode = import_js_beautify.default.js_beautify(code);
|
|
30371
34503
|
return {
|
|
30372
34504
|
code,
|
|
30373
34505
|
script: ` <script type="text/javascript" src="${fileName}"></script>
|