sun-form-v3 1.0.71 → 1.0.72
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/abap-DfvySaIJ.js +1404 -0
- package/dist/apex-B__0irD3.js +332 -0
- package/dist/assets/css.worker-OK053IOu.js +84 -0
- package/dist/assets/editor.worker-D9iUZyMP.js +11 -0
- package/dist/assets/html.worker-CL40hqKM.js +458 -0
- package/dist/assets/json.worker-6f9bhSHY.js +42 -0
- package/dist/assets/ts.worker-B6g3wjaE.js +37021 -0
- package/dist/azcli-CDMGhRmx.js +74 -0
- package/dist/bat-0Mk8aqzx.js +106 -0
- package/dist/bicep-BBi_I06Z.js +108 -0
- package/dist/cameligo-D0G_Zm6X.js +180 -0
- package/dist/clojure-o2ZKLeMp.js +767 -0
- package/dist/coffee-DOQff5VC.js +238 -0
- package/dist/cpp-CQGJnWhD.js +395 -0
- package/dist/csharp-C1jLsHl8.js +332 -0
- package/dist/csp-C_ttMQaW.js +59 -0
- package/dist/css-BC202kVV.js +193 -0
- package/dist/cssMode-D3INtz5D.js +1541 -0
- package/dist/cypher-DwtEH7Fi.js +269 -0
- package/dist/dart-D9XknsP2.js +287 -0
- package/dist/dockerfile-DgsNjqqa.js +136 -0
- package/dist/ecl-BAMCHBl6.js +462 -0
- package/dist/elixir-CegIttP8.js +575 -0
- package/dist/favicon.ico +0 -0
- package/dist/flow9-9608t7UV.js +148 -0
- package/dist/freemarker2-hasIzj0A.js +995 -0
- package/dist/fsharp-CCtt9-1_.js +223 -0
- package/dist/go-CGUIPbct.js +224 -0
- package/dist/graphql-BNRIFFIn.js +157 -0
- package/dist/handlebars-Cqza9dif.js +425 -0
- package/dist/hcl-C__KLIXe.js +189 -0
- package/dist/html-QpDlLWtS.js +314 -0
- package/dist/htmlMode-3p93KT8l.js +1551 -0
- package/dist/index2-jkDcibEo.js +120443 -0
- package/dist/ini-CeKYn_zA.js +77 -0
- package/dist/java-Dm24deQl.js +238 -0
- package/dist/javascript-CSPB5Brm.js +76 -0
- package/dist/jsonMode-qA6pURD0.js +1957 -0
- package/dist/julia-BImNW7VE.js +517 -0
- package/dist/kotlin-BfE79GEb.js +259 -0
- package/dist/less-DglNOcaC.js +168 -0
- package/dist/lexon-BA0dRz9Q.js +163 -0
- package/dist/liquid-BWuASSim.js +246 -0
- package/dist/lua-DMkWzJcm.js +168 -0
- package/dist/m3-sA-5shO8.js +216 -0
- package/dist/markdown-OYRB1igA.js +235 -0
- package/dist/mdx-CnHJXO9F.js +171 -0
- package/dist/mips-rRzkJ_7G.js +204 -0
- package/dist/msdax-DoVJdUhd.js +381 -0
- package/dist/mysql-Ty44IHXo.js +884 -0
- package/dist/objective-c-VUfyhYrA.js +189 -0
- package/dist/pascal-DkASiYyw.js +257 -0
- package/dist/pascaligo-p-ELPlVO.js +170 -0
- package/dist/perl-Cjl1FxLZ.js +632 -0
- package/dist/pgsql-DjVenF7s.js +857 -0
- package/dist/php-CwvGzZOO.js +506 -0
- package/dist/pla-Br1iaBIV.js +143 -0
- package/dist/postiats-BaeP8zZY.js +913 -0
- package/dist/powerquery-CLCshuo8.js +896 -0
- package/dist/powershell-CZV50w5N.js +245 -0
- package/dist/protobuf-MV3XTewJ.js +426 -0
- package/dist/pug-DkDg4c4l.js +408 -0
- package/dist/python-CRYsEVap.js +282 -0
- package/dist/qsharp-BAtiKA97.js +291 -0
- package/dist/r-8ocrd-h-.js +249 -0
- package/dist/razor-DyEtGntt.js +556 -0
- package/dist/redis-9sZiddxc.js +308 -0
- package/dist/redshift-DQfTOGC0.js +815 -0
- package/dist/restructuredtext-DXU-vkgr.js +180 -0
- package/dist/ruby-DotfqwMf.js +517 -0
- package/dist/rust-BIauJ5KN.js +349 -0
- package/dist/sb-CmWMvDEV.js +121 -0
- package/dist/scala-C81brEbk.js +376 -0
- package/dist/scheme-D0pcFz2x.js +114 -0
- package/dist/scss-BOdN2fGG.js +268 -0
- package/dist/shell-6E09eAkU.js +227 -0
- package/dist/solidity-CWStzA1K.js +1373 -0
- package/dist/sophia-76Sb6CWe.js +205 -0
- package/dist/sparql-BmZTkOWT.js +207 -0
- package/dist/sql-Cs9TBAW5.js +859 -0
- package/dist/st-B-rqE1Bu.js +422 -0
- package/dist/style.css +1 -0
- package/dist/sun-form-v3.es.js +4 -0
- package/dist/sun-form-v3.umd.js +1902 -0
- package/dist/swift-Btsj6YxQ.js +318 -0
- package/dist/systemverilog-B3RHBRa2.js +582 -0
- package/dist/tcl-Dpj776pn.js +238 -0
- package/dist/tsMode-BrlIPEQw.js +885 -0
- package/dist/twig-Bb9JmBsE.js +398 -0
- package/dist/typescript-CYTudnTM.js +349 -0
- package/dist/typespec-CDWeg3SU.js +123 -0
- package/dist/vb-DEXnYwEI.js +378 -0
- package/dist/wgsl-D602c1lx.js +445 -0
- package/dist/xml-B-x5164u.js +101 -0
- package/dist/yaml-Buq2hM65.js +212 -0
- package/package.json +7 -10
- package/src/App.vue +0 -9
- package/src/assets/font/YouSheBiaoTiHei-2.ttf +0 -0
- package/src/assets/font/demo.css +0 -539
- package/src/assets/font/demo_index.html +0 -1200
- package/src/assets/font/iconfont.css +0 -191
- package/src/assets/font/iconfont.js +0 -1
- package/src/assets/font/iconfont.json +0 -317
- package/src/assets/font/iconfont.ttf +0 -0
- package/src/assets/font/iconfont.woff +0 -0
- package/src/assets/font/iconfont.woff2 +0 -0
- package/src/assets/img/bg_footer.png +0 -0
- package/src/assets/img/bg_title.png +0 -0
- package/src/assets/img/file.png +0 -0
- package/src/assets/img/logo.png +0 -0
- package/src/assets/img/logo2.png +0 -0
- package/src/assets/img/logo22.png +0 -0
- package/src/assets/img/logo23.png +0 -0
- package/src/assets/img/logo3.png +0 -0
- package/src/assets/img//347/237/251/345/275/242@2x.png +0 -0
- package/src/assets/logo.svg +0 -1
- package/src/assets/styles/element/index.scss +0 -15
- package/src/assets/styles/index.css +0 -3
- package/src/components/a.js +0 -14
- package/src/components/aDesigner/config.vue +0 -127
- package/src/components/aDesigner/design.vue +0 -20
- package/src/components/aDesigner/index.vue +0 -144
- package/src/components/aDesigner/panel.vue +0 -144
- package/src/components/aDesigner/show.vue +0 -24
- package/src/components/widgetCommonComps/commonApiConfig/index.vue +0 -194
- package/src/components/widgetCommonComps/commonCard/index.vue +0 -36
- package/src/components/widgetCommonComps/commonCodeEditor/editor.vue +0 -219
- package/src/components/widgetCommonComps/commonCodeEditor/modalEditor.vue +0 -68
- package/src/components/widgetCommonComps/commonCollapseCard/index.vue +0 -10
- package/src/components/widgetCommonComps/commonContainer/index.vue +0 -95
- package/src/components/widgetCommonComps/commonJsonInput/index.vue +0 -59
- package/src/components/widgetCommonComps/commonLabelContainer/index.vue +0 -39
- package/src/components/widgetCommonComps/commonSidetree/index.vue +0 -61
- package/src/components/widgetCommonComps/commonTypeInput/index.vue +0 -75
- package/src/components/widgetCommonComps/commonWidgetLabelContainer/index.vue +0 -55
- package/src/components/widgetCommonComps/index copy.js +0 -17
- package/src/components/widgetCommonComps/index.js +0 -17
- package/src/components/widgetConfigComps/config-input/index.vue +0 -60
- package/src/components/widgetConfigComps/index copy.js +0 -13
- package/src/components/widgetConfigComps/index.js +0 -17
- package/src/components/widgetShowComps/index.js +0 -29
- package/src/components/widgetShowComps/widget-form/index.vue +0 -43
- package/src/components/widgetShowComps/widget-homepage/index.vue +0 -41
- package/src/components/widgetShowComps/widget-input/index.vue +0 -85
- package/src/components/widgetShowComps/widget-select/index.vue +0 -31
- package/src/designer.js +0 -342
- package/src/http.js +0 -293
- package/src/index.js +0 -24
- package/src/index2.js +0 -23
- package/src/main.js +0 -19
- package/src/remark.js +0 -708
- package/src/testBtn.vue +0 -11
- package/src/testInput.vue +0 -12
- package/src/util/jsformat.js +0 -568
- package/src/widgetConfig.js +0 -1112
package/src/testBtn.vue
DELETED
package/src/testInput.vue
DELETED
package/src/util/jsformat.js
DELETED
@@ -1,568 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
export function js_beautify(js_source_text, indent_size, indent_character, indent_level)
|
4
|
-
{
|
5
|
-
|
6
|
-
var input, output, token_text, last_type, last_text, last_word, current_mode, modes, indent_string;
|
7
|
-
var whitespace, wordchar, punct, parser_pos, line_starters, in_case;
|
8
|
-
var prefix, token_type, do_block_just_closed, var_line, var_line_tainted;
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
function trim_output()
|
13
|
-
{
|
14
|
-
while (output.length && (output[output.length - 1] === ' ' || output[output.length - 1] === indent_string)) {
|
15
|
-
output.pop();
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
function print_newline(ignore_repeated)
|
20
|
-
{
|
21
|
-
ignore_repeated = typeof ignore_repeated === 'undefined' ? true: ignore_repeated;
|
22
|
-
|
23
|
-
trim_output();
|
24
|
-
|
25
|
-
if (!output.length) {
|
26
|
-
return; // no newline on start of file
|
27
|
-
}
|
28
|
-
|
29
|
-
if (output[output.length - 1] !== "\n" || !ignore_repeated) {
|
30
|
-
output.push("\n");
|
31
|
-
}
|
32
|
-
for (var i = 0; i < indent_level; i++) {
|
33
|
-
output.push(indent_string);
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
function print_space()
|
40
|
-
{
|
41
|
-
var last_output = output.length ? output[output.length - 1] : ' ';
|
42
|
-
if (last_output !== ' ' && last_output !== '\n' && last_output !== indent_string) { // prevent occassional duplicate space
|
43
|
-
output.push(' ');
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
|
48
|
-
function print_token()
|
49
|
-
{
|
50
|
-
output.push(token_text);
|
51
|
-
}
|
52
|
-
|
53
|
-
function indent()
|
54
|
-
{
|
55
|
-
indent_level++;
|
56
|
-
}
|
57
|
-
|
58
|
-
|
59
|
-
function unindent()
|
60
|
-
{
|
61
|
-
if (indent_level) {
|
62
|
-
indent_level--;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
|
67
|
-
function remove_indent()
|
68
|
-
{
|
69
|
-
if (output.length && output[output.length - 1] === indent_string) {
|
70
|
-
output.pop();
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
function set_mode(mode)
|
76
|
-
{
|
77
|
-
modes.push(current_mode);
|
78
|
-
current_mode = mode;
|
79
|
-
}
|
80
|
-
|
81
|
-
|
82
|
-
function restore_mode()
|
83
|
-
{
|
84
|
-
do_block_just_closed = current_mode === 'DO_BLOCK';
|
85
|
-
current_mode = modes.pop();
|
86
|
-
}
|
87
|
-
|
88
|
-
|
89
|
-
function in_array(what, arr)
|
90
|
-
{
|
91
|
-
for (var i = 0; i < arr.length; i++)
|
92
|
-
{
|
93
|
-
if (arr[i] === what) {
|
94
|
-
return true;
|
95
|
-
}
|
96
|
-
}
|
97
|
-
return false;
|
98
|
-
}
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
function get_next_token()
|
103
|
-
{
|
104
|
-
var n_newlines = 0;
|
105
|
-
var c = '';
|
106
|
-
|
107
|
-
do {
|
108
|
-
if (parser_pos >= input.length) {
|
109
|
-
return ['', 'TK_EOF'];
|
110
|
-
}
|
111
|
-
c = input.charAt(parser_pos);
|
112
|
-
|
113
|
-
parser_pos += 1;
|
114
|
-
if (c === "\n") {
|
115
|
-
n_newlines += 1;
|
116
|
-
}
|
117
|
-
}
|
118
|
-
while (in_array(c, whitespace));
|
119
|
-
|
120
|
-
if (n_newlines > 1) {
|
121
|
-
for (var i = 0; i < 2; i++) {
|
122
|
-
print_newline(i === 0);
|
123
|
-
}
|
124
|
-
}
|
125
|
-
var wanted_newline = (n_newlines === 1);
|
126
|
-
|
127
|
-
|
128
|
-
if (in_array(c, wordchar)) {
|
129
|
-
if (parser_pos < input.length) {
|
130
|
-
while (in_array(input.charAt(parser_pos), wordchar)) {
|
131
|
-
c += input.charAt(parser_pos);
|
132
|
-
parser_pos += 1;
|
133
|
-
if (parser_pos === input.length) {
|
134
|
-
break;
|
135
|
-
}
|
136
|
-
}
|
137
|
-
}
|
138
|
-
|
139
|
-
// small and surprisingly unugly hack for 1E-10 representation
|
140
|
-
if (parser_pos !== input.length && c.match(/^[0-9]+[Ee]$/) && input.charAt(parser_pos) === '-') {
|
141
|
-
parser_pos += 1;
|
142
|
-
|
143
|
-
var t = get_next_token(parser_pos);
|
144
|
-
c += '-' + t[0];
|
145
|
-
return [c, 'TK_WORD'];
|
146
|
-
}
|
147
|
-
|
148
|
-
if (c === 'in') { // hack for 'in' operator
|
149
|
-
return [c, 'TK_OPERATOR'];
|
150
|
-
}
|
151
|
-
return [c, 'TK_WORD'];
|
152
|
-
}
|
153
|
-
|
154
|
-
if (c === '(' || c === '[') {
|
155
|
-
return [c, 'TK_START_EXPR'];
|
156
|
-
}
|
157
|
-
|
158
|
-
if (c === ')' || c === ']') {
|
159
|
-
return [c, 'TK_END_EXPR'];
|
160
|
-
}
|
161
|
-
|
162
|
-
if (c === '{') {
|
163
|
-
return [c, 'TK_START_BLOCK'];
|
164
|
-
}
|
165
|
-
|
166
|
-
if (c === '}') {
|
167
|
-
return [c, 'TK_END_BLOCK'];
|
168
|
-
}
|
169
|
-
|
170
|
-
if (c === ';') {
|
171
|
-
return [c, 'TK_END_COMMAND'];
|
172
|
-
}
|
173
|
-
|
174
|
-
if (c === '/') {
|
175
|
-
var comment = '';
|
176
|
-
// peek for comment /* ... */
|
177
|
-
if (input.charAt(parser_pos) === '*') {
|
178
|
-
parser_pos += 1;
|
179
|
-
if (parser_pos < input.length) {
|
180
|
-
while (! (input.charAt(parser_pos) === '*' && input.charAt(parser_pos + 1) && input.charAt(parser_pos + 1) === '/') && parser_pos < input.length) {
|
181
|
-
comment += input.charAt(parser_pos);
|
182
|
-
parser_pos += 1;
|
183
|
-
if (parser_pos >= input.length) {
|
184
|
-
break;
|
185
|
-
}
|
186
|
-
}
|
187
|
-
}
|
188
|
-
parser_pos += 2;
|
189
|
-
return ['/*' + comment + '*/', 'TK_BLOCK_COMMENT'];
|
190
|
-
}
|
191
|
-
// peek for comment // ...
|
192
|
-
if (input.charAt(parser_pos) === '/') {
|
193
|
-
comment = c;
|
194
|
-
while (input.charAt(parser_pos) !== "\x0d" && input.charAt(parser_pos) !== "\x0a") {
|
195
|
-
comment += input.charAt(parser_pos);
|
196
|
-
parser_pos += 1;
|
197
|
-
if (parser_pos >= input.length) {
|
198
|
-
break;
|
199
|
-
}
|
200
|
-
}
|
201
|
-
parser_pos += 1;
|
202
|
-
if (wanted_newline) {
|
203
|
-
print_newline();
|
204
|
-
}
|
205
|
-
return [comment, 'TK_COMMENT'];
|
206
|
-
}
|
207
|
-
|
208
|
-
}
|
209
|
-
|
210
|
-
if (c === "'" || // string
|
211
|
-
c === '"' || // string
|
212
|
-
(c === '/' &&
|
213
|
-
((last_type === 'TK_WORD' && last_text === 'return') || (last_type === 'TK_START_EXPR' || last_type === 'TK_END_BLOCK' || last_type === 'TK_OPERATOR' || last_type === 'TK_EOF' || last_type === 'TK_END_COMMAND')))) { // regexp
|
214
|
-
var sep = c;
|
215
|
-
var esc = false;
|
216
|
-
c = '';
|
217
|
-
|
218
|
-
if (parser_pos < input.length) {
|
219
|
-
|
220
|
-
while (esc || input.charAt(parser_pos) !== sep) {
|
221
|
-
c += input.charAt(parser_pos);
|
222
|
-
if (!esc) {
|
223
|
-
esc = input.charAt(parser_pos) === '\\';
|
224
|
-
} else {
|
225
|
-
esc = false;
|
226
|
-
}
|
227
|
-
parser_pos += 1;
|
228
|
-
if (parser_pos >= input.length) {
|
229
|
-
break;
|
230
|
-
}
|
231
|
-
}
|
232
|
-
|
233
|
-
}
|
234
|
-
|
235
|
-
parser_pos += 1;
|
236
|
-
if (last_type === 'TK_END_COMMAND') {
|
237
|
-
print_newline();
|
238
|
-
}
|
239
|
-
return [sep + c + sep, 'TK_STRING'];
|
240
|
-
}
|
241
|
-
|
242
|
-
if (in_array(c, punct)) {
|
243
|
-
while (parser_pos < input.length && in_array(c + input.charAt(parser_pos), punct)) {
|
244
|
-
c += input.charAt(parser_pos);
|
245
|
-
parser_pos += 1;
|
246
|
-
if (parser_pos >= input.length) {
|
247
|
-
break;
|
248
|
-
}
|
249
|
-
}
|
250
|
-
return [c, 'TK_OPERATOR'];
|
251
|
-
}
|
252
|
-
|
253
|
-
return [c, 'TK_UNKNOWN'];
|
254
|
-
}
|
255
|
-
|
256
|
-
|
257
|
-
//----------------------------------
|
258
|
-
|
259
|
-
indent_character = indent_character || ' ';
|
260
|
-
indent_size = indent_size || 2;
|
261
|
-
|
262
|
-
indent_string = '';
|
263
|
-
while (indent_size--) {
|
264
|
-
indent_string += indent_character;
|
265
|
-
}
|
266
|
-
|
267
|
-
input = js_source_text;
|
268
|
-
|
269
|
-
last_word = ''; // last 'TK_WORD' passed
|
270
|
-
last_type = 'TK_START_EXPR'; // last token type
|
271
|
-
last_text = ''; // last token text
|
272
|
-
output = [];
|
273
|
-
|
274
|
-
do_block_just_closed = false;
|
275
|
-
var_line = false;
|
276
|
-
var_line_tainted = false;
|
277
|
-
|
278
|
-
whitespace = "\n\r\t ".split('');
|
279
|
-
wordchar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'.split('');
|
280
|
-
punct = '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |='.split(' ');
|
281
|
-
|
282
|
-
// words which should always start on new line.
|
283
|
-
line_starters = 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function'.split(',');
|
284
|
-
|
285
|
-
// states showing if we are currently in expression (i.e. "if" case) - 'EXPRESSION', or in usual block (like, procedure), 'BLOCK'.
|
286
|
-
// some formatting depends on that.
|
287
|
-
current_mode = 'BLOCK';
|
288
|
-
modes = [current_mode];
|
289
|
-
|
290
|
-
indent_level = indent_level || 0;
|
291
|
-
parser_pos = 0; // parser position
|
292
|
-
in_case = false; // flag for parser that case/default has been processed, and next colon needs special attention
|
293
|
-
while (true) {
|
294
|
-
var t = get_next_token(parser_pos);
|
295
|
-
token_text = t[0];
|
296
|
-
token_type = t[1];
|
297
|
-
if (token_type === 'TK_EOF') {
|
298
|
-
break;
|
299
|
-
}
|
300
|
-
|
301
|
-
switch (token_type) {
|
302
|
-
|
303
|
-
case 'TK_START_EXPR':
|
304
|
-
var_line = false;
|
305
|
-
set_mode('EXPRESSION');
|
306
|
-
if (last_type === 'TK_END_EXPR' || last_type === 'TK_START_EXPR') {
|
307
|
-
// do nothing on (( and )( and ][ and ]( ..
|
308
|
-
} else if (last_type !== 'TK_WORD' && last_type !== 'TK_OPERATOR') {
|
309
|
-
print_space();
|
310
|
-
} else if (in_array(last_word, line_starters) && last_word !== 'function') {
|
311
|
-
print_space();
|
312
|
-
}
|
313
|
-
print_token();
|
314
|
-
break;
|
315
|
-
|
316
|
-
case 'TK_END_EXPR':
|
317
|
-
print_token();
|
318
|
-
restore_mode();
|
319
|
-
break;
|
320
|
-
|
321
|
-
case 'TK_START_BLOCK':
|
322
|
-
|
323
|
-
if (last_word === 'do') {
|
324
|
-
set_mode('DO_BLOCK');
|
325
|
-
} else {
|
326
|
-
set_mode('BLOCK');
|
327
|
-
}
|
328
|
-
if (last_type !== 'TK_OPERATOR' && last_type !== 'TK_START_EXPR') {
|
329
|
-
if (last_type === 'TK_START_BLOCK') {
|
330
|
-
print_newline();
|
331
|
-
} else {
|
332
|
-
print_space();
|
333
|
-
}
|
334
|
-
}
|
335
|
-
print_token();
|
336
|
-
indent();
|
337
|
-
break;
|
338
|
-
|
339
|
-
case 'TK_END_BLOCK':
|
340
|
-
if (last_type === 'TK_START_BLOCK') {
|
341
|
-
// nothing
|
342
|
-
trim_output();
|
343
|
-
unindent();
|
344
|
-
} else {
|
345
|
-
unindent();
|
346
|
-
print_newline();
|
347
|
-
}
|
348
|
-
print_token();
|
349
|
-
restore_mode();
|
350
|
-
break;
|
351
|
-
|
352
|
-
case 'TK_WORD':
|
353
|
-
|
354
|
-
if (do_block_just_closed) {
|
355
|
-
print_space();
|
356
|
-
print_token();
|
357
|
-
print_space();
|
358
|
-
break;
|
359
|
-
}
|
360
|
-
|
361
|
-
if (token_text === 'case' || token_text === 'default') {
|
362
|
-
if (last_text === ':') {
|
363
|
-
// switch cases following one another
|
364
|
-
remove_indent();
|
365
|
-
} else {
|
366
|
-
// case statement starts in the same line where switch
|
367
|
-
unindent();
|
368
|
-
print_newline();
|
369
|
-
indent();
|
370
|
-
}
|
371
|
-
print_token();
|
372
|
-
in_case = true;
|
373
|
-
break;
|
374
|
-
}
|
375
|
-
|
376
|
-
|
377
|
-
prefix = 'NONE';
|
378
|
-
if (last_type === 'TK_END_BLOCK') {
|
379
|
-
if (!in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
|
380
|
-
prefix = 'NEWLINE';
|
381
|
-
} else {
|
382
|
-
prefix = 'SPACE';
|
383
|
-
print_space();
|
384
|
-
}
|
385
|
-
} else if (last_type === 'TK_END_COMMAND' && (current_mode === 'BLOCK' || current_mode === 'DO_BLOCK')) {
|
386
|
-
prefix = 'NEWLINE';
|
387
|
-
} else if (last_type === 'TK_END_COMMAND' && current_mode === 'EXPRESSION') {
|
388
|
-
prefix = 'SPACE';
|
389
|
-
} else if (last_type === 'TK_WORD') {
|
390
|
-
prefix = 'SPACE';
|
391
|
-
} else if (last_type === 'TK_START_BLOCK') {
|
392
|
-
prefix = 'NEWLINE';
|
393
|
-
} else if (last_type === 'TK_END_EXPR') {
|
394
|
-
print_space();
|
395
|
-
prefix = 'NEWLINE';
|
396
|
-
}
|
397
|
-
|
398
|
-
if (last_type !== 'TK_END_BLOCK' && in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
|
399
|
-
print_newline();
|
400
|
-
} else if (in_array(token_text, line_starters) || prefix === 'NEWLINE') {
|
401
|
-
if (last_text === 'else') {
|
402
|
-
// no need to force newline on else break
|
403
|
-
print_space();
|
404
|
-
} else if ((last_type === 'TK_START_EXPR' || last_text === '=') && token_text === 'function') {
|
405
|
-
// no need to force newline on 'function': (function
|
406
|
-
// DONOTHING
|
407
|
-
} else if (last_type === 'TK_WORD' && (last_text === 'return' || last_text === 'throw')) {
|
408
|
-
// no newline between 'return nnn'
|
409
|
-
print_space();
|
410
|
-
} else if (last_type !== 'TK_END_EXPR') {
|
411
|
-
if ((last_type !== 'TK_START_EXPR' || token_text !== 'var') && last_text !== ':') {
|
412
|
-
// no need to force newline on 'var': for (var x = 0...)
|
413
|
-
if (token_text === 'if' && last_type === 'TK_WORD' && last_word === 'else') {
|
414
|
-
// no newline for } else if {
|
415
|
-
print_space();
|
416
|
-
} else {
|
417
|
-
print_newline();
|
418
|
-
}
|
419
|
-
}
|
420
|
-
} else {
|
421
|
-
if (in_array(token_text, line_starters) && last_text !== ')') {
|
422
|
-
print_newline();
|
423
|
-
}
|
424
|
-
}
|
425
|
-
} else if (prefix === 'SPACE') {
|
426
|
-
print_space();
|
427
|
-
}
|
428
|
-
print_token();
|
429
|
-
last_word = token_text;
|
430
|
-
|
431
|
-
if (token_text === 'var') {
|
432
|
-
var_line = true;
|
433
|
-
var_line_tainted = false;
|
434
|
-
}
|
435
|
-
|
436
|
-
break;
|
437
|
-
|
438
|
-
case 'TK_END_COMMAND':
|
439
|
-
|
440
|
-
print_token();
|
441
|
-
var_line = false;
|
442
|
-
break;
|
443
|
-
|
444
|
-
case 'TK_STRING':
|
445
|
-
|
446
|
-
if (last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK') {
|
447
|
-
print_newline();
|
448
|
-
} else if (last_type === 'TK_WORD') {
|
449
|
-
print_space();
|
450
|
-
}
|
451
|
-
print_token();
|
452
|
-
break;
|
453
|
-
|
454
|
-
case 'TK_OPERATOR':
|
455
|
-
|
456
|
-
var start_delim = true;
|
457
|
-
var end_delim = true;
|
458
|
-
if (var_line && token_text !== ',') {
|
459
|
-
var_line_tainted = true;
|
460
|
-
if (token_text === ':') {
|
461
|
-
var_line = false;
|
462
|
-
}
|
463
|
-
}
|
464
|
-
|
465
|
-
if (token_text === ':' && in_case) {
|
466
|
-
print_token(); // colon really asks for separate treatment
|
467
|
-
print_newline();
|
468
|
-
break;
|
469
|
-
}
|
470
|
-
|
471
|
-
in_case = false;
|
472
|
-
|
473
|
-
if (token_text === ',') {
|
474
|
-
if (var_line) {
|
475
|
-
if (var_line_tainted) {
|
476
|
-
print_token();
|
477
|
-
print_newline();
|
478
|
-
var_line_tainted = false;
|
479
|
-
} else {
|
480
|
-
print_token();
|
481
|
-
print_space();
|
482
|
-
}
|
483
|
-
} else if (last_type === 'TK_END_BLOCK') {
|
484
|
-
print_token();
|
485
|
-
print_newline();
|
486
|
-
} else {
|
487
|
-
if (current_mode === 'BLOCK') {
|
488
|
-
print_token();
|
489
|
-
print_newline();
|
490
|
-
} else {
|
491
|
-
// EXPR od DO_BLOCK
|
492
|
-
print_token();
|
493
|
-
print_space();
|
494
|
-
}
|
495
|
-
}
|
496
|
-
break;
|
497
|
-
} else if (token_text === '--' || token_text === '++') { // unary operators special case
|
498
|
-
if (last_text === ';') {
|
499
|
-
// space for (;; ++i)
|
500
|
-
start_delim = true;
|
501
|
-
end_delim = false;
|
502
|
-
} else {
|
503
|
-
start_delim = false;
|
504
|
-
end_delim = false;
|
505
|
-
}
|
506
|
-
} else if (token_text === '!' && last_type === 'TK_START_EXPR') {
|
507
|
-
// special case handling: if (!a)
|
508
|
-
start_delim = false;
|
509
|
-
end_delim = false;
|
510
|
-
} else if (last_type === 'TK_OPERATOR') {
|
511
|
-
start_delim = false;
|
512
|
-
end_delim = false;
|
513
|
-
} else if (last_type === 'TK_END_EXPR') {
|
514
|
-
start_delim = true;
|
515
|
-
end_delim = true;
|
516
|
-
} else if (token_text === '.') {
|
517
|
-
// decimal digits or object.property
|
518
|
-
start_delim = false;
|
519
|
-
end_delim = false;
|
520
|
-
|
521
|
-
} else if (token_text === ':') {
|
522
|
-
// zz: xx
|
523
|
-
// can't differentiate ternary op, so for now it's a ? b: c; without space before colon
|
524
|
-
if (last_text.match(/^\d+$/)) {
|
525
|
-
// a little help for ternary a ? 1 : 0;
|
526
|
-
start_delim = true;
|
527
|
-
} else {
|
528
|
-
start_delim = false;
|
529
|
-
}
|
530
|
-
}
|
531
|
-
if (start_delim) {
|
532
|
-
print_space();
|
533
|
-
}
|
534
|
-
|
535
|
-
print_token();
|
536
|
-
|
537
|
-
if (end_delim) {
|
538
|
-
print_space();
|
539
|
-
}
|
540
|
-
break;
|
541
|
-
|
542
|
-
case 'TK_BLOCK_COMMENT':
|
543
|
-
|
544
|
-
print_newline();
|
545
|
-
print_token();
|
546
|
-
print_newline();
|
547
|
-
break;
|
548
|
-
|
549
|
-
case 'TK_COMMENT':
|
550
|
-
|
551
|
-
// print_newline();
|
552
|
-
print_space();
|
553
|
-
print_token();
|
554
|
-
print_newline();
|
555
|
-
break;
|
556
|
-
|
557
|
-
case 'TK_UNKNOWN':
|
558
|
-
print_token();
|
559
|
-
break;
|
560
|
-
}
|
561
|
-
|
562
|
-
last_type = token_type;
|
563
|
-
last_text = token_text;
|
564
|
-
}
|
565
|
-
|
566
|
-
return output.join('');
|
567
|
-
|
568
|
-
}
|