efront 3.13.1 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/pivot/api.yml +7 -0
- package/apps/pivot/log/boot.html +2 -0
- package/apps/pivot/log/boot.js +44 -0
- package/apps/pivot/log/boot.less +11 -0
- package/apps/pivot/log/count.html +5 -1
- package/apps/pivot/log/count.js +11 -4
- package/apps/pivot/log/count.less +10 -2
- package/apps/pivot/main.js +9 -10
- package/apps/pivot/menu.yml +7 -3
- package/apps/pivot/proxy/edit.js +1 -0
- package/apps/pivot/proxy/list.js +12 -0
- package/apps/pivot/user/edit.js +1 -0
- package/apps/pivot/user/list.js +4 -0
- package/apps/pivot/user/tag/edit.js +1 -0
- package/apps/pivot/user/tag/list.js +3 -0
- package/coms/basic/cross_.js +8 -1
- package/coms/basic/encodePack.js +2 -9
- package/coms/basic/parseURL_test.js +2 -0
- package/coms/basic/renderExpress.js +1 -1
- package/coms/compile/common.js +165 -6
- package/coms/compile/scanner.js +7 -4
- package/coms/compile/scanner2.js +2 -117
- package/coms/compile/washcode.js +313 -0
- package/coms/frame/route.js +3 -0
- package/coms/pivot/plist.js +1 -1
- package/coms/typescript-helpers/__classPrivateFieldIn.js +11 -0
- package/coms/zimoli/cross.js +2 -3
- package/coms/zimoli/data.js +22 -4
- package/coms/zimoli/field.html +15 -10
- package/coms/zimoli/model.js +22 -1
- package/coms/zimoli/prompt.js +3 -1
- package/coms/zimoli/render.js +11 -8
- package/coms/zimoli/renderDefaults.js +1 -0
- package/coms/zimoli/search.js +5 -4
- package/coms/zimoli/select.js +7 -3
- package/coms/zimoli/selectList.js +7 -7
- package/coms/zimoli/selectListEdit.js +1 -1
- package/coms/zimoli/success.js +4 -0
- package/coms/zimoli/success.less +13 -0
- package/coms/zimoli/view.less +4 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/apps/pivot/home/short.html +0 -1
- package/apps/pivot/home/short.js +0 -5
- package/apps/pivot/home/short.less +0 -1
package/apps/pivot/api.yml
CHANGED
|
@@ -11,3 +11,10 @@
|
|
|
11
11
|
version: options ::version
|
|
12
12
|
uptime: options ::uptime
|
|
13
13
|
count: options ::count
|
|
14
|
+
bootlog: options ::similar
|
|
15
|
+
https://www.ip.cn/ :
|
|
16
|
+
iplocation: get https://www.ip.cn/api/index?ip=:ip&type=1
|
|
17
|
+
# https://ipchaxun.com/ :
|
|
18
|
+
# iplocation: get:[].info%20label:nth-child(n+2)>span:nth-child(2) :ip/
|
|
19
|
+
# https://www.ip138.com/:
|
|
20
|
+
# iplocation: get:head>script:nth-last-child(1) iplookup.asp?ip=:ip&action=2
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var fields = refilm`
|
|
2
|
+
地址/ip
|
|
3
|
+
地理位置/ip ${function (e) {
|
|
4
|
+
var ip = e.data[e.field.key];
|
|
5
|
+
var m = /(\d+\.){3}\d+$/.exec(ip);
|
|
6
|
+
if (m) {
|
|
7
|
+
var setAddress = function (a) {
|
|
8
|
+
var l = document.createElement('label');
|
|
9
|
+
l.innerText = a;
|
|
10
|
+
appendChild(e, l);
|
|
11
|
+
};
|
|
12
|
+
if (e.data.address) setAddress(e.data.address);
|
|
13
|
+
else data.from("iplocation", { ip: m[0] }, function (a) {
|
|
14
|
+
e.data.address = a.address;
|
|
15
|
+
setAddress(a.address);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return e;
|
|
19
|
+
}}
|
|
20
|
+
启动时间/time ${function (e) {
|
|
21
|
+
e.innerHTML = filterTime(e.data[e.field.key]);
|
|
22
|
+
}}
|
|
23
|
+
端口/port input
|
|
24
|
+
版本/version
|
|
25
|
+
进程/pid
|
|
26
|
+
`;
|
|
27
|
+
function main() {
|
|
28
|
+
var page = div();
|
|
29
|
+
page.innerHTML = template;
|
|
30
|
+
var items = data.from("bootlog", datas => {
|
|
31
|
+
datas.forEach(a => {
|
|
32
|
+
var [v, p] = a.ppid.split("/");
|
|
33
|
+
a.version = v;
|
|
34
|
+
a.pid = p;
|
|
35
|
+
});
|
|
36
|
+
datas.sort((a, b) => b.time - a.time);
|
|
37
|
+
return datas;
|
|
38
|
+
});
|
|
39
|
+
renderWithDefaults(page, {
|
|
40
|
+
items,
|
|
41
|
+
fields
|
|
42
|
+
});
|
|
43
|
+
return page;
|
|
44
|
+
}
|
package/apps/pivot/log/count.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
var fields = refilm`
|
|
2
|
-
路径/path
|
|
2
|
+
路径/path html
|
|
3
3
|
访问量/count
|
|
4
4
|
`;
|
|
5
5
|
function main() {
|
|
6
6
|
var page = div();
|
|
7
7
|
page.innerHTML = template;
|
|
8
|
+
var items = data.from("count", a => {
|
|
9
|
+
return Object.keys(a).map(b => ({ path: b, count: a[b] }));
|
|
10
|
+
});
|
|
8
11
|
renderWithDefaults(page, {
|
|
9
|
-
items
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
items,
|
|
13
|
+
searchText: "",
|
|
14
|
+
filter() {
|
|
15
|
+
var text = this.searchText;
|
|
16
|
+
if (!text) return this.items = items;
|
|
17
|
+
this.items = search(text, items, 'path');
|
|
18
|
+
},
|
|
12
19
|
fields
|
|
13
20
|
});
|
|
14
21
|
return page;
|
package/apps/pivot/main.js
CHANGED
|
@@ -7,16 +7,15 @@ cross.addReform(async function ({ status, url, headers }, reform, reject) {
|
|
|
7
7
|
var base1 = protocol + "//" + host + "/";
|
|
8
8
|
if (base !== base1) {
|
|
9
9
|
data.setSource(base1, null);
|
|
10
|
-
var page = await popup("/auth/login", base1);
|
|
11
|
-
care(page, "login", function (info) {
|
|
12
|
-
data.setSource(base1, info);
|
|
13
|
-
headers.authorization = info;
|
|
14
|
-
reform();
|
|
15
|
-
});
|
|
16
|
-
on("remove")(page, reject);
|
|
17
|
-
return false;
|
|
18
10
|
}
|
|
19
|
-
|
|
11
|
+
var page = await popup("/auth/login", base1);
|
|
12
|
+
care(page, "login", function (info) {
|
|
13
|
+
data.setSource(base1, info);
|
|
14
|
+
headers.authorization = info;
|
|
15
|
+
reform();
|
|
16
|
+
});
|
|
17
|
+
on("remove")(page, reject);
|
|
18
|
+
return false;
|
|
20
19
|
}
|
|
21
20
|
})
|
|
22
21
|
data.setReporter(function (m, t) {
|
|
@@ -27,7 +26,7 @@ data.bindInstance("base", async function (base) {
|
|
|
27
26
|
cross.addDirect(base.base);
|
|
28
27
|
var apimap = await data.getConfig();
|
|
29
28
|
for (var k in apimap) {
|
|
30
|
-
apimap[k].base = base.base;
|
|
29
|
+
if (apimap[k].method === 'options') apimap[k].base = base.base;
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
32
|
var base = data.getInstance('base').base;
|
package/apps/pivot/menu.yml
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
首页: /home/welcome
|
|
2
2
|
WEB:
|
|
3
3
|
共享目录: /share/list
|
|
4
|
-
短链接: /
|
|
4
|
+
短链接: /proxy/list
|
|
5
5
|
文件管理: /wow/root
|
|
6
6
|
长连接管理: /link/list
|
|
7
7
|
任务:
|
|
8
8
|
密钥管理: /token/list
|
|
9
9
|
任务建立: /task/list
|
|
10
10
|
定期执行: /tick/list
|
|
11
|
-
|
|
11
|
+
用户:
|
|
12
|
+
账号列表: /user/list
|
|
13
|
+
标签管理: /user/tag/list
|
|
12
14
|
服务器日志:
|
|
13
|
-
访问计数: /log/count
|
|
15
|
+
访问计数: /log/count
|
|
16
|
+
启动记录: /log/boot
|
|
17
|
+
# 并发记忆: /log/lock
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pedit.bind(null, "短链接", "proxy");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var fields = refilm`
|
|
2
|
+
*代理路径/url input/20
|
|
3
|
+
真实路径/realpath url/2000
|
|
4
|
+
/ - ${[{
|
|
5
|
+
name: "访问",
|
|
6
|
+
do(o) {
|
|
7
|
+
var url = o.url;
|
|
8
|
+
if (!/^\//.test(url)) url = "/" + url;
|
|
9
|
+
window.open(url,null);
|
|
10
|
+
}
|
|
11
|
+
}]}`;
|
|
12
|
+
return plist.bind(null, '短链接', "proxy", fields, "/proxy/edit");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pedit.bind(null, "用户信息", "user");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pedit.bind(null, "标签", "tag");
|
package/coms/basic/cross_.js
CHANGED
|
@@ -180,7 +180,14 @@ function cross_(jsonp, digest = noop, method, url, headers) {
|
|
|
180
180
|
};
|
|
181
181
|
xhr.form = function (data) {
|
|
182
182
|
xhr.data(data);
|
|
183
|
-
|
|
183
|
+
var hasFile = false;
|
|
184
|
+
if (FormData) for (var k in jsondata) {
|
|
185
|
+
if (isFile(jsondata[k])) {
|
|
186
|
+
hasFile = true;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (hasFile) {
|
|
184
191
|
datas = new FormData;
|
|
185
192
|
for (var k in jsondata) {
|
|
186
193
|
datas.append(k, jsondata[k]);
|
package/coms/basic/encodePack.js
CHANGED
|
@@ -277,27 +277,20 @@ function pack2(buff) {
|
|
|
277
277
|
var result = [];
|
|
278
278
|
for (var cx = 0, dx = buff.length, bx = 32 * 1024 * 1024; cx < dx; cx += bx) {
|
|
279
279
|
var b = buff.slice(cx, cx + bx);
|
|
280
|
-
var
|
|
281
|
-
l = encodeRange(l);
|
|
282
|
-
p = encodeRange(p);
|
|
280
|
+
var b = scan(b);
|
|
283
281
|
var e = encodeRange(b);
|
|
284
282
|
var el = int(e.length);
|
|
285
283
|
result.push(concatTypedArray([
|
|
286
284
|
[
|
|
287
285
|
range_compress,
|
|
288
286
|
other_compress << 5 | el.length,
|
|
289
|
-
l.length >> 8,
|
|
290
|
-
l.length & 0xff,
|
|
291
|
-
p.length >> 8,
|
|
292
|
-
p.length & 0xff
|
|
293
287
|
],
|
|
294
|
-
el,
|
|
288
|
+
el, e]));
|
|
295
289
|
}
|
|
296
290
|
result = concatTypedArray(result);
|
|
297
291
|
return pack0(buff, result);
|
|
298
292
|
}
|
|
299
293
|
module.exports = function (buff, type) {
|
|
300
|
-
type = 1;
|
|
301
294
|
switch (type) {
|
|
302
295
|
case 1:
|
|
303
296
|
return pack(buff);
|
|
@@ -12,6 +12,8 @@ test('http://yunxu1019@live.cn@github.com/?a', 'username', 'yunxu1019@live.cn')
|
|
|
12
12
|
test('localhost', 'host', 'localhost')
|
|
13
13
|
test('localhost:80', 'port', '80')
|
|
14
14
|
test('localhost:80/', 'port', '80')
|
|
15
|
+
test('efront.cc', 'host', 'efront.cc')
|
|
16
|
+
test('127.0.0.1', 'host', '127.0.0.1')
|
|
15
17
|
test(':80', 'port', '80')
|
|
16
18
|
test('80', 'port', '80')
|
|
17
19
|
test('/80', 'pathname', '/80')
|
|
@@ -3,7 +3,7 @@ function createSeek(express) {
|
|
|
3
3
|
express.forEach(function (search) {
|
|
4
4
|
if (dist) {
|
|
5
5
|
if (/[\=]/.test(dist)) dist = `(${dist})`;
|
|
6
|
-
dist =
|
|
6
|
+
dist = `typeof ${dist}!=='undefined'&&${dist}!==null?${dist}${search}:''`
|
|
7
7
|
} else {
|
|
8
8
|
dist = search;
|
|
9
9
|
}
|
package/coms/compile/common.js
CHANGED
|
@@ -110,7 +110,7 @@ var skipAssignment = function (o) {
|
|
|
110
110
|
}
|
|
111
111
|
return o;
|
|
112
112
|
};
|
|
113
|
-
var createScoped = function (parsed) {
|
|
113
|
+
var createScoped = function (parsed, wash) {
|
|
114
114
|
var used = Object.create(null); var vars = Object.create(null), lets = vars;
|
|
115
115
|
var scoped = [], funcbody = scoped;
|
|
116
116
|
scoped.isfunc = true;
|
|
@@ -206,7 +206,7 @@ var createScoped = function (parsed) {
|
|
|
206
206
|
}
|
|
207
207
|
o = o0;
|
|
208
208
|
mergeTo(used, used0);
|
|
209
|
-
|
|
209
|
+
mapDeclared(m, declared);
|
|
210
210
|
continue loop;
|
|
211
211
|
case "function":
|
|
212
212
|
isFunction = true;
|
|
@@ -308,6 +308,7 @@ var createScoped = function (parsed) {
|
|
|
308
308
|
o.isExpress = isExpress;
|
|
309
309
|
if (isFunction || isCatch) {
|
|
310
310
|
var [declared, used0, o0, skiped] = getDeclared(o.first, 'argument');
|
|
311
|
+
scoped.args = declared;
|
|
311
312
|
mergeTo(used, used0);
|
|
312
313
|
while (skiped.length) {
|
|
313
314
|
var o1 = run(skiped[0], 0);
|
|
@@ -315,7 +316,7 @@ var createScoped = function (parsed) {
|
|
|
315
316
|
if (sindex < 0) break;
|
|
316
317
|
skiped.splice(0, sindex + 1);
|
|
317
318
|
}
|
|
318
|
-
|
|
319
|
+
mapDeclared(isCatch ? lets : vars, declared);
|
|
319
320
|
}
|
|
320
321
|
else {
|
|
321
322
|
run(o.first);
|
|
@@ -334,6 +335,19 @@ var createScoped = function (parsed) {
|
|
|
334
335
|
if (o.type === SCOPED && o.entry === "{") {
|
|
335
336
|
o.isExpress = isExpress;
|
|
336
337
|
run(o.first);
|
|
338
|
+
if (wash && isFunction) {
|
|
339
|
+
var e = o.next;
|
|
340
|
+
if (e && e.type === EXPRESS && /^[\.\[]/.test(e.text) || e && e.type === SCOPED && e.entry === "[") {
|
|
341
|
+
scoped.target = true;
|
|
342
|
+
e = e.next;
|
|
343
|
+
}
|
|
344
|
+
if (e && e.type === SCOPED && e.entry === '(') {
|
|
345
|
+
if (e.first) {
|
|
346
|
+
scoped.pass = getDeclared(e.first)[0];
|
|
347
|
+
}
|
|
348
|
+
if (scoped.target) scoped.target = scoped.pass.shift();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
337
351
|
}
|
|
338
352
|
else {
|
|
339
353
|
do {
|
|
@@ -407,7 +421,8 @@ var createScoped = function (parsed) {
|
|
|
407
421
|
return scoped;
|
|
408
422
|
};
|
|
409
423
|
var getDeclared = function (o, kind) {
|
|
410
|
-
var declared =
|
|
424
|
+
var declared = [], used = Object.create(null); var skiped = [];
|
|
425
|
+
var prop = null;
|
|
411
426
|
loop: while (o) {
|
|
412
427
|
while (o && o.type === STAMP && o.text === ',') o = o.next;
|
|
413
428
|
if (!o) break;
|
|
@@ -423,12 +438,14 @@ var getDeclared = function (o, kind) {
|
|
|
423
438
|
if (o.text === "*" && o.next) {
|
|
424
439
|
if (o.next.type === STRAP && o.next.text === 'as') {
|
|
425
440
|
o = o.next.next;
|
|
441
|
+
prop = "*";
|
|
426
442
|
continue;
|
|
427
443
|
}
|
|
428
444
|
}
|
|
429
445
|
case PROPERTY:
|
|
430
446
|
if (o.next) {
|
|
431
447
|
if (o.next.type === STAMP && o.next.text === ":" || o.next.type === STRAP && o.next.text === "as") {
|
|
448
|
+
prop = "." + o.text;
|
|
432
449
|
o = o.next.next;
|
|
433
450
|
continue;
|
|
434
451
|
}
|
|
@@ -437,7 +454,9 @@ var getDeclared = function (o, kind) {
|
|
|
437
454
|
case VALUE:
|
|
438
455
|
case EXPRESS:
|
|
439
456
|
var n = o.text.replace(/^\.\.\.|\.\.\.$/g, '');
|
|
440
|
-
declared
|
|
457
|
+
declared.push(n);
|
|
458
|
+
if (n !== o.text) declared["..."] = n;
|
|
459
|
+
else if (prop) declared[prop] = n;
|
|
441
460
|
o.kind = kind;
|
|
442
461
|
saveTo(used, n, o);
|
|
443
462
|
o = o.next;
|
|
@@ -446,7 +465,8 @@ var getDeclared = function (o, kind) {
|
|
|
446
465
|
var [d, u, _, s] = getDeclared(o.first, kind);
|
|
447
466
|
while (s.length) skiped.push.apply(skiped, s.splice(0, 1024));
|
|
448
467
|
mergeTo(used, u);
|
|
449
|
-
|
|
468
|
+
declared.push(d);
|
|
469
|
+
if (prop) declared[prop] = d;
|
|
450
470
|
o = o.next;
|
|
451
471
|
break;
|
|
452
472
|
default:
|
|
@@ -483,9 +503,21 @@ var getDeclared = function (o, kind) {
|
|
|
483
503
|
if (!o) break;
|
|
484
504
|
if (o.type !== STAMP) break;
|
|
485
505
|
if (o.text !== ',') break;
|
|
506
|
+
prop = null;
|
|
486
507
|
}
|
|
487
508
|
return [declared, used, o, skiped];
|
|
488
509
|
};
|
|
510
|
+
var mapDeclared = function (map, declared) {
|
|
511
|
+
var rest = [declared];
|
|
512
|
+
while (rest.length) {
|
|
513
|
+
var r = rest.pop();
|
|
514
|
+
for (var d of r) {
|
|
515
|
+
if (d instanceof Array) rest.push(d);
|
|
516
|
+
else map[d] = true;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return map;
|
|
520
|
+
};
|
|
489
521
|
var saveTo = function (used, k, o) {
|
|
490
522
|
if (!(used[k] instanceof Array)) used[k] = [];
|
|
491
523
|
used[k].push(o);
|
|
@@ -498,6 +530,132 @@ var mergeTo = function (used, used0) {
|
|
|
498
530
|
}
|
|
499
531
|
};
|
|
500
532
|
|
|
533
|
+
var needBreak = function (prev, next) {
|
|
534
|
+
if (!prev || !next) return;
|
|
535
|
+
if (prev.type === STAMP && /^[,;]$/.test(prev.text)) return;
|
|
536
|
+
if (next.type === STAMP && /^[,;]$/.test(next.text)) return;
|
|
537
|
+
if (prev.type === EXPRESS && /\.$/.test(prev.text)) return;
|
|
538
|
+
if (next.type === EXPRESS && /^\./.test(next.text)) return;
|
|
539
|
+
if (next.type === PROPERTY) return ";";
|
|
540
|
+
if (next.type === STAMP && next.text === "*") return ";";
|
|
541
|
+
if (
|
|
542
|
+
[EXPRESS, VALUE, QUOTED].indexOf(prev.type) >= 0
|
|
543
|
+
|| prev.type === STAMP && /^(\+\+|\-\-)$/.test(prev.text)
|
|
544
|
+
|| prev.type === SCOPED && (prev.isExpress || prev.isObject)
|
|
545
|
+
) {
|
|
546
|
+
if ([EXPRESS, VALUE, QUOTED, LABEL].indexOf(next.type) >= 0) return ";";
|
|
547
|
+
if (next.type === STRAP) {
|
|
548
|
+
if (!/^(in|of|extends|instanceof|as)$/.test(next.text)) return ";";
|
|
549
|
+
return " ";
|
|
550
|
+
}
|
|
551
|
+
if (next.type === SCOPED) {
|
|
552
|
+
if (!next.isExpress) return ";";
|
|
553
|
+
}
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (prev.type === STRAP) {
|
|
557
|
+
if ([STRAP, EXPRESS, VALUE, QUOTED].indexOf(next.type) >= 0) return " ";
|
|
558
|
+
if (next.type === LABEL) return ";";
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
var createString = function (parsed) {
|
|
563
|
+
var pressed = parsed.pressed;
|
|
564
|
+
var lasttype;
|
|
565
|
+
var result = [];
|
|
566
|
+
var run = (o, i, a) => {
|
|
567
|
+
var prev = o.prev;
|
|
568
|
+
if (!~[SPACE, COMMENT, STAMP, PIECE].indexOf(o.type) && prev && lasttype !== SPACE && !pressed) {
|
|
569
|
+
if (~[QUOTED, SCOPED, STRAP, LABEL, COMMENT].indexOf(lasttype)
|
|
570
|
+
|| prev.type === STAMP
|
|
571
|
+
&& (!/[\+\-\~\!]$/.test(prev.text) || /[\+\-]$/.test(prev.text) && prev.prev
|
|
572
|
+
&& (!~[STAMP, STRAP, SCOPED].indexOf(prev.prev.type) || prev.prev.type === SCOPED && prev.prev.isExpress)
|
|
573
|
+
)) {
|
|
574
|
+
if (o.type !== SCOPED && (o.type !== EXPRESS || !/^\./.test(o.text))) {
|
|
575
|
+
result.push(" ");
|
|
576
|
+
lasttype = SPACE
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
switch (o.type) {
|
|
581
|
+
case COMMENT:
|
|
582
|
+
// 每一次要远行,我都不得不对自己的物品去粗取精。取舍之间,什么重要,什么不是那么重要,都有了一道明显的分界线。
|
|
583
|
+
if (!pressed) {
|
|
584
|
+
if (lasttype !== SPACE && o.prev) result.push(' ');
|
|
585
|
+
result.push(o.text);
|
|
586
|
+
}
|
|
587
|
+
break;
|
|
588
|
+
case SPACE:
|
|
589
|
+
if (!pressed) {
|
|
590
|
+
result.push(o.text);
|
|
591
|
+
lasttype = SPACE;
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
var b = needBreak(o.prev, o.next);
|
|
595
|
+
if (b) result.push(b);
|
|
596
|
+
break;
|
|
597
|
+
case QUOTED:
|
|
598
|
+
if (!o.length) {
|
|
599
|
+
result.push(o.text);
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
case SCOPED:
|
|
603
|
+
if (!pressed && o.type !== QUOTED && (lasttype === STRAP || lasttype === COMMENT || lasttype === STAMP
|
|
604
|
+
&& (!o.prev || !/[\+\-\~\!]$/.test(o.prev.text) || /[\+\-]$/.test(o.prev.text) && (!o.prev.prev || !~[STAMP, STRAP].indexOf(o.prev.prev.type)))
|
|
605
|
+
|| lasttype === SCOPED && o.entry === "{"
|
|
606
|
+
)) result.push(" ");
|
|
607
|
+
result.push(o.entry);
|
|
608
|
+
if (o.length > 0) {
|
|
609
|
+
if (o.entry === "{" && result[0].type !== SPACE) {
|
|
610
|
+
if (!pressed) {
|
|
611
|
+
result.push(" ");
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
lasttype = undefined;
|
|
615
|
+
o.forEach(run);
|
|
616
|
+
if (/^[,;]$/.test(result[result.length - 1]) && pressed) {
|
|
617
|
+
if (!o.prev || o.prev.text !== 'for') result.pop();
|
|
618
|
+
}
|
|
619
|
+
if (o.leave === "}" && (!o.next || o.next.type !== PIECE) && o[o.length - 1].type !== SPACE) {
|
|
620
|
+
if (!pressed) result.push(" ");
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
result.push(o.leave);
|
|
624
|
+
break;
|
|
625
|
+
default:
|
|
626
|
+
if (o instanceof Object) {
|
|
627
|
+
if ([STRAP, EXPRESS, PROPERTY, VALUE, COMMENT].indexOf(lasttype) >= 0 && [STRAP, EXPRESS, PROPERTY, VALUE].indexOf(o.type) >= 0) {
|
|
628
|
+
result.push(" ");
|
|
629
|
+
}
|
|
630
|
+
else if (o.prev && o.type === STAMP && !/^([,;])$/.test(o.text)) {
|
|
631
|
+
if (result[result.length - 1] === " " || (lasttype === PROPERTY || !o.isExpress && o.prev && o.prev.type !== LABEL) && o.text === ':') { }
|
|
632
|
+
else if (lasttype === STAMP) {
|
|
633
|
+
result.push(" ");
|
|
634
|
+
}
|
|
635
|
+
else if (/^(\+\+|\-\-)$/.test(o.prev.text) && o.prev.prev) {
|
|
636
|
+
var prev_prev = o.prev.prev;
|
|
637
|
+
if (
|
|
638
|
+
prev_prev.type === STRAP && !prev_prev.isExpress
|
|
639
|
+
|| prev_prev.type === EXPRESS
|
|
640
|
+
|| prev_prev.type === VALUE
|
|
641
|
+
) result.push(";");
|
|
642
|
+
}
|
|
643
|
+
else if (!/^(\+\+|\-\-)$/.test(o.text)) {
|
|
644
|
+
if (!pressed && lasttype !== SPACE) result.push(" ");
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
result.push(o.text);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
result.push(o);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
lasttype = o.type;
|
|
654
|
+
if (o.isprop) lasttype = PROPERTY;
|
|
655
|
+
};
|
|
656
|
+
parsed.forEach(run);
|
|
657
|
+
return result.join("");
|
|
658
|
+
}
|
|
501
659
|
|
|
502
660
|
module.exports = {
|
|
503
661
|
/*-1 */COMMENT,
|
|
@@ -514,6 +672,7 @@ module.exports = {
|
|
|
514
672
|
number_reg,
|
|
515
673
|
skipAssignment,
|
|
516
674
|
getDeclared,
|
|
675
|
+
createString,
|
|
517
676
|
createScoped,
|
|
518
677
|
saveTo,
|
|
519
678
|
mergeTo
|
package/coms/compile/scanner.js
CHANGED
|
@@ -293,9 +293,9 @@ function single_comment_scanner2(index) {
|
|
|
293
293
|
// single_comment_scanner2.call(string, 0);
|
|
294
294
|
// }, count); //3354+
|
|
295
295
|
// console.log(t1, t2);
|
|
296
|
-
function block_code_scanner(index, blocks = []) {
|
|
296
|
+
function block_code_scanner(index, blocks = [], keepdeep = Infinity) {
|
|
297
297
|
var save = (blocks instanceof Array) ? function (scanner, children) {
|
|
298
|
-
if (saved_index < index) {
|
|
298
|
+
if (deep < keepdeep && saved_index < index) {
|
|
299
299
|
blocks.push(new Block(scanner, saved_index, index, children));
|
|
300
300
|
saved_index = index;
|
|
301
301
|
}
|
|
@@ -618,7 +618,7 @@ function lookback_scanner(blockIndex, blocks) {
|
|
|
618
618
|
return tempIndex;
|
|
619
619
|
}
|
|
620
620
|
|
|
621
|
-
var scanner = module.exports = function (s) {
|
|
621
|
+
var scanner = module.exports = function (s, keepdeep) {
|
|
622
622
|
var blocks = [];
|
|
623
623
|
var s = String(s);
|
|
624
624
|
// var time = Date.now();
|
|
@@ -626,10 +626,13 @@ var scanner = module.exports = function (s) {
|
|
|
626
626
|
// block_code_scanner.call(s, 0, blocks);
|
|
627
627
|
// }//angular 1.5.3 x1000 7.0s
|
|
628
628
|
// console.log(Date.now() - time);
|
|
629
|
-
block_code_scanner.call(s, 0, blocks);
|
|
629
|
+
block_code_scanner.call(s, 0, blocks, keepdeep);
|
|
630
630
|
// console.log(blocks.map(a => s.slice(a.start, a.end)).join())
|
|
631
631
|
return blocks;
|
|
632
632
|
};
|
|
633
|
+
scanner.autoskip = function (code, start) {
|
|
634
|
+
return block_code_scanner.call(code, start, null);
|
|
635
|
+
};
|
|
633
636
|
function Block(scanner, start, end, children) {
|
|
634
637
|
this.type = scanner;
|
|
635
638
|
this.start = start;
|