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.
- package/apps/kugou/main.js +1 -3
- package/coms/basic/assert.js +10 -2
- package/coms/basic/extends_.js +13 -0
- package/coms/basic/loader.js +22 -17
- package/coms/basic/mark.js +155 -0
- package/coms/basic/queue.js +11 -14
- package/coms/basic/rest_.js +27 -0
- package/coms/basic/submit_.js +3 -1
- package/{apps → coms}/kugou/api.js +2 -0
- package/coms/kugou/buildList.js +7 -1
- package/coms/kugou/player.js +1 -0
- package/coms/kugou/song.html +1 -1
- package/coms/kugou/song.js +1 -0
- package/coms/kugou/song.less +12 -1
- package/coms/zimoli/cloneVisible.js +1 -0
- package/coms/zimoli/compile.js +64 -1
- package/coms/{compile → zimoli}/compile_test.js +0 -0
- package/coms/zimoli/data.js +8 -2
- package/coms/zimoli/input.js +6 -4
- package/coms/zimoli/render.js +1 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme.md +0 -1
- package/apps/zimoli/book/main.js +0 -8
- package/apps/zimoli/broadcast/main.js +0 -8
- package/apps/zimoli/collection/add.html +0 -13
- package/apps/zimoli/collection/add.js +0 -14
- package/apps/zimoli/collection/add.less +0 -0
- package/apps/zimoli/collection/main.html +0 -0
- package/apps/zimoli/collection/main.js +0 -13
- package/apps/zimoli/collection/main.less +0 -8
- package/apps/zimoli/config.js +0 -14
- package/apps/zimoli/extra/pending.html +0 -1
- package/apps/zimoli/extra/pending.js +0 -8
- package/apps/zimoli/extra/pending.less +0 -15
- package/apps/zimoli/files/info.js +0 -7
- package/apps/zimoli/files/main.js +0 -108
- package/apps/zimoli/files/main.less +0 -26
- package/apps/zimoli/images/avatar.png +0 -0
- package/apps/zimoli/images/background.jpg +0 -0
- package/apps/zimoli/index.html +0 -42
- package/apps/zimoli/kugou/font/demo.css +0 -539
- package/apps/zimoli/kugou/font/demo_index.html +0 -1159
- package/apps/zimoli/kugou/font/iconfont.css +0 -189
- package/apps/zimoli/kugou/font/iconfont.eot +0 -0
- package/apps/zimoli/kugou/font/iconfont.js +0 -1
- package/apps/zimoli/kugou/font/iconfont.svg +0 -155
- package/apps/zimoli/kugou/font/iconfont.ttf +0 -0
- package/apps/zimoli/kugou/font/iconfont.woff +0 -0
- package/apps/zimoli/kugou/font/iconfont.woff2 +0 -0
- package/apps/zimoli/kugou/listen.html +0 -15
- package/apps/zimoli/kugou/listen.js +0 -37
- package/apps/zimoli/kugou/listen.less +0 -114
- package/apps/zimoli/kugou/mine.html +0 -53
- package/apps/zimoli/kugou/mine.js +0 -21
- package/apps/zimoli/kugou/mine.less +0 -106
- package/apps/zimoli/kugou/search.js +0 -109
- package/apps/zimoli/kugou/search.less +0 -50
- package/apps/zimoli/kugou/sing.js +0 -42
- package/apps/zimoli/kugou/sing.less +0 -93
- package/apps/zimoli/kugou/view.html +0 -39
- package/apps/zimoli/kugou/view.js +0 -17
- package/apps/zimoli/kugou/view.less +0 -84
- package/apps/zimoli/login/qq.js +0 -20
- package/apps/zimoli/login/qq_callback.html +0 -15
- package/apps/zimoli/main.js +0 -87
- package/apps/zimoli/main.less +0 -81
- package/apps/zimoli/message/chatList.js +0 -57
- package/apps/zimoli/message/chatList.less +0 -52
- package/apps/zimoli/message/commentList.js +0 -55
- package/apps/zimoli/message/commentList.less +0 -55
- package/apps/zimoli/message/informList.js +0 -69
- package/apps/zimoli/message/informList.less +0 -51
- package/apps/zimoli/message/main.js +0 -59
- package/apps/zimoli/message/main.less +0 -51
- package/apps/zimoli/message/praiseList.js +0 -3
- package/apps/zimoli/message/praiseList.less +0 -7
- package/apps/zimoli/nearby/main.js +0 -8
- package/apps/zimoli/skin/main.js +0 -47
- package/apps/zimoli/skin/main.less +0 -31
- package/apps/zimoli/user/getPassword.js +0 -82
- package/apps/zimoli/user/getPassword.less +0 -14
- package/apps/zimoli/user/login.html +0 -12
- package/apps/zimoli/user/login.js +0 -50
- package/apps/zimoli/user/login.less +0 -139
- package/apps/zimoli/user/profile-bg.jpg +0 -0
- package/apps/zimoli/user/profile.html +0 -32
- package/apps/zimoli/user/profile.js +0 -63
- package/apps/zimoli/user/profile.less +0 -50
- package/apps/zimoli/user/register.js +0 -20
- package/apps/zimoli/user/register.less +0 -3
- package/apps/zimoli/user/setting.js +0 -90
- package/apps/zimoli/user/setting.less +0 -11
- package/apps/zimoli/user/welcome.js +0 -36
- package/apps/zimoli/user/welcome.less +0 -136
- package/apps/zimoli/watch/main.html +0 -22
- package/apps/zimoli/watch/main.js +0 -76
- package/apps/zimoli/watch/main.less +0 -54
- package/apps/zimoli/yuanfen/main.js +0 -55
- package/apps/zimoli/yuanfen/main.json +0 -0
- package/coms/compile/breakcode.js +0 -78
- package/coms/compile/common.js +0 -688
- package/coms/compile/compile.js +0 -64
- package/coms/compile/keywords.js +0 -6
- package/coms/compile/namelist.js +0 -142
- package/coms/compile/namelist_test.js +0 -7
- package/coms/compile/required.js +0 -20
- package/coms/compile/scanner.js +0 -653
- package/coms/compile/scanner2.js +0 -921
- package/coms/compile/scanner2_test.js +0 -85
- package/coms/compile/scanner_test.js +0 -10
- package/coms/compile/washcode.js +0 -313
- package/coms/zimoli/mark.js +0 -70
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
var fs = require("fs");
|
|
2
|
-
var path = require("path");
|
|
3
|
-
var esprima = require("../esprima/index");
|
|
4
|
-
var typescript = require("../typescript/index");
|
|
5
|
-
var console = require("../efront/colored_console");
|
|
6
|
-
var scanner = require("./scanner2");
|
|
7
|
-
var data = fs.readFileSync(path.join(__dirname, "../typescript/index.js")).toString();
|
|
8
|
-
var data2 = fs.readFileSync(path.join(__dirname, "./scanner2.js")).toString();
|
|
9
|
-
// data='{ \r\na( ){ return a;} }';
|
|
10
|
-
function test(parser, name) {
|
|
11
|
-
var time = new Date;
|
|
12
|
-
var parsed = parser(data);
|
|
13
|
-
// var scanned1 = scanner(`\`a\${b}c\``);
|
|
14
|
-
console.log(new Date - time, name);
|
|
15
|
-
return parsed;
|
|
16
|
-
}
|
|
17
|
-
function testSpeed() {
|
|
18
|
-
|
|
19
|
-
console.log(data.slice(6426300, 6426400))
|
|
20
|
-
var scanned = test(scanner, 'scanner2');
|
|
21
|
-
var start = new Date();
|
|
22
|
-
var data3 = scanned.press().toString();
|
|
23
|
-
console.log(new Date - start, 'press().toString()');
|
|
24
|
-
fs.writeFileSync(path.join(__dirname, "./scanner2_temp.js"), data3);
|
|
25
|
-
|
|
26
|
-
test(esprima.parse, 'esprima.parse');
|
|
27
|
-
test(esprima.tokenize, 'esprima.tokenize');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function testVariables() {
|
|
31
|
-
var rootpath = path.join(__dirname, "../zimoli/");
|
|
32
|
-
var getVariables = require("./variables");
|
|
33
|
-
var names = fs.readdirSync(rootpath);
|
|
34
|
-
names.forEach(n => {
|
|
35
|
-
if (!/\.js$/i.test(n)) return;
|
|
36
|
-
var data3 = fs.readFileSync(path.join(rootpath, n)).toString().replace(/^\s*#!/, '//');
|
|
37
|
-
try {
|
|
38
|
-
var jst = esprima.parse(data3);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
data3 = typescript.transpile(data3);
|
|
41
|
-
jst = esprima.parse(data3);
|
|
42
|
-
}
|
|
43
|
-
console.info(n);
|
|
44
|
-
if (n === "grid.js") debugger;
|
|
45
|
-
var globals = scanner(data3).getUndecleared();
|
|
46
|
-
var {
|
|
47
|
-
unDeclaredVariables: undeclares
|
|
48
|
-
} = getVariables(jst);
|
|
49
|
-
var warn = false;
|
|
50
|
-
for (var k in globals) {
|
|
51
|
-
if (!(k in undeclares)) {
|
|
52
|
-
warn = true;
|
|
53
|
-
if (warn) console.warn(n, k, 'globals:', globals[k], 'undeclared:', undeclares[k]);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
for (var k in undeclares) {
|
|
57
|
-
if (!(k in globals)) {
|
|
58
|
-
warn = true;
|
|
59
|
-
if (warn) console.warn(n, k, 'globals:', globals[k], 'undeclared:', undeclares[k]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
function testRegexp() {
|
|
67
|
-
var m = scanner(`/${/[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g.source}/g/** a */`)
|
|
68
|
-
console.log(m)
|
|
69
|
-
}
|
|
70
|
-
function testStatic() {
|
|
71
|
-
var m = scanner(`class a{static{console.log(1)}}`);
|
|
72
|
-
console.log(m);
|
|
73
|
-
}
|
|
74
|
-
function testAssign() {
|
|
75
|
-
var m = scanner(`a=function(){}
|
|
76
|
-
a()`);
|
|
77
|
-
console.log(m.press().toString());
|
|
78
|
-
}
|
|
79
|
-
// testSpeed();
|
|
80
|
-
// testVariables();
|
|
81
|
-
// testRegexp();
|
|
82
|
-
// testStatic();
|
|
83
|
-
testAssign();
|
|
84
|
-
// var typescript = require("../typescript/index");
|
|
85
|
-
// typescript.transpile(data.toString(), { noEmitHelpers: true });
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var scanner = require("./scanner");
|
|
2
|
-
var fs = require("fs");
|
|
3
|
-
function scanner_test() {
|
|
4
|
-
var time = new Date;
|
|
5
|
-
var str = fs.readFileSync('coms/typescript/index.js').toString();
|
|
6
|
-
var res = scanner(str);
|
|
7
|
-
res.forEach(a => a.data = str.slice(a.start, a.end))
|
|
8
|
-
console.log(res, new Date - time);
|
|
9
|
-
}
|
|
10
|
-
scanner_test();
|
package/coms/compile/washcode.js
DELETED
|
@@ -1,313 +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
|
-
skipAssignment,
|
|
14
|
-
getDeclared,
|
|
15
|
-
createScoped,
|
|
16
|
-
createString,
|
|
17
|
-
} = require("./common");
|
|
18
|
-
var strings = require("../basic/strings");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 按语句分割代码
|
|
22
|
-
*/
|
|
23
|
-
var createExpressList = function (parsed) {
|
|
24
|
-
var list = [];
|
|
25
|
-
for (var cx = 0, dx = parsed.length; cx < dx; cx++) {
|
|
26
|
-
var o = parsed[cx];
|
|
27
|
-
switch (o.type) {
|
|
28
|
-
case LABEL:
|
|
29
|
-
var exp = [o];
|
|
30
|
-
exp.first = exp[0];
|
|
31
|
-
list.push(exp);
|
|
32
|
-
break;
|
|
33
|
-
case STRAP:
|
|
34
|
-
case SCOPED:
|
|
35
|
-
case EXPRESS:
|
|
36
|
-
case VALUE:
|
|
37
|
-
case QUOTED:
|
|
38
|
-
var o0 = skipAssignment(o);
|
|
39
|
-
var exp = [];
|
|
40
|
-
do {
|
|
41
|
-
exp.push(o);
|
|
42
|
-
o = parsed[++cx];
|
|
43
|
-
} while (o0 !== o);
|
|
44
|
-
cx--;
|
|
45
|
-
patchExpress(exp);
|
|
46
|
-
list.push(exp);
|
|
47
|
-
break;
|
|
48
|
-
case COMMENT:
|
|
49
|
-
case SPACE:
|
|
50
|
-
case STAMP:
|
|
51
|
-
list.push([o]);
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
console.log(o.type, 'type');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return list;
|
|
58
|
-
};
|
|
59
|
-
var getFunctionEnd = function (first) {
|
|
60
|
-
if (!first) return false;
|
|
61
|
-
var o = first.next;
|
|
62
|
-
if (!o) return false;
|
|
63
|
-
if (first.type === STRAP && first.text === 'function') {
|
|
64
|
-
if (o.type === EXPRESS) o = o.next;
|
|
65
|
-
if (!o) return false;
|
|
66
|
-
if (o.next && !o.next.next) return o.next;
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
var patchExpress = function (exp) {
|
|
71
|
-
if (!exp.first) {
|
|
72
|
-
exp.first = exp[0];
|
|
73
|
-
}
|
|
74
|
-
if (!exp.lastUncomment) {
|
|
75
|
-
exp.lastUncomment = exp[exp.length - 1];
|
|
76
|
-
}
|
|
77
|
-
if (exp.first) {
|
|
78
|
-
delete exp.first.prev;
|
|
79
|
-
}
|
|
80
|
-
if (exp.lastUncomment) {
|
|
81
|
-
delete exp.lastUncomment.next;
|
|
82
|
-
}
|
|
83
|
-
var first = exp.first;
|
|
84
|
-
if (first && first.type === QUOTED && /^(['"`])use strict\1/i.test(first.text)) {
|
|
85
|
-
exp.saved = true;
|
|
86
|
-
}
|
|
87
|
-
if (first && first.type === SCOPED && first.entry === '(') {
|
|
88
|
-
var ff = first.first;
|
|
89
|
-
var fn = first.next;
|
|
90
|
-
if (fn && fn.type === SCOPED && fn.entry === '(') {
|
|
91
|
-
var fe = getFunctionEnd(ff);
|
|
92
|
-
if (fe) {
|
|
93
|
-
first.push(fn);
|
|
94
|
-
var fnn = fn.next;
|
|
95
|
-
if (fnn) {
|
|
96
|
-
first.next = fnn;
|
|
97
|
-
fnn.prev = first;
|
|
98
|
-
}
|
|
99
|
-
fn.prev = fe;
|
|
100
|
-
fe.next = fn;
|
|
101
|
-
delete fn.next;
|
|
102
|
-
exp.splice(1, 1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
function createExpressKey(exp) {
|
|
109
|
-
var keys = [];
|
|
110
|
-
for (var e of exp) {
|
|
111
|
-
if (e.type === EXPRESS) {
|
|
112
|
-
var t = e.text;
|
|
113
|
-
while (t.length > 0) {
|
|
114
|
-
if (/^\./.test(t)) {
|
|
115
|
-
if (!keys.length) keys.push('');
|
|
116
|
-
t = t.slice(1);
|
|
117
|
-
}
|
|
118
|
-
var m = /[^\.\[]+/.exec(t);
|
|
119
|
-
if (m) {
|
|
120
|
-
m = m[0];
|
|
121
|
-
keys.push(m);
|
|
122
|
-
t = t.slice(m.length);
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
var m = /^\[(['"`])([\s\S]*?)\1\]/.exec(t)
|
|
126
|
-
if (m) {
|
|
127
|
-
m = m[0];
|
|
128
|
-
t = t.slice(m.length);
|
|
129
|
-
m = m.slice(1, m.length - 1);
|
|
130
|
-
m = strings.decode(m);
|
|
131
|
-
keys.push(m);
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return keys.join('.');
|
|
139
|
-
}
|
|
140
|
-
function needLeft(o) {
|
|
141
|
-
if (o.type === EXPRESS && /^[\.\[]/.test(o.text)) return true;
|
|
142
|
-
if (o.type === SCOPED && o.entry === '[') return true;
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
function needRight(o) {
|
|
146
|
-
if (o.type === EXPRESS && /[\.\]]$/.test(o.text)) return true;
|
|
147
|
-
if (o.type === SCOPED && o.entry === '[') return true;
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
function renameId(id, amap) {
|
|
151
|
-
var m = /^[^\.]+/.exec(id);
|
|
152
|
-
if (m) {
|
|
153
|
-
var id0 = m[0];
|
|
154
|
-
var w = amap[id0];
|
|
155
|
-
if (w) return w + id.slice(id0.length);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
function checkRefered(scope) {
|
|
159
|
-
var { used } = scope;
|
|
160
|
-
var map = Object.create(null);
|
|
161
|
-
for (var k in used) {
|
|
162
|
-
var u = used[k];
|
|
163
|
-
for (var o of u) {
|
|
164
|
-
var right = [];
|
|
165
|
-
var e = o;
|
|
166
|
-
while (e) {
|
|
167
|
-
if (right.length) {
|
|
168
|
-
if (!needRight(right[right.length - 1]) && !needLeft(e)) break;
|
|
169
|
-
}
|
|
170
|
-
right.push(e);
|
|
171
|
-
e = e.next;
|
|
172
|
-
}
|
|
173
|
-
if (right.length) {
|
|
174
|
-
var key = createExpressKey(right);
|
|
175
|
-
var iswrite = false;
|
|
176
|
-
iswrite = !!o.kind || !!e && e.type === STAMP && /(?<![\!\=])\=$/.test(e.text);
|
|
177
|
-
if (key) map[key] = map[key] | 1 + iswrite;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
var readed, writed;
|
|
182
|
-
for (var k in map) {
|
|
183
|
-
if (map[k] >> 1) {
|
|
184
|
-
if (!writed) writed = Object.create(null);
|
|
185
|
-
writed[k] = true;
|
|
186
|
-
}
|
|
187
|
-
if (map[k] & 1) {
|
|
188
|
-
if (!readed) readed = Object.create(null);
|
|
189
|
-
readed[k] = true;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
for (var s of scope) {
|
|
193
|
-
if (s.isfunc && s.pass) {
|
|
194
|
-
var [writed0, readed0] = checkRefered(s);
|
|
195
|
-
var { pass, args } = s;
|
|
196
|
-
var amap = {};
|
|
197
|
-
for (var cx = 0, dx = pass.length; cx < dx; cx++) {
|
|
198
|
-
amap[args[cx]] = pass[cx];
|
|
199
|
-
}
|
|
200
|
-
for (var w in writed0) {
|
|
201
|
-
var id = renameId(w, amap);
|
|
202
|
-
if (id) writed[id] = true;
|
|
203
|
-
}
|
|
204
|
-
for (var r in readed0) {
|
|
205
|
-
var id = renameId(r, amap);
|
|
206
|
-
if (id) readed[id] = true;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return [writed, readed];
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
var getroot = function (pick) {
|
|
215
|
-
if (pick) {
|
|
216
|
-
var match = /^[^\.]+/.exec(pick);
|
|
217
|
-
if (match) match = match[0];
|
|
218
|
-
return match;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function washcode(code, pick) {
|
|
223
|
-
var avoid = getroot(pick);
|
|
224
|
-
var needs = Object.assign(Object.create(null), pick ? { [pick]: true } : code.envs);
|
|
225
|
-
var explist = createExpressList(code);
|
|
226
|
-
var maped = Object.create(null);
|
|
227
|
-
for (var exp of explist) {
|
|
228
|
-
exp.scoped = createScoped(exp, true);
|
|
229
|
-
if (avoid && avoid in exp.scoped.used) {
|
|
230
|
-
if (code.vars[avoid] && !code.envs[avoid] && !maped[avoid]) {
|
|
231
|
-
exp.saved = true;
|
|
232
|
-
maped[avoid] = true;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
var [writed, readed] = checkRefered(exp.scoped);
|
|
236
|
-
exp.writed = writed;
|
|
237
|
-
exp.readed = readed;
|
|
238
|
-
}
|
|
239
|
-
var count = 0;
|
|
240
|
-
while (count < explist.length) {
|
|
241
|
-
var saved_count = count;
|
|
242
|
-
for (var exp of explist) {
|
|
243
|
-
if (exp.saved) continue;
|
|
244
|
-
if (!exp.first) {
|
|
245
|
-
exp.saved = true;
|
|
246
|
-
count++;
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
var { writed, readed } = exp;
|
|
250
|
-
for (var w in writed) {
|
|
251
|
-
if (w === avoid) continue;
|
|
252
|
-
if (needs[w] || getroot(w) in code.envs) {
|
|
253
|
-
exp.saved = true;
|
|
254
|
-
for (var r in readed) {
|
|
255
|
-
|
|
256
|
-
var rs = r.split('.');
|
|
257
|
-
while (rs.length) {
|
|
258
|
-
needs[rs.join('.')] = true;
|
|
259
|
-
rs.pop();
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
count++;
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (saved_count === count) break;
|
|
268
|
-
}
|
|
269
|
-
for (var cx = 0, dx = explist.length; cx < dx; cx++) {
|
|
270
|
-
var exp = explist[cx];
|
|
271
|
-
var prev = explist[cx - 1], next = explist[cx + 1];
|
|
272
|
-
if (!exp.first) {
|
|
273
|
-
if (!exp.saved) continue;
|
|
274
|
-
if (exp.length !== 1 || !prev && !next) continue;
|
|
275
|
-
if (exp[0].type === STAMP) {
|
|
276
|
-
if (prev && !prev.saved || next && !next.saved) {
|
|
277
|
-
exp.saved = false;
|
|
278
|
-
}
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (next && !next.saved) {
|
|
282
|
-
exp.saved = false;
|
|
283
|
-
}
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
if (!exp.saved) {
|
|
287
|
-
if (exp[0].type === STRAP && /^(let|var|const)$/.test(exp[0].text)) {
|
|
288
|
-
var save = false, inc = 2;
|
|
289
|
-
while (next && next[0].type === STAMP && /^,$/.test(next[0].text)) {
|
|
290
|
-
next.saved = false;
|
|
291
|
-
next = explist[cx + inc++];
|
|
292
|
-
if (!next) break;
|
|
293
|
-
if (next.saved) {
|
|
294
|
-
save = true;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
next = explist[cx + inc++];
|
|
298
|
-
}
|
|
299
|
-
exp.saved = save;
|
|
300
|
-
if (exp.saved) {
|
|
301
|
-
if (!prev.saved) prev.saved = true;
|
|
302
|
-
exp.splice(1, exp.length - 1, ' ');
|
|
303
|
-
patchExpress(exp);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
explist = explist.filter(e => e.saved);
|
|
309
|
-
var text = explist.map(createString).join("");
|
|
310
|
-
return text;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
module.exports = washcode;
|
package/coms/zimoli/mark.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var couple = function (marker, source) {
|
|
2
|
-
var len1 = source.length;
|
|
3
|
-
var len2 = marker.length;
|
|
4
|
-
var match = "", begin1 = len1, begin2 = len2;
|
|
5
|
-
for (var cx = -len1, dx = len2; cx < dx; cx++) {
|
|
6
|
-
var c1 = cx >= 0 ? 0 : -cx;
|
|
7
|
-
var c2 = cx >= 0 ? cx : 0;
|
|
8
|
-
var d1 = len1 - c1;
|
|
9
|
-
var d2 = len2 - c2;
|
|
10
|
-
var start = 0, end = 0;
|
|
11
|
-
for (var ct = 0, dt = d1 > d2 ? d2 : d1; ct < dt; ct++) {
|
|
12
|
-
if (source[c1 + ct] === marker[c2 + ct]) {
|
|
13
|
-
end = ct + 1;
|
|
14
|
-
if (end === dt && end - start > match.length) {
|
|
15
|
-
match = source.slice(c1 + start, c1 + end);
|
|
16
|
-
begin1 = c1 + start;
|
|
17
|
-
begin2 = c2 + start;
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
if (end - start > match.length) {
|
|
21
|
-
match = source.slice(c1 + start, c1 + end);
|
|
22
|
-
begin1 = c1 + start;
|
|
23
|
-
begin2 = c2 + start;
|
|
24
|
-
}
|
|
25
|
-
start = ct + 1;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return [match, begin1, begin2];
|
|
30
|
-
};
|
|
31
|
-
var MARK_PRE = "<b>";
|
|
32
|
-
var MARK_AFT = "</b>";
|
|
33
|
-
var mark = function (source, search) {
|
|
34
|
-
return power(source, search)[1];
|
|
35
|
-
};
|
|
36
|
-
var power = function (source, search) {
|
|
37
|
-
if (!search || !source) {
|
|
38
|
-
return [0, source];
|
|
39
|
-
}
|
|
40
|
-
var matchers = couple(source, search);
|
|
41
|
-
var match_text = matchers[0];
|
|
42
|
-
var match_start2 = matchers[2];
|
|
43
|
-
if (search.length === 1) {
|
|
44
|
-
var p = 0;
|
|
45
|
-
var res = source.replace(new RegExp(search.replace(/[\\\*\?\+\(\)\[]/g, "\\$&"), "g"), () => {
|
|
46
|
-
if (!p) p = 1;
|
|
47
|
-
return MARK_PRE + search + MARK_AFT;
|
|
48
|
-
});
|
|
49
|
-
return [p, res];
|
|
50
|
-
}
|
|
51
|
-
if (match_text.length > 1) {
|
|
52
|
-
var match_text_pre = source.slice(0, match_start2);
|
|
53
|
-
var match_text_aft = source.slice(match_start2 + match_text.length);
|
|
54
|
-
var pp = 0, ap = 0;
|
|
55
|
-
var p = match_text.length;
|
|
56
|
-
if (match_text_pre.length) p += .1 / match_text_pre.length - .2;
|
|
57
|
-
if (match_text_aft.length) p += .1 / match_text_aft.length - .1;
|
|
58
|
-
if (match_text_pre.length > 1) {
|
|
59
|
-
[pp, match_text_pre] = power(match_text_pre, search);
|
|
60
|
-
}
|
|
61
|
-
if (match_text_aft.length > 1) {
|
|
62
|
-
[ap, match_text_aft] = power(match_text_aft, search);
|
|
63
|
-
}
|
|
64
|
-
p += (pp + ap) * .01;
|
|
65
|
-
return [p, match_text_pre + MARK_PRE + match_text + MARK_AFT + match_text_aft];
|
|
66
|
-
}
|
|
67
|
-
return [0, source];
|
|
68
|
-
};
|
|
69
|
-
mark.power = power;
|
|
70
|
-
mark.couple = couple;
|