@angelscmf/front 1.0.30 → 1.0.32
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/README.md +41 -18
- package/dist/AngelsFrontAnimationLibrary.js +15 -14
- package/dist/AngelsFrontAnimationLibrary.js.map +1 -1
- package/dist/AngelsFrontAnimationLibrary.mjs +15 -14
- package/dist/AngelsFrontAnimationLibrary.mjs.map +1 -1
- package/dist/AngelsFrontApplication.js +59 -47
- package/dist/AngelsFrontApplication.js.map +1 -1
- package/dist/AngelsFrontApplication.mjs +59 -47
- package/dist/AngelsFrontApplication.mjs.map +1 -1
- package/dist/AngelsFrontDOMLibrary.d.mts +3 -2
- package/dist/AngelsFrontDOMLibrary.d.ts +3 -2
- package/dist/AngelsFrontDOMLibrary.js +30 -16
- package/dist/AngelsFrontDOMLibrary.js.map +1 -1
- package/dist/AngelsFrontDOMLibrary.mjs +29 -16
- package/dist/AngelsFrontDOMLibrary.mjs.map +1 -1
- package/dist/AngelsFrontElement.d.mts +2 -1
- package/dist/AngelsFrontElement.d.ts +2 -1
- package/dist/AngelsFrontElement.js +15 -14
- package/dist/AngelsFrontElement.js.map +1 -1
- package/dist/AngelsFrontElement.mjs +15 -14
- package/dist/AngelsFrontElement.mjs.map +1 -1
- package/dist/AngelsFrontLoader.js +4452 -25
- package/dist/AngelsFrontLoader.js.map +1 -1
- package/dist/AngelsFrontLoader.mjs +4452 -25
- package/dist/AngelsFrontLoader.mjs.map +1 -1
- package/dist/AngelsFrontPage.js +59 -47
- package/dist/AngelsFrontPage.js.map +1 -1
- package/dist/AngelsFrontPage.mjs +59 -47
- package/dist/AngelsFrontPage.mjs.map +1 -1
- package/dist/AngelsFrontWidgetClass.js +59 -47
- package/dist/AngelsFrontWidgetClass.js.map +1 -1
- package/dist/AngelsFrontWidgetClass.mjs +59 -47
- package/dist/AngelsFrontWidgetClass.mjs.map +1 -1
- package/package.json +4 -1
- package/sass/AngelsDesign.scss +5 -0
- package/sass/angelsTags/_a-alpha.scss +29 -0
- package/sass/angelsTags/_a-center.scss +15 -0
- package/sass/angelsTags/_a-float.scss +42 -0
- package/sass/angelsTags/_a-icenter.scss +15 -0
- package/sass/angelsTags/_a-page.scss +2 -2
- package/sass/angelsTags/_a-text-transform.scss +29 -0
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
2
27
|
var __async = (__this, __arguments, generator) => {
|
|
3
28
|
return new Promise((resolve, reject) => {
|
|
4
29
|
var fulfilled = (value) => {
|
|
@@ -8,36 +33,4279 @@ var __async = (__this, __arguments, generator) => {
|
|
|
8
33
|
reject(e);
|
|
9
34
|
}
|
|
10
35
|
};
|
|
11
|
-
var rejected = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
step(generator.throw(value));
|
|
14
|
-
} catch (e) {
|
|
15
|
-
reject(e);
|
|
36
|
+
var rejected = (value) => {
|
|
37
|
+
try {
|
|
38
|
+
step(generator.throw(value));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
reject(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
44
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// node_modules/js-beautify/js/src/core/output.js
|
|
49
|
+
var require_output = __commonJS({
|
|
50
|
+
"node_modules/js-beautify/js/src/core/output.js"(exports2, module2) {
|
|
51
|
+
"use strict";
|
|
52
|
+
function OutputLine(parent) {
|
|
53
|
+
this.__parent = parent;
|
|
54
|
+
this.__character_count = 0;
|
|
55
|
+
this.__indent_count = -1;
|
|
56
|
+
this.__alignment_count = 0;
|
|
57
|
+
this.__wrap_point_index = 0;
|
|
58
|
+
this.__wrap_point_character_count = 0;
|
|
59
|
+
this.__wrap_point_indent_count = -1;
|
|
60
|
+
this.__wrap_point_alignment_count = 0;
|
|
61
|
+
this.__items = [];
|
|
62
|
+
}
|
|
63
|
+
OutputLine.prototype.clone_empty = function() {
|
|
64
|
+
var line = new OutputLine(this.__parent);
|
|
65
|
+
line.set_indent(this.__indent_count, this.__alignment_count);
|
|
66
|
+
return line;
|
|
67
|
+
};
|
|
68
|
+
OutputLine.prototype.item = function(index) {
|
|
69
|
+
if (index < 0) {
|
|
70
|
+
return this.__items[this.__items.length + index];
|
|
71
|
+
} else {
|
|
72
|
+
return this.__items[index];
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
OutputLine.prototype.has_match = function(pattern) {
|
|
76
|
+
for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
|
|
77
|
+
if (this.__items[lastCheckedOutput].match(pattern)) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
};
|
|
83
|
+
OutputLine.prototype.set_indent = function(indent, alignment) {
|
|
84
|
+
if (this.is_empty()) {
|
|
85
|
+
this.__indent_count = indent || 0;
|
|
86
|
+
this.__alignment_count = alignment || 0;
|
|
87
|
+
this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
OutputLine.prototype._set_wrap_point = function() {
|
|
91
|
+
if (this.__parent.wrap_line_length) {
|
|
92
|
+
this.__wrap_point_index = this.__items.length;
|
|
93
|
+
this.__wrap_point_character_count = this.__character_count;
|
|
94
|
+
this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
|
|
95
|
+
this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
OutputLine.prototype._should_wrap = function() {
|
|
99
|
+
return this.__wrap_point_index && this.__character_count > this.__parent.wrap_line_length && this.__wrap_point_character_count > this.__parent.next_line.__character_count;
|
|
100
|
+
};
|
|
101
|
+
OutputLine.prototype._allow_wrap = function() {
|
|
102
|
+
if (this._should_wrap()) {
|
|
103
|
+
this.__parent.add_new_line();
|
|
104
|
+
var next = this.__parent.current_line;
|
|
105
|
+
next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
|
|
106
|
+
next.__items = this.__items.slice(this.__wrap_point_index);
|
|
107
|
+
this.__items = this.__items.slice(0, this.__wrap_point_index);
|
|
108
|
+
next.__character_count += this.__character_count - this.__wrap_point_character_count;
|
|
109
|
+
this.__character_count = this.__wrap_point_character_count;
|
|
110
|
+
if (next.__items[0] === " ") {
|
|
111
|
+
next.__items.splice(0, 1);
|
|
112
|
+
next.__character_count -= 1;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
};
|
|
118
|
+
OutputLine.prototype.is_empty = function() {
|
|
119
|
+
return this.__items.length === 0;
|
|
120
|
+
};
|
|
121
|
+
OutputLine.prototype.last = function() {
|
|
122
|
+
if (!this.is_empty()) {
|
|
123
|
+
return this.__items[this.__items.length - 1];
|
|
124
|
+
} else {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
OutputLine.prototype.push = function(item) {
|
|
129
|
+
this.__items.push(item);
|
|
130
|
+
var last_newline_index = item.lastIndexOf("\n");
|
|
131
|
+
if (last_newline_index !== -1) {
|
|
132
|
+
this.__character_count = item.length - last_newline_index;
|
|
133
|
+
} else {
|
|
134
|
+
this.__character_count += item.length;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
OutputLine.prototype.pop = function() {
|
|
138
|
+
var item = null;
|
|
139
|
+
if (!this.is_empty()) {
|
|
140
|
+
item = this.__items.pop();
|
|
141
|
+
this.__character_count -= item.length;
|
|
142
|
+
}
|
|
143
|
+
return item;
|
|
144
|
+
};
|
|
145
|
+
OutputLine.prototype._remove_indent = function() {
|
|
146
|
+
if (this.__indent_count > 0) {
|
|
147
|
+
this.__indent_count -= 1;
|
|
148
|
+
this.__character_count -= this.__parent.indent_size;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
OutputLine.prototype._remove_wrap_indent = function() {
|
|
152
|
+
if (this.__wrap_point_indent_count > 0) {
|
|
153
|
+
this.__wrap_point_indent_count -= 1;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
OutputLine.prototype.trim = function() {
|
|
157
|
+
while (this.last() === " ") {
|
|
158
|
+
this.__items.pop();
|
|
159
|
+
this.__character_count -= 1;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
OutputLine.prototype.toString = function() {
|
|
163
|
+
var result = "";
|
|
164
|
+
if (this.is_empty()) {
|
|
165
|
+
if (this.__parent.indent_empty_lines) {
|
|
166
|
+
result = this.__parent.get_indent_string(this.__indent_count);
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
|
|
170
|
+
result += this.__items.join("");
|
|
171
|
+
}
|
|
172
|
+
return result;
|
|
173
|
+
};
|
|
174
|
+
function IndentStringCache(options, baseIndentString) {
|
|
175
|
+
this.__cache = [""];
|
|
176
|
+
this.__indent_size = options.indent_size;
|
|
177
|
+
this.__indent_string = options.indent_char;
|
|
178
|
+
if (!options.indent_with_tabs) {
|
|
179
|
+
this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
|
|
180
|
+
}
|
|
181
|
+
baseIndentString = baseIndentString || "";
|
|
182
|
+
if (options.indent_level > 0) {
|
|
183
|
+
baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
|
|
184
|
+
}
|
|
185
|
+
this.__base_string = baseIndentString;
|
|
186
|
+
this.__base_string_length = baseIndentString.length;
|
|
187
|
+
}
|
|
188
|
+
IndentStringCache.prototype.get_indent_size = function(indent, column) {
|
|
189
|
+
var result = this.__base_string_length;
|
|
190
|
+
column = column || 0;
|
|
191
|
+
if (indent < 0) {
|
|
192
|
+
result = 0;
|
|
193
|
+
}
|
|
194
|
+
result += indent * this.__indent_size;
|
|
195
|
+
result += column;
|
|
196
|
+
return result;
|
|
197
|
+
};
|
|
198
|
+
IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
|
|
199
|
+
var result = this.__base_string;
|
|
200
|
+
column = column || 0;
|
|
201
|
+
if (indent_level < 0) {
|
|
202
|
+
indent_level = 0;
|
|
203
|
+
result = "";
|
|
204
|
+
}
|
|
205
|
+
column += indent_level * this.__indent_size;
|
|
206
|
+
this.__ensure_cache(column);
|
|
207
|
+
result += this.__cache[column];
|
|
208
|
+
return result;
|
|
209
|
+
};
|
|
210
|
+
IndentStringCache.prototype.__ensure_cache = function(column) {
|
|
211
|
+
while (column >= this.__cache.length) {
|
|
212
|
+
this.__add_column();
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
IndentStringCache.prototype.__add_column = function() {
|
|
216
|
+
var column = this.__cache.length;
|
|
217
|
+
var indent = 0;
|
|
218
|
+
var result = "";
|
|
219
|
+
if (this.__indent_size && column >= this.__indent_size) {
|
|
220
|
+
indent = Math.floor(column / this.__indent_size);
|
|
221
|
+
column -= indent * this.__indent_size;
|
|
222
|
+
result = new Array(indent + 1).join(this.__indent_string);
|
|
223
|
+
}
|
|
224
|
+
if (column) {
|
|
225
|
+
result += new Array(column + 1).join(" ");
|
|
226
|
+
}
|
|
227
|
+
this.__cache.push(result);
|
|
228
|
+
};
|
|
229
|
+
function Output(options, baseIndentString) {
|
|
230
|
+
this.__indent_cache = new IndentStringCache(options, baseIndentString);
|
|
231
|
+
this.raw = false;
|
|
232
|
+
this._end_with_newline = options.end_with_newline;
|
|
233
|
+
this.indent_size = options.indent_size;
|
|
234
|
+
this.wrap_line_length = options.wrap_line_length;
|
|
235
|
+
this.indent_empty_lines = options.indent_empty_lines;
|
|
236
|
+
this.__lines = [];
|
|
237
|
+
this.previous_line = null;
|
|
238
|
+
this.current_line = null;
|
|
239
|
+
this.next_line = new OutputLine(this);
|
|
240
|
+
this.space_before_token = false;
|
|
241
|
+
this.non_breaking_space = false;
|
|
242
|
+
this.previous_token_wrapped = false;
|
|
243
|
+
this.__add_outputline();
|
|
244
|
+
}
|
|
245
|
+
Output.prototype.__add_outputline = function() {
|
|
246
|
+
this.previous_line = this.current_line;
|
|
247
|
+
this.current_line = this.next_line.clone_empty();
|
|
248
|
+
this.__lines.push(this.current_line);
|
|
249
|
+
};
|
|
250
|
+
Output.prototype.get_line_number = function() {
|
|
251
|
+
return this.__lines.length;
|
|
252
|
+
};
|
|
253
|
+
Output.prototype.get_indent_string = function(indent, column) {
|
|
254
|
+
return this.__indent_cache.get_indent_string(indent, column);
|
|
255
|
+
};
|
|
256
|
+
Output.prototype.get_indent_size = function(indent, column) {
|
|
257
|
+
return this.__indent_cache.get_indent_size(indent, column);
|
|
258
|
+
};
|
|
259
|
+
Output.prototype.is_empty = function() {
|
|
260
|
+
return !this.previous_line && this.current_line.is_empty();
|
|
261
|
+
};
|
|
262
|
+
Output.prototype.add_new_line = function(force_newline) {
|
|
263
|
+
if (this.is_empty() || !force_newline && this.just_added_newline()) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
if (!this.raw) {
|
|
267
|
+
this.__add_outputline();
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
270
|
+
};
|
|
271
|
+
Output.prototype.get_code = function(eol) {
|
|
272
|
+
this.trim(true);
|
|
273
|
+
var last_item = this.current_line.pop();
|
|
274
|
+
if (last_item) {
|
|
275
|
+
if (last_item[last_item.length - 1] === "\n") {
|
|
276
|
+
last_item = last_item.replace(/\n+$/g, "");
|
|
277
|
+
}
|
|
278
|
+
this.current_line.push(last_item);
|
|
279
|
+
}
|
|
280
|
+
if (this._end_with_newline) {
|
|
281
|
+
this.__add_outputline();
|
|
282
|
+
}
|
|
283
|
+
var sweet_code = this.__lines.join("\n");
|
|
284
|
+
if (eol !== "\n") {
|
|
285
|
+
sweet_code = sweet_code.replace(/[\n]/g, eol);
|
|
286
|
+
}
|
|
287
|
+
return sweet_code;
|
|
288
|
+
};
|
|
289
|
+
Output.prototype.set_wrap_point = function() {
|
|
290
|
+
this.current_line._set_wrap_point();
|
|
291
|
+
};
|
|
292
|
+
Output.prototype.set_indent = function(indent, alignment) {
|
|
293
|
+
indent = indent || 0;
|
|
294
|
+
alignment = alignment || 0;
|
|
295
|
+
this.next_line.set_indent(indent, alignment);
|
|
296
|
+
if (this.__lines.length > 1) {
|
|
297
|
+
this.current_line.set_indent(indent, alignment);
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
this.current_line.set_indent();
|
|
301
|
+
return false;
|
|
302
|
+
};
|
|
303
|
+
Output.prototype.add_raw_token = function(token) {
|
|
304
|
+
for (var x = 0; x < token.newlines; x++) {
|
|
305
|
+
this.__add_outputline();
|
|
306
|
+
}
|
|
307
|
+
this.current_line.set_indent(-1);
|
|
308
|
+
this.current_line.push(token.whitespace_before);
|
|
309
|
+
this.current_line.push(token.text);
|
|
310
|
+
this.space_before_token = false;
|
|
311
|
+
this.non_breaking_space = false;
|
|
312
|
+
this.previous_token_wrapped = false;
|
|
313
|
+
};
|
|
314
|
+
Output.prototype.add_token = function(printable_token) {
|
|
315
|
+
this.__add_space_before_token();
|
|
316
|
+
this.current_line.push(printable_token);
|
|
317
|
+
this.space_before_token = false;
|
|
318
|
+
this.non_breaking_space = false;
|
|
319
|
+
this.previous_token_wrapped = this.current_line._allow_wrap();
|
|
320
|
+
};
|
|
321
|
+
Output.prototype.__add_space_before_token = function() {
|
|
322
|
+
if (this.space_before_token && !this.just_added_newline()) {
|
|
323
|
+
if (!this.non_breaking_space) {
|
|
324
|
+
this.set_wrap_point();
|
|
325
|
+
}
|
|
326
|
+
this.current_line.push(" ");
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
Output.prototype.remove_indent = function(index) {
|
|
330
|
+
var output_length = this.__lines.length;
|
|
331
|
+
while (index < output_length) {
|
|
332
|
+
this.__lines[index]._remove_indent();
|
|
333
|
+
index++;
|
|
334
|
+
}
|
|
335
|
+
this.current_line._remove_wrap_indent();
|
|
336
|
+
};
|
|
337
|
+
Output.prototype.trim = function(eat_newlines) {
|
|
338
|
+
eat_newlines = eat_newlines === void 0 ? false : eat_newlines;
|
|
339
|
+
this.current_line.trim();
|
|
340
|
+
while (eat_newlines && this.__lines.length > 1 && this.current_line.is_empty()) {
|
|
341
|
+
this.__lines.pop();
|
|
342
|
+
this.current_line = this.__lines[this.__lines.length - 1];
|
|
343
|
+
this.current_line.trim();
|
|
344
|
+
}
|
|
345
|
+
this.previous_line = this.__lines.length > 1 ? this.__lines[this.__lines.length - 2] : null;
|
|
346
|
+
};
|
|
347
|
+
Output.prototype.just_added_newline = function() {
|
|
348
|
+
return this.current_line.is_empty();
|
|
349
|
+
};
|
|
350
|
+
Output.prototype.just_added_blankline = function() {
|
|
351
|
+
return this.is_empty() || this.current_line.is_empty() && this.previous_line.is_empty();
|
|
352
|
+
};
|
|
353
|
+
Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
|
|
354
|
+
var index = this.__lines.length - 2;
|
|
355
|
+
while (index >= 0) {
|
|
356
|
+
var potentialEmptyLine = this.__lines[index];
|
|
357
|
+
if (potentialEmptyLine.is_empty()) {
|
|
358
|
+
break;
|
|
359
|
+
} else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 && potentialEmptyLine.item(-1) !== ends_with) {
|
|
360
|
+
this.__lines.splice(index + 1, 0, new OutputLine(this));
|
|
361
|
+
this.previous_line = this.__lines[this.__lines.length - 2];
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
index--;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
module2.exports.Output = Output;
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// node_modules/js-beautify/js/src/core/token.js
|
|
372
|
+
var require_token = __commonJS({
|
|
373
|
+
"node_modules/js-beautify/js/src/core/token.js"(exports2, module2) {
|
|
374
|
+
"use strict";
|
|
375
|
+
function Token(type, text, newlines, whitespace_before) {
|
|
376
|
+
this.type = type;
|
|
377
|
+
this.text = text;
|
|
378
|
+
this.comments_before = null;
|
|
379
|
+
this.newlines = newlines || 0;
|
|
380
|
+
this.whitespace_before = whitespace_before || "";
|
|
381
|
+
this.parent = null;
|
|
382
|
+
this.next = null;
|
|
383
|
+
this.previous = null;
|
|
384
|
+
this.opened = null;
|
|
385
|
+
this.closed = null;
|
|
386
|
+
this.directives = null;
|
|
387
|
+
}
|
|
388
|
+
module2.exports.Token = Token;
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// node_modules/js-beautify/js/src/javascript/acorn.js
|
|
393
|
+
var require_acorn = __commonJS({
|
|
394
|
+
"node_modules/js-beautify/js/src/javascript/acorn.js"(exports2) {
|
|
395
|
+
"use strict";
|
|
396
|
+
var baseASCIIidentifierStartChars = "\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
|
|
397
|
+
var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
|
|
398
|
+
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";
|
|
399
|
+
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";
|
|
400
|
+
var unicodeEscapeOrCodePoint = "\\\\u[0-9a-fA-F]{4}|\\\\u\\{[0-9a-fA-F]+\\}";
|
|
401
|
+
var identifierStart = "(?:" + unicodeEscapeOrCodePoint + "|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
|
|
402
|
+
var identifierChars = "(?:" + unicodeEscapeOrCodePoint + "|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
|
|
403
|
+
exports2.identifier = new RegExp(identifierStart + identifierChars, "g");
|
|
404
|
+
exports2.identifierStart = new RegExp(identifierStart);
|
|
405
|
+
exports2.identifierMatch = new RegExp("(?:" + unicodeEscapeOrCodePoint + "|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
|
|
406
|
+
exports2.newline = /[\n\r\u2028\u2029]/;
|
|
407
|
+
exports2.lineBreak = new RegExp("\r\n|" + exports2.newline.source);
|
|
408
|
+
exports2.allLineBreaks = new RegExp(exports2.lineBreak.source, "g");
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// node_modules/js-beautify/js/src/core/options.js
|
|
413
|
+
var require_options = __commonJS({
|
|
414
|
+
"node_modules/js-beautify/js/src/core/options.js"(exports2, module2) {
|
|
415
|
+
"use strict";
|
|
416
|
+
function Options(options, merge_child_field) {
|
|
417
|
+
this.raw_options = _mergeOpts(options, merge_child_field);
|
|
418
|
+
this.disabled = this._get_boolean("disabled");
|
|
419
|
+
this.eol = this._get_characters("eol", "auto");
|
|
420
|
+
this.end_with_newline = this._get_boolean("end_with_newline");
|
|
421
|
+
this.indent_size = this._get_number("indent_size", 4);
|
|
422
|
+
this.indent_char = this._get_characters("indent_char", " ");
|
|
423
|
+
this.indent_level = this._get_number("indent_level");
|
|
424
|
+
this.preserve_newlines = this._get_boolean("preserve_newlines", true);
|
|
425
|
+
this.max_preserve_newlines = this._get_number("max_preserve_newlines", 32786);
|
|
426
|
+
if (!this.preserve_newlines) {
|
|
427
|
+
this.max_preserve_newlines = 0;
|
|
428
|
+
}
|
|
429
|
+
this.indent_with_tabs = this._get_boolean("indent_with_tabs", this.indent_char === " ");
|
|
430
|
+
if (this.indent_with_tabs) {
|
|
431
|
+
this.indent_char = " ";
|
|
432
|
+
if (this.indent_size === 1) {
|
|
433
|
+
this.indent_size = 4;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
this.wrap_line_length = this._get_number("wrap_line_length", this._get_number("max_char"));
|
|
437
|
+
this.indent_empty_lines = this._get_boolean("indent_empty_lines");
|
|
438
|
+
this.templating = this._get_selection_list("templating", ["auto", "none", "angular", "django", "erb", "handlebars", "php", "smarty"], ["auto"]);
|
|
439
|
+
}
|
|
440
|
+
Options.prototype._get_array = function(name, default_value) {
|
|
441
|
+
var option_value = this.raw_options[name];
|
|
442
|
+
var result = default_value || [];
|
|
443
|
+
if (typeof option_value === "object") {
|
|
444
|
+
if (option_value !== null && typeof option_value.concat === "function") {
|
|
445
|
+
result = option_value.concat();
|
|
446
|
+
}
|
|
447
|
+
} else if (typeof option_value === "string") {
|
|
448
|
+
result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
|
|
449
|
+
}
|
|
450
|
+
return result;
|
|
451
|
+
};
|
|
452
|
+
Options.prototype._get_boolean = function(name, default_value) {
|
|
453
|
+
var option_value = this.raw_options[name];
|
|
454
|
+
var result = option_value === void 0 ? !!default_value : !!option_value;
|
|
455
|
+
return result;
|
|
456
|
+
};
|
|
457
|
+
Options.prototype._get_characters = function(name, default_value) {
|
|
458
|
+
var option_value = this.raw_options[name];
|
|
459
|
+
var result = default_value || "";
|
|
460
|
+
if (typeof option_value === "string") {
|
|
461
|
+
result = option_value.replace(/\\r/, "\r").replace(/\\n/, "\n").replace(/\\t/, " ");
|
|
462
|
+
}
|
|
463
|
+
return result;
|
|
464
|
+
};
|
|
465
|
+
Options.prototype._get_number = function(name, default_value) {
|
|
466
|
+
var option_value = this.raw_options[name];
|
|
467
|
+
default_value = parseInt(default_value, 10);
|
|
468
|
+
if (isNaN(default_value)) {
|
|
469
|
+
default_value = 0;
|
|
470
|
+
}
|
|
471
|
+
var result = parseInt(option_value, 10);
|
|
472
|
+
if (isNaN(result)) {
|
|
473
|
+
result = default_value;
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
476
|
+
};
|
|
477
|
+
Options.prototype._get_selection = function(name, selection_list, default_value) {
|
|
478
|
+
var result = this._get_selection_list(name, selection_list, default_value);
|
|
479
|
+
if (result.length !== 1) {
|
|
480
|
+
throw new Error(
|
|
481
|
+
"Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" + selection_list + "\nYou passed in: '" + this.raw_options[name] + "'"
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
return result[0];
|
|
485
|
+
};
|
|
486
|
+
Options.prototype._get_selection_list = function(name, selection_list, default_value) {
|
|
487
|
+
if (!selection_list || selection_list.length === 0) {
|
|
488
|
+
throw new Error("Selection list cannot be empty.");
|
|
489
|
+
}
|
|
490
|
+
default_value = default_value || [selection_list[0]];
|
|
491
|
+
if (!this._is_valid_selection(default_value, selection_list)) {
|
|
492
|
+
throw new Error("Invalid Default Value!");
|
|
493
|
+
}
|
|
494
|
+
var result = this._get_array(name, default_value);
|
|
495
|
+
if (!this._is_valid_selection(result, selection_list)) {
|
|
496
|
+
throw new Error(
|
|
497
|
+
"Invalid Option Value: The option '" + name + "' can contain only the following values:\n" + selection_list + "\nYou passed in: '" + this.raw_options[name] + "'"
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
return result;
|
|
501
|
+
};
|
|
502
|
+
Options.prototype._is_valid_selection = function(result, selection_list) {
|
|
503
|
+
return result.length && selection_list.length && !result.some(function(item) {
|
|
504
|
+
return selection_list.indexOf(item) === -1;
|
|
505
|
+
});
|
|
506
|
+
};
|
|
507
|
+
function _mergeOpts(allOptions, childFieldName) {
|
|
508
|
+
var finalOpts = {};
|
|
509
|
+
allOptions = _normalizeOpts(allOptions);
|
|
510
|
+
var name;
|
|
511
|
+
for (name in allOptions) {
|
|
512
|
+
if (name !== childFieldName) {
|
|
513
|
+
finalOpts[name] = allOptions[name];
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
if (childFieldName && allOptions[childFieldName]) {
|
|
517
|
+
for (name in allOptions[childFieldName]) {
|
|
518
|
+
finalOpts[name] = allOptions[childFieldName][name];
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return finalOpts;
|
|
522
|
+
}
|
|
523
|
+
function _normalizeOpts(options) {
|
|
524
|
+
var convertedOpts = {};
|
|
525
|
+
var key;
|
|
526
|
+
for (key in options) {
|
|
527
|
+
var newKey = key.replace(/-/g, "_");
|
|
528
|
+
convertedOpts[newKey] = options[key];
|
|
529
|
+
}
|
|
530
|
+
return convertedOpts;
|
|
531
|
+
}
|
|
532
|
+
module2.exports.Options = Options;
|
|
533
|
+
module2.exports.normalizeOpts = _normalizeOpts;
|
|
534
|
+
module2.exports.mergeOpts = _mergeOpts;
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
// node_modules/js-beautify/js/src/javascript/options.js
|
|
539
|
+
var require_options2 = __commonJS({
|
|
540
|
+
"node_modules/js-beautify/js/src/javascript/options.js"(exports2, module2) {
|
|
541
|
+
"use strict";
|
|
542
|
+
var BaseOptions = require_options().Options;
|
|
543
|
+
var validPositionValues = ["before-newline", "after-newline", "preserve-newline"];
|
|
544
|
+
function Options(options) {
|
|
545
|
+
BaseOptions.call(this, options, "js");
|
|
546
|
+
var raw_brace_style = this.raw_options.brace_style || null;
|
|
547
|
+
if (raw_brace_style === "expand-strict") {
|
|
548
|
+
this.raw_options.brace_style = "expand";
|
|
549
|
+
} else if (raw_brace_style === "collapse-preserve-inline") {
|
|
550
|
+
this.raw_options.brace_style = "collapse,preserve-inline";
|
|
551
|
+
} else if (this.raw_options.braces_on_own_line !== void 0) {
|
|
552
|
+
this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
|
|
553
|
+
}
|
|
554
|
+
var brace_style_split = this._get_selection_list("brace_style", ["collapse", "expand", "end-expand", "none", "preserve-inline"]);
|
|
555
|
+
this.brace_preserve_inline = false;
|
|
556
|
+
this.brace_style = "collapse";
|
|
557
|
+
for (var bs = 0; bs < brace_style_split.length; bs++) {
|
|
558
|
+
if (brace_style_split[bs] === "preserve-inline") {
|
|
559
|
+
this.brace_preserve_inline = true;
|
|
560
|
+
} else {
|
|
561
|
+
this.brace_style = brace_style_split[bs];
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
this.unindent_chained_methods = this._get_boolean("unindent_chained_methods");
|
|
565
|
+
this.break_chained_methods = this._get_boolean("break_chained_methods");
|
|
566
|
+
this.space_in_paren = this._get_boolean("space_in_paren");
|
|
567
|
+
this.space_in_empty_paren = this._get_boolean("space_in_empty_paren");
|
|
568
|
+
this.jslint_happy = this._get_boolean("jslint_happy");
|
|
569
|
+
this.space_after_anon_function = this._get_boolean("space_after_anon_function");
|
|
570
|
+
this.space_after_named_function = this._get_boolean("space_after_named_function");
|
|
571
|
+
this.keep_array_indentation = this._get_boolean("keep_array_indentation");
|
|
572
|
+
this.space_before_conditional = this._get_boolean("space_before_conditional", true);
|
|
573
|
+
this.unescape_strings = this._get_boolean("unescape_strings");
|
|
574
|
+
this.e4x = this._get_boolean("e4x");
|
|
575
|
+
this.comma_first = this._get_boolean("comma_first");
|
|
576
|
+
this.operator_position = this._get_selection("operator_position", validPositionValues);
|
|
577
|
+
this.test_output_raw = this._get_boolean("test_output_raw");
|
|
578
|
+
if (this.jslint_happy) {
|
|
579
|
+
this.space_after_anon_function = true;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
Options.prototype = new BaseOptions();
|
|
583
|
+
module2.exports.Options = Options;
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
// node_modules/js-beautify/js/src/core/inputscanner.js
|
|
588
|
+
var require_inputscanner = __commonJS({
|
|
589
|
+
"node_modules/js-beautify/js/src/core/inputscanner.js"(exports2, module2) {
|
|
590
|
+
"use strict";
|
|
591
|
+
var regexp_has_sticky = RegExp.prototype.hasOwnProperty("sticky");
|
|
592
|
+
function InputScanner(input_string) {
|
|
593
|
+
this.__input = input_string || "";
|
|
594
|
+
this.__input_length = this.__input.length;
|
|
595
|
+
this.__position = 0;
|
|
596
|
+
}
|
|
597
|
+
InputScanner.prototype.restart = function() {
|
|
598
|
+
this.__position = 0;
|
|
599
|
+
};
|
|
600
|
+
InputScanner.prototype.back = function() {
|
|
601
|
+
if (this.__position > 0) {
|
|
602
|
+
this.__position -= 1;
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
InputScanner.prototype.hasNext = function() {
|
|
606
|
+
return this.__position < this.__input_length;
|
|
607
|
+
};
|
|
608
|
+
InputScanner.prototype.next = function() {
|
|
609
|
+
var val = null;
|
|
610
|
+
if (this.hasNext()) {
|
|
611
|
+
val = this.__input.charAt(this.__position);
|
|
612
|
+
this.__position += 1;
|
|
613
|
+
}
|
|
614
|
+
return val;
|
|
615
|
+
};
|
|
616
|
+
InputScanner.prototype.peek = function(index) {
|
|
617
|
+
var val = null;
|
|
618
|
+
index = index || 0;
|
|
619
|
+
index += this.__position;
|
|
620
|
+
if (index >= 0 && index < this.__input_length) {
|
|
621
|
+
val = this.__input.charAt(index);
|
|
622
|
+
}
|
|
623
|
+
return val;
|
|
624
|
+
};
|
|
625
|
+
InputScanner.prototype.__match = function(pattern, index) {
|
|
626
|
+
pattern.lastIndex = index;
|
|
627
|
+
var pattern_match = pattern.exec(this.__input);
|
|
628
|
+
if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
|
|
629
|
+
if (pattern_match.index !== index) {
|
|
630
|
+
pattern_match = null;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return pattern_match;
|
|
634
|
+
};
|
|
635
|
+
InputScanner.prototype.test = function(pattern, index) {
|
|
636
|
+
index = index || 0;
|
|
637
|
+
index += this.__position;
|
|
638
|
+
if (index >= 0 && index < this.__input_length) {
|
|
639
|
+
return !!this.__match(pattern, index);
|
|
640
|
+
} else {
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
InputScanner.prototype.testChar = function(pattern, index) {
|
|
645
|
+
var val = this.peek(index);
|
|
646
|
+
pattern.lastIndex = 0;
|
|
647
|
+
return val !== null && pattern.test(val);
|
|
648
|
+
};
|
|
649
|
+
InputScanner.prototype.match = function(pattern) {
|
|
650
|
+
var pattern_match = this.__match(pattern, this.__position);
|
|
651
|
+
if (pattern_match) {
|
|
652
|
+
this.__position += pattern_match[0].length;
|
|
653
|
+
} else {
|
|
654
|
+
pattern_match = null;
|
|
655
|
+
}
|
|
656
|
+
return pattern_match;
|
|
657
|
+
};
|
|
658
|
+
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
|
|
659
|
+
var val = "";
|
|
660
|
+
var match;
|
|
661
|
+
if (starting_pattern) {
|
|
662
|
+
match = this.match(starting_pattern);
|
|
663
|
+
if (match) {
|
|
664
|
+
val += match[0];
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (until_pattern && (match || !starting_pattern)) {
|
|
668
|
+
val += this.readUntil(until_pattern, until_after);
|
|
669
|
+
}
|
|
670
|
+
return val;
|
|
671
|
+
};
|
|
672
|
+
InputScanner.prototype.readUntil = function(pattern, until_after) {
|
|
673
|
+
var val = "";
|
|
674
|
+
var match_index = this.__position;
|
|
675
|
+
pattern.lastIndex = this.__position;
|
|
676
|
+
var pattern_match = pattern.exec(this.__input);
|
|
677
|
+
if (pattern_match) {
|
|
678
|
+
match_index = pattern_match.index;
|
|
679
|
+
if (until_after) {
|
|
680
|
+
match_index += pattern_match[0].length;
|
|
681
|
+
}
|
|
682
|
+
} else {
|
|
683
|
+
match_index = this.__input_length;
|
|
684
|
+
}
|
|
685
|
+
val = this.__input.substring(this.__position, match_index);
|
|
686
|
+
this.__position = match_index;
|
|
687
|
+
return val;
|
|
688
|
+
};
|
|
689
|
+
InputScanner.prototype.readUntilAfter = function(pattern) {
|
|
690
|
+
return this.readUntil(pattern, true);
|
|
691
|
+
};
|
|
692
|
+
InputScanner.prototype.get_regexp = function(pattern, match_from) {
|
|
693
|
+
var result = null;
|
|
694
|
+
var flags = "g";
|
|
695
|
+
if (match_from && regexp_has_sticky) {
|
|
696
|
+
flags = "y";
|
|
697
|
+
}
|
|
698
|
+
if (typeof pattern === "string" && pattern !== "") {
|
|
699
|
+
result = new RegExp(pattern, flags);
|
|
700
|
+
} else if (pattern) {
|
|
701
|
+
result = new RegExp(pattern.source, flags);
|
|
702
|
+
}
|
|
703
|
+
return result;
|
|
704
|
+
};
|
|
705
|
+
InputScanner.prototype.get_literal_regexp = function(literal_string) {
|
|
706
|
+
return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
|
|
707
|
+
};
|
|
708
|
+
InputScanner.prototype.peekUntilAfter = function(pattern) {
|
|
709
|
+
var start = this.__position;
|
|
710
|
+
var val = this.readUntilAfter(pattern);
|
|
711
|
+
this.__position = start;
|
|
712
|
+
return val;
|
|
713
|
+
};
|
|
714
|
+
InputScanner.prototype.lookBack = function(testVal) {
|
|
715
|
+
var start = this.__position - 1;
|
|
716
|
+
return start >= testVal.length && this.__input.substring(start - testVal.length, start).toLowerCase() === testVal;
|
|
717
|
+
};
|
|
718
|
+
module2.exports.InputScanner = InputScanner;
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
// node_modules/js-beautify/js/src/core/tokenstream.js
|
|
723
|
+
var require_tokenstream = __commonJS({
|
|
724
|
+
"node_modules/js-beautify/js/src/core/tokenstream.js"(exports2, module2) {
|
|
725
|
+
"use strict";
|
|
726
|
+
function TokenStream(parent_token) {
|
|
727
|
+
this.__tokens = [];
|
|
728
|
+
this.__tokens_length = this.__tokens.length;
|
|
729
|
+
this.__position = 0;
|
|
730
|
+
this.__parent_token = parent_token;
|
|
731
|
+
}
|
|
732
|
+
TokenStream.prototype.restart = function() {
|
|
733
|
+
this.__position = 0;
|
|
734
|
+
};
|
|
735
|
+
TokenStream.prototype.isEmpty = function() {
|
|
736
|
+
return this.__tokens_length === 0;
|
|
737
|
+
};
|
|
738
|
+
TokenStream.prototype.hasNext = function() {
|
|
739
|
+
return this.__position < this.__tokens_length;
|
|
740
|
+
};
|
|
741
|
+
TokenStream.prototype.next = function() {
|
|
742
|
+
var val = null;
|
|
743
|
+
if (this.hasNext()) {
|
|
744
|
+
val = this.__tokens[this.__position];
|
|
745
|
+
this.__position += 1;
|
|
746
|
+
}
|
|
747
|
+
return val;
|
|
748
|
+
};
|
|
749
|
+
TokenStream.prototype.peek = function(index) {
|
|
750
|
+
var val = null;
|
|
751
|
+
index = index || 0;
|
|
752
|
+
index += this.__position;
|
|
753
|
+
if (index >= 0 && index < this.__tokens_length) {
|
|
754
|
+
val = this.__tokens[index];
|
|
755
|
+
}
|
|
756
|
+
return val;
|
|
757
|
+
};
|
|
758
|
+
TokenStream.prototype.add = function(token) {
|
|
759
|
+
if (this.__parent_token) {
|
|
760
|
+
token.parent = this.__parent_token;
|
|
761
|
+
}
|
|
762
|
+
this.__tokens.push(token);
|
|
763
|
+
this.__tokens_length += 1;
|
|
764
|
+
};
|
|
765
|
+
module2.exports.TokenStream = TokenStream;
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
// node_modules/js-beautify/js/src/core/pattern.js
|
|
770
|
+
var require_pattern = __commonJS({
|
|
771
|
+
"node_modules/js-beautify/js/src/core/pattern.js"(exports2, module2) {
|
|
772
|
+
"use strict";
|
|
773
|
+
function Pattern(input_scanner, parent) {
|
|
774
|
+
this._input = input_scanner;
|
|
775
|
+
this._starting_pattern = null;
|
|
776
|
+
this._match_pattern = null;
|
|
777
|
+
this._until_pattern = null;
|
|
778
|
+
this._until_after = false;
|
|
779
|
+
if (parent) {
|
|
780
|
+
this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
|
|
781
|
+
this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
|
|
782
|
+
this._until_pattern = this._input.get_regexp(parent._until_pattern);
|
|
783
|
+
this._until_after = parent._until_after;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
Pattern.prototype.read = function() {
|
|
787
|
+
var result = this._input.read(this._starting_pattern);
|
|
788
|
+
if (!this._starting_pattern || result) {
|
|
789
|
+
result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
|
|
790
|
+
}
|
|
791
|
+
return result;
|
|
792
|
+
};
|
|
793
|
+
Pattern.prototype.read_match = function() {
|
|
794
|
+
return this._input.match(this._match_pattern);
|
|
795
|
+
};
|
|
796
|
+
Pattern.prototype.until_after = function(pattern) {
|
|
797
|
+
var result = this._create();
|
|
798
|
+
result._until_after = true;
|
|
799
|
+
result._until_pattern = this._input.get_regexp(pattern);
|
|
800
|
+
result._update();
|
|
801
|
+
return result;
|
|
802
|
+
};
|
|
803
|
+
Pattern.prototype.until = function(pattern) {
|
|
804
|
+
var result = this._create();
|
|
805
|
+
result._until_after = false;
|
|
806
|
+
result._until_pattern = this._input.get_regexp(pattern);
|
|
807
|
+
result._update();
|
|
808
|
+
return result;
|
|
809
|
+
};
|
|
810
|
+
Pattern.prototype.starting_with = function(pattern) {
|
|
811
|
+
var result = this._create();
|
|
812
|
+
result._starting_pattern = this._input.get_regexp(pattern, true);
|
|
813
|
+
result._update();
|
|
814
|
+
return result;
|
|
815
|
+
};
|
|
816
|
+
Pattern.prototype.matching = function(pattern) {
|
|
817
|
+
var result = this._create();
|
|
818
|
+
result._match_pattern = this._input.get_regexp(pattern, true);
|
|
819
|
+
result._update();
|
|
820
|
+
return result;
|
|
821
|
+
};
|
|
822
|
+
Pattern.prototype._create = function() {
|
|
823
|
+
return new Pattern(this._input, this);
|
|
824
|
+
};
|
|
825
|
+
Pattern.prototype._update = function() {
|
|
826
|
+
};
|
|
827
|
+
module2.exports.Pattern = Pattern;
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
// node_modules/js-beautify/js/src/core/whitespacepattern.js
|
|
832
|
+
var require_whitespacepattern = __commonJS({
|
|
833
|
+
"node_modules/js-beautify/js/src/core/whitespacepattern.js"(exports2, module2) {
|
|
834
|
+
"use strict";
|
|
835
|
+
var Pattern = require_pattern().Pattern;
|
|
836
|
+
function WhitespacePattern(input_scanner, parent) {
|
|
837
|
+
Pattern.call(this, input_scanner, parent);
|
|
838
|
+
if (parent) {
|
|
839
|
+
this._line_regexp = this._input.get_regexp(parent._line_regexp);
|
|
840
|
+
} else {
|
|
841
|
+
this.__set_whitespace_patterns("", "");
|
|
842
|
+
}
|
|
843
|
+
this.newline_count = 0;
|
|
844
|
+
this.whitespace_before_token = "";
|
|
845
|
+
}
|
|
846
|
+
WhitespacePattern.prototype = new Pattern();
|
|
847
|
+
WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
|
|
848
|
+
whitespace_chars += "\\t ";
|
|
849
|
+
newline_chars += "\\n\\r";
|
|
850
|
+
this._match_pattern = this._input.get_regexp(
|
|
851
|
+
"[" + whitespace_chars + newline_chars + "]+",
|
|
852
|
+
true
|
|
853
|
+
);
|
|
854
|
+
this._newline_regexp = this._input.get_regexp(
|
|
855
|
+
"\\r\\n|[" + newline_chars + "]"
|
|
856
|
+
);
|
|
857
|
+
};
|
|
858
|
+
WhitespacePattern.prototype.read = function() {
|
|
859
|
+
this.newline_count = 0;
|
|
860
|
+
this.whitespace_before_token = "";
|
|
861
|
+
var resulting_string = this._input.read(this._match_pattern);
|
|
862
|
+
if (resulting_string === " ") {
|
|
863
|
+
this.whitespace_before_token = " ";
|
|
864
|
+
} else if (resulting_string) {
|
|
865
|
+
var matches = this.__split(this._newline_regexp, resulting_string);
|
|
866
|
+
this.newline_count = matches.length - 1;
|
|
867
|
+
this.whitespace_before_token = matches[this.newline_count];
|
|
868
|
+
}
|
|
869
|
+
return resulting_string;
|
|
870
|
+
};
|
|
871
|
+
WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
|
|
872
|
+
var result = this._create();
|
|
873
|
+
result.__set_whitespace_patterns(whitespace_chars, newline_chars);
|
|
874
|
+
result._update();
|
|
875
|
+
return result;
|
|
876
|
+
};
|
|
877
|
+
WhitespacePattern.prototype._create = function() {
|
|
878
|
+
return new WhitespacePattern(this._input, this);
|
|
879
|
+
};
|
|
880
|
+
WhitespacePattern.prototype.__split = function(regexp, input_string) {
|
|
881
|
+
regexp.lastIndex = 0;
|
|
882
|
+
var start_index = 0;
|
|
883
|
+
var result = [];
|
|
884
|
+
var next_match = regexp.exec(input_string);
|
|
885
|
+
while (next_match) {
|
|
886
|
+
result.push(input_string.substring(start_index, next_match.index));
|
|
887
|
+
start_index = next_match.index + next_match[0].length;
|
|
888
|
+
next_match = regexp.exec(input_string);
|
|
889
|
+
}
|
|
890
|
+
if (start_index < input_string.length) {
|
|
891
|
+
result.push(input_string.substring(start_index, input_string.length));
|
|
892
|
+
} else {
|
|
893
|
+
result.push("");
|
|
894
|
+
}
|
|
895
|
+
return result;
|
|
896
|
+
};
|
|
897
|
+
module2.exports.WhitespacePattern = WhitespacePattern;
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
// node_modules/js-beautify/js/src/core/tokenizer.js
|
|
902
|
+
var require_tokenizer = __commonJS({
|
|
903
|
+
"node_modules/js-beautify/js/src/core/tokenizer.js"(exports2, module2) {
|
|
904
|
+
"use strict";
|
|
905
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
906
|
+
var Token = require_token().Token;
|
|
907
|
+
var TokenStream = require_tokenstream().TokenStream;
|
|
908
|
+
var WhitespacePattern = require_whitespacepattern().WhitespacePattern;
|
|
909
|
+
var TOKEN = {
|
|
910
|
+
START: "TK_START",
|
|
911
|
+
RAW: "TK_RAW",
|
|
912
|
+
EOF: "TK_EOF"
|
|
913
|
+
};
|
|
914
|
+
var Tokenizer = function(input_string, options) {
|
|
915
|
+
this._input = new InputScanner(input_string);
|
|
916
|
+
this._options = options || {};
|
|
917
|
+
this.__tokens = null;
|
|
918
|
+
this._patterns = {};
|
|
919
|
+
this._patterns.whitespace = new WhitespacePattern(this._input);
|
|
920
|
+
};
|
|
921
|
+
Tokenizer.prototype.tokenize = function() {
|
|
922
|
+
this._input.restart();
|
|
923
|
+
this.__tokens = new TokenStream();
|
|
924
|
+
this._reset();
|
|
925
|
+
var current;
|
|
926
|
+
var previous = new Token(TOKEN.START, "");
|
|
927
|
+
var open_token = null;
|
|
928
|
+
var open_stack = [];
|
|
929
|
+
var comments = new TokenStream();
|
|
930
|
+
while (previous.type !== TOKEN.EOF) {
|
|
931
|
+
current = this._get_next_token(previous, open_token);
|
|
932
|
+
while (this._is_comment(current)) {
|
|
933
|
+
comments.add(current);
|
|
934
|
+
current = this._get_next_token(previous, open_token);
|
|
935
|
+
}
|
|
936
|
+
if (!comments.isEmpty()) {
|
|
937
|
+
current.comments_before = comments;
|
|
938
|
+
comments = new TokenStream();
|
|
939
|
+
}
|
|
940
|
+
current.parent = open_token;
|
|
941
|
+
if (this._is_opening(current)) {
|
|
942
|
+
open_stack.push(open_token);
|
|
943
|
+
open_token = current;
|
|
944
|
+
} else if (open_token && this._is_closing(current, open_token)) {
|
|
945
|
+
current.opened = open_token;
|
|
946
|
+
open_token.closed = current;
|
|
947
|
+
open_token = open_stack.pop();
|
|
948
|
+
current.parent = open_token;
|
|
949
|
+
}
|
|
950
|
+
current.previous = previous;
|
|
951
|
+
previous.next = current;
|
|
952
|
+
this.__tokens.add(current);
|
|
953
|
+
previous = current;
|
|
954
|
+
}
|
|
955
|
+
return this.__tokens;
|
|
956
|
+
};
|
|
957
|
+
Tokenizer.prototype._is_first_token = function() {
|
|
958
|
+
return this.__tokens.isEmpty();
|
|
959
|
+
};
|
|
960
|
+
Tokenizer.prototype._reset = function() {
|
|
961
|
+
};
|
|
962
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
963
|
+
this._readWhitespace();
|
|
964
|
+
var resulting_string = this._input.read(/.+/g);
|
|
965
|
+
if (resulting_string) {
|
|
966
|
+
return this._create_token(TOKEN.RAW, resulting_string);
|
|
967
|
+
} else {
|
|
968
|
+
return this._create_token(TOKEN.EOF, "");
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
972
|
+
return false;
|
|
973
|
+
};
|
|
974
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
975
|
+
return false;
|
|
976
|
+
};
|
|
977
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
978
|
+
return false;
|
|
979
|
+
};
|
|
980
|
+
Tokenizer.prototype._create_token = function(type, text) {
|
|
981
|
+
var token = new Token(
|
|
982
|
+
type,
|
|
983
|
+
text,
|
|
984
|
+
this._patterns.whitespace.newline_count,
|
|
985
|
+
this._patterns.whitespace.whitespace_before_token
|
|
986
|
+
);
|
|
987
|
+
return token;
|
|
988
|
+
};
|
|
989
|
+
Tokenizer.prototype._readWhitespace = function() {
|
|
990
|
+
return this._patterns.whitespace.read();
|
|
991
|
+
};
|
|
992
|
+
module2.exports.Tokenizer = Tokenizer;
|
|
993
|
+
module2.exports.TOKEN = TOKEN;
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
// node_modules/js-beautify/js/src/core/directives.js
|
|
998
|
+
var require_directives = __commonJS({
|
|
999
|
+
"node_modules/js-beautify/js/src/core/directives.js"(exports2, module2) {
|
|
1000
|
+
"use strict";
|
|
1001
|
+
function Directives(start_block_pattern, end_block_pattern) {
|
|
1002
|
+
start_block_pattern = typeof start_block_pattern === "string" ? start_block_pattern : start_block_pattern.source;
|
|
1003
|
+
end_block_pattern = typeof end_block_pattern === "string" ? end_block_pattern : end_block_pattern.source;
|
|
1004
|
+
this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, "g");
|
|
1005
|
+
this.__directive_pattern = / (\w+)[:](\w+)/g;
|
|
1006
|
+
this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, "g");
|
|
1007
|
+
}
|
|
1008
|
+
Directives.prototype.get_directives = function(text) {
|
|
1009
|
+
if (!text.match(this.__directives_block_pattern)) {
|
|
1010
|
+
return null;
|
|
1011
|
+
}
|
|
1012
|
+
var directives = {};
|
|
1013
|
+
this.__directive_pattern.lastIndex = 0;
|
|
1014
|
+
var directive_match = this.__directive_pattern.exec(text);
|
|
1015
|
+
while (directive_match) {
|
|
1016
|
+
directives[directive_match[1]] = directive_match[2];
|
|
1017
|
+
directive_match = this.__directive_pattern.exec(text);
|
|
1018
|
+
}
|
|
1019
|
+
return directives;
|
|
1020
|
+
};
|
|
1021
|
+
Directives.prototype.readIgnored = function(input) {
|
|
1022
|
+
return input.readUntilAfter(this.__directives_end_ignore_pattern);
|
|
1023
|
+
};
|
|
1024
|
+
module2.exports.Directives = Directives;
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
// node_modules/js-beautify/js/src/core/templatablepattern.js
|
|
1029
|
+
var require_templatablepattern = __commonJS({
|
|
1030
|
+
"node_modules/js-beautify/js/src/core/templatablepattern.js"(exports2, module2) {
|
|
1031
|
+
"use strict";
|
|
1032
|
+
var Pattern = require_pattern().Pattern;
|
|
1033
|
+
var template_names = {
|
|
1034
|
+
django: false,
|
|
1035
|
+
erb: false,
|
|
1036
|
+
handlebars: false,
|
|
1037
|
+
php: false,
|
|
1038
|
+
smarty: false,
|
|
1039
|
+
angular: false
|
|
1040
|
+
};
|
|
1041
|
+
function TemplatablePattern(input_scanner, parent) {
|
|
1042
|
+
Pattern.call(this, input_scanner, parent);
|
|
1043
|
+
this.__template_pattern = null;
|
|
1044
|
+
this._disabled = Object.assign({}, template_names);
|
|
1045
|
+
this._excluded = Object.assign({}, template_names);
|
|
1046
|
+
if (parent) {
|
|
1047
|
+
this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
|
|
1048
|
+
this._excluded = Object.assign(this._excluded, parent._excluded);
|
|
1049
|
+
this._disabled = Object.assign(this._disabled, parent._disabled);
|
|
1050
|
+
}
|
|
1051
|
+
var pattern = new Pattern(input_scanner);
|
|
1052
|
+
this.__patterns = {
|
|
1053
|
+
handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
|
|
1054
|
+
handlebars_unescaped: pattern.starting_with(/{{{/).until_after(/}}}/),
|
|
1055
|
+
handlebars: pattern.starting_with(/{{/).until_after(/}}/),
|
|
1056
|
+
php: pattern.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),
|
|
1057
|
+
erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
|
|
1058
|
+
// django coflicts with handlebars a bit.
|
|
1059
|
+
django: pattern.starting_with(/{%/).until_after(/%}/),
|
|
1060
|
+
django_value: pattern.starting_with(/{{/).until_after(/}}/),
|
|
1061
|
+
django_comment: pattern.starting_with(/{#/).until_after(/#}/),
|
|
1062
|
+
smarty: pattern.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),
|
|
1063
|
+
smarty_comment: pattern.starting_with(/{\*/).until_after(/\*}/),
|
|
1064
|
+
smarty_literal: pattern.starting_with(/{literal}/).until_after(/{\/literal}/)
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
TemplatablePattern.prototype = new Pattern();
|
|
1068
|
+
TemplatablePattern.prototype._create = function() {
|
|
1069
|
+
return new TemplatablePattern(this._input, this);
|
|
1070
|
+
};
|
|
1071
|
+
TemplatablePattern.prototype._update = function() {
|
|
1072
|
+
this.__set_templated_pattern();
|
|
1073
|
+
};
|
|
1074
|
+
TemplatablePattern.prototype.disable = function(language) {
|
|
1075
|
+
var result = this._create();
|
|
1076
|
+
result._disabled[language] = true;
|
|
1077
|
+
result._update();
|
|
1078
|
+
return result;
|
|
1079
|
+
};
|
|
1080
|
+
TemplatablePattern.prototype.read_options = function(options) {
|
|
1081
|
+
var result = this._create();
|
|
1082
|
+
for (var language in template_names) {
|
|
1083
|
+
result._disabled[language] = options.templating.indexOf(language) === -1;
|
|
1084
|
+
}
|
|
1085
|
+
result._update();
|
|
1086
|
+
return result;
|
|
1087
|
+
};
|
|
1088
|
+
TemplatablePattern.prototype.exclude = function(language) {
|
|
1089
|
+
var result = this._create();
|
|
1090
|
+
result._excluded[language] = true;
|
|
1091
|
+
result._update();
|
|
1092
|
+
return result;
|
|
1093
|
+
};
|
|
1094
|
+
TemplatablePattern.prototype.read = function() {
|
|
1095
|
+
var result = "";
|
|
1096
|
+
if (this._match_pattern) {
|
|
1097
|
+
result = this._input.read(this._starting_pattern);
|
|
1098
|
+
} else {
|
|
1099
|
+
result = this._input.read(this._starting_pattern, this.__template_pattern);
|
|
1100
|
+
}
|
|
1101
|
+
var next = this._read_template();
|
|
1102
|
+
while (next) {
|
|
1103
|
+
if (this._match_pattern) {
|
|
1104
|
+
next += this._input.read(this._match_pattern);
|
|
1105
|
+
} else {
|
|
1106
|
+
next += this._input.readUntil(this.__template_pattern);
|
|
1107
|
+
}
|
|
1108
|
+
result += next;
|
|
1109
|
+
next = this._read_template();
|
|
1110
|
+
}
|
|
1111
|
+
if (this._until_after) {
|
|
1112
|
+
result += this._input.readUntilAfter(this._until_pattern);
|
|
1113
|
+
}
|
|
1114
|
+
return result;
|
|
1115
|
+
};
|
|
1116
|
+
TemplatablePattern.prototype.__set_templated_pattern = function() {
|
|
1117
|
+
var items = [];
|
|
1118
|
+
if (!this._disabled.php) {
|
|
1119
|
+
items.push(this.__patterns.php._starting_pattern.source);
|
|
1120
|
+
}
|
|
1121
|
+
if (!this._disabled.handlebars) {
|
|
1122
|
+
items.push(this.__patterns.handlebars._starting_pattern.source);
|
|
1123
|
+
}
|
|
1124
|
+
if (!this._disabled.angular) {
|
|
1125
|
+
items.push(this.__patterns.handlebars._starting_pattern.source);
|
|
1126
|
+
}
|
|
1127
|
+
if (!this._disabled.erb) {
|
|
1128
|
+
items.push(this.__patterns.erb._starting_pattern.source);
|
|
1129
|
+
}
|
|
1130
|
+
if (!this._disabled.django) {
|
|
1131
|
+
items.push(this.__patterns.django._starting_pattern.source);
|
|
1132
|
+
items.push(this.__patterns.django_value._starting_pattern.source);
|
|
1133
|
+
items.push(this.__patterns.django_comment._starting_pattern.source);
|
|
1134
|
+
}
|
|
1135
|
+
if (!this._disabled.smarty) {
|
|
1136
|
+
items.push(this.__patterns.smarty._starting_pattern.source);
|
|
1137
|
+
}
|
|
1138
|
+
if (this._until_pattern) {
|
|
1139
|
+
items.push(this._until_pattern.source);
|
|
1140
|
+
}
|
|
1141
|
+
this.__template_pattern = this._input.get_regexp("(?:" + items.join("|") + ")");
|
|
1142
|
+
};
|
|
1143
|
+
TemplatablePattern.prototype._read_template = function() {
|
|
1144
|
+
var resulting_string = "";
|
|
1145
|
+
var c = this._input.peek();
|
|
1146
|
+
if (c === "<") {
|
|
1147
|
+
var peek1 = this._input.peek(1);
|
|
1148
|
+
if (!this._disabled.php && !this._excluded.php && peek1 === "?") {
|
|
1149
|
+
resulting_string = resulting_string || this.__patterns.php.read();
|
|
1150
|
+
}
|
|
1151
|
+
if (!this._disabled.erb && !this._excluded.erb && peek1 === "%") {
|
|
1152
|
+
resulting_string = resulting_string || this.__patterns.erb.read();
|
|
1153
|
+
}
|
|
1154
|
+
} else if (c === "{") {
|
|
1155
|
+
if (!this._disabled.handlebars && !this._excluded.handlebars) {
|
|
1156
|
+
resulting_string = resulting_string || this.__patterns.handlebars_comment.read();
|
|
1157
|
+
resulting_string = resulting_string || this.__patterns.handlebars_unescaped.read();
|
|
1158
|
+
resulting_string = resulting_string || this.__patterns.handlebars.read();
|
|
1159
|
+
}
|
|
1160
|
+
if (!this._disabled.django) {
|
|
1161
|
+
if (!this._excluded.django && !this._excluded.handlebars) {
|
|
1162
|
+
resulting_string = resulting_string || this.__patterns.django_value.read();
|
|
1163
|
+
}
|
|
1164
|
+
if (!this._excluded.django) {
|
|
1165
|
+
resulting_string = resulting_string || this.__patterns.django_comment.read();
|
|
1166
|
+
resulting_string = resulting_string || this.__patterns.django.read();
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
if (!this._disabled.smarty) {
|
|
1170
|
+
if (this._disabled.django && this._disabled.handlebars) {
|
|
1171
|
+
resulting_string = resulting_string || this.__patterns.smarty_comment.read();
|
|
1172
|
+
resulting_string = resulting_string || this.__patterns.smarty_literal.read();
|
|
1173
|
+
resulting_string = resulting_string || this.__patterns.smarty.read();
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
return resulting_string;
|
|
1178
|
+
};
|
|
1179
|
+
module2.exports.TemplatablePattern = TemplatablePattern;
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
// node_modules/js-beautify/js/src/javascript/tokenizer.js
|
|
1184
|
+
var require_tokenizer2 = __commonJS({
|
|
1185
|
+
"node_modules/js-beautify/js/src/javascript/tokenizer.js"(exports2, module2) {
|
|
1186
|
+
"use strict";
|
|
1187
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
1188
|
+
var BaseTokenizer = require_tokenizer().Tokenizer;
|
|
1189
|
+
var BASETOKEN = require_tokenizer().TOKEN;
|
|
1190
|
+
var Directives = require_directives().Directives;
|
|
1191
|
+
var acorn = require_acorn();
|
|
1192
|
+
var Pattern = require_pattern().Pattern;
|
|
1193
|
+
var TemplatablePattern = require_templatablepattern().TemplatablePattern;
|
|
1194
|
+
function in_array(what, arr) {
|
|
1195
|
+
return arr.indexOf(what) !== -1;
|
|
1196
|
+
}
|
|
1197
|
+
var TOKEN = {
|
|
1198
|
+
START_EXPR: "TK_START_EXPR",
|
|
1199
|
+
END_EXPR: "TK_END_EXPR",
|
|
1200
|
+
START_BLOCK: "TK_START_BLOCK",
|
|
1201
|
+
END_BLOCK: "TK_END_BLOCK",
|
|
1202
|
+
WORD: "TK_WORD",
|
|
1203
|
+
RESERVED: "TK_RESERVED",
|
|
1204
|
+
SEMICOLON: "TK_SEMICOLON",
|
|
1205
|
+
STRING: "TK_STRING",
|
|
1206
|
+
EQUALS: "TK_EQUALS",
|
|
1207
|
+
OPERATOR: "TK_OPERATOR",
|
|
1208
|
+
COMMA: "TK_COMMA",
|
|
1209
|
+
BLOCK_COMMENT: "TK_BLOCK_COMMENT",
|
|
1210
|
+
COMMENT: "TK_COMMENT",
|
|
1211
|
+
DOT: "TK_DOT",
|
|
1212
|
+
UNKNOWN: "TK_UNKNOWN",
|
|
1213
|
+
START: BASETOKEN.START,
|
|
1214
|
+
RAW: BASETOKEN.RAW,
|
|
1215
|
+
EOF: BASETOKEN.EOF
|
|
1216
|
+
};
|
|
1217
|
+
var directives_core = new Directives(/\/\*/, /\*\//);
|
|
1218
|
+
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_]+)?/;
|
|
1219
|
+
var digit = /[0-9]/;
|
|
1220
|
+
var dot_pattern = /[^\d\.]/;
|
|
1221
|
+
var positionable_operators = ">>> === !== &&= ??= ||= << && >= ** != == <= >> || ?? |> < / - + > : & % ? ^ | *".split(" ");
|
|
1222
|
+
var punct = ">>>= ... >>= <<= === >>> !== **= &&= ??= ||= => ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> = ! ? > < : / ^ - + * & % ~ |";
|
|
1223
|
+
punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
|
|
1224
|
+
punct = "\\?\\.(?!\\d) " + punct;
|
|
1225
|
+
punct = punct.replace(/ /g, "|");
|
|
1226
|
+
var punct_pattern = new RegExp(punct);
|
|
1227
|
+
var line_starters = "continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export".split(",");
|
|
1228
|
+
var reserved_words = line_starters.concat(["do", "in", "of", "else", "get", "set", "new", "catch", "finally", "typeof", "yield", "async", "await", "from", "as", "class", "extends"]);
|
|
1229
|
+
var reserved_word_pattern = new RegExp("^(?:" + reserved_words.join("|") + ")$");
|
|
1230
|
+
var in_html_comment;
|
|
1231
|
+
var Tokenizer = function(input_string, options) {
|
|
1232
|
+
BaseTokenizer.call(this, input_string, options);
|
|
1233
|
+
this._patterns.whitespace = this._patterns.whitespace.matching(
|
|
1234
|
+
/\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
|
|
1235
|
+
/\u2028\u2029/.source
|
|
1236
|
+
);
|
|
1237
|
+
var pattern_reader = new Pattern(this._input);
|
|
1238
|
+
var templatable = new TemplatablePattern(this._input).read_options(this._options);
|
|
1239
|
+
this.__patterns = {
|
|
1240
|
+
template: templatable,
|
|
1241
|
+
identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
|
|
1242
|
+
number: pattern_reader.matching(number_pattern),
|
|
1243
|
+
punct: pattern_reader.matching(punct_pattern),
|
|
1244
|
+
// comment ends just before nearest linefeed or end of file
|
|
1245
|
+
comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
|
|
1246
|
+
// /* ... */ comment ends with nearest */ or end of file
|
|
1247
|
+
block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
|
|
1248
|
+
html_comment_start: pattern_reader.matching(/<!--/),
|
|
1249
|
+
html_comment_end: pattern_reader.matching(/-->/),
|
|
1250
|
+
include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
|
|
1251
|
+
shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
|
|
1252
|
+
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*>/),
|
|
1253
|
+
single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
|
|
1254
|
+
double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
|
|
1255
|
+
template_text: templatable.until(/[`\\$]/),
|
|
1256
|
+
template_expression: templatable.until(/[`}\\]/)
|
|
1257
|
+
};
|
|
1258
|
+
};
|
|
1259
|
+
Tokenizer.prototype = new BaseTokenizer();
|
|
1260
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
1261
|
+
return current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.BLOCK_COMMENT || current_token.type === TOKEN.UNKNOWN;
|
|
1262
|
+
};
|
|
1263
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
1264
|
+
return current_token.type === TOKEN.START_BLOCK || current_token.type === TOKEN.START_EXPR;
|
|
1265
|
+
};
|
|
1266
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
1267
|
+
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 === "{"));
|
|
1268
|
+
};
|
|
1269
|
+
Tokenizer.prototype._reset = function() {
|
|
1270
|
+
in_html_comment = false;
|
|
1271
|
+
};
|
|
1272
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
1273
|
+
var token = null;
|
|
1274
|
+
this._readWhitespace();
|
|
1275
|
+
var c = this._input.peek();
|
|
1276
|
+
if (c === null) {
|
|
1277
|
+
return this._create_token(TOKEN.EOF, "");
|
|
1278
|
+
}
|
|
1279
|
+
token = token || this._read_non_javascript(c);
|
|
1280
|
+
token = token || this._read_string(c);
|
|
1281
|
+
token = token || this._read_pair(c, this._input.peek(1));
|
|
1282
|
+
token = token || this._read_word(previous_token);
|
|
1283
|
+
token = token || this._read_singles(c);
|
|
1284
|
+
token = token || this._read_comment(c);
|
|
1285
|
+
token = token || this._read_regexp(c, previous_token);
|
|
1286
|
+
token = token || this._read_xml(c, previous_token);
|
|
1287
|
+
token = token || this._read_punctuation();
|
|
1288
|
+
token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
|
|
1289
|
+
return token;
|
|
1290
|
+
};
|
|
1291
|
+
Tokenizer.prototype._read_word = function(previous_token) {
|
|
1292
|
+
var resulting_string;
|
|
1293
|
+
resulting_string = this.__patterns.identifier.read();
|
|
1294
|
+
if (resulting_string !== "") {
|
|
1295
|
+
resulting_string = resulting_string.replace(acorn.allLineBreaks, "\n");
|
|
1296
|
+
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)) {
|
|
1297
|
+
if ((resulting_string === "in" || resulting_string === "of") && (previous_token.type === TOKEN.WORD || previous_token.type === TOKEN.STRING)) {
|
|
1298
|
+
return this._create_token(TOKEN.OPERATOR, resulting_string);
|
|
1299
|
+
}
|
|
1300
|
+
return this._create_token(TOKEN.RESERVED, resulting_string);
|
|
1301
|
+
}
|
|
1302
|
+
return this._create_token(TOKEN.WORD, resulting_string);
|
|
1303
|
+
}
|
|
1304
|
+
resulting_string = this.__patterns.number.read();
|
|
1305
|
+
if (resulting_string !== "") {
|
|
1306
|
+
return this._create_token(TOKEN.WORD, resulting_string);
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
Tokenizer.prototype._read_singles = function(c) {
|
|
1310
|
+
var token = null;
|
|
1311
|
+
if (c === "(" || c === "[") {
|
|
1312
|
+
token = this._create_token(TOKEN.START_EXPR, c);
|
|
1313
|
+
} else if (c === ")" || c === "]") {
|
|
1314
|
+
token = this._create_token(TOKEN.END_EXPR, c);
|
|
1315
|
+
} else if (c === "{") {
|
|
1316
|
+
token = this._create_token(TOKEN.START_BLOCK, c);
|
|
1317
|
+
} else if (c === "}") {
|
|
1318
|
+
token = this._create_token(TOKEN.END_BLOCK, c);
|
|
1319
|
+
} else if (c === ";") {
|
|
1320
|
+
token = this._create_token(TOKEN.SEMICOLON, c);
|
|
1321
|
+
} else if (c === "." && dot_pattern.test(this._input.peek(1))) {
|
|
1322
|
+
token = this._create_token(TOKEN.DOT, c);
|
|
1323
|
+
} else if (c === ",") {
|
|
1324
|
+
token = this._create_token(TOKEN.COMMA, c);
|
|
1325
|
+
}
|
|
1326
|
+
if (token) {
|
|
1327
|
+
this._input.next();
|
|
1328
|
+
}
|
|
1329
|
+
return token;
|
|
1330
|
+
};
|
|
1331
|
+
Tokenizer.prototype._read_pair = function(c, d) {
|
|
1332
|
+
var token = null;
|
|
1333
|
+
if (c === "#" && d === "{") {
|
|
1334
|
+
token = this._create_token(TOKEN.START_BLOCK, c + d);
|
|
1335
|
+
}
|
|
1336
|
+
if (token) {
|
|
1337
|
+
this._input.next();
|
|
1338
|
+
this._input.next();
|
|
1339
|
+
}
|
|
1340
|
+
return token;
|
|
1341
|
+
};
|
|
1342
|
+
Tokenizer.prototype._read_punctuation = function() {
|
|
1343
|
+
var resulting_string = this.__patterns.punct.read();
|
|
1344
|
+
if (resulting_string !== "") {
|
|
1345
|
+
if (resulting_string === "=") {
|
|
1346
|
+
return this._create_token(TOKEN.EQUALS, resulting_string);
|
|
1347
|
+
} else if (resulting_string === "?.") {
|
|
1348
|
+
return this._create_token(TOKEN.DOT, resulting_string);
|
|
1349
|
+
} else {
|
|
1350
|
+
return this._create_token(TOKEN.OPERATOR, resulting_string);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
Tokenizer.prototype._read_non_javascript = function(c) {
|
|
1355
|
+
var resulting_string = "";
|
|
1356
|
+
if (c === "#") {
|
|
1357
|
+
if (this._is_first_token()) {
|
|
1358
|
+
resulting_string = this.__patterns.shebang.read();
|
|
1359
|
+
if (resulting_string) {
|
|
1360
|
+
return this._create_token(TOKEN.UNKNOWN, resulting_string.trim() + "\n");
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
resulting_string = this.__patterns.include.read();
|
|
1364
|
+
if (resulting_string) {
|
|
1365
|
+
return this._create_token(TOKEN.UNKNOWN, resulting_string.trim() + "\n");
|
|
1366
|
+
}
|
|
1367
|
+
c = this._input.next();
|
|
1368
|
+
var sharp = "#";
|
|
1369
|
+
if (this._input.hasNext() && this._input.testChar(digit)) {
|
|
1370
|
+
do {
|
|
1371
|
+
c = this._input.next();
|
|
1372
|
+
sharp += c;
|
|
1373
|
+
} while (this._input.hasNext() && c !== "#" && c !== "=");
|
|
1374
|
+
if (c === "#") {
|
|
1375
|
+
} else if (this._input.peek() === "[" && this._input.peek(1) === "]") {
|
|
1376
|
+
sharp += "[]";
|
|
1377
|
+
this._input.next();
|
|
1378
|
+
this._input.next();
|
|
1379
|
+
} else if (this._input.peek() === "{" && this._input.peek(1) === "}") {
|
|
1380
|
+
sharp += "{}";
|
|
1381
|
+
this._input.next();
|
|
1382
|
+
this._input.next();
|
|
1383
|
+
}
|
|
1384
|
+
return this._create_token(TOKEN.WORD, sharp);
|
|
1385
|
+
}
|
|
1386
|
+
this._input.back();
|
|
1387
|
+
} else if (c === "<" && this._is_first_token()) {
|
|
1388
|
+
resulting_string = this.__patterns.html_comment_start.read();
|
|
1389
|
+
if (resulting_string) {
|
|
1390
|
+
while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
|
|
1391
|
+
resulting_string += this._input.next();
|
|
1392
|
+
}
|
|
1393
|
+
in_html_comment = true;
|
|
1394
|
+
return this._create_token(TOKEN.COMMENT, resulting_string);
|
|
1395
|
+
}
|
|
1396
|
+
} else if (in_html_comment && c === "-") {
|
|
1397
|
+
resulting_string = this.__patterns.html_comment_end.read();
|
|
1398
|
+
if (resulting_string) {
|
|
1399
|
+
in_html_comment = false;
|
|
1400
|
+
return this._create_token(TOKEN.COMMENT, resulting_string);
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
return null;
|
|
1404
|
+
};
|
|
1405
|
+
Tokenizer.prototype._read_comment = function(c) {
|
|
1406
|
+
var token = null;
|
|
1407
|
+
if (c === "/") {
|
|
1408
|
+
var comment = "";
|
|
1409
|
+
if (this._input.peek(1) === "*") {
|
|
1410
|
+
comment = this.__patterns.block_comment.read();
|
|
1411
|
+
var directives = directives_core.get_directives(comment);
|
|
1412
|
+
if (directives && directives.ignore === "start") {
|
|
1413
|
+
comment += directives_core.readIgnored(this._input);
|
|
1414
|
+
}
|
|
1415
|
+
comment = comment.replace(acorn.allLineBreaks, "\n");
|
|
1416
|
+
token = this._create_token(TOKEN.BLOCK_COMMENT, comment);
|
|
1417
|
+
token.directives = directives;
|
|
1418
|
+
} else if (this._input.peek(1) === "/") {
|
|
1419
|
+
comment = this.__patterns.comment.read();
|
|
1420
|
+
token = this._create_token(TOKEN.COMMENT, comment);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
return token;
|
|
1424
|
+
};
|
|
1425
|
+
Tokenizer.prototype._read_string = function(c) {
|
|
1426
|
+
if (c === "`" || c === "'" || c === '"') {
|
|
1427
|
+
var resulting_string = this._input.next();
|
|
1428
|
+
this.has_char_escapes = false;
|
|
1429
|
+
if (c === "`") {
|
|
1430
|
+
resulting_string += this._read_string_recursive("`", true, "${");
|
|
1431
|
+
} else {
|
|
1432
|
+
resulting_string += this._read_string_recursive(c);
|
|
1433
|
+
}
|
|
1434
|
+
if (this.has_char_escapes && this._options.unescape_strings) {
|
|
1435
|
+
resulting_string = unescape_string(resulting_string);
|
|
1436
|
+
}
|
|
1437
|
+
if (this._input.peek() === c) {
|
|
1438
|
+
resulting_string += this._input.next();
|
|
1439
|
+
}
|
|
1440
|
+
resulting_string = resulting_string.replace(acorn.allLineBreaks, "\n");
|
|
1441
|
+
return this._create_token(TOKEN.STRING, resulting_string);
|
|
1442
|
+
}
|
|
1443
|
+
return null;
|
|
1444
|
+
};
|
|
1445
|
+
Tokenizer.prototype._allow_regexp_or_xml = function(previous_token) {
|
|
1446
|
+
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, [
|
|
1447
|
+
TOKEN.COMMENT,
|
|
1448
|
+
TOKEN.START_EXPR,
|
|
1449
|
+
TOKEN.START_BLOCK,
|
|
1450
|
+
TOKEN.START,
|
|
1451
|
+
TOKEN.END_BLOCK,
|
|
1452
|
+
TOKEN.OPERATOR,
|
|
1453
|
+
TOKEN.EQUALS,
|
|
1454
|
+
TOKEN.EOF,
|
|
1455
|
+
TOKEN.SEMICOLON,
|
|
1456
|
+
TOKEN.COMMA
|
|
1457
|
+
]);
|
|
1458
|
+
};
|
|
1459
|
+
Tokenizer.prototype._read_regexp = function(c, previous_token) {
|
|
1460
|
+
if (c === "/" && this._allow_regexp_or_xml(previous_token)) {
|
|
1461
|
+
var resulting_string = this._input.next();
|
|
1462
|
+
var esc = false;
|
|
1463
|
+
var in_char_class = false;
|
|
1464
|
+
while (this._input.hasNext() && ((esc || in_char_class || this._input.peek() !== c) && !this._input.testChar(acorn.newline))) {
|
|
1465
|
+
resulting_string += this._input.peek();
|
|
1466
|
+
if (!esc) {
|
|
1467
|
+
esc = this._input.peek() === "\\";
|
|
1468
|
+
if (this._input.peek() === "[") {
|
|
1469
|
+
in_char_class = true;
|
|
1470
|
+
} else if (this._input.peek() === "]") {
|
|
1471
|
+
in_char_class = false;
|
|
1472
|
+
}
|
|
1473
|
+
} else {
|
|
1474
|
+
esc = false;
|
|
1475
|
+
}
|
|
1476
|
+
this._input.next();
|
|
1477
|
+
}
|
|
1478
|
+
if (this._input.peek() === c) {
|
|
1479
|
+
resulting_string += this._input.next();
|
|
1480
|
+
resulting_string += this._input.read(acorn.identifier);
|
|
1481
|
+
}
|
|
1482
|
+
return this._create_token(TOKEN.STRING, resulting_string);
|
|
1483
|
+
}
|
|
1484
|
+
return null;
|
|
1485
|
+
};
|
|
1486
|
+
Tokenizer.prototype._read_xml = function(c, previous_token) {
|
|
1487
|
+
if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
|
|
1488
|
+
var xmlStr = "";
|
|
1489
|
+
var match = this.__patterns.xml.read_match();
|
|
1490
|
+
if (match) {
|
|
1491
|
+
var rootTag = match[2].replace(/^{\s+/, "{").replace(/\s+}$/, "}");
|
|
1492
|
+
var isCurlyRoot = rootTag.indexOf("{") === 0;
|
|
1493
|
+
var depth = 0;
|
|
1494
|
+
while (match) {
|
|
1495
|
+
var isEndTag = !!match[1];
|
|
1496
|
+
var tagName = match[2];
|
|
1497
|
+
var isSingletonTag = !!match[match.length - 1] || tagName.slice(0, 8) === "![CDATA[";
|
|
1498
|
+
if (!isSingletonTag && (tagName === rootTag || isCurlyRoot && tagName.replace(/^{\s+/, "{").replace(/\s+}$/, "}"))) {
|
|
1499
|
+
if (isEndTag) {
|
|
1500
|
+
--depth;
|
|
1501
|
+
} else {
|
|
1502
|
+
++depth;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
xmlStr += match[0];
|
|
1506
|
+
if (depth <= 0) {
|
|
1507
|
+
break;
|
|
1508
|
+
}
|
|
1509
|
+
match = this.__patterns.xml.read_match();
|
|
1510
|
+
}
|
|
1511
|
+
if (!match) {
|
|
1512
|
+
xmlStr += this._input.match(/[\s\S]*/g)[0];
|
|
1513
|
+
}
|
|
1514
|
+
xmlStr = xmlStr.replace(acorn.allLineBreaks, "\n");
|
|
1515
|
+
return this._create_token(TOKEN.STRING, xmlStr);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
return null;
|
|
1519
|
+
};
|
|
1520
|
+
function unescape_string(s) {
|
|
1521
|
+
var out = "", escaped = 0;
|
|
1522
|
+
var input_scan = new InputScanner(s);
|
|
1523
|
+
var matched = null;
|
|
1524
|
+
while (input_scan.hasNext()) {
|
|
1525
|
+
matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
|
|
1526
|
+
if (matched) {
|
|
1527
|
+
out += matched[0];
|
|
1528
|
+
}
|
|
1529
|
+
if (input_scan.peek() === "\\") {
|
|
1530
|
+
input_scan.next();
|
|
1531
|
+
if (input_scan.peek() === "x") {
|
|
1532
|
+
matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
|
|
1533
|
+
} else if (input_scan.peek() === "u") {
|
|
1534
|
+
matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
|
|
1535
|
+
if (!matched) {
|
|
1536
|
+
matched = input_scan.match(/u\{([0-9A-Fa-f]+)\}/g);
|
|
1537
|
+
}
|
|
1538
|
+
} else {
|
|
1539
|
+
out += "\\";
|
|
1540
|
+
if (input_scan.hasNext()) {
|
|
1541
|
+
out += input_scan.next();
|
|
1542
|
+
}
|
|
1543
|
+
continue;
|
|
1544
|
+
}
|
|
1545
|
+
if (!matched) {
|
|
1546
|
+
return s;
|
|
1547
|
+
}
|
|
1548
|
+
escaped = parseInt(matched[1], 16);
|
|
1549
|
+
if (escaped > 126 && escaped <= 255 && matched[0].indexOf("x") === 0) {
|
|
1550
|
+
return s;
|
|
1551
|
+
} else if (escaped >= 0 && escaped < 32) {
|
|
1552
|
+
out += "\\" + matched[0];
|
|
1553
|
+
} else if (escaped > 1114111) {
|
|
1554
|
+
out += "\\" + matched[0];
|
|
1555
|
+
} else if (escaped === 34 || escaped === 39 || escaped === 92) {
|
|
1556
|
+
out += "\\" + String.fromCharCode(escaped);
|
|
1557
|
+
} else {
|
|
1558
|
+
out += String.fromCharCode(escaped);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
return out;
|
|
1563
|
+
}
|
|
1564
|
+
Tokenizer.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
|
|
1565
|
+
var current_char;
|
|
1566
|
+
var pattern;
|
|
1567
|
+
if (delimiter === "'") {
|
|
1568
|
+
pattern = this.__patterns.single_quote;
|
|
1569
|
+
} else if (delimiter === '"') {
|
|
1570
|
+
pattern = this.__patterns.double_quote;
|
|
1571
|
+
} else if (delimiter === "`") {
|
|
1572
|
+
pattern = this.__patterns.template_text;
|
|
1573
|
+
} else if (delimiter === "}") {
|
|
1574
|
+
pattern = this.__patterns.template_expression;
|
|
1575
|
+
}
|
|
1576
|
+
var resulting_string = pattern.read();
|
|
1577
|
+
var next = "";
|
|
1578
|
+
while (this._input.hasNext()) {
|
|
1579
|
+
next = this._input.next();
|
|
1580
|
+
if (next === delimiter || !allow_unescaped_newlines && acorn.newline.test(next)) {
|
|
1581
|
+
this._input.back();
|
|
1582
|
+
break;
|
|
1583
|
+
} else if (next === "\\" && this._input.hasNext()) {
|
|
1584
|
+
current_char = this._input.peek();
|
|
1585
|
+
if (current_char === "x" || current_char === "u") {
|
|
1586
|
+
this.has_char_escapes = true;
|
|
1587
|
+
} else if (current_char === "\r" && this._input.peek(1) === "\n") {
|
|
1588
|
+
this._input.next();
|
|
1589
|
+
}
|
|
1590
|
+
next += this._input.next();
|
|
1591
|
+
} else if (start_sub) {
|
|
1592
|
+
if (start_sub === "${" && next === "$" && this._input.peek() === "{") {
|
|
1593
|
+
next += this._input.next();
|
|
1594
|
+
}
|
|
1595
|
+
if (start_sub === next) {
|
|
1596
|
+
if (delimiter === "`") {
|
|
1597
|
+
next += this._read_string_recursive("}", allow_unescaped_newlines, "`");
|
|
1598
|
+
} else {
|
|
1599
|
+
next += this._read_string_recursive("`", allow_unescaped_newlines, "${");
|
|
1600
|
+
}
|
|
1601
|
+
if (this._input.hasNext()) {
|
|
1602
|
+
next += this._input.next();
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
next += pattern.read();
|
|
1607
|
+
resulting_string += next;
|
|
1608
|
+
}
|
|
1609
|
+
return resulting_string;
|
|
1610
|
+
};
|
|
1611
|
+
module2.exports.Tokenizer = Tokenizer;
|
|
1612
|
+
module2.exports.TOKEN = TOKEN;
|
|
1613
|
+
module2.exports.positionable_operators = positionable_operators.slice();
|
|
1614
|
+
module2.exports.line_starters = line_starters.slice();
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
|
|
1618
|
+
// node_modules/js-beautify/js/src/javascript/beautifier.js
|
|
1619
|
+
var require_beautifier = __commonJS({
|
|
1620
|
+
"node_modules/js-beautify/js/src/javascript/beautifier.js"(exports2, module2) {
|
|
1621
|
+
"use strict";
|
|
1622
|
+
var Output = require_output().Output;
|
|
1623
|
+
var Token = require_token().Token;
|
|
1624
|
+
var acorn = require_acorn();
|
|
1625
|
+
var Options = require_options2().Options;
|
|
1626
|
+
var Tokenizer = require_tokenizer2().Tokenizer;
|
|
1627
|
+
var line_starters = require_tokenizer2().line_starters;
|
|
1628
|
+
var positionable_operators = require_tokenizer2().positionable_operators;
|
|
1629
|
+
var TOKEN = require_tokenizer2().TOKEN;
|
|
1630
|
+
function in_array(what, arr) {
|
|
1631
|
+
return arr.indexOf(what) !== -1;
|
|
1632
|
+
}
|
|
1633
|
+
function ltrim(s) {
|
|
1634
|
+
return s.replace(/^\s+/g, "");
|
|
1635
|
+
}
|
|
1636
|
+
function generateMapFromStrings(list) {
|
|
1637
|
+
var result = {};
|
|
1638
|
+
for (var x = 0; x < list.length; x++) {
|
|
1639
|
+
result[list[x].replace(/-/g, "_")] = list[x];
|
|
1640
|
+
}
|
|
1641
|
+
return result;
|
|
1642
|
+
}
|
|
1643
|
+
function reserved_word(token, word) {
|
|
1644
|
+
return token && token.type === TOKEN.RESERVED && token.text === word;
|
|
1645
|
+
}
|
|
1646
|
+
function reserved_array(token, words) {
|
|
1647
|
+
return token && token.type === TOKEN.RESERVED && in_array(token.text, words);
|
|
1648
|
+
}
|
|
1649
|
+
var special_words = ["case", "return", "do", "if", "throw", "else", "await", "break", "continue", "async"];
|
|
1650
|
+
var validPositionValues = ["before-newline", "after-newline", "preserve-newline"];
|
|
1651
|
+
var OPERATOR_POSITION = generateMapFromStrings(validPositionValues);
|
|
1652
|
+
var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
|
|
1653
|
+
var MODE = {
|
|
1654
|
+
BlockStatement: "BlockStatement",
|
|
1655
|
+
// 'BLOCK'
|
|
1656
|
+
Statement: "Statement",
|
|
1657
|
+
// 'STATEMENT'
|
|
1658
|
+
ObjectLiteral: "ObjectLiteral",
|
|
1659
|
+
// 'OBJECT',
|
|
1660
|
+
ArrayLiteral: "ArrayLiteral",
|
|
1661
|
+
//'[EXPRESSION]',
|
|
1662
|
+
ForInitializer: "ForInitializer",
|
|
1663
|
+
//'(FOR-EXPRESSION)',
|
|
1664
|
+
Conditional: "Conditional",
|
|
1665
|
+
//'(COND-EXPRESSION)',
|
|
1666
|
+
Expression: "Expression"
|
|
1667
|
+
//'(EXPRESSION)'
|
|
1668
|
+
};
|
|
1669
|
+
function remove_redundant_indentation(output, frame) {
|
|
1670
|
+
if (frame.multiline_frame || frame.mode === MODE.ForInitializer || frame.mode === MODE.Conditional) {
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
output.remove_indent(frame.start_line_index);
|
|
1674
|
+
}
|
|
1675
|
+
function split_linebreaks(s) {
|
|
1676
|
+
s = s.replace(acorn.allLineBreaks, "\n");
|
|
1677
|
+
var out = [], idx = s.indexOf("\n");
|
|
1678
|
+
while (idx !== -1) {
|
|
1679
|
+
out.push(s.substring(0, idx));
|
|
1680
|
+
s = s.substring(idx + 1);
|
|
1681
|
+
idx = s.indexOf("\n");
|
|
1682
|
+
}
|
|
1683
|
+
if (s.length) {
|
|
1684
|
+
out.push(s);
|
|
1685
|
+
}
|
|
1686
|
+
return out;
|
|
1687
|
+
}
|
|
1688
|
+
function is_array(mode) {
|
|
1689
|
+
return mode === MODE.ArrayLiteral;
|
|
1690
|
+
}
|
|
1691
|
+
function is_expression(mode) {
|
|
1692
|
+
return in_array(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
|
|
1693
|
+
}
|
|
1694
|
+
function all_lines_start_with(lines, c) {
|
|
1695
|
+
for (var i = 0; i < lines.length; i++) {
|
|
1696
|
+
var line = lines[i].trim();
|
|
1697
|
+
if (line.charAt(0) !== c) {
|
|
1698
|
+
return false;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
return true;
|
|
1702
|
+
}
|
|
1703
|
+
function each_line_matches_indent(lines, indent) {
|
|
1704
|
+
var i = 0, len = lines.length, line;
|
|
1705
|
+
for (; i < len; i++) {
|
|
1706
|
+
line = lines[i];
|
|
1707
|
+
if (line && line.indexOf(indent) !== 0) {
|
|
1708
|
+
return false;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
return true;
|
|
1712
|
+
}
|
|
1713
|
+
function Beautifier(source_text, options) {
|
|
1714
|
+
options = options || {};
|
|
1715
|
+
this._source_text = source_text || "";
|
|
1716
|
+
this._output = null;
|
|
1717
|
+
this._tokens = null;
|
|
1718
|
+
this._last_last_text = null;
|
|
1719
|
+
this._flags = null;
|
|
1720
|
+
this._previous_flags = null;
|
|
1721
|
+
this._flag_store = null;
|
|
1722
|
+
this._options = new Options(options);
|
|
1723
|
+
}
|
|
1724
|
+
Beautifier.prototype.create_flags = function(flags_base, mode) {
|
|
1725
|
+
var next_indent_level = 0;
|
|
1726
|
+
if (flags_base) {
|
|
1727
|
+
next_indent_level = flags_base.indentation_level;
|
|
1728
|
+
if (!this._output.just_added_newline() && flags_base.line_indent_level > next_indent_level) {
|
|
1729
|
+
next_indent_level = flags_base.line_indent_level;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
var next_flags = {
|
|
1733
|
+
mode,
|
|
1734
|
+
parent: flags_base,
|
|
1735
|
+
last_token: flags_base ? flags_base.last_token : new Token(TOKEN.START_BLOCK, ""),
|
|
1736
|
+
// last token text
|
|
1737
|
+
last_word: flags_base ? flags_base.last_word : "",
|
|
1738
|
+
// last TOKEN.WORD passed
|
|
1739
|
+
declaration_statement: false,
|
|
1740
|
+
declaration_assignment: false,
|
|
1741
|
+
multiline_frame: false,
|
|
1742
|
+
inline_frame: false,
|
|
1743
|
+
if_block: false,
|
|
1744
|
+
else_block: false,
|
|
1745
|
+
class_start_block: false,
|
|
1746
|
+
// class A { INSIDE HERE } or class B extends C { INSIDE HERE }
|
|
1747
|
+
do_block: false,
|
|
1748
|
+
do_while: false,
|
|
1749
|
+
import_block: false,
|
|
1750
|
+
in_case_statement: false,
|
|
1751
|
+
// switch(..){ INSIDE HERE }
|
|
1752
|
+
in_case: false,
|
|
1753
|
+
// we're on the exact line with "case 0:"
|
|
1754
|
+
case_body: false,
|
|
1755
|
+
// the indented case-action block
|
|
1756
|
+
case_block: false,
|
|
1757
|
+
// the indented case-action block is wrapped with {}
|
|
1758
|
+
indentation_level: next_indent_level,
|
|
1759
|
+
alignment: 0,
|
|
1760
|
+
line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
|
|
1761
|
+
start_line_index: this._output.get_line_number(),
|
|
1762
|
+
ternary_depth: 0
|
|
1763
|
+
};
|
|
1764
|
+
return next_flags;
|
|
1765
|
+
};
|
|
1766
|
+
Beautifier.prototype._reset = function(source_text) {
|
|
1767
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
1768
|
+
this._last_last_text = "";
|
|
1769
|
+
this._output = new Output(this._options, baseIndentString);
|
|
1770
|
+
this._output.raw = this._options.test_output_raw;
|
|
1771
|
+
this._flag_store = [];
|
|
1772
|
+
this.set_mode(MODE.BlockStatement);
|
|
1773
|
+
var tokenizer = new Tokenizer(source_text, this._options);
|
|
1774
|
+
this._tokens = tokenizer.tokenize();
|
|
1775
|
+
return source_text;
|
|
1776
|
+
};
|
|
1777
|
+
Beautifier.prototype.beautify = function() {
|
|
1778
|
+
if (this._options.disabled) {
|
|
1779
|
+
return this._source_text;
|
|
1780
|
+
}
|
|
1781
|
+
var sweet_code;
|
|
1782
|
+
var source_text = this._reset(this._source_text);
|
|
1783
|
+
var eol = this._options.eol;
|
|
1784
|
+
if (this._options.eol === "auto") {
|
|
1785
|
+
eol = "\n";
|
|
1786
|
+
if (source_text && acorn.lineBreak.test(source_text || "")) {
|
|
1787
|
+
eol = source_text.match(acorn.lineBreak)[0];
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
var current_token = this._tokens.next();
|
|
1791
|
+
while (current_token) {
|
|
1792
|
+
this.handle_token(current_token);
|
|
1793
|
+
this._last_last_text = this._flags.last_token.text;
|
|
1794
|
+
this._flags.last_token = current_token;
|
|
1795
|
+
current_token = this._tokens.next();
|
|
1796
|
+
}
|
|
1797
|
+
sweet_code = this._output.get_code(eol);
|
|
1798
|
+
return sweet_code;
|
|
1799
|
+
};
|
|
1800
|
+
Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
|
|
1801
|
+
if (current_token.type === TOKEN.START_EXPR) {
|
|
1802
|
+
this.handle_start_expr(current_token);
|
|
1803
|
+
} else if (current_token.type === TOKEN.END_EXPR) {
|
|
1804
|
+
this.handle_end_expr(current_token);
|
|
1805
|
+
} else if (current_token.type === TOKEN.START_BLOCK) {
|
|
1806
|
+
this.handle_start_block(current_token);
|
|
1807
|
+
} else if (current_token.type === TOKEN.END_BLOCK) {
|
|
1808
|
+
this.handle_end_block(current_token);
|
|
1809
|
+
} else if (current_token.type === TOKEN.WORD) {
|
|
1810
|
+
this.handle_word(current_token);
|
|
1811
|
+
} else if (current_token.type === TOKEN.RESERVED) {
|
|
1812
|
+
this.handle_word(current_token);
|
|
1813
|
+
} else if (current_token.type === TOKEN.SEMICOLON) {
|
|
1814
|
+
this.handle_semicolon(current_token);
|
|
1815
|
+
} else if (current_token.type === TOKEN.STRING) {
|
|
1816
|
+
this.handle_string(current_token);
|
|
1817
|
+
} else if (current_token.type === TOKEN.EQUALS) {
|
|
1818
|
+
this.handle_equals(current_token);
|
|
1819
|
+
} else if (current_token.type === TOKEN.OPERATOR) {
|
|
1820
|
+
this.handle_operator(current_token);
|
|
1821
|
+
} else if (current_token.type === TOKEN.COMMA) {
|
|
1822
|
+
this.handle_comma(current_token);
|
|
1823
|
+
} else if (current_token.type === TOKEN.BLOCK_COMMENT) {
|
|
1824
|
+
this.handle_block_comment(current_token, preserve_statement_flags);
|
|
1825
|
+
} else if (current_token.type === TOKEN.COMMENT) {
|
|
1826
|
+
this.handle_comment(current_token, preserve_statement_flags);
|
|
1827
|
+
} else if (current_token.type === TOKEN.DOT) {
|
|
1828
|
+
this.handle_dot(current_token);
|
|
1829
|
+
} else if (current_token.type === TOKEN.EOF) {
|
|
1830
|
+
this.handle_eof(current_token);
|
|
1831
|
+
} else if (current_token.type === TOKEN.UNKNOWN) {
|
|
1832
|
+
this.handle_unknown(current_token, preserve_statement_flags);
|
|
1833
|
+
} else {
|
|
1834
|
+
this.handle_unknown(current_token, preserve_statement_flags);
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
|
|
1838
|
+
var newlines = current_token.newlines;
|
|
1839
|
+
var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
|
|
1840
|
+
if (current_token.comments_before) {
|
|
1841
|
+
var comment_token = current_token.comments_before.next();
|
|
1842
|
+
while (comment_token) {
|
|
1843
|
+
this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
|
|
1844
|
+
this.handle_token(comment_token, preserve_statement_flags);
|
|
1845
|
+
comment_token = current_token.comments_before.next();
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
if (keep_whitespace) {
|
|
1849
|
+
for (var i = 0; i < newlines; i += 1) {
|
|
1850
|
+
this.print_newline(i > 0, preserve_statement_flags);
|
|
1851
|
+
}
|
|
1852
|
+
} else {
|
|
1853
|
+
if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
|
|
1854
|
+
newlines = this._options.max_preserve_newlines;
|
|
1855
|
+
}
|
|
1856
|
+
if (this._options.preserve_newlines) {
|
|
1857
|
+
if (newlines > 1) {
|
|
1858
|
+
this.print_newline(false, preserve_statement_flags);
|
|
1859
|
+
for (var j = 1; j < newlines; j += 1) {
|
|
1860
|
+
this.print_newline(true, preserve_statement_flags);
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1866
|
+
var newline_restricted_tokens = ["async", "break", "continue", "return", "throw", "yield"];
|
|
1867
|
+
Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
|
|
1868
|
+
force_linewrap = force_linewrap === void 0 ? false : force_linewrap;
|
|
1869
|
+
if (this._output.just_added_newline()) {
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
var shouldPreserveOrForce = this._options.preserve_newlines && current_token.newlines || force_linewrap;
|
|
1873
|
+
var operatorLogicApplies = in_array(this._flags.last_token.text, positionable_operators) || in_array(current_token.text, positionable_operators);
|
|
1874
|
+
if (operatorLogicApplies) {
|
|
1875
|
+
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);
|
|
1876
|
+
shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
|
|
1877
|
+
}
|
|
1878
|
+
if (shouldPreserveOrForce) {
|
|
1879
|
+
this.print_newline(false, true);
|
|
1880
|
+
} else if (this._options.wrap_line_length) {
|
|
1881
|
+
if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
this._output.set_wrap_point();
|
|
1885
|
+
}
|
|
1886
|
+
};
|
|
1887
|
+
Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
|
|
1888
|
+
if (!preserve_statement_flags) {
|
|
1889
|
+
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 === "++")) {
|
|
1890
|
+
var next_token = this._tokens.peek();
|
|
1891
|
+
while (this._flags.mode === MODE.Statement && !(this._flags.if_block && reserved_word(next_token, "else")) && !this._flags.do_block) {
|
|
1892
|
+
this.restore_mode();
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
if (this._output.add_new_line(force_newline)) {
|
|
1897
|
+
this._flags.multiline_frame = true;
|
|
1898
|
+
}
|
|
1899
|
+
};
|
|
1900
|
+
Beautifier.prototype.print_token_line_indentation = function(current_token) {
|
|
1901
|
+
if (this._output.just_added_newline()) {
|
|
1902
|
+
if (this._options.keep_array_indentation && current_token.newlines && (current_token.text === "[" || is_array(this._flags.mode))) {
|
|
1903
|
+
this._output.current_line.set_indent(-1);
|
|
1904
|
+
this._output.current_line.push(current_token.whitespace_before);
|
|
1905
|
+
this._output.space_before_token = false;
|
|
1906
|
+
} else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
|
|
1907
|
+
this._flags.line_indent_level = this._flags.indentation_level;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
Beautifier.prototype.print_token = function(current_token) {
|
|
1912
|
+
if (this._output.raw) {
|
|
1913
|
+
this._output.add_raw_token(current_token);
|
|
1914
|
+
return;
|
|
1915
|
+
}
|
|
1916
|
+
if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN.COMMA && this._output.just_added_newline()) {
|
|
1917
|
+
if (this._output.previous_line.last() === ",") {
|
|
1918
|
+
var popped = this._output.previous_line.pop();
|
|
1919
|
+
if (this._output.previous_line.is_empty()) {
|
|
1920
|
+
this._output.previous_line.push(popped);
|
|
1921
|
+
this._output.trim(true);
|
|
1922
|
+
this._output.current_line.pop();
|
|
1923
|
+
this._output.trim();
|
|
1924
|
+
}
|
|
1925
|
+
this.print_token_line_indentation(current_token);
|
|
1926
|
+
this._output.add_token(",");
|
|
1927
|
+
this._output.space_before_token = true;
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
this.print_token_line_indentation(current_token);
|
|
1931
|
+
this._output.non_breaking_space = true;
|
|
1932
|
+
this._output.add_token(current_token.text);
|
|
1933
|
+
if (this._output.previous_token_wrapped) {
|
|
1934
|
+
this._flags.multiline_frame = true;
|
|
1935
|
+
}
|
|
1936
|
+
};
|
|
1937
|
+
Beautifier.prototype.indent = function() {
|
|
1938
|
+
this._flags.indentation_level += 1;
|
|
1939
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
1940
|
+
};
|
|
1941
|
+
Beautifier.prototype.deindent = function() {
|
|
1942
|
+
if (this._flags.indentation_level > 0 && (!this._flags.parent || this._flags.indentation_level > this._flags.parent.indentation_level)) {
|
|
1943
|
+
this._flags.indentation_level -= 1;
|
|
1944
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
1945
|
+
}
|
|
1946
|
+
};
|
|
1947
|
+
Beautifier.prototype.set_mode = function(mode) {
|
|
1948
|
+
if (this._flags) {
|
|
1949
|
+
this._flag_store.push(this._flags);
|
|
1950
|
+
this._previous_flags = this._flags;
|
|
1951
|
+
} else {
|
|
1952
|
+
this._previous_flags = this.create_flags(null, mode);
|
|
1953
|
+
}
|
|
1954
|
+
this._flags = this.create_flags(this._previous_flags, mode);
|
|
1955
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
1956
|
+
};
|
|
1957
|
+
Beautifier.prototype.restore_mode = function() {
|
|
1958
|
+
if (this._flag_store.length > 0) {
|
|
1959
|
+
this._previous_flags = this._flags;
|
|
1960
|
+
this._flags = this._flag_store.pop();
|
|
1961
|
+
if (this._previous_flags.mode === MODE.Statement) {
|
|
1962
|
+
remove_redundant_indentation(this._output, this._previous_flags);
|
|
1963
|
+
}
|
|
1964
|
+
this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
|
|
1965
|
+
}
|
|
1966
|
+
};
|
|
1967
|
+
Beautifier.prototype.start_of_object_property = function() {
|
|
1968
|
+
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"]));
|
|
1969
|
+
};
|
|
1970
|
+
Beautifier.prototype.start_of_statement = function(current_token) {
|
|
1971
|
+
var start = false;
|
|
1972
|
+
start = start || reserved_array(this._flags.last_token, ["var", "let", "const"]) && current_token.type === TOKEN.WORD;
|
|
1973
|
+
start = start || reserved_word(this._flags.last_token, "do");
|
|
1974
|
+
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;
|
|
1975
|
+
start = start || reserved_word(this._flags.last_token, "else") && !(reserved_word(current_token, "if") && !current_token.comments_before);
|
|
1976
|
+
start = start || this._flags.last_token.type === TOKEN.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional);
|
|
1977
|
+
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;
|
|
1978
|
+
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"]));
|
|
1979
|
+
if (start) {
|
|
1980
|
+
this.set_mode(MODE.Statement);
|
|
1981
|
+
this.indent();
|
|
1982
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
1983
|
+
if (!this.start_of_object_property()) {
|
|
1984
|
+
this.allow_wrap_or_preserved_newline(
|
|
1985
|
+
current_token,
|
|
1986
|
+
reserved_array(current_token, ["do", "for", "if", "while"])
|
|
1987
|
+
);
|
|
1988
|
+
}
|
|
1989
|
+
return true;
|
|
1990
|
+
}
|
|
1991
|
+
return false;
|
|
1992
|
+
};
|
|
1993
|
+
Beautifier.prototype.handle_start_expr = function(current_token) {
|
|
1994
|
+
if (!this.start_of_statement(current_token)) {
|
|
1995
|
+
this.handle_whitespace_and_comments(current_token);
|
|
1996
|
+
}
|
|
1997
|
+
var next_mode = MODE.Expression;
|
|
1998
|
+
if (current_token.text === "[") {
|
|
1999
|
+
if (this._flags.last_token.type === TOKEN.WORD || this._flags.last_token.text === ")") {
|
|
2000
|
+
if (reserved_array(this._flags.last_token, line_starters)) {
|
|
2001
|
+
this._output.space_before_token = true;
|
|
2002
|
+
}
|
|
2003
|
+
this.print_token(current_token);
|
|
2004
|
+
this.set_mode(next_mode);
|
|
2005
|
+
this.indent();
|
|
2006
|
+
if (this._options.space_in_paren) {
|
|
2007
|
+
this._output.space_before_token = true;
|
|
2008
|
+
}
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
next_mode = MODE.ArrayLiteral;
|
|
2012
|
+
if (is_array(this._flags.mode)) {
|
|
2013
|
+
if (this._flags.last_token.text === "[" || this._flags.last_token.text === "," && (this._last_last_text === "]" || this._last_last_text === "}")) {
|
|
2014
|
+
if (!this._options.keep_array_indentation) {
|
|
2015
|
+
this.print_newline();
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
if (!in_array(this._flags.last_token.type, [TOKEN.START_EXPR, TOKEN.END_EXPR, TOKEN.WORD, TOKEN.OPERATOR, TOKEN.DOT])) {
|
|
2020
|
+
this._output.space_before_token = true;
|
|
2021
|
+
}
|
|
2022
|
+
} else {
|
|
2023
|
+
if (this._flags.last_token.type === TOKEN.RESERVED) {
|
|
2024
|
+
if (this._flags.last_token.text === "for") {
|
|
2025
|
+
this._output.space_before_token = this._options.space_before_conditional;
|
|
2026
|
+
next_mode = MODE.ForInitializer;
|
|
2027
|
+
} else if (in_array(this._flags.last_token.text, ["if", "while", "switch"])) {
|
|
2028
|
+
this._output.space_before_token = this._options.space_before_conditional;
|
|
2029
|
+
next_mode = MODE.Conditional;
|
|
2030
|
+
} else if (in_array(this._flags.last_word, ["await", "async"])) {
|
|
2031
|
+
this._output.space_before_token = true;
|
|
2032
|
+
} else if (this._flags.last_token.text === "import" && current_token.whitespace_before === "") {
|
|
2033
|
+
this._output.space_before_token = false;
|
|
2034
|
+
} else if (in_array(this._flags.last_token.text, line_starters) || this._flags.last_token.text === "catch") {
|
|
2035
|
+
this._output.space_before_token = true;
|
|
2036
|
+
}
|
|
2037
|
+
} else if (this._flags.last_token.type === TOKEN.EQUALS || this._flags.last_token.type === TOKEN.OPERATOR) {
|
|
2038
|
+
if (!this.start_of_object_property()) {
|
|
2039
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2040
|
+
}
|
|
2041
|
+
} else if (this._flags.last_token.type === TOKEN.WORD) {
|
|
2042
|
+
this._output.space_before_token = false;
|
|
2043
|
+
var peek_back_two = this._tokens.peek(-3);
|
|
2044
|
+
if (this._options.space_after_named_function && peek_back_two) {
|
|
2045
|
+
var peek_back_three = this._tokens.peek(-4);
|
|
2046
|
+
if (reserved_array(peek_back_two, ["async", "function"]) || peek_back_two.text === "*" && reserved_array(peek_back_three, ["async", "function"])) {
|
|
2047
|
+
this._output.space_before_token = true;
|
|
2048
|
+
} else if (this._flags.mode === MODE.ObjectLiteral) {
|
|
2049
|
+
if (peek_back_two.text === "{" || peek_back_two.text === "," || peek_back_two.text === "*" && (peek_back_three.text === "{" || peek_back_three.text === ",")) {
|
|
2050
|
+
this._output.space_before_token = true;
|
|
2051
|
+
}
|
|
2052
|
+
} else if (this._flags.parent && this._flags.parent.class_start_block) {
|
|
2053
|
+
this._output.space_before_token = true;
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
} else {
|
|
2057
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2058
|
+
}
|
|
2059
|
+
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, ["{", ","]))) {
|
|
2060
|
+
this._output.space_before_token = this._options.space_after_anon_function;
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
if (this._flags.last_token.text === ";" || this._flags.last_token.type === TOKEN.START_BLOCK) {
|
|
2064
|
+
this.print_newline();
|
|
2065
|
+
} 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) {
|
|
2066
|
+
this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
|
|
2067
|
+
}
|
|
2068
|
+
this.print_token(current_token);
|
|
2069
|
+
this.set_mode(next_mode);
|
|
2070
|
+
if (this._options.space_in_paren) {
|
|
2071
|
+
this._output.space_before_token = true;
|
|
2072
|
+
}
|
|
2073
|
+
this.indent();
|
|
2074
|
+
};
|
|
2075
|
+
Beautifier.prototype.handle_end_expr = function(current_token) {
|
|
2076
|
+
while (this._flags.mode === MODE.Statement) {
|
|
2077
|
+
this.restore_mode();
|
|
2078
|
+
}
|
|
2079
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2080
|
+
if (this._flags.multiline_frame) {
|
|
2081
|
+
this.allow_wrap_or_preserved_newline(
|
|
2082
|
+
current_token,
|
|
2083
|
+
current_token.text === "]" && is_array(this._flags.mode) && !this._options.keep_array_indentation
|
|
2084
|
+
);
|
|
2085
|
+
}
|
|
2086
|
+
if (this._options.space_in_paren) {
|
|
2087
|
+
if (this._flags.last_token.type === TOKEN.START_EXPR && !this._options.space_in_empty_paren) {
|
|
2088
|
+
this._output.trim();
|
|
2089
|
+
this._output.space_before_token = false;
|
|
2090
|
+
} else {
|
|
2091
|
+
this._output.space_before_token = true;
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
this.deindent();
|
|
2095
|
+
this.print_token(current_token);
|
|
2096
|
+
this.restore_mode();
|
|
2097
|
+
remove_redundant_indentation(this._output, this._previous_flags);
|
|
2098
|
+
if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
|
|
2099
|
+
this._previous_flags.mode = MODE.Expression;
|
|
2100
|
+
this._flags.do_block = false;
|
|
2101
|
+
this._flags.do_while = false;
|
|
2102
|
+
}
|
|
2103
|
+
};
|
|
2104
|
+
Beautifier.prototype.handle_start_block = function(current_token) {
|
|
2105
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2106
|
+
var next_token = this._tokens.peek();
|
|
2107
|
+
var second_token = this._tokens.peek(1);
|
|
2108
|
+
if (this._flags.last_word === "switch" && this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
2109
|
+
this.set_mode(MODE.BlockStatement);
|
|
2110
|
+
this._flags.in_case_statement = true;
|
|
2111
|
+
} else if (this._flags.case_body) {
|
|
2112
|
+
this.set_mode(MODE.BlockStatement);
|
|
2113
|
+
} 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]))) {
|
|
2114
|
+
if (in_array(this._last_last_text, ["class", "interface"]) && !in_array(second_token.text, [":", ","])) {
|
|
2115
|
+
this.set_mode(MODE.BlockStatement);
|
|
2116
|
+
} else {
|
|
2117
|
+
this.set_mode(MODE.ObjectLiteral);
|
|
2118
|
+
}
|
|
2119
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === "=>") {
|
|
2120
|
+
this.set_mode(MODE.BlockStatement);
|
|
2121
|
+
} 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"])) {
|
|
2122
|
+
this.set_mode(MODE.ObjectLiteral);
|
|
2123
|
+
} else {
|
|
2124
|
+
this.set_mode(MODE.BlockStatement);
|
|
2125
|
+
}
|
|
2126
|
+
if (this._flags.last_token) {
|
|
2127
|
+
if (reserved_array(this._flags.last_token.previous, ["class", "extends"])) {
|
|
2128
|
+
this._flags.class_start_block = true;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
var empty_braces = !next_token.comments_before && next_token.text === "}";
|
|
2132
|
+
var empty_anonymous_function = empty_braces && this._flags.last_word === "function" && this._flags.last_token.type === TOKEN.END_EXPR;
|
|
2133
|
+
if (this._options.brace_preserve_inline) {
|
|
2134
|
+
var index = 0;
|
|
2135
|
+
var check_token = null;
|
|
2136
|
+
this._flags.inline_frame = true;
|
|
2137
|
+
do {
|
|
2138
|
+
index += 1;
|
|
2139
|
+
check_token = this._tokens.peek(index - 1);
|
|
2140
|
+
if (check_token.newlines) {
|
|
2141
|
+
this._flags.inline_frame = false;
|
|
2142
|
+
break;
|
|
2143
|
+
}
|
|
2144
|
+
} while (check_token.type !== TOKEN.EOF && !(check_token.type === TOKEN.END_BLOCK && check_token.opened === current_token));
|
|
2145
|
+
}
|
|
2146
|
+
if ((this._options.brace_style === "expand" || this._options.brace_style === "none" && current_token.newlines) && !this._flags.inline_frame) {
|
|
2147
|
+
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")) {
|
|
2148
|
+
this._output.space_before_token = true;
|
|
2149
|
+
} else {
|
|
2150
|
+
this.print_newline(false, true);
|
|
2151
|
+
}
|
|
2152
|
+
} else {
|
|
2153
|
+
if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.COMMA)) {
|
|
2154
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._options.space_in_paren) {
|
|
2155
|
+
this._output.space_before_token = true;
|
|
2156
|
+
}
|
|
2157
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR && this._flags.inline_frame) {
|
|
2158
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2159
|
+
this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
|
|
2160
|
+
this._flags.multiline_frame = false;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
if (this._flags.last_token.type !== TOKEN.OPERATOR && this._flags.last_token.type !== TOKEN.START_EXPR) {
|
|
2164
|
+
if (in_array(this._flags.last_token.type, [TOKEN.START_BLOCK, TOKEN.SEMICOLON]) && !this._flags.inline_frame) {
|
|
2165
|
+
this.print_newline();
|
|
2166
|
+
} else {
|
|
2167
|
+
this._output.space_before_token = true;
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
this.print_token(current_token);
|
|
2172
|
+
this.indent();
|
|
2173
|
+
if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
|
|
2174
|
+
this.print_newline();
|
|
2175
|
+
}
|
|
2176
|
+
};
|
|
2177
|
+
Beautifier.prototype.handle_end_block = function(current_token) {
|
|
2178
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2179
|
+
while (this._flags.mode === MODE.Statement) {
|
|
2180
|
+
this.restore_mode();
|
|
2181
|
+
}
|
|
2182
|
+
var empty_braces = this._flags.last_token.type === TOKEN.START_BLOCK;
|
|
2183
|
+
if (this._flags.inline_frame && !empty_braces) {
|
|
2184
|
+
this._output.space_before_token = true;
|
|
2185
|
+
} else if (this._options.brace_style === "expand") {
|
|
2186
|
+
if (!empty_braces) {
|
|
2187
|
+
this.print_newline();
|
|
2188
|
+
}
|
|
2189
|
+
} else {
|
|
2190
|
+
if (!empty_braces) {
|
|
2191
|
+
if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
|
|
2192
|
+
this._options.keep_array_indentation = false;
|
|
2193
|
+
this.print_newline();
|
|
2194
|
+
this._options.keep_array_indentation = true;
|
|
2195
|
+
} else {
|
|
2196
|
+
this.print_newline();
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
this.restore_mode();
|
|
2201
|
+
this.print_token(current_token);
|
|
2202
|
+
};
|
|
2203
|
+
Beautifier.prototype.handle_word = function(current_token) {
|
|
2204
|
+
if (current_token.type === TOKEN.RESERVED) {
|
|
2205
|
+
if (in_array(current_token.text, ["set", "get"]) && this._flags.mode !== MODE.ObjectLiteral) {
|
|
2206
|
+
current_token.type = TOKEN.WORD;
|
|
2207
|
+
} else if (current_token.text === "import" && in_array(this._tokens.peek().text, ["(", "."])) {
|
|
2208
|
+
current_token.type = TOKEN.WORD;
|
|
2209
|
+
} else if (in_array(current_token.text, ["as", "from"]) && !this._flags.import_block) {
|
|
2210
|
+
current_token.type = TOKEN.WORD;
|
|
2211
|
+
} else if (this._flags.mode === MODE.ObjectLiteral) {
|
|
2212
|
+
var next_token = this._tokens.peek();
|
|
2213
|
+
if (next_token.text === ":") {
|
|
2214
|
+
current_token.type = TOKEN.WORD;
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
if (this.start_of_statement(current_token)) {
|
|
2219
|
+
if (reserved_array(this._flags.last_token, ["var", "let", "const"]) && current_token.type === TOKEN.WORD) {
|
|
2220
|
+
this._flags.declaration_statement = true;
|
|
2221
|
+
}
|
|
2222
|
+
} 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"]))) {
|
|
2223
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2224
|
+
this.print_newline();
|
|
2225
|
+
} else {
|
|
2226
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2227
|
+
}
|
|
2228
|
+
if (this._flags.do_block && !this._flags.do_while) {
|
|
2229
|
+
if (reserved_word(current_token, "while")) {
|
|
2230
|
+
this._output.space_before_token = true;
|
|
2231
|
+
this.print_token(current_token);
|
|
2232
|
+
this._output.space_before_token = true;
|
|
2233
|
+
this._flags.do_while = true;
|
|
2234
|
+
return;
|
|
2235
|
+
} else {
|
|
2236
|
+
this.print_newline();
|
|
2237
|
+
this._flags.do_block = false;
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
if (this._flags.if_block) {
|
|
2241
|
+
if (!this._flags.else_block && reserved_word(current_token, "else")) {
|
|
2242
|
+
this._flags.else_block = true;
|
|
2243
|
+
} else {
|
|
2244
|
+
while (this._flags.mode === MODE.Statement) {
|
|
2245
|
+
this.restore_mode();
|
|
2246
|
+
}
|
|
2247
|
+
this._flags.if_block = false;
|
|
2248
|
+
this._flags.else_block = false;
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
if (this._flags.in_case_statement && reserved_array(current_token, ["case", "default"])) {
|
|
2252
|
+
this.print_newline();
|
|
2253
|
+
if (!this._flags.case_block && (this._flags.case_body || this._options.jslint_happy)) {
|
|
2254
|
+
this.deindent();
|
|
2255
|
+
}
|
|
2256
|
+
this._flags.case_body = false;
|
|
2257
|
+
this.print_token(current_token);
|
|
2258
|
+
this._flags.in_case = true;
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
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) {
|
|
2262
|
+
if (!this.start_of_object_property() && !// start of object property is different for numeric values with +/- prefix operators
|
|
2263
|
+
(in_array(this._flags.last_token.text, ["+", "-"]) && this._last_last_text === ":" && this._flags.parent.mode === MODE.ObjectLiteral)) {
|
|
2264
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
if (reserved_word(current_token, "function")) {
|
|
2268
|
+
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)) {
|
|
2269
|
+
if (!this._output.just_added_blankline() && !current_token.comments_before) {
|
|
2270
|
+
this.print_newline();
|
|
2271
|
+
this.print_newline(true);
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD) {
|
|
2275
|
+
if (reserved_array(this._flags.last_token, ["get", "set", "new", "export"]) || reserved_array(this._flags.last_token, newline_restricted_tokens)) {
|
|
2276
|
+
this._output.space_before_token = true;
|
|
2277
|
+
} else if (reserved_word(this._flags.last_token, "default") && this._last_last_text === "export") {
|
|
2278
|
+
this._output.space_before_token = true;
|
|
2279
|
+
} else if (this._flags.last_token.text === "declare") {
|
|
2280
|
+
this._output.space_before_token = true;
|
|
2281
|
+
} else {
|
|
2282
|
+
this.print_newline();
|
|
2283
|
+
}
|
|
2284
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR || this._flags.last_token.text === "=") {
|
|
2285
|
+
this._output.space_before_token = true;
|
|
2286
|
+
} else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) {
|
|
2287
|
+
} else {
|
|
2288
|
+
this.print_newline();
|
|
2289
|
+
}
|
|
2290
|
+
this.print_token(current_token);
|
|
2291
|
+
this._flags.last_word = current_token.text;
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
var prefix = "NONE";
|
|
2295
|
+
if (this._flags.last_token.type === TOKEN.END_BLOCK) {
|
|
2296
|
+
if (this._previous_flags.inline_frame) {
|
|
2297
|
+
prefix = "SPACE";
|
|
2298
|
+
} else if (!reserved_array(current_token, ["else", "catch", "finally", "from"])) {
|
|
2299
|
+
prefix = "NEWLINE";
|
|
2300
|
+
} else {
|
|
2301
|
+
if (this._options.brace_style === "expand" || this._options.brace_style === "end-expand" || this._options.brace_style === "none" && current_token.newlines) {
|
|
2302
|
+
prefix = "NEWLINE";
|
|
2303
|
+
} else {
|
|
2304
|
+
prefix = "SPACE";
|
|
2305
|
+
this._output.space_before_token = true;
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
} else if (this._flags.last_token.type === TOKEN.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
|
|
2309
|
+
prefix = "NEWLINE";
|
|
2310
|
+
} else if (this._flags.last_token.type === TOKEN.SEMICOLON && is_expression(this._flags.mode)) {
|
|
2311
|
+
prefix = "SPACE";
|
|
2312
|
+
} else if (this._flags.last_token.type === TOKEN.STRING) {
|
|
2313
|
+
prefix = "NEWLINE";
|
|
2314
|
+
} 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, ["{", ","]))) {
|
|
2315
|
+
prefix = "SPACE";
|
|
2316
|
+
} else if (this._flags.last_token.type === TOKEN.START_BLOCK) {
|
|
2317
|
+
if (this._flags.inline_frame) {
|
|
2318
|
+
prefix = "SPACE";
|
|
2319
|
+
} else {
|
|
2320
|
+
prefix = "NEWLINE";
|
|
2321
|
+
}
|
|
2322
|
+
} else if (this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
2323
|
+
this._output.space_before_token = true;
|
|
2324
|
+
prefix = "NEWLINE";
|
|
2325
|
+
}
|
|
2326
|
+
if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ")") {
|
|
2327
|
+
if (this._flags.inline_frame || this._flags.last_token.text === "else" || this._flags.last_token.text === "export") {
|
|
2328
|
+
prefix = "SPACE";
|
|
2329
|
+
} else {
|
|
2330
|
+
prefix = "NEWLINE";
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
if (reserved_array(current_token, ["else", "catch", "finally"])) {
|
|
2334
|
+
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) {
|
|
2335
|
+
this.print_newline();
|
|
2336
|
+
} else {
|
|
2337
|
+
this._output.trim(true);
|
|
2338
|
+
var line = this._output.current_line;
|
|
2339
|
+
if (line.last() !== "}") {
|
|
2340
|
+
this.print_newline();
|
|
2341
|
+
}
|
|
2342
|
+
this._output.space_before_token = true;
|
|
2343
|
+
}
|
|
2344
|
+
} else if (prefix === "NEWLINE") {
|
|
2345
|
+
if (reserved_array(this._flags.last_token, special_words)) {
|
|
2346
|
+
this._output.space_before_token = true;
|
|
2347
|
+
} else if (this._flags.last_token.text === "declare" && reserved_array(current_token, ["var", "let", "const"])) {
|
|
2348
|
+
this._output.space_before_token = true;
|
|
2349
|
+
} else if (this._flags.last_token.type !== TOKEN.END_EXPR) {
|
|
2350
|
+
if ((this._flags.last_token.type !== TOKEN.START_EXPR || !reserved_array(current_token, ["var", "let", "const"])) && this._flags.last_token.text !== ":") {
|
|
2351
|
+
if (reserved_word(current_token, "if") && reserved_word(current_token.previous, "else")) {
|
|
2352
|
+
this._output.space_before_token = true;
|
|
2353
|
+
} else {
|
|
2354
|
+
this.print_newline();
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
} else if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ")") {
|
|
2358
|
+
this.print_newline();
|
|
2359
|
+
}
|
|
2360
|
+
} else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === "," && this._last_last_text === "}") {
|
|
2361
|
+
this.print_newline();
|
|
2362
|
+
} else if (prefix === "SPACE") {
|
|
2363
|
+
this._output.space_before_token = true;
|
|
2364
|
+
}
|
|
2365
|
+
if (current_token.previous && (current_token.previous.type === TOKEN.WORD || current_token.previous.type === TOKEN.RESERVED)) {
|
|
2366
|
+
this._output.space_before_token = true;
|
|
2367
|
+
}
|
|
2368
|
+
this.print_token(current_token);
|
|
2369
|
+
this._flags.last_word = current_token.text;
|
|
2370
|
+
if (current_token.type === TOKEN.RESERVED) {
|
|
2371
|
+
if (current_token.text === "do") {
|
|
2372
|
+
this._flags.do_block = true;
|
|
2373
|
+
} else if (current_token.text === "if") {
|
|
2374
|
+
this._flags.if_block = true;
|
|
2375
|
+
} else if (current_token.text === "import") {
|
|
2376
|
+
this._flags.import_block = true;
|
|
2377
|
+
} else if (this._flags.import_block && reserved_word(current_token, "from")) {
|
|
2378
|
+
this._flags.import_block = false;
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
};
|
|
2382
|
+
Beautifier.prototype.handle_semicolon = function(current_token) {
|
|
2383
|
+
if (this.start_of_statement(current_token)) {
|
|
2384
|
+
this._output.space_before_token = false;
|
|
2385
|
+
} else {
|
|
2386
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2387
|
+
}
|
|
2388
|
+
var next_token = this._tokens.peek();
|
|
2389
|
+
while (this._flags.mode === MODE.Statement && !(this._flags.if_block && reserved_word(next_token, "else")) && !this._flags.do_block) {
|
|
2390
|
+
this.restore_mode();
|
|
2391
|
+
}
|
|
2392
|
+
if (this._flags.import_block) {
|
|
2393
|
+
this._flags.import_block = false;
|
|
2394
|
+
}
|
|
2395
|
+
this.print_token(current_token);
|
|
2396
|
+
};
|
|
2397
|
+
Beautifier.prototype.handle_string = function(current_token) {
|
|
2398
|
+
if (current_token.text.startsWith("`") && current_token.newlines === 0 && current_token.whitespace_before === "" && (current_token.previous.text === ")" || this._flags.last_token.type === TOKEN.WORD)) {
|
|
2399
|
+
} else if (this.start_of_statement(current_token)) {
|
|
2400
|
+
this._output.space_before_token = true;
|
|
2401
|
+
} else {
|
|
2402
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2403
|
+
if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD || this._flags.inline_frame) {
|
|
2404
|
+
this._output.space_before_token = true;
|
|
2405
|
+
} 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) {
|
|
2406
|
+
if (!this.start_of_object_property()) {
|
|
2407
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2408
|
+
}
|
|
2409
|
+
} 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) {
|
|
2410
|
+
this._output.space_before_token = true;
|
|
2411
|
+
} else {
|
|
2412
|
+
this.print_newline();
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
this.print_token(current_token);
|
|
2416
|
+
};
|
|
2417
|
+
Beautifier.prototype.handle_equals = function(current_token) {
|
|
2418
|
+
if (this.start_of_statement(current_token)) {
|
|
2419
|
+
} else {
|
|
2420
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2421
|
+
}
|
|
2422
|
+
if (this._flags.declaration_statement) {
|
|
2423
|
+
this._flags.declaration_assignment = true;
|
|
2424
|
+
}
|
|
2425
|
+
this._output.space_before_token = true;
|
|
2426
|
+
this.print_token(current_token);
|
|
2427
|
+
this._output.space_before_token = true;
|
|
2428
|
+
};
|
|
2429
|
+
Beautifier.prototype.handle_comma = function(current_token) {
|
|
2430
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
2431
|
+
this.print_token(current_token);
|
|
2432
|
+
this._output.space_before_token = true;
|
|
2433
|
+
if (this._flags.declaration_statement) {
|
|
2434
|
+
if (is_expression(this._flags.parent.mode)) {
|
|
2435
|
+
this._flags.declaration_assignment = false;
|
|
2436
|
+
}
|
|
2437
|
+
if (this._flags.declaration_assignment) {
|
|
2438
|
+
this._flags.declaration_assignment = false;
|
|
2439
|
+
this.print_newline(false, true);
|
|
2440
|
+
} else if (this._options.comma_first) {
|
|
2441
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2442
|
+
}
|
|
2443
|
+
} else if (this._flags.mode === MODE.ObjectLiteral || this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral) {
|
|
2444
|
+
if (this._flags.mode === MODE.Statement) {
|
|
2445
|
+
this.restore_mode();
|
|
2446
|
+
}
|
|
2447
|
+
if (!this._flags.inline_frame) {
|
|
2448
|
+
this.print_newline();
|
|
2449
|
+
}
|
|
2450
|
+
} else if (this._options.comma_first) {
|
|
2451
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2452
|
+
}
|
|
2453
|
+
};
|
|
2454
|
+
Beautifier.prototype.handle_operator = function(current_token) {
|
|
2455
|
+
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]));
|
|
2456
|
+
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 === ",");
|
|
2457
|
+
if (this.start_of_statement(current_token)) {
|
|
2458
|
+
} else {
|
|
2459
|
+
var preserve_statement_flags = !isGeneratorAsterisk;
|
|
2460
|
+
this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
|
|
2461
|
+
}
|
|
2462
|
+
if (current_token.text === "*" && this._flags.last_token.type === TOKEN.DOT) {
|
|
2463
|
+
this.print_token(current_token);
|
|
2464
|
+
return;
|
|
2465
|
+
}
|
|
2466
|
+
if (current_token.text === "::") {
|
|
2467
|
+
this.print_token(current_token);
|
|
2468
|
+
return;
|
|
2469
|
+
}
|
|
2470
|
+
if (in_array(current_token.text, ["-", "+"]) && this.start_of_object_property()) {
|
|
2471
|
+
this.print_token(current_token);
|
|
2472
|
+
return;
|
|
2473
|
+
}
|
|
2474
|
+
if (this._flags.last_token.type === TOKEN.OPERATOR && in_array(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
|
|
2475
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2476
|
+
}
|
|
2477
|
+
if (current_token.text === ":" && this._flags.in_case) {
|
|
2478
|
+
this.print_token(current_token);
|
|
2479
|
+
this._flags.in_case = false;
|
|
2480
|
+
this._flags.case_body = true;
|
|
2481
|
+
if (this._tokens.peek().type !== TOKEN.START_BLOCK) {
|
|
2482
|
+
this.indent();
|
|
2483
|
+
this.print_newline();
|
|
2484
|
+
this._flags.case_block = false;
|
|
2485
|
+
} else {
|
|
2486
|
+
this._flags.case_block = true;
|
|
2487
|
+
this._output.space_before_token = true;
|
|
2488
|
+
}
|
|
2489
|
+
return;
|
|
2490
|
+
}
|
|
2491
|
+
var space_before = true;
|
|
2492
|
+
var space_after = true;
|
|
2493
|
+
var in_ternary = false;
|
|
2494
|
+
if (current_token.text === ":") {
|
|
2495
|
+
if (this._flags.ternary_depth === 0) {
|
|
2496
|
+
space_before = false;
|
|
2497
|
+
} else {
|
|
2498
|
+
this._flags.ternary_depth -= 1;
|
|
2499
|
+
in_ternary = true;
|
|
2500
|
+
}
|
|
2501
|
+
} else if (current_token.text === "?") {
|
|
2502
|
+
this._flags.ternary_depth += 1;
|
|
2503
|
+
}
|
|
2504
|
+
if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array(current_token.text, positionable_operators)) {
|
|
2505
|
+
var isColon = current_token.text === ":";
|
|
2506
|
+
var isTernaryColon = isColon && in_ternary;
|
|
2507
|
+
var isOtherColon = isColon && !in_ternary;
|
|
2508
|
+
switch (this._options.operator_position) {
|
|
2509
|
+
case OPERATOR_POSITION.before_newline:
|
|
2510
|
+
this._output.space_before_token = !isOtherColon;
|
|
2511
|
+
this.print_token(current_token);
|
|
2512
|
+
if (!isColon || isTernaryColon) {
|
|
2513
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2514
|
+
}
|
|
2515
|
+
this._output.space_before_token = true;
|
|
2516
|
+
return;
|
|
2517
|
+
case OPERATOR_POSITION.after_newline:
|
|
2518
|
+
this._output.space_before_token = true;
|
|
2519
|
+
if (!isColon || isTernaryColon) {
|
|
2520
|
+
if (this._tokens.peek().newlines) {
|
|
2521
|
+
this.print_newline(false, true);
|
|
2522
|
+
} else {
|
|
2523
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2524
|
+
}
|
|
2525
|
+
} else {
|
|
2526
|
+
this._output.space_before_token = false;
|
|
2527
|
+
}
|
|
2528
|
+
this.print_token(current_token);
|
|
2529
|
+
this._output.space_before_token = true;
|
|
2530
|
+
return;
|
|
2531
|
+
case OPERATOR_POSITION.preserve_newline:
|
|
2532
|
+
if (!isOtherColon) {
|
|
2533
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2534
|
+
}
|
|
2535
|
+
space_before = !(this._output.just_added_newline() || isOtherColon);
|
|
2536
|
+
this._output.space_before_token = space_before;
|
|
2537
|
+
this.print_token(current_token);
|
|
2538
|
+
this._output.space_before_token = true;
|
|
2539
|
+
return;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
if (isGeneratorAsterisk) {
|
|
2543
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2544
|
+
space_before = false;
|
|
2545
|
+
var next_token = this._tokens.peek();
|
|
2546
|
+
space_after = next_token && in_array(next_token.type, [TOKEN.WORD, TOKEN.RESERVED]);
|
|
2547
|
+
} else if (current_token.text === "...") {
|
|
2548
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2549
|
+
space_before = this._flags.last_token.type === TOKEN.START_BLOCK;
|
|
2550
|
+
space_after = false;
|
|
2551
|
+
} else if (in_array(current_token.text, ["--", "++", "!", "~"]) || isUnary) {
|
|
2552
|
+
if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR) {
|
|
2553
|
+
this.allow_wrap_or_preserved_newline(current_token);
|
|
2554
|
+
}
|
|
2555
|
+
space_before = false;
|
|
2556
|
+
space_after = false;
|
|
2557
|
+
if (current_token.newlines && (current_token.text === "--" || current_token.text === "++" || current_token.text === "~")) {
|
|
2558
|
+
var new_line_needed = reserved_array(this._flags.last_token, special_words) && current_token.newlines;
|
|
2559
|
+
if (new_line_needed && (this._previous_flags.if_block || this._previous_flags.else_block)) {
|
|
2560
|
+
this.restore_mode();
|
|
2561
|
+
}
|
|
2562
|
+
this.print_newline(new_line_needed, true);
|
|
2563
|
+
}
|
|
2564
|
+
if (this._flags.last_token.text === ";" && is_expression(this._flags.mode)) {
|
|
2565
|
+
space_before = true;
|
|
2566
|
+
}
|
|
2567
|
+
if (this._flags.last_token.type === TOKEN.RESERVED) {
|
|
2568
|
+
space_before = true;
|
|
2569
|
+
} else if (this._flags.last_token.type === TOKEN.END_EXPR) {
|
|
2570
|
+
space_before = !(this._flags.last_token.text === "]" && (current_token.text === "--" || current_token.text === "++"));
|
|
2571
|
+
} else if (this._flags.last_token.type === TOKEN.OPERATOR) {
|
|
2572
|
+
space_before = in_array(current_token.text, ["--", "-", "++", "+"]) && in_array(this._flags.last_token.text, ["--", "-", "++", "+"]);
|
|
2573
|
+
if (in_array(current_token.text, ["+", "-"]) && in_array(this._flags.last_token.text, ["--", "++"])) {
|
|
2574
|
+
space_after = true;
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
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 === ";")) {
|
|
2578
|
+
this.print_newline();
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
this._output.space_before_token = this._output.space_before_token || space_before;
|
|
2582
|
+
this.print_token(current_token);
|
|
2583
|
+
this._output.space_before_token = space_after;
|
|
2584
|
+
};
|
|
2585
|
+
Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
|
|
2586
|
+
if (this._output.raw) {
|
|
2587
|
+
this._output.add_raw_token(current_token);
|
|
2588
|
+
if (current_token.directives && current_token.directives.preserve === "end") {
|
|
2589
|
+
this._output.raw = this._options.test_output_raw;
|
|
2590
|
+
}
|
|
2591
|
+
return;
|
|
2592
|
+
}
|
|
2593
|
+
if (current_token.directives) {
|
|
2594
|
+
this.print_newline(false, preserve_statement_flags);
|
|
2595
|
+
this.print_token(current_token);
|
|
2596
|
+
if (current_token.directives.preserve === "start") {
|
|
2597
|
+
this._output.raw = true;
|
|
2598
|
+
}
|
|
2599
|
+
this.print_newline(false, true);
|
|
2600
|
+
return;
|
|
2601
|
+
}
|
|
2602
|
+
if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
|
|
2603
|
+
this._output.space_before_token = true;
|
|
2604
|
+
this.print_token(current_token);
|
|
2605
|
+
this._output.space_before_token = true;
|
|
2606
|
+
return;
|
|
2607
|
+
} else {
|
|
2608
|
+
this.print_block_commment(current_token, preserve_statement_flags);
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
|
|
2612
|
+
var lines = split_linebreaks(current_token.text);
|
|
2613
|
+
var j;
|
|
2614
|
+
var javadoc = false;
|
|
2615
|
+
var starless = false;
|
|
2616
|
+
var lastIndent = current_token.whitespace_before;
|
|
2617
|
+
var lastIndentLength = lastIndent.length;
|
|
2618
|
+
this.print_newline(false, preserve_statement_flags);
|
|
2619
|
+
this.print_token_line_indentation(current_token);
|
|
2620
|
+
this._output.add_token(lines[0]);
|
|
2621
|
+
this.print_newline(false, preserve_statement_flags);
|
|
2622
|
+
if (lines.length > 1) {
|
|
2623
|
+
lines = lines.slice(1);
|
|
2624
|
+
javadoc = all_lines_start_with(lines, "*");
|
|
2625
|
+
starless = each_line_matches_indent(lines, lastIndent);
|
|
2626
|
+
if (javadoc) {
|
|
2627
|
+
this._flags.alignment = 1;
|
|
2628
|
+
}
|
|
2629
|
+
for (j = 0; j < lines.length; j++) {
|
|
2630
|
+
if (javadoc) {
|
|
2631
|
+
this.print_token_line_indentation(current_token);
|
|
2632
|
+
this._output.add_token(ltrim(lines[j]));
|
|
2633
|
+
} else if (starless && lines[j]) {
|
|
2634
|
+
this.print_token_line_indentation(current_token);
|
|
2635
|
+
this._output.add_token(lines[j].substring(lastIndentLength));
|
|
2636
|
+
} else {
|
|
2637
|
+
this._output.current_line.set_indent(-1);
|
|
2638
|
+
this._output.add_token(lines[j]);
|
|
2639
|
+
}
|
|
2640
|
+
this.print_newline(false, preserve_statement_flags);
|
|
2641
|
+
}
|
|
2642
|
+
this._flags.alignment = 0;
|
|
2643
|
+
}
|
|
2644
|
+
};
|
|
2645
|
+
Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
|
|
2646
|
+
if (current_token.newlines) {
|
|
2647
|
+
this.print_newline(false, preserve_statement_flags);
|
|
2648
|
+
} else {
|
|
2649
|
+
this._output.trim(true);
|
|
2650
|
+
}
|
|
2651
|
+
this._output.space_before_token = true;
|
|
2652
|
+
this.print_token(current_token);
|
|
2653
|
+
this.print_newline(false, preserve_statement_flags);
|
|
2654
|
+
};
|
|
2655
|
+
Beautifier.prototype.handle_dot = function(current_token) {
|
|
2656
|
+
if (this.start_of_statement(current_token)) {
|
|
2657
|
+
} else {
|
|
2658
|
+
this.handle_whitespace_and_comments(current_token, true);
|
|
2659
|
+
}
|
|
2660
|
+
if (this._flags.last_token.text.match("^[0-9]+$")) {
|
|
2661
|
+
this._output.space_before_token = true;
|
|
2662
|
+
}
|
|
2663
|
+
if (reserved_array(this._flags.last_token, special_words)) {
|
|
2664
|
+
this._output.space_before_token = false;
|
|
2665
|
+
} else {
|
|
2666
|
+
this.allow_wrap_or_preserved_newline(
|
|
2667
|
+
current_token,
|
|
2668
|
+
this._flags.last_token.text === ")" && this._options.break_chained_methods
|
|
2669
|
+
);
|
|
2670
|
+
}
|
|
2671
|
+
if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
|
|
2672
|
+
this.deindent();
|
|
2673
|
+
}
|
|
2674
|
+
this.print_token(current_token);
|
|
2675
|
+
};
|
|
2676
|
+
Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
|
|
2677
|
+
this.print_token(current_token);
|
|
2678
|
+
if (current_token.text[current_token.text.length - 1] === "\n") {
|
|
2679
|
+
this.print_newline(false, preserve_statement_flags);
|
|
2680
|
+
}
|
|
2681
|
+
};
|
|
2682
|
+
Beautifier.prototype.handle_eof = function(current_token) {
|
|
2683
|
+
while (this._flags.mode === MODE.Statement) {
|
|
2684
|
+
this.restore_mode();
|
|
2685
|
+
}
|
|
2686
|
+
this.handle_whitespace_and_comments(current_token);
|
|
2687
|
+
};
|
|
2688
|
+
module2.exports.Beautifier = Beautifier;
|
|
2689
|
+
}
|
|
2690
|
+
});
|
|
2691
|
+
|
|
2692
|
+
// node_modules/js-beautify/js/src/javascript/index.js
|
|
2693
|
+
var require_javascript = __commonJS({
|
|
2694
|
+
"node_modules/js-beautify/js/src/javascript/index.js"(exports2, module2) {
|
|
2695
|
+
"use strict";
|
|
2696
|
+
var Beautifier = require_beautifier().Beautifier;
|
|
2697
|
+
var Options = require_options2().Options;
|
|
2698
|
+
function js_beautify(js_source_text, options) {
|
|
2699
|
+
var beautifier = new Beautifier(js_source_text, options);
|
|
2700
|
+
return beautifier.beautify();
|
|
2701
|
+
}
|
|
2702
|
+
module2.exports = js_beautify;
|
|
2703
|
+
module2.exports.defaultOptions = function() {
|
|
2704
|
+
return new Options();
|
|
2705
|
+
};
|
|
2706
|
+
}
|
|
2707
|
+
});
|
|
2708
|
+
|
|
2709
|
+
// node_modules/js-beautify/js/src/css/options.js
|
|
2710
|
+
var require_options3 = __commonJS({
|
|
2711
|
+
"node_modules/js-beautify/js/src/css/options.js"(exports2, module2) {
|
|
2712
|
+
"use strict";
|
|
2713
|
+
var BaseOptions = require_options().Options;
|
|
2714
|
+
function Options(options) {
|
|
2715
|
+
BaseOptions.call(this, options, "css");
|
|
2716
|
+
this.selector_separator_newline = this._get_boolean("selector_separator_newline", true);
|
|
2717
|
+
this.newline_between_rules = this._get_boolean("newline_between_rules", true);
|
|
2718
|
+
var space_around_selector_separator = this._get_boolean("space_around_selector_separator");
|
|
2719
|
+
this.space_around_combinator = this._get_boolean("space_around_combinator") || space_around_selector_separator;
|
|
2720
|
+
var brace_style_split = this._get_selection_list("brace_style", ["collapse", "expand", "end-expand", "none", "preserve-inline"]);
|
|
2721
|
+
this.brace_style = "collapse";
|
|
2722
|
+
for (var bs = 0; bs < brace_style_split.length; bs++) {
|
|
2723
|
+
if (brace_style_split[bs] !== "expand") {
|
|
2724
|
+
this.brace_style = "collapse";
|
|
2725
|
+
} else {
|
|
2726
|
+
this.brace_style = brace_style_split[bs];
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
Options.prototype = new BaseOptions();
|
|
2731
|
+
module2.exports.Options = Options;
|
|
2732
|
+
}
|
|
2733
|
+
});
|
|
2734
|
+
|
|
2735
|
+
// node_modules/js-beautify/js/src/css/beautifier.js
|
|
2736
|
+
var require_beautifier2 = __commonJS({
|
|
2737
|
+
"node_modules/js-beautify/js/src/css/beautifier.js"(exports2, module2) {
|
|
2738
|
+
"use strict";
|
|
2739
|
+
var Options = require_options3().Options;
|
|
2740
|
+
var Output = require_output().Output;
|
|
2741
|
+
var InputScanner = require_inputscanner().InputScanner;
|
|
2742
|
+
var Directives = require_directives().Directives;
|
|
2743
|
+
var directives_core = new Directives(/\/\*/, /\*\//);
|
|
2744
|
+
var lineBreak = /\r\n|[\r\n]/;
|
|
2745
|
+
var allLineBreaks = /\r\n|[\r\n]/g;
|
|
2746
|
+
var whitespaceChar = /\s/;
|
|
2747
|
+
var whitespacePattern = /(?:\s|\n)+/g;
|
|
2748
|
+
var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
|
|
2749
|
+
var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
|
|
2750
|
+
function Beautifier(source_text, options) {
|
|
2751
|
+
this._source_text = source_text || "";
|
|
2752
|
+
this._options = new Options(options);
|
|
2753
|
+
this._ch = null;
|
|
2754
|
+
this._input = null;
|
|
2755
|
+
this.NESTED_AT_RULE = {
|
|
2756
|
+
"page": true,
|
|
2757
|
+
"font-face": true,
|
|
2758
|
+
"keyframes": true,
|
|
2759
|
+
// also in CONDITIONAL_GROUP_RULE below
|
|
2760
|
+
"media": true,
|
|
2761
|
+
"supports": true,
|
|
2762
|
+
"document": true
|
|
2763
|
+
};
|
|
2764
|
+
this.CONDITIONAL_GROUP_RULE = {
|
|
2765
|
+
"media": true,
|
|
2766
|
+
"supports": true,
|
|
2767
|
+
"document": true
|
|
2768
|
+
};
|
|
2769
|
+
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
|
|
2770
|
+
"grid-template-areas",
|
|
2771
|
+
"grid-template"
|
|
2772
|
+
];
|
|
2773
|
+
}
|
|
2774
|
+
Beautifier.prototype.eatString = function(endChars) {
|
|
2775
|
+
var result = "";
|
|
2776
|
+
this._ch = this._input.next();
|
|
2777
|
+
while (this._ch) {
|
|
2778
|
+
result += this._ch;
|
|
2779
|
+
if (this._ch === "\\") {
|
|
2780
|
+
result += this._input.next();
|
|
2781
|
+
} else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
|
|
2782
|
+
break;
|
|
2783
|
+
}
|
|
2784
|
+
this._ch = this._input.next();
|
|
2785
|
+
}
|
|
2786
|
+
return result;
|
|
2787
|
+
};
|
|
2788
|
+
Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
|
|
2789
|
+
var result = whitespaceChar.test(this._input.peek());
|
|
2790
|
+
var newline_count = 0;
|
|
2791
|
+
while (whitespaceChar.test(this._input.peek())) {
|
|
2792
|
+
this._ch = this._input.next();
|
|
2793
|
+
if (allowAtLeastOneNewLine && this._ch === "\n") {
|
|
2794
|
+
if (newline_count === 0 || newline_count < this._options.max_preserve_newlines) {
|
|
2795
|
+
newline_count++;
|
|
2796
|
+
this._output.add_new_line(true);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
return result;
|
|
2801
|
+
};
|
|
2802
|
+
Beautifier.prototype.foundNestedPseudoClass = function() {
|
|
2803
|
+
var openParen = 0;
|
|
2804
|
+
var i = 1;
|
|
2805
|
+
var ch = this._input.peek(i);
|
|
2806
|
+
while (ch) {
|
|
2807
|
+
if (ch === "{") {
|
|
2808
|
+
return true;
|
|
2809
|
+
} else if (ch === "(") {
|
|
2810
|
+
openParen += 1;
|
|
2811
|
+
} else if (ch === ")") {
|
|
2812
|
+
if (openParen === 0) {
|
|
2813
|
+
return false;
|
|
2814
|
+
}
|
|
2815
|
+
openParen -= 1;
|
|
2816
|
+
} else if (ch === ";" || ch === "}") {
|
|
2817
|
+
return false;
|
|
2818
|
+
}
|
|
2819
|
+
i++;
|
|
2820
|
+
ch = this._input.peek(i);
|
|
2821
|
+
}
|
|
2822
|
+
return false;
|
|
2823
|
+
};
|
|
2824
|
+
Beautifier.prototype.print_string = function(output_string) {
|
|
2825
|
+
this._output.set_indent(this._indentLevel);
|
|
2826
|
+
this._output.non_breaking_space = true;
|
|
2827
|
+
this._output.add_token(output_string);
|
|
2828
|
+
};
|
|
2829
|
+
Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) {
|
|
2830
|
+
if (isAfterSpace) {
|
|
2831
|
+
this._output.space_before_token = true;
|
|
2832
|
+
}
|
|
2833
|
+
};
|
|
2834
|
+
Beautifier.prototype.indent = function() {
|
|
2835
|
+
this._indentLevel++;
|
|
2836
|
+
};
|
|
2837
|
+
Beautifier.prototype.outdent = function() {
|
|
2838
|
+
if (this._indentLevel > 0) {
|
|
2839
|
+
this._indentLevel--;
|
|
2840
|
+
}
|
|
2841
|
+
};
|
|
2842
|
+
Beautifier.prototype.beautify = function() {
|
|
2843
|
+
if (this._options.disabled) {
|
|
2844
|
+
return this._source_text;
|
|
2845
|
+
}
|
|
2846
|
+
var source_text = this._source_text;
|
|
2847
|
+
var eol = this._options.eol;
|
|
2848
|
+
if (eol === "auto") {
|
|
2849
|
+
eol = "\n";
|
|
2850
|
+
if (source_text && lineBreak.test(source_text || "")) {
|
|
2851
|
+
eol = source_text.match(lineBreak)[0];
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
source_text = source_text.replace(allLineBreaks, "\n");
|
|
2855
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
2856
|
+
this._output = new Output(this._options, baseIndentString);
|
|
2857
|
+
this._input = new InputScanner(source_text);
|
|
2858
|
+
this._indentLevel = 0;
|
|
2859
|
+
this._nestedLevel = 0;
|
|
2860
|
+
this._ch = null;
|
|
2861
|
+
var parenLevel = 0;
|
|
2862
|
+
var insideRule = false;
|
|
2863
|
+
var insidePropertyValue = false;
|
|
2864
|
+
var enteringConditionalGroup = false;
|
|
2865
|
+
var insideNonNestedAtRule = false;
|
|
2866
|
+
var insideScssMap = false;
|
|
2867
|
+
var topCharacter = this._ch;
|
|
2868
|
+
var insideNonSemiColonValues = false;
|
|
2869
|
+
var whitespace;
|
|
2870
|
+
var isAfterSpace;
|
|
2871
|
+
var previous_ch;
|
|
2872
|
+
while (true) {
|
|
2873
|
+
whitespace = this._input.read(whitespacePattern);
|
|
2874
|
+
isAfterSpace = whitespace !== "";
|
|
2875
|
+
previous_ch = topCharacter;
|
|
2876
|
+
this._ch = this._input.next();
|
|
2877
|
+
if (this._ch === "\\" && this._input.hasNext()) {
|
|
2878
|
+
this._ch += this._input.next();
|
|
2879
|
+
}
|
|
2880
|
+
topCharacter = this._ch;
|
|
2881
|
+
if (!this._ch) {
|
|
2882
|
+
break;
|
|
2883
|
+
} else if (this._ch === "/" && this._input.peek() === "*") {
|
|
2884
|
+
this._output.add_new_line();
|
|
2885
|
+
this._input.back();
|
|
2886
|
+
var comment = this._input.read(block_comment_pattern);
|
|
2887
|
+
var directives = directives_core.get_directives(comment);
|
|
2888
|
+
if (directives && directives.ignore === "start") {
|
|
2889
|
+
comment += directives_core.readIgnored(this._input);
|
|
2890
|
+
}
|
|
2891
|
+
this.print_string(comment);
|
|
2892
|
+
this.eatWhitespace(true);
|
|
2893
|
+
this._output.add_new_line();
|
|
2894
|
+
} else if (this._ch === "/" && this._input.peek() === "/") {
|
|
2895
|
+
this._output.space_before_token = true;
|
|
2896
|
+
this._input.back();
|
|
2897
|
+
this.print_string(this._input.read(comment_pattern));
|
|
2898
|
+
this.eatWhitespace(true);
|
|
2899
|
+
} else if (this._ch === "$") {
|
|
2900
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
2901
|
+
this.print_string(this._ch);
|
|
2902
|
+
var variable = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
|
|
2903
|
+
if (variable.match(/[ :]$/)) {
|
|
2904
|
+
variable = this.eatString(": ").replace(/\s+$/, "");
|
|
2905
|
+
this.print_string(variable);
|
|
2906
|
+
this._output.space_before_token = true;
|
|
2907
|
+
}
|
|
2908
|
+
if (parenLevel === 0 && variable.indexOf(":") !== -1) {
|
|
2909
|
+
insidePropertyValue = true;
|
|
2910
|
+
this.indent();
|
|
2911
|
+
}
|
|
2912
|
+
} else if (this._ch === "@") {
|
|
2913
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
2914
|
+
if (this._input.peek() === "{") {
|
|
2915
|
+
this.print_string(this._ch + this.eatString("}"));
|
|
2916
|
+
} else {
|
|
2917
|
+
this.print_string(this._ch);
|
|
2918
|
+
var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
|
|
2919
|
+
if (variableOrRule.match(/[ :]$/)) {
|
|
2920
|
+
variableOrRule = this.eatString(": ").replace(/\s+$/, "");
|
|
2921
|
+
this.print_string(variableOrRule);
|
|
2922
|
+
this._output.space_before_token = true;
|
|
2923
|
+
}
|
|
2924
|
+
if (parenLevel === 0 && variableOrRule.indexOf(":") !== -1) {
|
|
2925
|
+
insidePropertyValue = true;
|
|
2926
|
+
this.indent();
|
|
2927
|
+
} else if (variableOrRule in this.NESTED_AT_RULE) {
|
|
2928
|
+
this._nestedLevel += 1;
|
|
2929
|
+
if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
|
|
2930
|
+
enteringConditionalGroup = true;
|
|
2931
|
+
}
|
|
2932
|
+
} else if (parenLevel === 0 && !insidePropertyValue) {
|
|
2933
|
+
insideNonNestedAtRule = true;
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
} else if (this._ch === "#" && this._input.peek() === "{") {
|
|
2937
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
2938
|
+
this.print_string(this._ch + this.eatString("}"));
|
|
2939
|
+
} else if (this._ch === "{") {
|
|
2940
|
+
if (insidePropertyValue) {
|
|
2941
|
+
insidePropertyValue = false;
|
|
2942
|
+
this.outdent();
|
|
2943
|
+
}
|
|
2944
|
+
insideNonNestedAtRule = false;
|
|
2945
|
+
if (enteringConditionalGroup) {
|
|
2946
|
+
enteringConditionalGroup = false;
|
|
2947
|
+
insideRule = this._indentLevel >= this._nestedLevel;
|
|
2948
|
+
} else {
|
|
2949
|
+
insideRule = this._indentLevel >= this._nestedLevel - 1;
|
|
2950
|
+
}
|
|
2951
|
+
if (this._options.newline_between_rules && insideRule) {
|
|
2952
|
+
if (this._output.previous_line && this._output.previous_line.item(-1) !== "{") {
|
|
2953
|
+
this._output.ensure_empty_line_above("/", ",");
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
this._output.space_before_token = true;
|
|
2957
|
+
if (this._options.brace_style === "expand") {
|
|
2958
|
+
this._output.add_new_line();
|
|
2959
|
+
this.print_string(this._ch);
|
|
2960
|
+
this.indent();
|
|
2961
|
+
this._output.set_indent(this._indentLevel);
|
|
2962
|
+
} else {
|
|
2963
|
+
if (previous_ch === "(") {
|
|
2964
|
+
this._output.space_before_token = false;
|
|
2965
|
+
} else if (previous_ch !== ",") {
|
|
2966
|
+
this.indent();
|
|
2967
|
+
}
|
|
2968
|
+
this.print_string(this._ch);
|
|
2969
|
+
}
|
|
2970
|
+
this.eatWhitespace(true);
|
|
2971
|
+
this._output.add_new_line();
|
|
2972
|
+
} else if (this._ch === "}") {
|
|
2973
|
+
this.outdent();
|
|
2974
|
+
this._output.add_new_line();
|
|
2975
|
+
if (previous_ch === "{") {
|
|
2976
|
+
this._output.trim(true);
|
|
2977
|
+
}
|
|
2978
|
+
if (insidePropertyValue) {
|
|
2979
|
+
this.outdent();
|
|
2980
|
+
insidePropertyValue = false;
|
|
2981
|
+
}
|
|
2982
|
+
this.print_string(this._ch);
|
|
2983
|
+
insideRule = false;
|
|
2984
|
+
if (this._nestedLevel) {
|
|
2985
|
+
this._nestedLevel--;
|
|
2986
|
+
}
|
|
2987
|
+
this.eatWhitespace(true);
|
|
2988
|
+
this._output.add_new_line();
|
|
2989
|
+
if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
|
|
2990
|
+
if (this._input.peek() !== "}") {
|
|
2991
|
+
this._output.add_new_line(true);
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
if (this._input.peek() === ")") {
|
|
2995
|
+
this._output.trim(true);
|
|
2996
|
+
if (this._options.brace_style === "expand") {
|
|
2997
|
+
this._output.add_new_line(true);
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
} else if (this._ch === ":") {
|
|
3001
|
+
for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
|
|
3002
|
+
if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
|
|
3003
|
+
insideNonSemiColonValues = true;
|
|
3004
|
+
break;
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideNonNestedAtRule && parenLevel === 0) {
|
|
3008
|
+
this.print_string(":");
|
|
3009
|
+
if (!insidePropertyValue) {
|
|
3010
|
+
insidePropertyValue = true;
|
|
3011
|
+
this._output.space_before_token = true;
|
|
3012
|
+
this.eatWhitespace(true);
|
|
3013
|
+
this.indent();
|
|
3014
|
+
}
|
|
3015
|
+
} else {
|
|
3016
|
+
if (this._input.lookBack(" ")) {
|
|
3017
|
+
this._output.space_before_token = true;
|
|
3018
|
+
}
|
|
3019
|
+
if (this._input.peek() === ":") {
|
|
3020
|
+
this._ch = this._input.next();
|
|
3021
|
+
this.print_string("::");
|
|
3022
|
+
} else {
|
|
3023
|
+
this.print_string(":");
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
} else if (this._ch === '"' || this._ch === "'") {
|
|
3027
|
+
var preserveQuoteSpace = previous_ch === '"' || previous_ch === "'";
|
|
3028
|
+
this.preserveSingleSpace(preserveQuoteSpace || isAfterSpace);
|
|
3029
|
+
this.print_string(this._ch + this.eatString(this._ch));
|
|
3030
|
+
this.eatWhitespace(true);
|
|
3031
|
+
} else if (this._ch === ";") {
|
|
3032
|
+
insideNonSemiColonValues = false;
|
|
3033
|
+
if (parenLevel === 0) {
|
|
3034
|
+
if (insidePropertyValue) {
|
|
3035
|
+
this.outdent();
|
|
3036
|
+
insidePropertyValue = false;
|
|
3037
|
+
}
|
|
3038
|
+
insideNonNestedAtRule = false;
|
|
3039
|
+
this.print_string(this._ch);
|
|
3040
|
+
this.eatWhitespace(true);
|
|
3041
|
+
if (this._input.peek() !== "/") {
|
|
3042
|
+
this._output.add_new_line();
|
|
3043
|
+
}
|
|
3044
|
+
} else {
|
|
3045
|
+
this.print_string(this._ch);
|
|
3046
|
+
this.eatWhitespace(true);
|
|
3047
|
+
this._output.space_before_token = true;
|
|
3048
|
+
}
|
|
3049
|
+
} else if (this._ch === "(") {
|
|
3050
|
+
if (this._input.lookBack("url")) {
|
|
3051
|
+
this.print_string(this._ch);
|
|
3052
|
+
this.eatWhitespace();
|
|
3053
|
+
parenLevel++;
|
|
3054
|
+
this.indent();
|
|
3055
|
+
this._ch = this._input.next();
|
|
3056
|
+
if (this._ch === ")" || this._ch === '"' || this._ch === "'") {
|
|
3057
|
+
this._input.back();
|
|
3058
|
+
} else if (this._ch) {
|
|
3059
|
+
this.print_string(this._ch + this.eatString(")"));
|
|
3060
|
+
if (parenLevel) {
|
|
3061
|
+
parenLevel--;
|
|
3062
|
+
this.outdent();
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
} else {
|
|
3066
|
+
var space_needed = false;
|
|
3067
|
+
if (this._input.lookBack("with")) {
|
|
3068
|
+
space_needed = true;
|
|
3069
|
+
}
|
|
3070
|
+
this.preserveSingleSpace(isAfterSpace || space_needed);
|
|
3071
|
+
this.print_string(this._ch);
|
|
3072
|
+
if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
|
|
3073
|
+
this._output.add_new_line();
|
|
3074
|
+
insideScssMap = true;
|
|
3075
|
+
} else {
|
|
3076
|
+
this.eatWhitespace();
|
|
3077
|
+
parenLevel++;
|
|
3078
|
+
this.indent();
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
} else if (this._ch === ")") {
|
|
3082
|
+
if (parenLevel) {
|
|
3083
|
+
parenLevel--;
|
|
3084
|
+
this.outdent();
|
|
3085
|
+
}
|
|
3086
|
+
if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
|
|
3087
|
+
insideScssMap = false;
|
|
3088
|
+
this.outdent();
|
|
3089
|
+
this._output.add_new_line();
|
|
3090
|
+
}
|
|
3091
|
+
this.print_string(this._ch);
|
|
3092
|
+
} else if (this._ch === ",") {
|
|
3093
|
+
this.print_string(this._ch);
|
|
3094
|
+
this.eatWhitespace(true);
|
|
3095
|
+
if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideNonNestedAtRule) {
|
|
3096
|
+
this._output.add_new_line();
|
|
3097
|
+
} else {
|
|
3098
|
+
this._output.space_before_token = true;
|
|
3099
|
+
}
|
|
3100
|
+
} else if ((this._ch === ">" || this._ch === "+" || this._ch === "~") && !insidePropertyValue && parenLevel === 0) {
|
|
3101
|
+
if (this._options.space_around_combinator) {
|
|
3102
|
+
this._output.space_before_token = true;
|
|
3103
|
+
this.print_string(this._ch);
|
|
3104
|
+
this._output.space_before_token = true;
|
|
3105
|
+
} else {
|
|
3106
|
+
this.print_string(this._ch);
|
|
3107
|
+
this.eatWhitespace();
|
|
3108
|
+
if (this._ch && whitespaceChar.test(this._ch)) {
|
|
3109
|
+
this._ch = "";
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
} else if (this._ch === "]") {
|
|
3113
|
+
this.print_string(this._ch);
|
|
3114
|
+
} else if (this._ch === "[") {
|
|
3115
|
+
this.preserveSingleSpace(isAfterSpace);
|
|
3116
|
+
this.print_string(this._ch);
|
|
3117
|
+
} else if (this._ch === "=") {
|
|
3118
|
+
this.eatWhitespace();
|
|
3119
|
+
this.print_string("=");
|
|
3120
|
+
if (whitespaceChar.test(this._ch)) {
|
|
3121
|
+
this._ch = "";
|
|
3122
|
+
}
|
|
3123
|
+
} else if (this._ch === "!" && !this._input.lookBack("\\")) {
|
|
3124
|
+
this._output.space_before_token = true;
|
|
3125
|
+
this.print_string(this._ch);
|
|
3126
|
+
} else {
|
|
3127
|
+
var preserveAfterSpace = previous_ch === '"' || previous_ch === "'";
|
|
3128
|
+
this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
|
|
3129
|
+
this.print_string(this._ch);
|
|
3130
|
+
if (!this._output.just_added_newline() && this._input.peek() === "\n" && insideNonSemiColonValues) {
|
|
3131
|
+
this._output.add_new_line();
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
var sweetCode = this._output.get_code(eol);
|
|
3136
|
+
return sweetCode;
|
|
3137
|
+
};
|
|
3138
|
+
module2.exports.Beautifier = Beautifier;
|
|
3139
|
+
}
|
|
3140
|
+
});
|
|
3141
|
+
|
|
3142
|
+
// node_modules/js-beautify/js/src/css/index.js
|
|
3143
|
+
var require_css = __commonJS({
|
|
3144
|
+
"node_modules/js-beautify/js/src/css/index.js"(exports2, module2) {
|
|
3145
|
+
"use strict";
|
|
3146
|
+
var Beautifier = require_beautifier2().Beautifier;
|
|
3147
|
+
var Options = require_options3().Options;
|
|
3148
|
+
function css_beautify(source_text, options) {
|
|
3149
|
+
var beautifier = new Beautifier(source_text, options);
|
|
3150
|
+
return beautifier.beautify();
|
|
3151
|
+
}
|
|
3152
|
+
module2.exports = css_beautify;
|
|
3153
|
+
module2.exports.defaultOptions = function() {
|
|
3154
|
+
return new Options();
|
|
3155
|
+
};
|
|
3156
|
+
}
|
|
3157
|
+
});
|
|
3158
|
+
|
|
3159
|
+
// node_modules/js-beautify/js/src/html/options.js
|
|
3160
|
+
var require_options4 = __commonJS({
|
|
3161
|
+
"node_modules/js-beautify/js/src/html/options.js"(exports2, module2) {
|
|
3162
|
+
"use strict";
|
|
3163
|
+
var BaseOptions = require_options().Options;
|
|
3164
|
+
function Options(options) {
|
|
3165
|
+
BaseOptions.call(this, options, "html");
|
|
3166
|
+
if (this.templating.length === 1 && this.templating[0] === "auto") {
|
|
3167
|
+
this.templating = ["django", "erb", "handlebars", "php"];
|
|
3168
|
+
}
|
|
3169
|
+
this.indent_inner_html = this._get_boolean("indent_inner_html");
|
|
3170
|
+
this.indent_body_inner_html = this._get_boolean("indent_body_inner_html", true);
|
|
3171
|
+
this.indent_head_inner_html = this._get_boolean("indent_head_inner_html", true);
|
|
3172
|
+
this.indent_handlebars = this._get_boolean("indent_handlebars", true);
|
|
3173
|
+
this.wrap_attributes = this._get_selection(
|
|
3174
|
+
"wrap_attributes",
|
|
3175
|
+
["auto", "force", "force-aligned", "force-expand-multiline", "aligned-multiple", "preserve", "preserve-aligned"]
|
|
3176
|
+
);
|
|
3177
|
+
this.wrap_attributes_min_attrs = this._get_number("wrap_attributes_min_attrs", 2);
|
|
3178
|
+
this.wrap_attributes_indent_size = this._get_number("wrap_attributes_indent_size", this.indent_size);
|
|
3179
|
+
this.extra_liners = this._get_array("extra_liners", ["head", "body", "/html"]);
|
|
3180
|
+
this.inline = this._get_array("inline", [
|
|
3181
|
+
"a",
|
|
3182
|
+
"abbr",
|
|
3183
|
+
"area",
|
|
3184
|
+
"audio",
|
|
3185
|
+
"b",
|
|
3186
|
+
"bdi",
|
|
3187
|
+
"bdo",
|
|
3188
|
+
"br",
|
|
3189
|
+
"button",
|
|
3190
|
+
"canvas",
|
|
3191
|
+
"cite",
|
|
3192
|
+
"code",
|
|
3193
|
+
"data",
|
|
3194
|
+
"datalist",
|
|
3195
|
+
"del",
|
|
3196
|
+
"dfn",
|
|
3197
|
+
"em",
|
|
3198
|
+
"embed",
|
|
3199
|
+
"i",
|
|
3200
|
+
"iframe",
|
|
3201
|
+
"img",
|
|
3202
|
+
"input",
|
|
3203
|
+
"ins",
|
|
3204
|
+
"kbd",
|
|
3205
|
+
"keygen",
|
|
3206
|
+
"label",
|
|
3207
|
+
"map",
|
|
3208
|
+
"mark",
|
|
3209
|
+
"math",
|
|
3210
|
+
"meter",
|
|
3211
|
+
"noscript",
|
|
3212
|
+
"object",
|
|
3213
|
+
"output",
|
|
3214
|
+
"progress",
|
|
3215
|
+
"q",
|
|
3216
|
+
"ruby",
|
|
3217
|
+
"s",
|
|
3218
|
+
"samp",
|
|
3219
|
+
/* 'script', */
|
|
3220
|
+
"select",
|
|
3221
|
+
"small",
|
|
3222
|
+
"span",
|
|
3223
|
+
"strong",
|
|
3224
|
+
"sub",
|
|
3225
|
+
"sup",
|
|
3226
|
+
"svg",
|
|
3227
|
+
"template",
|
|
3228
|
+
"textarea",
|
|
3229
|
+
"time",
|
|
3230
|
+
"u",
|
|
3231
|
+
"var",
|
|
3232
|
+
"video",
|
|
3233
|
+
"wbr",
|
|
3234
|
+
"text",
|
|
3235
|
+
// obsolete inline tags
|
|
3236
|
+
"acronym",
|
|
3237
|
+
"big",
|
|
3238
|
+
"strike",
|
|
3239
|
+
"tt"
|
|
3240
|
+
]);
|
|
3241
|
+
this.inline_custom_elements = this._get_boolean("inline_custom_elements", true);
|
|
3242
|
+
this.void_elements = this._get_array("void_elements", [
|
|
3243
|
+
// HTLM void elements - aka self-closing tags - aka singletons
|
|
3244
|
+
// https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
|
|
3245
|
+
"area",
|
|
3246
|
+
"base",
|
|
3247
|
+
"br",
|
|
3248
|
+
"col",
|
|
3249
|
+
"embed",
|
|
3250
|
+
"hr",
|
|
3251
|
+
"img",
|
|
3252
|
+
"input",
|
|
3253
|
+
"keygen",
|
|
3254
|
+
"link",
|
|
3255
|
+
"menuitem",
|
|
3256
|
+
"meta",
|
|
3257
|
+
"param",
|
|
3258
|
+
"source",
|
|
3259
|
+
"track",
|
|
3260
|
+
"wbr",
|
|
3261
|
+
// NOTE: Optional tags are too complex for a simple list
|
|
3262
|
+
// they are hard coded in _do_optional_end_element
|
|
3263
|
+
// Doctype and xml elements
|
|
3264
|
+
"!doctype",
|
|
3265
|
+
"?xml",
|
|
3266
|
+
// obsolete tags
|
|
3267
|
+
// basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
|
|
3268
|
+
// isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
|
|
3269
|
+
"basefont",
|
|
3270
|
+
"isindex"
|
|
3271
|
+
]);
|
|
3272
|
+
this.unformatted = this._get_array("unformatted", []);
|
|
3273
|
+
this.content_unformatted = this._get_array("content_unformatted", [
|
|
3274
|
+
"pre",
|
|
3275
|
+
"textarea"
|
|
3276
|
+
]);
|
|
3277
|
+
this.unformatted_content_delimiter = this._get_characters("unformatted_content_delimiter");
|
|
3278
|
+
this.indent_scripts = this._get_selection("indent_scripts", ["normal", "keep", "separate"]);
|
|
3279
|
+
}
|
|
3280
|
+
Options.prototype = new BaseOptions();
|
|
3281
|
+
module2.exports.Options = Options;
|
|
3282
|
+
}
|
|
3283
|
+
});
|
|
3284
|
+
|
|
3285
|
+
// node_modules/js-beautify/js/src/html/tokenizer.js
|
|
3286
|
+
var require_tokenizer3 = __commonJS({
|
|
3287
|
+
"node_modules/js-beautify/js/src/html/tokenizer.js"(exports2, module2) {
|
|
3288
|
+
"use strict";
|
|
3289
|
+
var BaseTokenizer = require_tokenizer().Tokenizer;
|
|
3290
|
+
var BASETOKEN = require_tokenizer().TOKEN;
|
|
3291
|
+
var Directives = require_directives().Directives;
|
|
3292
|
+
var TemplatablePattern = require_templatablepattern().TemplatablePattern;
|
|
3293
|
+
var Pattern = require_pattern().Pattern;
|
|
3294
|
+
var TOKEN = {
|
|
3295
|
+
TAG_OPEN: "TK_TAG_OPEN",
|
|
3296
|
+
TAG_CLOSE: "TK_TAG_CLOSE",
|
|
3297
|
+
CONTROL_FLOW_OPEN: "TK_CONTROL_FLOW_OPEN",
|
|
3298
|
+
CONTROL_FLOW_CLOSE: "TK_CONTROL_FLOW_CLOSE",
|
|
3299
|
+
ATTRIBUTE: "TK_ATTRIBUTE",
|
|
3300
|
+
EQUALS: "TK_EQUALS",
|
|
3301
|
+
VALUE: "TK_VALUE",
|
|
3302
|
+
COMMENT: "TK_COMMENT",
|
|
3303
|
+
TEXT: "TK_TEXT",
|
|
3304
|
+
UNKNOWN: "TK_UNKNOWN",
|
|
3305
|
+
START: BASETOKEN.START,
|
|
3306
|
+
RAW: BASETOKEN.RAW,
|
|
3307
|
+
EOF: BASETOKEN.EOF
|
|
3308
|
+
};
|
|
3309
|
+
var directives_core = new Directives(/<\!--/, /-->/);
|
|
3310
|
+
var Tokenizer = function(input_string, options) {
|
|
3311
|
+
BaseTokenizer.call(this, input_string, options);
|
|
3312
|
+
this._current_tag_name = "";
|
|
3313
|
+
var templatable_reader = new TemplatablePattern(this._input).read_options(this._options);
|
|
3314
|
+
var pattern_reader = new Pattern(this._input);
|
|
3315
|
+
this.__patterns = {
|
|
3316
|
+
word: templatable_reader.until(/[\n\r\t <]/),
|
|
3317
|
+
word_control_flow_close_excluded: templatable_reader.until(/[\n\r\t <}]/),
|
|
3318
|
+
single_quote: templatable_reader.until_after(/'/),
|
|
3319
|
+
double_quote: templatable_reader.until_after(/"/),
|
|
3320
|
+
attribute: templatable_reader.until(/[\n\r\t =>]|\/>/),
|
|
3321
|
+
element_name: templatable_reader.until(/[\n\r\t >\/]/),
|
|
3322
|
+
angular_control_flow_start: pattern_reader.matching(/\@[a-zA-Z]+[^({]*[({]/),
|
|
3323
|
+
handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
|
|
3324
|
+
handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
|
|
3325
|
+
handlebars_open: pattern_reader.until(/[\n\r\t }]/),
|
|
3326
|
+
handlebars_raw_close: pattern_reader.until(/}}/),
|
|
3327
|
+
comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
|
|
3328
|
+
cdata: pattern_reader.starting_with(/<!\[CDATA\[/).until_after(/]]>/),
|
|
3329
|
+
// https://en.wikipedia.org/wiki/Conditional_comment
|
|
3330
|
+
conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
|
|
3331
|
+
processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
|
|
3332
|
+
};
|
|
3333
|
+
if (this._options.indent_handlebars) {
|
|
3334
|
+
this.__patterns.word = this.__patterns.word.exclude("handlebars");
|
|
3335
|
+
this.__patterns.word_control_flow_close_excluded = this.__patterns.word_control_flow_close_excluded.exclude("handlebars");
|
|
3336
|
+
}
|
|
3337
|
+
this._unformatted_content_delimiter = null;
|
|
3338
|
+
if (this._options.unformatted_content_delimiter) {
|
|
3339
|
+
var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
|
|
3340
|
+
this.__patterns.unformatted_content_delimiter = pattern_reader.matching(literal_regexp).until_after(literal_regexp);
|
|
3341
|
+
}
|
|
3342
|
+
};
|
|
3343
|
+
Tokenizer.prototype = new BaseTokenizer();
|
|
3344
|
+
Tokenizer.prototype._is_comment = function(current_token) {
|
|
3345
|
+
return false;
|
|
3346
|
+
};
|
|
3347
|
+
Tokenizer.prototype._is_opening = function(current_token) {
|
|
3348
|
+
return current_token.type === TOKEN.TAG_OPEN || current_token.type === TOKEN.CONTROL_FLOW_OPEN;
|
|
3349
|
+
};
|
|
3350
|
+
Tokenizer.prototype._is_closing = function(current_token, open_token) {
|
|
3351
|
+
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] === "{")) || current_token.type === TOKEN.CONTROL_FLOW_CLOSE && (current_token.text === "}" && open_token.text.endsWith("{"));
|
|
3352
|
+
};
|
|
3353
|
+
Tokenizer.prototype._reset = function() {
|
|
3354
|
+
this._current_tag_name = "";
|
|
3355
|
+
};
|
|
3356
|
+
Tokenizer.prototype._get_next_token = function(previous_token, open_token) {
|
|
3357
|
+
var token = null;
|
|
3358
|
+
this._readWhitespace();
|
|
3359
|
+
var c = this._input.peek();
|
|
3360
|
+
if (c === null) {
|
|
3361
|
+
return this._create_token(TOKEN.EOF, "");
|
|
3362
|
+
}
|
|
3363
|
+
token = token || this._read_open_handlebars(c, open_token);
|
|
3364
|
+
token = token || this._read_attribute(c, previous_token, open_token);
|
|
3365
|
+
token = token || this._read_close(c, open_token);
|
|
3366
|
+
token = token || this._read_script_and_style(c, previous_token);
|
|
3367
|
+
token = token || this._read_control_flows(c, open_token);
|
|
3368
|
+
token = token || this._read_raw_content(c, previous_token, open_token);
|
|
3369
|
+
token = token || this._read_content_word(c, open_token);
|
|
3370
|
+
token = token || this._read_comment_or_cdata(c);
|
|
3371
|
+
token = token || this._read_processing(c);
|
|
3372
|
+
token = token || this._read_open(c, open_token);
|
|
3373
|
+
token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
|
|
3374
|
+
return token;
|
|
3375
|
+
};
|
|
3376
|
+
Tokenizer.prototype._read_comment_or_cdata = function(c) {
|
|
3377
|
+
var token = null;
|
|
3378
|
+
var resulting_string = null;
|
|
3379
|
+
var directives = null;
|
|
3380
|
+
if (c === "<") {
|
|
3381
|
+
var peek1 = this._input.peek(1);
|
|
3382
|
+
if (peek1 === "!") {
|
|
3383
|
+
resulting_string = this.__patterns.comment.read();
|
|
3384
|
+
if (resulting_string) {
|
|
3385
|
+
directives = directives_core.get_directives(resulting_string);
|
|
3386
|
+
if (directives && directives.ignore === "start") {
|
|
3387
|
+
resulting_string += directives_core.readIgnored(this._input);
|
|
3388
|
+
}
|
|
3389
|
+
} else {
|
|
3390
|
+
resulting_string = this.__patterns.cdata.read();
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
if (resulting_string) {
|
|
3394
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
3395
|
+
token.directives = directives;
|
|
3396
|
+
}
|
|
16
3397
|
}
|
|
3398
|
+
return token;
|
|
17
3399
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3400
|
+
Tokenizer.prototype._read_processing = function(c) {
|
|
3401
|
+
var token = null;
|
|
3402
|
+
var resulting_string = null;
|
|
3403
|
+
var directives = null;
|
|
3404
|
+
if (c === "<") {
|
|
3405
|
+
var peek1 = this._input.peek(1);
|
|
3406
|
+
if (peek1 === "!" || peek1 === "?") {
|
|
3407
|
+
resulting_string = this.__patterns.conditional_comment.read();
|
|
3408
|
+
resulting_string = resulting_string || this.__patterns.processing.read();
|
|
3409
|
+
}
|
|
3410
|
+
if (resulting_string) {
|
|
3411
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
3412
|
+
token.directives = directives;
|
|
3413
|
+
}
|
|
3414
|
+
}
|
|
3415
|
+
return token;
|
|
3416
|
+
};
|
|
3417
|
+
Tokenizer.prototype._read_open = function(c, open_token) {
|
|
3418
|
+
var resulting_string = null;
|
|
3419
|
+
var token = null;
|
|
3420
|
+
if (!open_token || open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
|
|
3421
|
+
if (c === "<") {
|
|
3422
|
+
resulting_string = this._input.next();
|
|
3423
|
+
if (this._input.peek() === "/") {
|
|
3424
|
+
resulting_string += this._input.next();
|
|
3425
|
+
}
|
|
3426
|
+
resulting_string += this.__patterns.element_name.read();
|
|
3427
|
+
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
return token;
|
|
3431
|
+
};
|
|
3432
|
+
Tokenizer.prototype._read_open_handlebars = function(c, open_token) {
|
|
3433
|
+
var resulting_string = null;
|
|
3434
|
+
var token = null;
|
|
3435
|
+
if (!open_token || open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
|
|
3436
|
+
if ((this._options.templating.includes("angular") || this._options.indent_handlebars) && c === "{" && this._input.peek(1) === "{") {
|
|
3437
|
+
if (this._options.indent_handlebars && this._input.peek(2) === "!") {
|
|
3438
|
+
resulting_string = this.__patterns.handlebars_comment.read();
|
|
3439
|
+
resulting_string = resulting_string || this.__patterns.handlebars.read();
|
|
3440
|
+
token = this._create_token(TOKEN.COMMENT, resulting_string);
|
|
3441
|
+
} else {
|
|
3442
|
+
resulting_string = this.__patterns.handlebars_open.read();
|
|
3443
|
+
token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
return token;
|
|
3448
|
+
};
|
|
3449
|
+
Tokenizer.prototype._read_control_flows = function(c, open_token) {
|
|
3450
|
+
var resulting_string = "";
|
|
3451
|
+
var token = null;
|
|
3452
|
+
if (!this._options.templating.includes("angular")) {
|
|
3453
|
+
return token;
|
|
3454
|
+
}
|
|
3455
|
+
if (c === "@") {
|
|
3456
|
+
resulting_string = this.__patterns.angular_control_flow_start.read();
|
|
3457
|
+
if (resulting_string === "") {
|
|
3458
|
+
return token;
|
|
3459
|
+
}
|
|
3460
|
+
var opening_parentheses_count = resulting_string.endsWith("(") ? 1 : 0;
|
|
3461
|
+
var closing_parentheses_count = 0;
|
|
3462
|
+
while (!(resulting_string.endsWith("{") && opening_parentheses_count === closing_parentheses_count)) {
|
|
3463
|
+
var next_char = this._input.next();
|
|
3464
|
+
if (next_char === null) {
|
|
3465
|
+
break;
|
|
3466
|
+
} else if (next_char === "(") {
|
|
3467
|
+
opening_parentheses_count++;
|
|
3468
|
+
} else if (next_char === ")") {
|
|
3469
|
+
closing_parentheses_count++;
|
|
3470
|
+
}
|
|
3471
|
+
resulting_string += next_char;
|
|
3472
|
+
}
|
|
3473
|
+
token = this._create_token(TOKEN.CONTROL_FLOW_OPEN, resulting_string);
|
|
3474
|
+
} else if (c === "}" && open_token && open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
|
|
3475
|
+
resulting_string = this._input.next();
|
|
3476
|
+
token = this._create_token(TOKEN.CONTROL_FLOW_CLOSE, resulting_string);
|
|
3477
|
+
}
|
|
3478
|
+
return token;
|
|
3479
|
+
};
|
|
3480
|
+
Tokenizer.prototype._read_close = function(c, open_token) {
|
|
3481
|
+
var resulting_string = null;
|
|
3482
|
+
var token = null;
|
|
3483
|
+
if (open_token && open_token.type === TOKEN.TAG_OPEN) {
|
|
3484
|
+
if (open_token.text[0] === "<" && (c === ">" || c === "/" && this._input.peek(1) === ">")) {
|
|
3485
|
+
resulting_string = this._input.next();
|
|
3486
|
+
if (c === "/") {
|
|
3487
|
+
resulting_string += this._input.next();
|
|
3488
|
+
}
|
|
3489
|
+
token = this._create_token(TOKEN.TAG_CLOSE, resulting_string);
|
|
3490
|
+
} else if (open_token.text[0] === "{" && c === "}" && this._input.peek(1) === "}") {
|
|
3491
|
+
this._input.next();
|
|
3492
|
+
this._input.next();
|
|
3493
|
+
token = this._create_token(TOKEN.TAG_CLOSE, "}}");
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
return token;
|
|
3497
|
+
};
|
|
3498
|
+
Tokenizer.prototype._read_attribute = function(c, previous_token, open_token) {
|
|
3499
|
+
var token = null;
|
|
3500
|
+
var resulting_string = "";
|
|
3501
|
+
if (open_token && open_token.text[0] === "<") {
|
|
3502
|
+
if (c === "=") {
|
|
3503
|
+
token = this._create_token(TOKEN.EQUALS, this._input.next());
|
|
3504
|
+
} else if (c === '"' || c === "'") {
|
|
3505
|
+
var content = this._input.next();
|
|
3506
|
+
if (c === '"') {
|
|
3507
|
+
content += this.__patterns.double_quote.read();
|
|
3508
|
+
} else {
|
|
3509
|
+
content += this.__patterns.single_quote.read();
|
|
3510
|
+
}
|
|
3511
|
+
token = this._create_token(TOKEN.VALUE, content);
|
|
3512
|
+
} else {
|
|
3513
|
+
resulting_string = this.__patterns.attribute.read();
|
|
3514
|
+
if (resulting_string) {
|
|
3515
|
+
if (previous_token.type === TOKEN.EQUALS) {
|
|
3516
|
+
token = this._create_token(TOKEN.VALUE, resulting_string);
|
|
3517
|
+
} else {
|
|
3518
|
+
token = this._create_token(TOKEN.ATTRIBUTE, resulting_string);
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
return token;
|
|
3524
|
+
};
|
|
3525
|
+
Tokenizer.prototype._is_content_unformatted = function(tag_name) {
|
|
3526
|
+
return this._options.void_elements.indexOf(tag_name) === -1 && (this._options.content_unformatted.indexOf(tag_name) !== -1 || this._options.unformatted.indexOf(tag_name) !== -1);
|
|
3527
|
+
};
|
|
3528
|
+
Tokenizer.prototype._read_raw_content = function(c, previous_token, open_token) {
|
|
3529
|
+
var resulting_string = "";
|
|
3530
|
+
if (open_token && open_token.text[0] === "{") {
|
|
3531
|
+
resulting_string = this.__patterns.handlebars_raw_close.read();
|
|
3532
|
+
} else if (previous_token.type === TOKEN.TAG_CLOSE && previous_token.opened.text[0] === "<" && previous_token.text[0] !== "/") {
|
|
3533
|
+
var tag_name = previous_token.opened.text.substr(1).toLowerCase();
|
|
3534
|
+
if (this._is_content_unformatted(tag_name)) {
|
|
3535
|
+
resulting_string = this._input.readUntil(new RegExp("</" + tag_name + "[\\n\\r\\t ]*?>", "ig"));
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3538
|
+
if (resulting_string) {
|
|
3539
|
+
return this._create_token(TOKEN.TEXT, resulting_string);
|
|
3540
|
+
}
|
|
3541
|
+
return null;
|
|
3542
|
+
};
|
|
3543
|
+
Tokenizer.prototype._read_script_and_style = function(c, previous_token) {
|
|
3544
|
+
if (previous_token.type === TOKEN.TAG_CLOSE && previous_token.opened.text[0] === "<" && previous_token.text[0] !== "/") {
|
|
3545
|
+
var tag_name = previous_token.opened.text.substr(1).toLowerCase();
|
|
3546
|
+
if (tag_name === "script" || tag_name === "style") {
|
|
3547
|
+
var token = this._read_comment_or_cdata(c);
|
|
3548
|
+
if (token) {
|
|
3549
|
+
token.type = TOKEN.TEXT;
|
|
3550
|
+
return token;
|
|
3551
|
+
}
|
|
3552
|
+
var resulting_string = this._input.readUntil(new RegExp("</" + tag_name + "[\\n\\r\\t ]*?>", "ig"));
|
|
3553
|
+
if (resulting_string) {
|
|
3554
|
+
return this._create_token(TOKEN.TEXT, resulting_string);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
return null;
|
|
3559
|
+
};
|
|
3560
|
+
Tokenizer.prototype._read_content_word = function(c, open_token) {
|
|
3561
|
+
var resulting_string = "";
|
|
3562
|
+
if (this._options.unformatted_content_delimiter) {
|
|
3563
|
+
if (c === this._options.unformatted_content_delimiter[0]) {
|
|
3564
|
+
resulting_string = this.__patterns.unformatted_content_delimiter.read();
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
if (!resulting_string) {
|
|
3568
|
+
resulting_string = open_token && open_token.type === TOKEN.CONTROL_FLOW_OPEN ? this.__patterns.word_control_flow_close_excluded.read() : this.__patterns.word.read();
|
|
3569
|
+
}
|
|
3570
|
+
if (resulting_string) {
|
|
3571
|
+
return this._create_token(TOKEN.TEXT, resulting_string);
|
|
3572
|
+
}
|
|
3573
|
+
return null;
|
|
3574
|
+
};
|
|
3575
|
+
module2.exports.Tokenizer = Tokenizer;
|
|
3576
|
+
module2.exports.TOKEN = TOKEN;
|
|
3577
|
+
}
|
|
3578
|
+
});
|
|
3579
|
+
|
|
3580
|
+
// node_modules/js-beautify/js/src/html/beautifier.js
|
|
3581
|
+
var require_beautifier3 = __commonJS({
|
|
3582
|
+
"node_modules/js-beautify/js/src/html/beautifier.js"(exports2, module2) {
|
|
3583
|
+
"use strict";
|
|
3584
|
+
var Options = require_options4().Options;
|
|
3585
|
+
var Output = require_output().Output;
|
|
3586
|
+
var Tokenizer = require_tokenizer3().Tokenizer;
|
|
3587
|
+
var TOKEN = require_tokenizer3().TOKEN;
|
|
3588
|
+
var lineBreak = /\r\n|[\r\n]/;
|
|
3589
|
+
var allLineBreaks = /\r\n|[\r\n]/g;
|
|
3590
|
+
var Printer = function(options, base_indent_string) {
|
|
3591
|
+
this.indent_level = 0;
|
|
3592
|
+
this.alignment_size = 0;
|
|
3593
|
+
this.max_preserve_newlines = options.max_preserve_newlines;
|
|
3594
|
+
this.preserve_newlines = options.preserve_newlines;
|
|
3595
|
+
this._output = new Output(options, base_indent_string);
|
|
3596
|
+
};
|
|
3597
|
+
Printer.prototype.current_line_has_match = function(pattern) {
|
|
3598
|
+
return this._output.current_line.has_match(pattern);
|
|
3599
|
+
};
|
|
3600
|
+
Printer.prototype.set_space_before_token = function(value, non_breaking) {
|
|
3601
|
+
this._output.space_before_token = value;
|
|
3602
|
+
this._output.non_breaking_space = non_breaking;
|
|
3603
|
+
};
|
|
3604
|
+
Printer.prototype.set_wrap_point = function() {
|
|
3605
|
+
this._output.set_indent(this.indent_level, this.alignment_size);
|
|
3606
|
+
this._output.set_wrap_point();
|
|
3607
|
+
};
|
|
3608
|
+
Printer.prototype.add_raw_token = function(token) {
|
|
3609
|
+
this._output.add_raw_token(token);
|
|
3610
|
+
};
|
|
3611
|
+
Printer.prototype.print_preserved_newlines = function(raw_token) {
|
|
3612
|
+
var newlines = 0;
|
|
3613
|
+
if (raw_token.type !== TOKEN.TEXT && raw_token.previous.type !== TOKEN.TEXT) {
|
|
3614
|
+
newlines = raw_token.newlines ? 1 : 0;
|
|
3615
|
+
}
|
|
3616
|
+
if (this.preserve_newlines) {
|
|
3617
|
+
newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
|
|
3618
|
+
}
|
|
3619
|
+
for (var n = 0; n < newlines; n++) {
|
|
3620
|
+
this.print_newline(n > 0);
|
|
3621
|
+
}
|
|
3622
|
+
return newlines !== 0;
|
|
3623
|
+
};
|
|
3624
|
+
Printer.prototype.traverse_whitespace = function(raw_token) {
|
|
3625
|
+
if (raw_token.whitespace_before || raw_token.newlines) {
|
|
3626
|
+
if (!this.print_preserved_newlines(raw_token)) {
|
|
3627
|
+
this._output.space_before_token = true;
|
|
3628
|
+
}
|
|
3629
|
+
return true;
|
|
3630
|
+
}
|
|
3631
|
+
return false;
|
|
3632
|
+
};
|
|
3633
|
+
Printer.prototype.previous_token_wrapped = function() {
|
|
3634
|
+
return this._output.previous_token_wrapped;
|
|
3635
|
+
};
|
|
3636
|
+
Printer.prototype.print_newline = function(force) {
|
|
3637
|
+
this._output.add_new_line(force);
|
|
3638
|
+
};
|
|
3639
|
+
Printer.prototype.print_token = function(token) {
|
|
3640
|
+
if (token.text) {
|
|
3641
|
+
this._output.set_indent(this.indent_level, this.alignment_size);
|
|
3642
|
+
this._output.add_token(token.text);
|
|
3643
|
+
}
|
|
3644
|
+
};
|
|
3645
|
+
Printer.prototype.indent = function() {
|
|
3646
|
+
this.indent_level++;
|
|
3647
|
+
};
|
|
3648
|
+
Printer.prototype.deindent = function() {
|
|
3649
|
+
if (this.indent_level > 0) {
|
|
3650
|
+
this.indent_level--;
|
|
3651
|
+
this._output.set_indent(this.indent_level, this.alignment_size);
|
|
3652
|
+
}
|
|
3653
|
+
};
|
|
3654
|
+
Printer.prototype.get_full_indent = function(level) {
|
|
3655
|
+
level = this.indent_level + (level || 0);
|
|
3656
|
+
if (level < 1) {
|
|
3657
|
+
return "";
|
|
3658
|
+
}
|
|
3659
|
+
return this._output.get_indent_string(level);
|
|
3660
|
+
};
|
|
3661
|
+
var get_type_attribute = function(start_token) {
|
|
3662
|
+
var result = null;
|
|
3663
|
+
var raw_token = start_token.next;
|
|
3664
|
+
while (raw_token.type !== TOKEN.EOF && start_token.closed !== raw_token) {
|
|
3665
|
+
if (raw_token.type === TOKEN.ATTRIBUTE && raw_token.text === "type") {
|
|
3666
|
+
if (raw_token.next && raw_token.next.type === TOKEN.EQUALS && raw_token.next.next && raw_token.next.next.type === TOKEN.VALUE) {
|
|
3667
|
+
result = raw_token.next.next.text;
|
|
3668
|
+
}
|
|
3669
|
+
break;
|
|
3670
|
+
}
|
|
3671
|
+
raw_token = raw_token.next;
|
|
3672
|
+
}
|
|
3673
|
+
return result;
|
|
3674
|
+
};
|
|
3675
|
+
var get_custom_beautifier_name = function(tag_check, raw_token) {
|
|
3676
|
+
var typeAttribute = null;
|
|
3677
|
+
var result = null;
|
|
3678
|
+
if (!raw_token.closed) {
|
|
3679
|
+
return null;
|
|
3680
|
+
}
|
|
3681
|
+
if (tag_check === "script") {
|
|
3682
|
+
typeAttribute = "text/javascript";
|
|
3683
|
+
} else if (tag_check === "style") {
|
|
3684
|
+
typeAttribute = "text/css";
|
|
3685
|
+
}
|
|
3686
|
+
typeAttribute = get_type_attribute(raw_token) || typeAttribute;
|
|
3687
|
+
if (typeAttribute.search("text/css") > -1) {
|
|
3688
|
+
result = "css";
|
|
3689
|
+
} else if (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
|
|
3690
|
+
result = "javascript";
|
|
3691
|
+
} else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
|
|
3692
|
+
result = "html";
|
|
3693
|
+
} else if (typeAttribute.search(/test\/null/) > -1) {
|
|
3694
|
+
result = "null";
|
|
3695
|
+
}
|
|
3696
|
+
return result;
|
|
3697
|
+
};
|
|
3698
|
+
function in_array(what, arr) {
|
|
3699
|
+
return arr.indexOf(what) !== -1;
|
|
3700
|
+
}
|
|
3701
|
+
function TagFrame(parent, parser_token, indent_level) {
|
|
3702
|
+
this.parent = parent || null;
|
|
3703
|
+
this.tag = parser_token ? parser_token.tag_name : "";
|
|
3704
|
+
this.indent_level = indent_level || 0;
|
|
3705
|
+
this.parser_token = parser_token || null;
|
|
3706
|
+
}
|
|
3707
|
+
function TagStack(printer) {
|
|
3708
|
+
this._printer = printer;
|
|
3709
|
+
this._current_frame = null;
|
|
3710
|
+
}
|
|
3711
|
+
TagStack.prototype.get_parser_token = function() {
|
|
3712
|
+
return this._current_frame ? this._current_frame.parser_token : null;
|
|
3713
|
+
};
|
|
3714
|
+
TagStack.prototype.record_tag = function(parser_token) {
|
|
3715
|
+
var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
|
|
3716
|
+
this._current_frame = new_frame;
|
|
3717
|
+
};
|
|
3718
|
+
TagStack.prototype._try_pop_frame = function(frame) {
|
|
3719
|
+
var parser_token = null;
|
|
3720
|
+
if (frame) {
|
|
3721
|
+
parser_token = frame.parser_token;
|
|
3722
|
+
this._printer.indent_level = frame.indent_level;
|
|
3723
|
+
this._current_frame = frame.parent;
|
|
3724
|
+
}
|
|
3725
|
+
return parser_token;
|
|
3726
|
+
};
|
|
3727
|
+
TagStack.prototype._get_frame = function(tag_list, stop_list) {
|
|
3728
|
+
var frame = this._current_frame;
|
|
3729
|
+
while (frame) {
|
|
3730
|
+
if (tag_list.indexOf(frame.tag) !== -1) {
|
|
3731
|
+
break;
|
|
3732
|
+
} else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
|
|
3733
|
+
frame = null;
|
|
3734
|
+
break;
|
|
3735
|
+
}
|
|
3736
|
+
frame = frame.parent;
|
|
3737
|
+
}
|
|
3738
|
+
return frame;
|
|
3739
|
+
};
|
|
3740
|
+
TagStack.prototype.try_pop = function(tag, stop_list) {
|
|
3741
|
+
var frame = this._get_frame([tag], stop_list);
|
|
3742
|
+
return this._try_pop_frame(frame);
|
|
3743
|
+
};
|
|
3744
|
+
TagStack.prototype.indent_to_tag = function(tag_list) {
|
|
3745
|
+
var frame = this._get_frame(tag_list);
|
|
3746
|
+
if (frame) {
|
|
3747
|
+
this._printer.indent_level = frame.indent_level;
|
|
3748
|
+
}
|
|
3749
|
+
};
|
|
3750
|
+
function Beautifier(source_text, options, js_beautify, css_beautify) {
|
|
3751
|
+
this._source_text = source_text || "";
|
|
3752
|
+
options = options || {};
|
|
3753
|
+
this._js_beautify = js_beautify;
|
|
3754
|
+
this._css_beautify = css_beautify;
|
|
3755
|
+
this._tag_stack = null;
|
|
3756
|
+
var optionHtml = new Options(options, "html");
|
|
3757
|
+
this._options = optionHtml;
|
|
3758
|
+
this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, "force".length) === "force";
|
|
3759
|
+
this._is_wrap_attributes_force_expand_multiline = this._options.wrap_attributes === "force-expand-multiline";
|
|
3760
|
+
this._is_wrap_attributes_force_aligned = this._options.wrap_attributes === "force-aligned";
|
|
3761
|
+
this._is_wrap_attributes_aligned_multiple = this._options.wrap_attributes === "aligned-multiple";
|
|
3762
|
+
this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, "preserve".length) === "preserve";
|
|
3763
|
+
this._is_wrap_attributes_preserve_aligned = this._options.wrap_attributes === "preserve-aligned";
|
|
3764
|
+
}
|
|
3765
|
+
Beautifier.prototype.beautify = function() {
|
|
3766
|
+
if (this._options.disabled) {
|
|
3767
|
+
return this._source_text;
|
|
3768
|
+
}
|
|
3769
|
+
var source_text = this._source_text;
|
|
3770
|
+
var eol = this._options.eol;
|
|
3771
|
+
if (this._options.eol === "auto") {
|
|
3772
|
+
eol = "\n";
|
|
3773
|
+
if (source_text && lineBreak.test(source_text)) {
|
|
3774
|
+
eol = source_text.match(lineBreak)[0];
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
source_text = source_text.replace(allLineBreaks, "\n");
|
|
3778
|
+
var baseIndentString = source_text.match(/^[\t ]*/)[0];
|
|
3779
|
+
var last_token = {
|
|
3780
|
+
text: "",
|
|
3781
|
+
type: ""
|
|
3782
|
+
};
|
|
3783
|
+
var last_tag_token = new TagOpenParserToken(this._options);
|
|
3784
|
+
var printer = new Printer(this._options, baseIndentString);
|
|
3785
|
+
var tokens = new Tokenizer(source_text, this._options).tokenize();
|
|
3786
|
+
this._tag_stack = new TagStack(printer);
|
|
3787
|
+
var parser_token = null;
|
|
3788
|
+
var raw_token = tokens.next();
|
|
3789
|
+
while (raw_token.type !== TOKEN.EOF) {
|
|
3790
|
+
if (raw_token.type === TOKEN.TAG_OPEN || raw_token.type === TOKEN.COMMENT) {
|
|
3791
|
+
parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token, tokens);
|
|
3792
|
+
last_tag_token = parser_token;
|
|
3793
|
+
} 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) {
|
|
3794
|
+
parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, last_token);
|
|
3795
|
+
} else if (raw_token.type === TOKEN.TAG_CLOSE) {
|
|
3796
|
+
parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
|
|
3797
|
+
} else if (raw_token.type === TOKEN.TEXT) {
|
|
3798
|
+
parser_token = this._handle_text(printer, raw_token, last_tag_token);
|
|
3799
|
+
} else if (raw_token.type === TOKEN.CONTROL_FLOW_OPEN) {
|
|
3800
|
+
parser_token = this._handle_control_flow_open(printer, raw_token);
|
|
3801
|
+
} else if (raw_token.type === TOKEN.CONTROL_FLOW_CLOSE) {
|
|
3802
|
+
parser_token = this._handle_control_flow_close(printer, raw_token);
|
|
3803
|
+
} else {
|
|
3804
|
+
printer.add_raw_token(raw_token);
|
|
3805
|
+
}
|
|
3806
|
+
last_token = parser_token;
|
|
3807
|
+
raw_token = tokens.next();
|
|
3808
|
+
}
|
|
3809
|
+
var sweet_code = printer._output.get_code(eol);
|
|
3810
|
+
return sweet_code;
|
|
3811
|
+
};
|
|
3812
|
+
Beautifier.prototype._handle_control_flow_open = function(printer, raw_token) {
|
|
3813
|
+
var parser_token = {
|
|
3814
|
+
text: raw_token.text,
|
|
3815
|
+
type: raw_token.type
|
|
3816
|
+
};
|
|
3817
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
3818
|
+
if (raw_token.newlines) {
|
|
3819
|
+
printer.print_preserved_newlines(raw_token);
|
|
3820
|
+
} else {
|
|
3821
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
3822
|
+
}
|
|
3823
|
+
printer.print_token(raw_token);
|
|
3824
|
+
printer.indent();
|
|
3825
|
+
return parser_token;
|
|
3826
|
+
};
|
|
3827
|
+
Beautifier.prototype._handle_control_flow_close = function(printer, raw_token) {
|
|
3828
|
+
var parser_token = {
|
|
3829
|
+
text: raw_token.text,
|
|
3830
|
+
type: raw_token.type
|
|
3831
|
+
};
|
|
3832
|
+
printer.deindent();
|
|
3833
|
+
if (raw_token.newlines) {
|
|
3834
|
+
printer.print_preserved_newlines(raw_token);
|
|
3835
|
+
} else {
|
|
3836
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
3837
|
+
}
|
|
3838
|
+
printer.print_token(raw_token);
|
|
3839
|
+
return parser_token;
|
|
3840
|
+
};
|
|
3841
|
+
Beautifier.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
|
|
3842
|
+
var parser_token = {
|
|
3843
|
+
text: raw_token.text,
|
|
3844
|
+
type: raw_token.type
|
|
3845
|
+
};
|
|
3846
|
+
printer.alignment_size = 0;
|
|
3847
|
+
last_tag_token.tag_complete = true;
|
|
3848
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
3849
|
+
if (last_tag_token.is_unformatted) {
|
|
3850
|
+
printer.add_raw_token(raw_token);
|
|
3851
|
+
} else {
|
|
3852
|
+
if (last_tag_token.tag_start_char === "<") {
|
|
3853
|
+
printer.set_space_before_token(raw_token.text[0] === "/", true);
|
|
3854
|
+
if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
|
|
3855
|
+
printer.print_newline(false);
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
printer.print_token(raw_token);
|
|
3859
|
+
}
|
|
3860
|
+
if (last_tag_token.indent_content && !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
|
|
3861
|
+
printer.indent();
|
|
3862
|
+
last_tag_token.indent_content = false;
|
|
3863
|
+
}
|
|
3864
|
+
if (!last_tag_token.is_inline_element && !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
|
|
3865
|
+
printer.set_wrap_point();
|
|
3866
|
+
}
|
|
3867
|
+
return parser_token;
|
|
3868
|
+
};
|
|
3869
|
+
Beautifier.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, last_token) {
|
|
3870
|
+
var wrapped = last_tag_token.has_wrapped_attrs;
|
|
3871
|
+
var parser_token = {
|
|
3872
|
+
text: raw_token.text,
|
|
3873
|
+
type: raw_token.type
|
|
3874
|
+
};
|
|
3875
|
+
printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== "", true);
|
|
3876
|
+
if (last_tag_token.is_unformatted) {
|
|
3877
|
+
printer.add_raw_token(raw_token);
|
|
3878
|
+
} else if (last_tag_token.tag_start_char === "{" && raw_token.type === TOKEN.TEXT) {
|
|
3879
|
+
if (printer.print_preserved_newlines(raw_token)) {
|
|
3880
|
+
raw_token.newlines = 0;
|
|
3881
|
+
printer.add_raw_token(raw_token);
|
|
3882
|
+
} else {
|
|
3883
|
+
printer.print_token(raw_token);
|
|
3884
|
+
}
|
|
3885
|
+
} else {
|
|
3886
|
+
if (raw_token.type === TOKEN.ATTRIBUTE) {
|
|
3887
|
+
printer.set_space_before_token(true);
|
|
3888
|
+
} else if (raw_token.type === TOKEN.EQUALS) {
|
|
3889
|
+
printer.set_space_before_token(false);
|
|
3890
|
+
} else if (raw_token.type === TOKEN.VALUE && raw_token.previous.type === TOKEN.EQUALS) {
|
|
3891
|
+
printer.set_space_before_token(false);
|
|
3892
|
+
}
|
|
3893
|
+
if (raw_token.type === TOKEN.ATTRIBUTE && last_tag_token.tag_start_char === "<") {
|
|
3894
|
+
if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
|
|
3895
|
+
printer.traverse_whitespace(raw_token);
|
|
3896
|
+
wrapped = wrapped || raw_token.newlines !== 0;
|
|
3897
|
+
}
|
|
3898
|
+
if (this._is_wrap_attributes_force && last_tag_token.attr_count >= this._options.wrap_attributes_min_attrs && (last_token.type !== TOKEN.TAG_OPEN || // ie. second attribute and beyond
|
|
3899
|
+
this._is_wrap_attributes_force_expand_multiline)) {
|
|
3900
|
+
printer.print_newline(false);
|
|
3901
|
+
wrapped = true;
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
printer.print_token(raw_token);
|
|
3905
|
+
wrapped = wrapped || printer.previous_token_wrapped();
|
|
3906
|
+
last_tag_token.has_wrapped_attrs = wrapped;
|
|
3907
|
+
}
|
|
3908
|
+
return parser_token;
|
|
3909
|
+
};
|
|
3910
|
+
Beautifier.prototype._handle_text = function(printer, raw_token, last_tag_token) {
|
|
3911
|
+
var parser_token = {
|
|
3912
|
+
text: raw_token.text,
|
|
3913
|
+
type: "TK_CONTENT"
|
|
3914
|
+
};
|
|
3915
|
+
if (last_tag_token.custom_beautifier_name) {
|
|
3916
|
+
this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
|
|
3917
|
+
} else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
|
|
3918
|
+
printer.add_raw_token(raw_token);
|
|
3919
|
+
} else {
|
|
3920
|
+
printer.traverse_whitespace(raw_token);
|
|
3921
|
+
printer.print_token(raw_token);
|
|
3922
|
+
}
|
|
3923
|
+
return parser_token;
|
|
3924
|
+
};
|
|
3925
|
+
Beautifier.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
|
|
3926
|
+
var local = this;
|
|
3927
|
+
if (raw_token.text !== "") {
|
|
3928
|
+
var text = raw_token.text, _beautifier, script_indent_level = 1, pre = "", post = "";
|
|
3929
|
+
if (last_tag_token.custom_beautifier_name === "javascript" && typeof this._js_beautify === "function") {
|
|
3930
|
+
_beautifier = this._js_beautify;
|
|
3931
|
+
} else if (last_tag_token.custom_beautifier_name === "css" && typeof this._css_beautify === "function") {
|
|
3932
|
+
_beautifier = this._css_beautify;
|
|
3933
|
+
} else if (last_tag_token.custom_beautifier_name === "html") {
|
|
3934
|
+
_beautifier = function(html_source, options) {
|
|
3935
|
+
var beautifier = new Beautifier(html_source, options, local._js_beautify, local._css_beautify);
|
|
3936
|
+
return beautifier.beautify();
|
|
3937
|
+
};
|
|
3938
|
+
}
|
|
3939
|
+
if (this._options.indent_scripts === "keep") {
|
|
3940
|
+
script_indent_level = 0;
|
|
3941
|
+
} else if (this._options.indent_scripts === "separate") {
|
|
3942
|
+
script_indent_level = -printer.indent_level;
|
|
3943
|
+
}
|
|
3944
|
+
var indentation = printer.get_full_indent(script_indent_level);
|
|
3945
|
+
text = text.replace(/\n[ \t]*$/, "");
|
|
3946
|
+
if (last_tag_token.custom_beautifier_name !== "html" && text[0] === "<" && text.match(/^(<!--|<!\[CDATA\[)/)) {
|
|
3947
|
+
var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
|
|
3948
|
+
if (!matched) {
|
|
3949
|
+
printer.add_raw_token(raw_token);
|
|
3950
|
+
return;
|
|
3951
|
+
}
|
|
3952
|
+
pre = indentation + matched[1] + "\n";
|
|
3953
|
+
text = matched[4];
|
|
3954
|
+
if (matched[5]) {
|
|
3955
|
+
post = indentation + matched[5];
|
|
3956
|
+
}
|
|
3957
|
+
text = text.replace(/\n[ \t]*$/, "");
|
|
3958
|
+
if (matched[2] || matched[3].indexOf("\n") !== -1) {
|
|
3959
|
+
matched = matched[3].match(/[ \t]+$/);
|
|
3960
|
+
if (matched) {
|
|
3961
|
+
raw_token.whitespace_before = matched[0];
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
if (text) {
|
|
3966
|
+
if (_beautifier) {
|
|
3967
|
+
var Child_options = function() {
|
|
3968
|
+
this.eol = "\n";
|
|
3969
|
+
};
|
|
3970
|
+
Child_options.prototype = this._options.raw_options;
|
|
3971
|
+
var child_options = new Child_options();
|
|
3972
|
+
text = _beautifier(indentation + text, child_options);
|
|
3973
|
+
} else {
|
|
3974
|
+
var white = raw_token.whitespace_before;
|
|
3975
|
+
if (white) {
|
|
3976
|
+
text = text.replace(new RegExp("\n(" + white + ")?", "g"), "\n");
|
|
3977
|
+
}
|
|
3978
|
+
text = indentation + text.replace(/\n/g, "\n" + indentation);
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
if (pre) {
|
|
3982
|
+
if (!text) {
|
|
3983
|
+
text = pre + post;
|
|
3984
|
+
} else {
|
|
3985
|
+
text = pre + text + "\n" + post;
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
printer.print_newline(false);
|
|
3989
|
+
if (text) {
|
|
3990
|
+
raw_token.text = text;
|
|
3991
|
+
raw_token.whitespace_before = "";
|
|
3992
|
+
raw_token.newlines = 0;
|
|
3993
|
+
printer.add_raw_token(raw_token);
|
|
3994
|
+
printer.print_newline(true);
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
};
|
|
3998
|
+
Beautifier.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token, tokens) {
|
|
3999
|
+
var parser_token = this._get_tag_open_token(raw_token);
|
|
4000
|
+
if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) && !last_tag_token.is_empty_element && raw_token.type === TOKEN.TAG_OPEN && !parser_token.is_start_tag) {
|
|
4001
|
+
printer.add_raw_token(raw_token);
|
|
4002
|
+
parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
|
|
4003
|
+
} else {
|
|
4004
|
+
printer.traverse_whitespace(raw_token);
|
|
4005
|
+
this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
|
|
4006
|
+
if (!parser_token.is_inline_element) {
|
|
4007
|
+
printer.set_wrap_point();
|
|
4008
|
+
}
|
|
4009
|
+
printer.print_token(raw_token);
|
|
4010
|
+
}
|
|
4011
|
+
if (parser_token.is_start_tag && this._is_wrap_attributes_force) {
|
|
4012
|
+
var peek_index = 0;
|
|
4013
|
+
var peek_token;
|
|
4014
|
+
do {
|
|
4015
|
+
peek_token = tokens.peek(peek_index);
|
|
4016
|
+
if (peek_token.type === TOKEN.ATTRIBUTE) {
|
|
4017
|
+
parser_token.attr_count += 1;
|
|
4018
|
+
}
|
|
4019
|
+
peek_index += 1;
|
|
4020
|
+
} while (peek_token.type !== TOKEN.EOF && peek_token.type !== TOKEN.TAG_CLOSE);
|
|
4021
|
+
}
|
|
4022
|
+
if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
|
|
4023
|
+
parser_token.alignment_size = raw_token.text.length + 1;
|
|
4024
|
+
}
|
|
4025
|
+
if (!parser_token.tag_complete && !parser_token.is_unformatted) {
|
|
4026
|
+
printer.alignment_size = parser_token.alignment_size;
|
|
4027
|
+
}
|
|
4028
|
+
return parser_token;
|
|
4029
|
+
};
|
|
4030
|
+
var TagOpenParserToken = function(options, parent, raw_token) {
|
|
4031
|
+
this.parent = parent || null;
|
|
4032
|
+
this.text = "";
|
|
4033
|
+
this.type = "TK_TAG_OPEN";
|
|
4034
|
+
this.tag_name = "";
|
|
4035
|
+
this.is_inline_element = false;
|
|
4036
|
+
this.is_unformatted = false;
|
|
4037
|
+
this.is_content_unformatted = false;
|
|
4038
|
+
this.is_empty_element = false;
|
|
4039
|
+
this.is_start_tag = false;
|
|
4040
|
+
this.is_end_tag = false;
|
|
4041
|
+
this.indent_content = false;
|
|
4042
|
+
this.multiline_content = false;
|
|
4043
|
+
this.custom_beautifier_name = null;
|
|
4044
|
+
this.start_tag_token = null;
|
|
4045
|
+
this.attr_count = 0;
|
|
4046
|
+
this.has_wrapped_attrs = false;
|
|
4047
|
+
this.alignment_size = 0;
|
|
4048
|
+
this.tag_complete = false;
|
|
4049
|
+
this.tag_start_char = "";
|
|
4050
|
+
this.tag_check = "";
|
|
4051
|
+
if (!raw_token) {
|
|
4052
|
+
this.tag_complete = true;
|
|
4053
|
+
} else {
|
|
4054
|
+
var tag_check_match;
|
|
4055
|
+
this.tag_start_char = raw_token.text[0];
|
|
4056
|
+
this.text = raw_token.text;
|
|
4057
|
+
if (this.tag_start_char === "<") {
|
|
4058
|
+
tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
|
|
4059
|
+
this.tag_check = tag_check_match ? tag_check_match[1] : "";
|
|
4060
|
+
} else {
|
|
4061
|
+
tag_check_match = raw_token.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/);
|
|
4062
|
+
this.tag_check = tag_check_match ? tag_check_match[1] : "";
|
|
4063
|
+
if ((raw_token.text.startsWith("{{#>") || raw_token.text.startsWith("{{~#>")) && this.tag_check[0] === ">") {
|
|
4064
|
+
if (this.tag_check === ">" && raw_token.next !== null) {
|
|
4065
|
+
this.tag_check = raw_token.next.text.split(" ")[0];
|
|
4066
|
+
} else {
|
|
4067
|
+
this.tag_check = raw_token.text.split(">")[1];
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
this.tag_check = this.tag_check.toLowerCase();
|
|
4072
|
+
if (raw_token.type === TOKEN.COMMENT) {
|
|
4073
|
+
this.tag_complete = true;
|
|
4074
|
+
}
|
|
4075
|
+
this.is_start_tag = this.tag_check.charAt(0) !== "/";
|
|
4076
|
+
this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
|
|
4077
|
+
this.is_end_tag = !this.is_start_tag || raw_token.closed && raw_token.closed.text === "/>";
|
|
4078
|
+
var handlebar_starts = 2;
|
|
4079
|
+
if (this.tag_start_char === "{" && this.text.length >= 3) {
|
|
4080
|
+
if (this.text.charAt(2) === "~") {
|
|
4081
|
+
handlebar_starts = 3;
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
this.is_end_tag = this.is_end_tag || this.tag_start_char === "{" && (!options.indent_handlebars || this.text.length < 3 || /[^#\^]/.test(this.text.charAt(handlebar_starts)));
|
|
4085
|
+
}
|
|
4086
|
+
};
|
|
4087
|
+
Beautifier.prototype._get_tag_open_token = function(raw_token) {
|
|
4088
|
+
var parser_token = new TagOpenParserToken(this._options, this._tag_stack.get_parser_token(), raw_token);
|
|
4089
|
+
parser_token.alignment_size = this._options.wrap_attributes_indent_size;
|
|
4090
|
+
parser_token.is_end_tag = parser_token.is_end_tag || in_array(parser_token.tag_check, this._options.void_elements);
|
|
4091
|
+
parser_token.is_empty_element = parser_token.tag_complete || parser_token.is_start_tag && parser_token.is_end_tag;
|
|
4092
|
+
parser_token.is_unformatted = !parser_token.tag_complete && in_array(parser_token.tag_check, this._options.unformatted);
|
|
4093
|
+
parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array(parser_token.tag_check, this._options.content_unformatted);
|
|
4094
|
+
parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || this._options.inline_custom_elements && parser_token.tag_name.includes("-") || parser_token.tag_start_char === "{";
|
|
4095
|
+
return parser_token;
|
|
4096
|
+
};
|
|
4097
|
+
Beautifier.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
|
|
4098
|
+
if (!parser_token.is_empty_element) {
|
|
4099
|
+
if (parser_token.is_end_tag) {
|
|
4100
|
+
parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
|
|
4101
|
+
} else {
|
|
4102
|
+
if (this._do_optional_end_element(parser_token)) {
|
|
4103
|
+
if (!parser_token.is_inline_element) {
|
|
4104
|
+
printer.print_newline(false);
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
this._tag_stack.record_tag(parser_token);
|
|
4108
|
+
if ((parser_token.tag_name === "script" || parser_token.tag_name === "style") && !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
|
|
4109
|
+
parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
if (in_array(parser_token.tag_check, this._options.extra_liners)) {
|
|
4114
|
+
printer.print_newline(false);
|
|
4115
|
+
if (!printer._output.just_added_blankline()) {
|
|
4116
|
+
printer.print_newline(true);
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
if (parser_token.is_empty_element) {
|
|
4120
|
+
if (parser_token.tag_start_char === "{" && parser_token.tag_check === "else") {
|
|
4121
|
+
this._tag_stack.indent_to_tag(["if", "unless", "each"]);
|
|
4122
|
+
parser_token.indent_content = true;
|
|
4123
|
+
var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
|
|
4124
|
+
if (!foundIfOnCurrentLine) {
|
|
4125
|
+
printer.print_newline(false);
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
if (parser_token.tag_name === "!--" && last_token.type === TOKEN.TAG_CLOSE && last_tag_token.is_end_tag && parser_token.text.indexOf("\n") === -1) {
|
|
4129
|
+
} else {
|
|
4130
|
+
if (!(parser_token.is_inline_element || parser_token.is_unformatted)) {
|
|
4131
|
+
printer.print_newline(false);
|
|
4132
|
+
}
|
|
4133
|
+
this._calcluate_parent_multiline(printer, parser_token);
|
|
4134
|
+
}
|
|
4135
|
+
} else if (parser_token.is_end_tag) {
|
|
4136
|
+
var do_end_expand = false;
|
|
4137
|
+
do_end_expand = parser_token.start_tag_token && parser_token.start_tag_token.multiline_content;
|
|
4138
|
+
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";
|
|
4139
|
+
if (parser_token.is_content_unformatted || parser_token.is_unformatted) {
|
|
4140
|
+
do_end_expand = false;
|
|
4141
|
+
}
|
|
4142
|
+
if (do_end_expand) {
|
|
4143
|
+
printer.print_newline(false);
|
|
4144
|
+
}
|
|
4145
|
+
} else {
|
|
4146
|
+
parser_token.indent_content = !parser_token.custom_beautifier_name;
|
|
4147
|
+
if (parser_token.tag_start_char === "<") {
|
|
4148
|
+
if (parser_token.tag_name === "html") {
|
|
4149
|
+
parser_token.indent_content = this._options.indent_inner_html;
|
|
4150
|
+
} else if (parser_token.tag_name === "head") {
|
|
4151
|
+
parser_token.indent_content = this._options.indent_head_inner_html;
|
|
4152
|
+
} else if (parser_token.tag_name === "body") {
|
|
4153
|
+
parser_token.indent_content = this._options.indent_body_inner_html;
|
|
4154
|
+
}
|
|
4155
|
+
}
|
|
4156
|
+
if (!(parser_token.is_inline_element || parser_token.is_unformatted) && (last_token.type !== "TK_CONTENT" || parser_token.is_content_unformatted)) {
|
|
4157
|
+
printer.print_newline(false);
|
|
4158
|
+
}
|
|
4159
|
+
this._calcluate_parent_multiline(printer, parser_token);
|
|
4160
|
+
}
|
|
4161
|
+
};
|
|
4162
|
+
Beautifier.prototype._calcluate_parent_multiline = function(printer, parser_token) {
|
|
4163
|
+
if (parser_token.parent && printer._output.just_added_newline() && !((parser_token.is_inline_element || parser_token.is_unformatted) && parser_token.parent.is_inline_element)) {
|
|
4164
|
+
parser_token.parent.multiline_content = true;
|
|
4165
|
+
}
|
|
4166
|
+
};
|
|
4167
|
+
var p_closers = ["address", "article", "aside", "blockquote", "details", "div", "dl", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hr", "main", "menu", "nav", "ol", "p", "pre", "section", "table", "ul"];
|
|
4168
|
+
var p_parent_excludes = ["a", "audio", "del", "ins", "map", "noscript", "video"];
|
|
4169
|
+
Beautifier.prototype._do_optional_end_element = function(parser_token) {
|
|
4170
|
+
var result = null;
|
|
4171
|
+
if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
|
|
4172
|
+
return;
|
|
4173
|
+
}
|
|
4174
|
+
if (parser_token.tag_name === "body") {
|
|
4175
|
+
result = result || this._tag_stack.try_pop("head");
|
|
4176
|
+
} else if (parser_token.tag_name === "li") {
|
|
4177
|
+
result = result || this._tag_stack.try_pop("li", ["ol", "ul", "menu"]);
|
|
4178
|
+
} else if (parser_token.tag_name === "dd" || parser_token.tag_name === "dt") {
|
|
4179
|
+
result = result || this._tag_stack.try_pop("dt", ["dl"]);
|
|
4180
|
+
result = result || this._tag_stack.try_pop("dd", ["dl"]);
|
|
4181
|
+
} else if (parser_token.parent.tag_name === "p" && p_closers.indexOf(parser_token.tag_name) !== -1) {
|
|
4182
|
+
var p_parent = parser_token.parent.parent;
|
|
4183
|
+
if (!p_parent || p_parent_excludes.indexOf(p_parent.tag_name) === -1) {
|
|
4184
|
+
result = result || this._tag_stack.try_pop("p");
|
|
4185
|
+
}
|
|
4186
|
+
} else if (parser_token.tag_name === "rp" || parser_token.tag_name === "rt") {
|
|
4187
|
+
result = result || this._tag_stack.try_pop("rt", ["ruby", "rtc"]);
|
|
4188
|
+
result = result || this._tag_stack.try_pop("rp", ["ruby", "rtc"]);
|
|
4189
|
+
} else if (parser_token.tag_name === "optgroup") {
|
|
4190
|
+
result = result || this._tag_stack.try_pop("optgroup", ["select"]);
|
|
4191
|
+
} else if (parser_token.tag_name === "option") {
|
|
4192
|
+
result = result || this._tag_stack.try_pop("option", ["select", "datalist", "optgroup"]);
|
|
4193
|
+
} else if (parser_token.tag_name === "colgroup") {
|
|
4194
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
4195
|
+
} else if (parser_token.tag_name === "thead") {
|
|
4196
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
4197
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
4198
|
+
} else if (parser_token.tag_name === "tbody" || parser_token.tag_name === "tfoot") {
|
|
4199
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
4200
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
4201
|
+
result = result || this._tag_stack.try_pop("thead", ["table"]);
|
|
4202
|
+
result = result || this._tag_stack.try_pop("tbody", ["table"]);
|
|
4203
|
+
} else if (parser_token.tag_name === "tr") {
|
|
4204
|
+
result = result || this._tag_stack.try_pop("caption", ["table"]);
|
|
4205
|
+
result = result || this._tag_stack.try_pop("colgroup", ["table"]);
|
|
4206
|
+
result = result || this._tag_stack.try_pop("tr", ["table", "thead", "tbody", "tfoot"]);
|
|
4207
|
+
} else if (parser_token.tag_name === "th" || parser_token.tag_name === "td") {
|
|
4208
|
+
result = result || this._tag_stack.try_pop("td", ["table", "thead", "tbody", "tfoot", "tr"]);
|
|
4209
|
+
result = result || this._tag_stack.try_pop("th", ["table", "thead", "tbody", "tfoot", "tr"]);
|
|
4210
|
+
}
|
|
4211
|
+
parser_token.parent = this._tag_stack.get_parser_token();
|
|
4212
|
+
return result;
|
|
4213
|
+
};
|
|
4214
|
+
module2.exports.Beautifier = Beautifier;
|
|
4215
|
+
}
|
|
4216
|
+
});
|
|
4217
|
+
|
|
4218
|
+
// node_modules/js-beautify/js/src/html/index.js
|
|
4219
|
+
var require_html = __commonJS({
|
|
4220
|
+
"node_modules/js-beautify/js/src/html/index.js"(exports2, module2) {
|
|
4221
|
+
"use strict";
|
|
4222
|
+
var Beautifier = require_beautifier3().Beautifier;
|
|
4223
|
+
var Options = require_options4().Options;
|
|
4224
|
+
function style_html(html_source, options, js_beautify, css_beautify) {
|
|
4225
|
+
var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify);
|
|
4226
|
+
return beautifier.beautify();
|
|
4227
|
+
}
|
|
4228
|
+
module2.exports = style_html;
|
|
4229
|
+
module2.exports.defaultOptions = function() {
|
|
4230
|
+
return new Options();
|
|
4231
|
+
};
|
|
4232
|
+
}
|
|
4233
|
+
});
|
|
4234
|
+
|
|
4235
|
+
// node_modules/js-beautify/js/src/index.js
|
|
4236
|
+
var require_src = __commonJS({
|
|
4237
|
+
"node_modules/js-beautify/js/src/index.js"(exports2, module2) {
|
|
4238
|
+
"use strict";
|
|
4239
|
+
var js_beautify = require_javascript();
|
|
4240
|
+
var css_beautify = require_css();
|
|
4241
|
+
var html_beautify = require_html();
|
|
4242
|
+
function style_html(html_source, options, js, css) {
|
|
4243
|
+
js = js || js_beautify;
|
|
4244
|
+
css = css || css_beautify;
|
|
4245
|
+
return html_beautify(html_source, options, js, css);
|
|
4246
|
+
}
|
|
4247
|
+
style_html.defaultOptions = html_beautify.defaultOptions;
|
|
4248
|
+
module2.exports.js = js_beautify;
|
|
4249
|
+
module2.exports.css = css_beautify;
|
|
4250
|
+
module2.exports.html = style_html;
|
|
4251
|
+
}
|
|
4252
|
+
});
|
|
4253
|
+
|
|
4254
|
+
// node_modules/js-beautify/js/index.js
|
|
4255
|
+
var require_js = __commonJS({
|
|
4256
|
+
"node_modules/js-beautify/js/index.js"(exports2, module2) {
|
|
4257
|
+
"use strict";
|
|
4258
|
+
function get_beautify(js_beautify, css_beautify, html_beautify) {
|
|
4259
|
+
var beautify2 = function(src, config) {
|
|
4260
|
+
return js_beautify.js_beautify(src, config);
|
|
4261
|
+
};
|
|
4262
|
+
beautify2.js = js_beautify.js_beautify;
|
|
4263
|
+
beautify2.css = css_beautify.css_beautify;
|
|
4264
|
+
beautify2.html = html_beautify.html_beautify;
|
|
4265
|
+
beautify2.js_beautify = js_beautify.js_beautify;
|
|
4266
|
+
beautify2.css_beautify = css_beautify.css_beautify;
|
|
4267
|
+
beautify2.html_beautify = html_beautify.html_beautify;
|
|
4268
|
+
return beautify2;
|
|
4269
|
+
}
|
|
4270
|
+
if (typeof define === "function" && define.amd) {
|
|
4271
|
+
define([
|
|
4272
|
+
"./lib/beautify",
|
|
4273
|
+
"./lib/beautify-css",
|
|
4274
|
+
"./lib/beautify-html"
|
|
4275
|
+
], function(js_beautify, css_beautify, html_beautify) {
|
|
4276
|
+
return get_beautify(js_beautify, css_beautify, html_beautify);
|
|
4277
|
+
});
|
|
4278
|
+
} else {
|
|
4279
|
+
(function(mod) {
|
|
4280
|
+
var beautifier = require_src();
|
|
4281
|
+
beautifier.js_beautify = beautifier.js;
|
|
4282
|
+
beautifier.css_beautify = beautifier.css;
|
|
4283
|
+
beautifier.html_beautify = beautifier.html;
|
|
4284
|
+
mod.exports = get_beautify(beautifier, beautifier, beautifier);
|
|
4285
|
+
})(module2);
|
|
4286
|
+
}
|
|
4287
|
+
}
|
|
4288
|
+
});
|
|
22
4289
|
|
|
23
4290
|
// src/AngelsFrontElement.ts
|
|
24
|
-
var AngelsFrontElementClass = class {
|
|
4291
|
+
var AngelsFrontElementClass = class _AngelsFrontElementClass {
|
|
25
4292
|
constructor(element) {
|
|
26
|
-
this.
|
|
4293
|
+
this.aProxyBaseClass = _AngelsFrontElementClass;
|
|
4294
|
+
this.elementBase = element;
|
|
27
4295
|
return new Proxy(this, {
|
|
28
4296
|
get(target, prop, receiver) {
|
|
29
4297
|
if (prop in target) {
|
|
30
4298
|
return Reflect.get(target, prop);
|
|
31
4299
|
}
|
|
32
|
-
const valueOfProperty = Reflect.get(target.
|
|
4300
|
+
const valueOfProperty = Reflect.get(target.elementBase, prop);
|
|
33
4301
|
if (typeof valueOfProperty === "function") {
|
|
34
|
-
return valueOfProperty.bind(target.
|
|
4302
|
+
return valueOfProperty.bind(target.elementBase);
|
|
35
4303
|
}
|
|
36
4304
|
return valueOfProperty;
|
|
37
4305
|
},
|
|
38
4306
|
set(target, prop, newValue, receiver) {
|
|
39
|
-
if (prop in target.
|
|
40
|
-
target.
|
|
4307
|
+
if (prop in target.elementBase) {
|
|
4308
|
+
target.elementBase[prop] = newValue;
|
|
41
4309
|
} else {
|
|
42
4310
|
target[prop] = newValue;
|
|
43
4311
|
}
|
|
@@ -46,35 +4314,35 @@ var AngelsFrontElementClass = class {
|
|
|
46
4314
|
});
|
|
47
4315
|
}
|
|
48
4316
|
aConcealElement() {
|
|
49
|
-
aLibConcealElement(this.
|
|
4317
|
+
aLibConcealElement(this.elementBase);
|
|
50
4318
|
return this;
|
|
51
4319
|
}
|
|
52
4320
|
aEngageElement(switcher = void 0) {
|
|
53
|
-
aLibEngageElement(this.
|
|
4321
|
+
aLibEngageElement(this.elementBase, switcher);
|
|
54
4322
|
return this;
|
|
55
4323
|
}
|
|
56
4324
|
aHideElement() {
|
|
57
|
-
this.
|
|
4325
|
+
this.elementBase.hidden = true;
|
|
58
4326
|
return this;
|
|
59
4327
|
}
|
|
60
4328
|
aRevealElement() {
|
|
61
|
-
aLibRevealElement(this.
|
|
4329
|
+
aLibRevealElement(this.elementBase);
|
|
62
4330
|
return this;
|
|
63
4331
|
}
|
|
64
4332
|
aShowElement() {
|
|
65
|
-
this.
|
|
4333
|
+
this.elementBase.hidden = false;
|
|
66
4334
|
return this;
|
|
67
4335
|
}
|
|
68
4336
|
aSetTextContent(content) {
|
|
69
4337
|
const contentToSet = content.toString();
|
|
70
|
-
this.
|
|
4338
|
+
this.elementBase.textContent = contentToSet;
|
|
71
4339
|
return this;
|
|
72
4340
|
}
|
|
73
4341
|
aTextContent() {
|
|
74
|
-
if (this.
|
|
4342
|
+
if (this.elementBase.textContent === null) {
|
|
75
4343
|
return ``;
|
|
76
4344
|
}
|
|
77
|
-
return this.
|
|
4345
|
+
return this.elementBase.textContent;
|
|
78
4346
|
}
|
|
79
4347
|
};
|
|
80
4348
|
|
|
@@ -188,7 +4456,7 @@ var AngelsFrontMod = class {
|
|
|
188
4456
|
var AngelsFrontWidgetClass = class extends AngelsFrontMod {
|
|
189
4457
|
constructor(element) {
|
|
190
4458
|
super();
|
|
191
|
-
this.widElement =
|
|
4459
|
+
this.widElement = aLibPrepareElement(element);
|
|
192
4460
|
return new Proxy(this, {
|
|
193
4461
|
get(target, prop, receiver) {
|
|
194
4462
|
if (prop in target) {
|
|
@@ -272,6 +4540,17 @@ function aLibHideElement(selector) {
|
|
|
272
4540
|
element.hidden = true;
|
|
273
4541
|
return element;
|
|
274
4542
|
}
|
|
4543
|
+
function aLibPrepareElement(element) {
|
|
4544
|
+
let angelsFrontElement;
|
|
4545
|
+
if ("aProxyBaseClass" in element && element.aProxyBaseClass === AngelsFrontElementClass) {
|
|
4546
|
+
angelsFrontElement = element;
|
|
4547
|
+
} else if (element instanceof HTMLElement) {
|
|
4548
|
+
angelsFrontElement = new AngelsFrontElementClass(element);
|
|
4549
|
+
} else {
|
|
4550
|
+
throw Error("Cannot prepare element: invalid element type.");
|
|
4551
|
+
}
|
|
4552
|
+
return angelsFrontElement;
|
|
4553
|
+
}
|
|
275
4554
|
function aLibShowElement(selector) {
|
|
276
4555
|
const element = aLibRequireElement(selector);
|
|
277
4556
|
element.hidden = false;
|
|
@@ -280,7 +4559,7 @@ function aLibShowElement(selector) {
|
|
|
280
4559
|
function aLibToggleElement(originalElement, switcher = void 0) {
|
|
281
4560
|
const innerElement = aLibRequireElement(originalElement);
|
|
282
4561
|
if (switcher === void 0) {
|
|
283
|
-
switcher =
|
|
4562
|
+
switcher = innerElement.hidden;
|
|
284
4563
|
}
|
|
285
4564
|
if (switcher) {
|
|
286
4565
|
return aLibShowElement(innerElement);
|
|
@@ -606,6 +4885,152 @@ function angelsStateDefine() {
|
|
|
606
4885
|
return customElements.get("a-state");
|
|
607
4886
|
}
|
|
608
4887
|
|
|
4888
|
+
// src/AngelsFrontWebComponents/AngelsFrontDemoWebComponent.ts
|
|
4889
|
+
var import_js_beautify = __toESM(require_js());
|
|
4890
|
+
var AngelsFrontDemoWebComponent = class extends HTMLElement {
|
|
4891
|
+
constructor() {
|
|
4892
|
+
super();
|
|
4893
|
+
this.awcRoot = this.attachShadow({ mode: "open" });
|
|
4894
|
+
this.awcRoot.innerHTML = this.awcTemplate() + this.awcStyles();
|
|
4895
|
+
this.awcReDraw();
|
|
4896
|
+
}
|
|
4897
|
+
connectedCallback() {
|
|
4898
|
+
this.addEventListener("slotchange", this.awcReDraw.bind(this));
|
|
4899
|
+
}
|
|
4900
|
+
awcReDraw() {
|
|
4901
|
+
const headerPart = this.awcRoot.querySelector('[part="a-demo-header"]');
|
|
4902
|
+
const headerSlot = headerPart.querySelector("slot");
|
|
4903
|
+
headerPart.hidden = !headerSlot.assignedNodes({ flatten: true }).length;
|
|
4904
|
+
const resultSlot = this.awcRoot.querySelector('[part="a-demo-result"] slot');
|
|
4905
|
+
const codePart = this.awcRoot.querySelector('[part="a-demo-code"]');
|
|
4906
|
+
let code = resultSlot.assignedNodes({ flatten: true }).map((n) => n.outerHTML || n.textContent).join("");
|
|
4907
|
+
code = import_js_beautify.default.html(code, {});
|
|
4908
|
+
codePart.textContent = code.trim();
|
|
4909
|
+
}
|
|
4910
|
+
awcTemplate() {
|
|
4911
|
+
return `
|
|
4912
|
+
<div part="a-demo-header"><slot name="a-demo-header"></slot></div>
|
|
4913
|
+
<div part="a-demo-result"><slot></slot></div>
|
|
4914
|
+
<pre part="a-demo-code"></pre>
|
|
4915
|
+
`;
|
|
4916
|
+
}
|
|
4917
|
+
awcStyles() {
|
|
4918
|
+
return `
|
|
4919
|
+
<style>
|
|
4920
|
+
:host {
|
|
4921
|
+
--a-demo-borderColor: darkmagenta;
|
|
4922
|
+
--a-demo-borderRadius: var(--a-borderRadius, 4px);
|
|
4923
|
+
--a-demo-backgroundColor: #fffbf3;
|
|
4924
|
+
}
|
|
4925
|
+
:host {
|
|
4926
|
+
background: var(--a-demo-borderColor);
|
|
4927
|
+
border: 1px solid var(--a-demo-borderColor);
|
|
4928
|
+
border-radius: var(--a-demo-borderRadius);
|
|
4929
|
+
display: grid;
|
|
4930
|
+
gap: 1px;
|
|
4931
|
+
font-family: Arial, sans-serif;
|
|
4932
|
+
overflow: hidden;
|
|
4933
|
+
}
|
|
4934
|
+
:host > * {
|
|
4935
|
+
background: var(--a-demo-backgroundColor);
|
|
4936
|
+
padding: .5em;
|
|
4937
|
+
}
|
|
4938
|
+
[part="a-demo-header"] {
|
|
4939
|
+
}
|
|
4940
|
+
[part="a-demo-result"] slot {
|
|
4941
|
+
}
|
|
4942
|
+
[part="a-demo-code"] {
|
|
4943
|
+
margin: 0;
|
|
4944
|
+
overflow: auto;
|
|
4945
|
+
}
|
|
4946
|
+
</style>
|
|
4947
|
+
`;
|
|
4948
|
+
}
|
|
4949
|
+
};
|
|
4950
|
+
function angelsDemoDefine() {
|
|
4951
|
+
if (!customElements.get("a-demo")) {
|
|
4952
|
+
customElements.define("a-demo", AngelsFrontDemoWebComponent);
|
|
4953
|
+
}
|
|
4954
|
+
return customElements.get("a-demo");
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
// src/AngelsFrontWebComponents/AngelsFrontListWebComponent.ts
|
|
4958
|
+
var _AngelsFrontListWebComponent = class _AngelsFrontListWebComponent extends HTMLElement {
|
|
4959
|
+
constructor() {
|
|
4960
|
+
super();
|
|
4961
|
+
this.awcAppendStyles();
|
|
4962
|
+
}
|
|
4963
|
+
connectedCallback() {
|
|
4964
|
+
this.awcRender();
|
|
4965
|
+
}
|
|
4966
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
4967
|
+
this.awcRender();
|
|
4968
|
+
}
|
|
4969
|
+
awcAppendStyles() {
|
|
4970
|
+
if (_AngelsFrontListWebComponent.awcStylesAppended) {
|
|
4971
|
+
return;
|
|
4972
|
+
}
|
|
4973
|
+
_AngelsFrontListWebComponent.awcStylesAppended = true;
|
|
4974
|
+
const style = document.createElement("style");
|
|
4975
|
+
style.textContent = `
|
|
4976
|
+
a-list {
|
|
4977
|
+
--a-list-space: var(--a-halfSize, 0.5em);
|
|
4978
|
+
display: inline;
|
|
4979
|
+
}
|
|
4980
|
+
a-list::before {
|
|
4981
|
+
content: attr(a-list-prefix);
|
|
4982
|
+
display: inline;
|
|
4983
|
+
}
|
|
4984
|
+
a-list::after {
|
|
4985
|
+
content: attr(a-list-suffix);
|
|
4986
|
+
display: inline;
|
|
4987
|
+
}
|
|
4988
|
+
a-list .a-list-item:not(:last-child)::after {
|
|
4989
|
+
content: attr(a-list-separator);
|
|
4990
|
+
display: inline;
|
|
4991
|
+
margin-right: var(--a-list-space);
|
|
4992
|
+
}
|
|
4993
|
+
`;
|
|
4994
|
+
document.head.appendChild(style);
|
|
4995
|
+
}
|
|
4996
|
+
awcRender() {
|
|
4997
|
+
const itemsAttr = this.getAttribute("a-list");
|
|
4998
|
+
const separator = this.getAttribute("a-list-separator") || " ";
|
|
4999
|
+
if (itemsAttr) {
|
|
5000
|
+
try {
|
|
5001
|
+
const items = JSON.parse(itemsAttr);
|
|
5002
|
+
const children = [];
|
|
5003
|
+
if (Array.isArray(items)) {
|
|
5004
|
+
items.forEach((item, index) => {
|
|
5005
|
+
const span = document.createElement("a-list-item");
|
|
5006
|
+
span.textContent = item;
|
|
5007
|
+
span.classList.add("a-list-item");
|
|
5008
|
+
span.setAttribute("a-list-separator", this.getAttribute("a-list-separator") || " ");
|
|
5009
|
+
children.push(span);
|
|
5010
|
+
});
|
|
5011
|
+
} else {
|
|
5012
|
+
console.error('Attribute "a-list" must be an array of strings.');
|
|
5013
|
+
}
|
|
5014
|
+
this.replaceChildren(...children);
|
|
5015
|
+
} catch (error) {
|
|
5016
|
+
console.error(`Error parsing "a-list" attribute of "${itemsAttr}"`, error);
|
|
5017
|
+
this.replaceChildren();
|
|
5018
|
+
}
|
|
5019
|
+
} else {
|
|
5020
|
+
this.replaceChildren();
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
};
|
|
5024
|
+
_AngelsFrontListWebComponent.awcStylesAppended = false;
|
|
5025
|
+
_AngelsFrontListWebComponent.observedAttributes = ["a-list", "a-list-separator"];
|
|
5026
|
+
var AngelsFrontListWebComponent = _AngelsFrontListWebComponent;
|
|
5027
|
+
function angelsListDefine() {
|
|
5028
|
+
if (!customElements.get("a-list")) {
|
|
5029
|
+
customElements.define("a-list", AngelsFrontListWebComponent);
|
|
5030
|
+
}
|
|
5031
|
+
return customElements.get("a-list");
|
|
5032
|
+
}
|
|
5033
|
+
|
|
609
5034
|
// src/AngelsFrontLoader.ts
|
|
610
5035
|
window.aEngageElement = aLibEngageElement;
|
|
611
5036
|
window.aConcealElement = aLibConcealElement;
|
|
@@ -620,4 +5045,6 @@ angelsBoardDefine({
|
|
|
620
5045
|
displayHandler: aEngageElement
|
|
621
5046
|
});
|
|
622
5047
|
angelsStateDefine();
|
|
5048
|
+
angelsDemoDefine();
|
|
5049
|
+
angelsListDefine();
|
|
623
5050
|
//# sourceMappingURL=AngelsFrontLoader.js.map
|