efront 3.24.2 → 3.24.7

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.
Files changed (113) hide show
  1. package/apps/kugou/main.js +1 -3
  2. package/coms/basic/assert.js +10 -2
  3. package/coms/basic/extends_.js +13 -0
  4. package/coms/basic/loader.js +22 -17
  5. package/coms/basic/mark.js +155 -0
  6. package/coms/basic/queue.js +11 -14
  7. package/coms/basic/rest_.js +27 -0
  8. package/coms/basic/submit_.js +3 -1
  9. package/{apps → coms}/kugou/api.js +2 -0
  10. package/coms/kugou/buildList.js +7 -1
  11. package/coms/kugou/player.js +1 -0
  12. package/coms/kugou/song.html +1 -1
  13. package/coms/kugou/song.js +1 -0
  14. package/coms/kugou/song.less +12 -1
  15. package/coms/zimoli/cloneVisible.js +1 -0
  16. package/coms/zimoli/compile.js +64 -1
  17. package/coms/{compile → zimoli}/compile_test.js +0 -0
  18. package/coms/zimoli/data.js +8 -2
  19. package/coms/zimoli/input.js +6 -4
  20. package/coms/zimoli/render.js +1 -1
  21. package/package.json +1 -1
  22. package/public/efront.js +1 -1
  23. package/readme.md +0 -1
  24. package/apps/zimoli/book/main.js +0 -8
  25. package/apps/zimoli/broadcast/main.js +0 -8
  26. package/apps/zimoli/collection/add.html +0 -13
  27. package/apps/zimoli/collection/add.js +0 -14
  28. package/apps/zimoli/collection/add.less +0 -0
  29. package/apps/zimoli/collection/main.html +0 -0
  30. package/apps/zimoli/collection/main.js +0 -13
  31. package/apps/zimoli/collection/main.less +0 -8
  32. package/apps/zimoli/config.js +0 -14
  33. package/apps/zimoli/extra/pending.html +0 -1
  34. package/apps/zimoli/extra/pending.js +0 -8
  35. package/apps/zimoli/extra/pending.less +0 -15
  36. package/apps/zimoli/files/info.js +0 -7
  37. package/apps/zimoli/files/main.js +0 -108
  38. package/apps/zimoli/files/main.less +0 -26
  39. package/apps/zimoli/images/avatar.png +0 -0
  40. package/apps/zimoli/images/background.jpg +0 -0
  41. package/apps/zimoli/index.html +0 -42
  42. package/apps/zimoli/kugou/font/demo.css +0 -539
  43. package/apps/zimoli/kugou/font/demo_index.html +0 -1159
  44. package/apps/zimoli/kugou/font/iconfont.css +0 -189
  45. package/apps/zimoli/kugou/font/iconfont.eot +0 -0
  46. package/apps/zimoli/kugou/font/iconfont.js +0 -1
  47. package/apps/zimoli/kugou/font/iconfont.svg +0 -155
  48. package/apps/zimoli/kugou/font/iconfont.ttf +0 -0
  49. package/apps/zimoli/kugou/font/iconfont.woff +0 -0
  50. package/apps/zimoli/kugou/font/iconfont.woff2 +0 -0
  51. package/apps/zimoli/kugou/listen.html +0 -15
  52. package/apps/zimoli/kugou/listen.js +0 -37
  53. package/apps/zimoli/kugou/listen.less +0 -114
  54. package/apps/zimoli/kugou/mine.html +0 -53
  55. package/apps/zimoli/kugou/mine.js +0 -21
  56. package/apps/zimoli/kugou/mine.less +0 -106
  57. package/apps/zimoli/kugou/search.js +0 -109
  58. package/apps/zimoli/kugou/search.less +0 -50
  59. package/apps/zimoli/kugou/sing.js +0 -42
  60. package/apps/zimoli/kugou/sing.less +0 -93
  61. package/apps/zimoli/kugou/view.html +0 -39
  62. package/apps/zimoli/kugou/view.js +0 -17
  63. package/apps/zimoli/kugou/view.less +0 -84
  64. package/apps/zimoli/login/qq.js +0 -20
  65. package/apps/zimoli/login/qq_callback.html +0 -15
  66. package/apps/zimoli/main.js +0 -87
  67. package/apps/zimoli/main.less +0 -81
  68. package/apps/zimoli/message/chatList.js +0 -57
  69. package/apps/zimoli/message/chatList.less +0 -52
  70. package/apps/zimoli/message/commentList.js +0 -55
  71. package/apps/zimoli/message/commentList.less +0 -55
  72. package/apps/zimoli/message/informList.js +0 -69
  73. package/apps/zimoli/message/informList.less +0 -51
  74. package/apps/zimoli/message/main.js +0 -59
  75. package/apps/zimoli/message/main.less +0 -51
  76. package/apps/zimoli/message/praiseList.js +0 -3
  77. package/apps/zimoli/message/praiseList.less +0 -7
  78. package/apps/zimoli/nearby/main.js +0 -8
  79. package/apps/zimoli/skin/main.js +0 -47
  80. package/apps/zimoli/skin/main.less +0 -31
  81. package/apps/zimoli/user/getPassword.js +0 -82
  82. package/apps/zimoli/user/getPassword.less +0 -14
  83. package/apps/zimoli/user/login.html +0 -12
  84. package/apps/zimoli/user/login.js +0 -50
  85. package/apps/zimoli/user/login.less +0 -139
  86. package/apps/zimoli/user/profile-bg.jpg +0 -0
  87. package/apps/zimoli/user/profile.html +0 -32
  88. package/apps/zimoli/user/profile.js +0 -63
  89. package/apps/zimoli/user/profile.less +0 -50
  90. package/apps/zimoli/user/register.js +0 -20
  91. package/apps/zimoli/user/register.less +0 -3
  92. package/apps/zimoli/user/setting.js +0 -90
  93. package/apps/zimoli/user/setting.less +0 -11
  94. package/apps/zimoli/user/welcome.js +0 -36
  95. package/apps/zimoli/user/welcome.less +0 -136
  96. package/apps/zimoli/watch/main.html +0 -22
  97. package/apps/zimoli/watch/main.js +0 -76
  98. package/apps/zimoli/watch/main.less +0 -54
  99. package/apps/zimoli/yuanfen/main.js +0 -55
  100. package/apps/zimoli/yuanfen/main.json +0 -0
  101. package/coms/compile/breakcode.js +0 -78
  102. package/coms/compile/common.js +0 -688
  103. package/coms/compile/compile.js +0 -64
  104. package/coms/compile/keywords.js +0 -6
  105. package/coms/compile/namelist.js +0 -142
  106. package/coms/compile/namelist_test.js +0 -7
  107. package/coms/compile/required.js +0 -20
  108. package/coms/compile/scanner.js +0 -653
  109. package/coms/compile/scanner2.js +0 -921
  110. package/coms/compile/scanner2_test.js +0 -85
  111. package/coms/compile/scanner_test.js +0 -10
  112. package/coms/compile/washcode.js +0 -313
  113. package/coms/zimoli/mark.js +0 -70
@@ -1,688 +0,0 @@
1
- const [
2
- /*-1 */COMMENT,
3
- /* 0 */SPACE,
4
- /* 1 */STRAP,
5
- /* 2 */STAMP,
6
- /* 3 */VALUE,
7
- /* 4 */QUOTED,
8
- /* 5 */PIECE,
9
- /* 6 */EXPRESS,
10
- /* 7 */SCOPED,
11
- /* 8 */LABEL,
12
- /* 9 */PROPERTY,
13
- ] = new Array(20).fill(0).map((_, a) => a - 1);
14
- var number_reg = /^[\+\-]?(0x[0-9a-f]+|0b\d+|0o\d+|(\d*\.\d+|\d+\.?)(e[\+\-]?\d+|[mn])?)$/i;
15
- var skipAssignment = function (o) {
16
- var needpunc = false;
17
- var o0 = o;
18
- var qcount = 0;
19
- loop: while (o) switch (o.type) {
20
- case STAMP:
21
- switch (o.text) {
22
- case ",":
23
- case ";":
24
- break loop;
25
- case "++":
26
- case "--":
27
- o = o.next;
28
- break;
29
- case "!":
30
- case "~":
31
- case "+":
32
- case "-":
33
- o = o.next;
34
- needpunc = false;
35
- break;
36
- case "?":
37
- qcount++;
38
- needpunc = false;
39
- o = o.next;
40
- break;
41
- case ":":
42
- qcount--;
43
- if (qcount < 0) break loop;
44
- needpunc = false;
45
- o = o.next;
46
- break;
47
- default:
48
- if (/^[!~\+\-]+$/.test(o.text)) {
49
- needpunc = false;
50
- o = o.next;
51
- break;
52
- }
53
- if (!needpunc) break loop;
54
- needpunc = false;
55
- o = o.next;
56
- }
57
- break;
58
- case SCOPED:
59
- if (needpunc && o.entry === "{") break loop;
60
- o = o.next;
61
- needpunc = true;
62
- break;
63
- case EXPRESS:
64
- if (/^\.|\.$/.test(o.text)) {
65
- o = o.next;
66
- break;
67
- }
68
- else if (/^\[/.test(o.text)) {
69
- needpunc = true;
70
- o = o.next;
71
- break;
72
- }
73
- case VALUE:
74
- case QUOTED:
75
- if (needpunc) break loop;
76
- needpunc = true;
77
- o = o.next;
78
- break;
79
- case STRAP:
80
- if (needpunc) {
81
- if (!/^(in|instanceof)$/.test(o.text)) break loop;
82
- o = o.next;
83
- needpunc = false;
84
- }
85
- else if (o.text === "class") {
86
- o = o.next;
87
- while (o && !o.isClass) o = o.next;
88
- while (o && o.isClass) o = o.next;
89
- needpunc = true;
90
- break;
91
- }
92
- else if (o.text === "function") {
93
- o = o.next;
94
- if (o && o.type === STAMP) o = o.next;
95
- if (o && o.type === EXPRESS) o = o.next;
96
- if (o) o = o.next;
97
- if (o) o = o.next;
98
- needpunc = true;
99
- break;
100
- }
101
- else {
102
- o = o.next;
103
- needpunc = false;
104
- }
105
- break;
106
- default:
107
- console.log(o);
108
- throw new Error('代码结构异常!');
109
- o = o.next;
110
- }
111
- return o;
112
- };
113
- var createScoped = function (parsed, wash) {
114
- var used = Object.create(null); var vars = Object.create(null), lets = vars;
115
- var scoped = [], funcbody = scoped;
116
- scoped.isfunc = true;
117
- var run = function (o, id) {
118
- loop: while (o) {
119
- var isCatch = false;
120
- var isFunction = false;
121
- var isScope = false;
122
- var isArrow = false;
123
- var isDeclare = false;
124
- var isYield = false;
125
- var isClass = false;
126
- switch (o.type) {
127
- case QUOTED:
128
- if (o.length) {
129
- run(o.first);
130
- }
131
- break;
132
- case STAMP:
133
- break;
134
- case PROPERTY:
135
- if (o.next) {
136
- if (o.next.type !== STAMP || o.next.text !== ",") break;
137
- }
138
- if (o.prev && o.prev.type === STRAP && o.prev.text === 'as') {
139
- break;
140
- }
141
- case VALUE:
142
- if (number_reg.test(o.text)) break;
143
- case EXPRESS:
144
- if (o.prev && o.prev.type === EXPRESS) {
145
- if (/\.$/.test(o.prev.text)) break;
146
- }
147
- var u = o.text;
148
- if (/^\.\.\./.test(u)) u = u.slice(3);
149
- var u = u.replace(/^([^\.\[]*)[\s\S]*$/, '$1');
150
- if (!u) break;
151
- if (u === 'yield') funcbody.yield = false;
152
- if (o.next && o.next.type === STAMP && o.next.text === "=>") {
153
- isScope = true;
154
- isArrow = true;
155
- }
156
- else {
157
- saveTo(used, u, o);
158
- }
159
- break;
160
- case LABEL:
161
- var name = o.text;
162
- name = name.slice(0, name.length - 1);
163
- vars[name] = true;
164
- o.kind = "label";
165
- saveTo(used, name, o);
166
- break;
167
-
168
- case STRAP:
169
- var s = o.text;
170
- switch (s) {
171
- case "return":
172
- funcbody.return = true;
173
- break;
174
- case "await":
175
- funcbody.async = funcbody.await = true;
176
- break;
177
- case "yield":
178
- if (!funcbody.yield) {
179
- var next = o.next;
180
- if (next) {
181
-
182
- if (next.type === STAMP && !/[~!,;:]+$/.test(next.text)
183
- || next.type === STRAP && /in|of|as|from|instanceof/.test(next.text)
184
- || next.type === EXPRESS && /^\./.test(next.text)
185
- ) {
186
- funcbody.yield = false;
187
- }
188
- }
189
- saveTo(used, 'yield', o);
190
- }
191
- break;
192
- case "as":
193
- case "from":
194
- break;
195
- case "var":
196
- case "import":
197
- var m = vars;
198
- case "let":
199
- case "const":
200
- m = m || lets;
201
- var [declared, used0, o0, skiped] = getDeclared(o.next, s);
202
- while (skiped.length) {
203
- var o1 = run(skiped[0], 0);
204
- let sindex = skiped.indexOf(o1);
205
- if (sindex < 0) break;
206
- skiped.splice(0, sindex + 1);
207
- }
208
- o = o0;
209
- mergeTo(used, used0);
210
- mapDeclared(m, declared);
211
- continue loop;
212
- case "function":
213
- isFunction = true;
214
- if (o.next.type === STAMP) {
215
- isYield = true;
216
- o = o.next;
217
- }
218
- case "catch":
219
- if (s === 'catch') isCatch = true;
220
- case "class":
221
- if (s === 'class') isClass = true;
222
- if (!o.isExpress) {
223
- o = o.next;
224
-
225
- if (o.type === EXPRESS) {
226
- vars[o.text] = true;
227
- isDeclare = true;
228
- o.kind = isFunction ? 'function' : 'class';
229
- saveTo(used, o.text, o);
230
- o = o.next;
231
- }
232
- }
233
- isScope = true;
234
- break;
235
-
236
- }
237
- break;
238
- case SCOPED:
239
- if (o.entry === "(") {
240
- if (o.next && o.next.type === STAMP && o.next.text === "=>") {
241
- isArrow = true;
242
- isScope = true;
243
- }
244
- else if (o.prev && (o.prev.type === PROPERTY || o.prev.isprop)) {
245
- isFunction = true;
246
- isScope = true;
247
- var pp = o.prev.prev;
248
- if (pp && pp.type === STAMP && pp.isprop) {
249
- isYield = true;
250
- }
251
- }
252
- else {
253
- run(o.first);
254
- }
255
- }
256
- else if (o.entry === "{") {
257
- isScope = true;
258
- }
259
- else {
260
- run(o.first);
261
- }
262
- break;
263
- }
264
- if (isScope) {
265
- var _used = used;
266
- var _lets = lets;
267
- var _vars = vars;
268
- var _scoped = scoped;
269
- used = Object.create(null);
270
- lets = Object.create(null);
271
- vars = Object.create(null);
272
- scoped = [];
273
- var isExpress = o.isExpress;
274
-
275
- if (isFunction || isArrow) {
276
- scoped.used = used;
277
- scoped.vars = vars;
278
- lets = vars;
279
- if (isFunction) {
280
- vars.this = true, vars.arguments = true;
281
- scoped.yield = isYield;
282
- }
283
- scoped.isfunc = true;
284
- isFunction = true;
285
- funcbody = scoped;
286
- } else {
287
- vars = _vars;
288
- scoped.lets = lets;
289
- scoped.used = used;
290
- if (isClass) {
291
- lets.super = true;
292
- }
293
- }
294
- if (isArrow);
295
- else if (o.isExpress && o.type !== SCOPED && !isDeclare) {
296
- o = o.next;
297
- if (o.type === EXPRESS) {
298
- vars[o.text] = true;
299
- o.kind = isFunction ? 'function' : 'class';
300
- saveTo(used, o.text, o);
301
- o = o.next;
302
- }
303
- }
304
- if (!isFunction) while (o.type !== SCOPED) {
305
- // if (o.next && o.next.type === STAMP && o.next.text === "=>") break;
306
- o = run(o, 0);
307
- o = o.next;
308
- if (!o) break loop;
309
- }
310
-
311
- if (o.entry === "(") {
312
- o.isExpress = isExpress;
313
- if (isFunction || isCatch) {
314
- var [declared, used0, o0, skiped] = getDeclared(o.first, 'argument');
315
- scoped.args = declared;
316
- mergeTo(used, used0);
317
- while (skiped.length) {
318
- var o1 = run(skiped[0], 0);
319
- var sindex = skiped.indexOf(o1);
320
- if (sindex < 0) break;
321
- skiped.splice(0, sindex + 1);
322
- }
323
- mapDeclared(isCatch ? lets : vars, declared);
324
- }
325
- else {
326
- run(o.first);
327
- }
328
- o = o.next;
329
- if (!o) break;
330
- if (o.type === STAMP && o.text === "=>") o = o.next;
331
- }
332
- else if (isArrow) {
333
- vars[o.text] = true;
334
- o.kind = 'argument';
335
- saveTo(used, o.text, o);
336
- o = o.next.next;
337
- }
338
- if (!o) break;
339
- if (o.type === SCOPED && o.entry === "{") {
340
- o.isExpress = isExpress;
341
- run(o.first);
342
- if (wash && isFunction) {
343
- var e = o.next;
344
- if (e && e.type === EXPRESS && /^[\.\[]/.test(e.text) || e && e.type === SCOPED && e.entry === "[") {
345
- scoped.target = true;
346
- e = e.next;
347
- }
348
- if (e && e.type === SCOPED && e.entry === '(') {
349
- if (e.first) {
350
- scoped.pass = getDeclared(e.first)[0];
351
- }
352
- if (scoped.target) scoped.target = scoped.pass.shift();
353
- }
354
- }
355
- }
356
- else {
357
- do {
358
- if (o.type === STAMP && o.text === ";") break;
359
- o = run(o, 0);
360
- var next = o.next;
361
- if (!next) break;
362
- var e = o;
363
- if (o.type === STAMP && /^(\+\+|\-\-)$/.test(o.text) || ~[VALUE, QUOTED, SCOPED].indexOf(o.type) || EXPRESS === o.type && !/\.$/.test(o.text)) {
364
- if (~[VALUE, QUOTED, PROPERTY, LABEL].indexOf(next.type)) break;
365
- if (EXPRESS === next.type && !/^\./.test(next.text)) break;
366
- if (next.type === SCOPED && next.entry === "{") break;
367
- }
368
- o = next;
369
- } while (o);
370
- }
371
- var map = isFunction ? vars : lets;
372
- var keepscope = false;
373
- for (var k in map) {
374
- keepscope = true;
375
- break;
376
- }
377
- if (keepscope) {
378
- for (var k in used) {
379
- if (!(k in map)) {
380
- for (var u of used[k]) {
381
- saveTo(_used, k, u);
382
- }
383
- }
384
- }
385
- _scoped.push(scoped);
386
- }
387
- else {
388
- mergeTo(_used, used);
389
- if (scoped.length) _scoped.push(scoped);
390
- }
391
- if (vars.this) {
392
- delete vars.this;
393
- delete vars.arguments;
394
- }
395
- if (_scoped.isfunc && !funcbody.yield) {
396
- if (used.yield) _scoped.yield = false;
397
- funcbody = _scoped;
398
- }
399
- used = _used;
400
- lets = _lets;
401
- vars = _vars;
402
- scoped = _scoped;
403
- }
404
- if (id >= 0) break;
405
- if (o) o = o.next;
406
- }
407
- return o;
408
- };
409
- run(parsed.first);
410
- scoped.used = used;
411
- scoped.vars = vars;
412
- var envs = Object.create(null);
413
- for (var u in used) {
414
- if (!(u in vars)) {
415
- if (!/^(true|false|null|this|arguments)$/.test(u)) envs[u] = true;
416
- }
417
- }
418
- if (vars.yield) scoped.yield = false;
419
- if (scoped.yield !== false && envs.yield) {
420
- scoped.yield = true;
421
- delete envs.yield;
422
- delete used.yield;
423
- }
424
- scoped.envs = envs;
425
- return scoped;
426
- };
427
- var getDeclared = function (o, kind) {
428
- var declared = [], used = Object.create(null); var skiped = [];
429
- var prop = null;
430
- loop: while (o) {
431
- while (o && o.type === STAMP && o.text === ',') o = o.next;
432
- if (!o) break;
433
- if (o.isprop) {
434
- skiped.push(o);
435
- if (o.next && o.next.type === STAMP && o.next.text === ":") {
436
- o = o.next;
437
- o = o.next;
438
- }
439
- }
440
- switch (o.type) {
441
- case STAMP:
442
- if (o.text === "*" && o.next) {
443
- if (o.next.type === STRAP && o.next.text === 'as') {
444
- o = o.next.next;
445
- prop = "*";
446
- continue;
447
- }
448
- }
449
- case PROPERTY:
450
- if (o.next) {
451
- if (o.next.type === STAMP && o.next.text === ":" || o.next.type === STRAP && o.next.text === "as") {
452
- prop = "." + o.text;
453
- o = o.next.next;
454
- continue;
455
- }
456
- }
457
- case STRAP:
458
- case VALUE:
459
- case EXPRESS:
460
- var n = o.text.replace(/^\.\.\.|\.\.\.$/g, '');
461
- declared.push(n);
462
- if (n !== o.text) declared["..."] = n;
463
- else if (prop) declared[prop] = n;
464
- o.kind = kind;
465
- saveTo(used, n, o);
466
- o = o.next;
467
- break;
468
- case SCOPED:
469
- var [d, u, _, s] = getDeclared(o.first, kind);
470
- while (s.length) skiped.push.apply(skiped, s.splice(0, 1024));
471
- mergeTo(used, u);
472
- declared.push(d);
473
- if (prop) declared[prop] = d;
474
- o = o.next;
475
- break;
476
- default:
477
- console.log(o);
478
- throw new Error("代码结构异常");
479
- }
480
- if (!o) break;
481
- switch (o.type) {
482
- case STRAP:
483
- if (/^(in|of)$/.test(o.text)) {
484
- o = o.next;
485
- var o0 = skipAssignment(o);
486
- do {
487
- skiped.push(o);
488
- o = o.next;
489
- } while (o !== o0);
490
- o = o0;
491
- break;
492
- }
493
- break loop;
494
- case STAMP:
495
- if (o.text === "=") {
496
- o = o.next;
497
- var o0 = skipAssignment(o);
498
- do {
499
- skiped.push(o);
500
- o = o.next;
501
- } while (o !== o0);
502
- o = o0;
503
- break;
504
- }
505
- break;
506
- }
507
- if (!o) break;
508
- if (o.type !== STAMP) break;
509
- if (o.text !== ',') break;
510
- prop = null;
511
- }
512
- return [declared, used, o, skiped];
513
- };
514
- var mapDeclared = function (map, declared) {
515
- var rest = [declared];
516
- while (rest.length) {
517
- var r = rest.pop();
518
- for (var d of r) {
519
- if (d instanceof Array) rest.push(d);
520
- else map[d] = true;
521
- }
522
- }
523
- return map;
524
- };
525
- var saveTo = function (used, k, o) {
526
- if (!(used[k] instanceof Array)) used[k] = [];
527
- used[k].push(o);
528
- };
529
-
530
- var mergeTo = function (used, used0) {
531
- for (var k in used0) {
532
- var v = used0[k];
533
- for (var s of v) saveTo(used, k, s);
534
- }
535
- };
536
-
537
- var needBreak = function (prev, next) {
538
- if (!prev || !next) return;
539
- if (prev.type === STAMP && /^[,;]$/.test(prev.text)) return;
540
- if (next.type === STAMP && /^[,;]$/.test(next.text)) return;
541
- if (prev.type === EXPRESS && /\.$/.test(prev.text)) return;
542
- if (next.type === EXPRESS && /^\./.test(next.text)) return;
543
- if (next.type === PROPERTY) return ";";
544
- if (next.type === STAMP && next.text === "*") return ";";
545
- if (
546
- [EXPRESS, VALUE, QUOTED].indexOf(prev.type) >= 0
547
- || prev.type === STAMP && /^(\+\+|\-\-)$/.test(prev.text)
548
- || prev.type === SCOPED && (prev.isExpress || prev.isObject)
549
- ) {
550
- if ([EXPRESS, VALUE, QUOTED, LABEL].indexOf(next.type) >= 0) return ";";
551
- if (next.type === STRAP) {
552
- if (!/^(in|of|extends|instanceof|as)$/.test(next.text)) return ";";
553
- return " ";
554
- }
555
- if (next.type === SCOPED) {
556
- if (!next.isExpress) return ";";
557
- }
558
- return;
559
- }
560
- if (prev.type === STRAP) {
561
- if ([STRAP, EXPRESS, VALUE, QUOTED].indexOf(next.type) >= 0) return " ";
562
- if (next.type === LABEL) return ";";
563
- }
564
- };
565
-
566
- var createString = function (parsed) {
567
- var pressed = parsed.pressed;
568
- var lasttype;
569
- var result = [];
570
- var run = (o, i, a) => {
571
- var prev = o.prev;
572
- if (!~[SPACE, COMMENT, STAMP, PIECE].indexOf(o.type) && prev && lasttype !== SPACE && !pressed) {
573
- if (~[QUOTED, SCOPED, STRAP, LABEL, COMMENT].indexOf(lasttype)
574
- || prev.type === STAMP
575
- && (!/[\+\-\~\!]$/.test(prev.text) || /[\+\-]$/.test(prev.text) && prev.prev
576
- && (!~[STAMP, STRAP, SCOPED].indexOf(prev.prev.type) || prev.prev.type === SCOPED && prev.prev.isExpress)
577
- )) {
578
- if (o.type !== SCOPED && (o.type !== EXPRESS || !/^\./.test(o.text))) {
579
- result.push(" ");
580
- lasttype = SPACE
581
- }
582
- }
583
- }
584
- switch (o.type) {
585
- case COMMENT:
586
- // 每一次要远行,我都不得不对自己的物品去粗取精。取舍之间,什么重要,什么不是那么重要,都有了一道明显的分界线。
587
- if (!pressed) {
588
- if (lasttype !== SPACE && o.prev) result.push(' ');
589
- result.push(o.text);
590
- }
591
- break;
592
- case SPACE:
593
- if (!pressed) {
594
- result.push(o.text);
595
- lasttype = SPACE;
596
- break;
597
- }
598
- var b = needBreak(o.prev, o.next);
599
- if (b) result.push(b);
600
- break;
601
- case QUOTED:
602
- if (!o.length) {
603
- result.push(o.text);
604
- break;
605
- }
606
- case SCOPED:
607
- if (!pressed && o.type !== QUOTED && (lasttype === STRAP || lasttype === COMMENT || lasttype === STAMP
608
- && (!o.prev || !/[\+\-\~\!]$/.test(o.prev.text) || /[\+\-]$/.test(o.prev.text) && (!o.prev.prev || !~[STAMP, STRAP].indexOf(o.prev.prev.type)))
609
- || lasttype === SCOPED && o.entry === "{"
610
- )) result.push(" ");
611
- result.push(o.entry);
612
- if (o.length > 0) {
613
- if (o.entry === "{" && result[0].type !== SPACE) {
614
- if (!pressed) {
615
- result.push(" ");
616
- }
617
- }
618
- lasttype = undefined;
619
- o.forEach(run);
620
- if (/^[,;]$/.test(result[result.length - 1]) && pressed) {
621
- if (!o.prev || o.prev.text !== 'for') result.pop();
622
- }
623
- if (o.leave === "}" && (!o.next || o.next.type !== PIECE) && o[o.length - 1].type !== SPACE) {
624
- if (!pressed) result.push(" ");
625
- }
626
- }
627
- result.push(o.leave);
628
- break;
629
- default:
630
- if (o instanceof Object) {
631
- if ([STRAP, EXPRESS, PROPERTY, VALUE, COMMENT].indexOf(lasttype) >= 0 && [STRAP, EXPRESS, PROPERTY, VALUE].indexOf(o.type) >= 0) {
632
- result.push(" ");
633
- }
634
- else if (o.prev && o.type === STAMP && !/^([,;])$/.test(o.text)) {
635
- if (result[result.length - 1] === " " || (lasttype === PROPERTY || !o.isExpress && o.prev && o.prev.type !== LABEL) && o.text === ':') { }
636
- else if (lasttype === STAMP) {
637
- result.push(" ");
638
- }
639
- else if (/^(\+\+|\-\-)$/.test(o.prev.text) && o.prev.prev) {
640
- var prev_prev = o.prev.prev;
641
- if (
642
- prev_prev.type === STRAP && !prev_prev.isExpress
643
- || prev_prev.type === EXPRESS
644
- || prev_prev.type === VALUE
645
- ) result.push(";");
646
- }
647
- else if (!/^(\+\+|\-\-)$/.test(o.text)) {
648
- if (!pressed && lasttype !== SPACE) result.push(" ");
649
- }
650
- }
651
- if (o.type === VALUE) {
652
- if (/^0[0-7]+$/.test(o.text)) {
653
- o.text = '0o' + o.text.slice(1);
654
- }
655
- }
656
- result.push(o.text);
657
- }
658
- else {
659
- result.push(o);
660
- }
661
- }
662
- lasttype = o.type;
663
- if (o.isprop) lasttype = PROPERTY;
664
- };
665
- parsed.forEach(run);
666
- return result.join("");
667
- }
668
-
669
- module.exports = {
670
- /*-1 */COMMENT,
671
- /* 0 */SPACE,
672
- /* 1 */STRAP,
673
- /* 2 */STAMP,
674
- /* 3 */VALUE,
675
- /* 4 */QUOTED,
676
- /* 5 */PIECE,
677
- /* 6 */EXPRESS,
678
- /* 7 */SCOPED,
679
- /* 8 */LABEL,
680
- /* 9 */PROPERTY,
681
- number_reg,
682
- skipAssignment,
683
- getDeclared,
684
- createString,
685
- createScoped,
686
- saveTo,
687
- mergeTo
688
- };