efront 4.4.6 → 4.4.9
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/coms/basic/refilm_decode.js +8 -5
- package/coms/basic/renderExpress.js +113 -23
- package/coms/basic/renderExpress_test.js +14 -6
- package/coms/compile/Javascript.js +19 -16
- package/coms/compile/Program.js +1 -1
- package/coms/compile/common.js +8 -5
- package/coms/compile/common_test.js +2 -0
- package/coms/zimoli/data.js +5 -1
- package/coms/zimoli/model.js +1 -0
- package/package.json +1 -1
- package/public/efront.js +729 -1
|
@@ -257,8 +257,8 @@ function spreadkey(name) {
|
|
|
257
257
|
name = name.slice(0, commaindex);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
var [name, key] = scanSlant(name, '/', 0, name.length + 1);
|
|
261
|
-
return [name, key, needs];
|
|
260
|
+
var [name, key, holder] = scanSlant(name, '/', 0, name.length + 1);
|
|
261
|
+
return [name, key, needs, holder];
|
|
262
262
|
}
|
|
263
263
|
function parse(piece) {
|
|
264
264
|
if (/^[\-#]+$/.test(piece[0])) {
|
|
@@ -288,6 +288,8 @@ function parse(piece) {
|
|
|
288
288
|
var {
|
|
289
289
|
name, type, key, value, comment, options,
|
|
290
290
|
size, unit, ratio,
|
|
291
|
+
holder,
|
|
292
|
+
do: action,
|
|
291
293
|
needs, checks, repeat, endwith,
|
|
292
294
|
required, inlist, hidden, readonly,
|
|
293
295
|
delete_onempty, delete_onsubmit,
|
|
@@ -330,7 +332,7 @@ function parse(piece) {
|
|
|
330
332
|
last_type = type;
|
|
331
333
|
}
|
|
332
334
|
}
|
|
333
|
-
[name, key, needs] = spreadkey(name);
|
|
335
|
+
[name, key, needs, holder] = spreadkey(name);
|
|
334
336
|
if (key === undefined && !/^(title|label|headline)$/i.test(type)) key = name;
|
|
335
337
|
}
|
|
336
338
|
if (/^[a-z\d]+\/?\d+$/i.test(type)) {
|
|
@@ -419,14 +421,15 @@ function parse(piece) {
|
|
|
419
421
|
key = is(key);
|
|
420
422
|
}
|
|
421
423
|
else if (typeof name === 'string') {
|
|
422
|
-
[name, key = name, needs] = spreadkey(name);
|
|
424
|
+
[name, key = name, needs, holder] = spreadkey(name);
|
|
423
425
|
}
|
|
424
426
|
if (typeof size === 'string') size = parseFloat(size);
|
|
425
427
|
var field = {
|
|
426
428
|
name, type, key, value, comment, options,
|
|
427
|
-
size, unit, ratio,
|
|
429
|
+
size, unit, ratio, holder,
|
|
428
430
|
needs, checks, repeat, endwith,
|
|
429
431
|
required, inlist, hidden, readonly,
|
|
432
|
+
do: action,
|
|
430
433
|
delete_onempty, delete_onsubmit,
|
|
431
434
|
};
|
|
432
435
|
var parent = piecepath[piecepath.length - 1];
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
function splitSeek(express) {
|
|
2
2
|
var dist = [];
|
|
3
3
|
var x = 0;
|
|
4
|
+
var called = false;
|
|
4
5
|
express.forEach((e, i) => {
|
|
5
|
-
if (
|
|
6
|
+
if (isArray(e)) called = true;
|
|
7
|
+
if (i > x && /^\?/.test(e)) {
|
|
6
8
|
var exp = express.slice(x, x = i);
|
|
9
|
+
exp.called = called;
|
|
7
10
|
dist.push(exp);
|
|
11
|
+
called = false;
|
|
8
12
|
}
|
|
9
13
|
});
|
|
10
14
|
if (x < express.length) dist.push(express.slice(x, express.length));
|
|
15
|
+
dist[dist.length - 1].called = called;
|
|
11
16
|
dist.forEach(d => d[0] = d[0].replace(/^\?/, ''))
|
|
12
17
|
return dist;
|
|
13
18
|
}
|
|
@@ -24,31 +29,114 @@ function getTmpvar(explist) {
|
|
|
24
29
|
return tmpvar;
|
|
25
30
|
}
|
|
26
31
|
var autoDefine = false;
|
|
27
|
-
function
|
|
28
|
-
var
|
|
32
|
+
function joinsharp(sharped, ctx) {
|
|
33
|
+
var willcall = [], call = false;
|
|
34
|
+
for (var cx = 1, dx = sharped.length; cx < dx; cx++) {
|
|
35
|
+
if (/^\(/.test(sharped[cx])) {
|
|
36
|
+
var p = sharped[cx - 1];
|
|
37
|
+
if (/\)$/.test(p)) continue;
|
|
38
|
+
if (cx > 1 || /\./.test(p)) willcall[cx] = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
var result = [];
|
|
42
|
+
var will = false, call = false;
|
|
43
|
+
if (sharped[sharped.length - 1] === '.') sharped[sharped.length - 1] = "";
|
|
44
|
+
for (var cx = 0, dx = sharped.length; cx < dx; cx++) {
|
|
45
|
+
var s = sharped[cx];
|
|
46
|
+
var plus = /^\//.test(s);
|
|
47
|
+
if (plus) s = s.slice(1);
|
|
48
|
+
call = will;
|
|
49
|
+
will = willcall[cx + 1];
|
|
50
|
+
if (will) {
|
|
51
|
+
if (/\]/.test(s)) {
|
|
52
|
+
s = [s];
|
|
53
|
+
s.unshift('');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
s = s.split('.');
|
|
57
|
+
if (s.length > 1) {
|
|
58
|
+
s.unshift(s.splice(0, s.length - 1).join('.'));
|
|
59
|
+
s[1] = '.' + s[1];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
s.unshift("");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (plus) {
|
|
66
|
+
s[0] = result[result.length - 1] + s[0];
|
|
67
|
+
result[result.length - 1] = s;
|
|
68
|
+
}
|
|
69
|
+
else result.push(s);
|
|
70
|
+
}
|
|
71
|
+
else if (call) {
|
|
72
|
+
var params = s.replace(/^\(\s*([\s\S]*)\s*\)$/, '$1');
|
|
73
|
+
result.push(`["call"](${ctx}${params ? ',' + params : ''})`);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
if (plus) {
|
|
77
|
+
result[result.length - 1] += s;
|
|
78
|
+
}
|
|
79
|
+
else result.push(s);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
var wrapquote = false;
|
|
85
|
+
function createSeek(sharped, splited = true) {
|
|
86
|
+
if (splited) wrapquote = false;
|
|
87
|
+
if (sharped.length <= 1) return sharped[0];
|
|
88
|
+
var tmpvar = 'a', undef = '_', tmpctx = 'c';
|
|
89
|
+
var express = splited ? joinsharp(sharped, tmpctx) : sharped;
|
|
29
90
|
if (express.length <= 1) return express[0];
|
|
30
|
-
|
|
91
|
+
if (splited) wrapquote = true;
|
|
92
|
+
var [exp0, exp1] = express;
|
|
93
|
+
var notmp = typeof exp0 === 'string' && !/[\.\[\(\{]/.test(exp0);
|
|
31
94
|
if (express.length === 2) {
|
|
32
|
-
if (
|
|
33
|
-
if (notmp) return `typeof ${
|
|
34
|
-
return `function(${tmpvar},${undef}){return ${tmpvar}
|
|
95
|
+
if (splited && /^\?/.test(exp1)) {
|
|
96
|
+
if (notmp) return `typeof ${exp0}!=='undefined'&&${exp0}!==null?${exp0}:${exp1.slice(1)}`;
|
|
97
|
+
return `function(${tmpvar},${undef}){return ${tmpvar}==${undef}?${exp1.slice(1)}:${tmpvar}}(${exp0})`;
|
|
35
98
|
}
|
|
36
99
|
if (notmp) {
|
|
37
|
-
tmpvar = express[0];
|
|
38
100
|
if (autoDefine) {
|
|
39
|
-
return `typeof ${
|
|
101
|
+
return `typeof ${exp0}==='undefined'||${exp0}===null?void 0:${exp0}${exp1}`;
|
|
40
102
|
}
|
|
41
|
-
return `${
|
|
103
|
+
return `${exp0}==null?void 0:${exp0}${exp1}`;
|
|
42
104
|
};
|
|
43
|
-
|
|
105
|
+
if (isArray(exp0)) {
|
|
106
|
+
return `function(${tmpctx},${tmpvar},${undef}){${tmpvar}=${tmpctx}${exp0[exp0.length - 1]};return ${tmpvar}==${undef}?${undef}:${tmpvar}${exp1}}(${exp0.slice(0, exp0.length - 1)})`;
|
|
107
|
+
}
|
|
108
|
+
return `function(${tmpvar},${undef}){return ${tmpvar}==${undef}?${undef}:${tmpvar}${exp1}}(${exp0})`;
|
|
44
109
|
}
|
|
45
|
-
if (!
|
|
46
|
-
var
|
|
47
|
-
|
|
110
|
+
if (!splited) {
|
|
111
|
+
var called = express.called;
|
|
112
|
+
var prop = isArray(exp0) ? exp0[exp0.length - 1] : '';
|
|
113
|
+
var prop0 = prop;
|
|
114
|
+
var dist = express.slice(1).map(search => {
|
|
115
|
+
var res = prop ? `${tmpvar}=${tmpctx}${prop}` : '';
|
|
116
|
+
res += `if(${tmpvar}==${undef})return;`;
|
|
117
|
+
if (isArray(search)) {
|
|
118
|
+
prop = search[search.length - 1];
|
|
119
|
+
res += `${tmpctx}=${tmpvar}${search.slice(0, search.length - 1)},${tmpvar}=${tmpctx}${prop};`;
|
|
120
|
+
prop = '';
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
res += `${tmpvar}=${tmpvar}${search};`;
|
|
124
|
+
}
|
|
125
|
+
return res;
|
|
48
126
|
}).join('');
|
|
49
|
-
|
|
127
|
+
if (called) {
|
|
128
|
+
if (prop0) {
|
|
129
|
+
dist = `function(${tmpctx},${tmpvar},${undef}){${dist}return ${tmpvar}}(${exp0.slice(0, exp0.length - 1)})`;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
dist = `function(${tmpvar},${tmpctx},${undef}){${dist}return ${tmpvar}}(${exp0})`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
dist = `function(${tmpvar},${undef}){${dist}return ${tmpvar}}(${exp0})`;
|
|
137
|
+
}
|
|
50
138
|
if (notmp && autoDefine) {
|
|
51
|
-
dist = `typeof ${
|
|
139
|
+
dist = `typeof ${exp0}==='undefined'||${exp0}===null?void 0:${dist}`;
|
|
52
140
|
}
|
|
53
141
|
return dist;
|
|
54
142
|
}
|
|
@@ -59,14 +147,14 @@ function createSeek(express, split = true) {
|
|
|
59
147
|
tmpvar = getTmpvar(explist);
|
|
60
148
|
var dist = explist.slice(0, explist.length - 1).map(express => {
|
|
61
149
|
var dist = createSeek(express, false);
|
|
62
|
-
return `${tmpvar}=${dist};if(${tmpvar}
|
|
150
|
+
return `${tmpvar}=${dist};if(${tmpvar}!=null)return ${tmpvar};`;
|
|
63
151
|
}).join("") + `return ${createSeek(explist[explist.length - 1], false)}`;
|
|
64
152
|
return `function(${tmpvar}){${dist}}()`;
|
|
65
153
|
}
|
|
66
154
|
function main(express, autodef = true) {
|
|
67
155
|
autoDefine = autodef;
|
|
68
|
-
if (!/\?\s*\.(?=[^\d])|\?\s*[\?\]\}\)\:\,=|%&;\>\<]
|
|
69
|
-
var reg = /\\[\s\S]|\?\s*([\.](?!\d)|\?|$|(?=[\?\]\}\)
|
|
156
|
+
if (!/\?\s*\.(?=[^\d])|\?\s*[\?\]\}\)\:\,=|%&;\>\<]|\?\.?\s*$/.test(express)) return express;
|
|
157
|
+
var reg = /\\[\s\S]|\?\s*([\.](?!\d)|\?|$|(?=[\?\]\}\)\:\,\=\|%&;\>\<\*\/]))|[\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<\~\{\}\[\]\(\)'"`\s]/g;
|
|
70
158
|
var cache = [], queue = [];
|
|
71
159
|
var exp = [];
|
|
72
160
|
var instr = false;
|
|
@@ -80,8 +168,11 @@ function main(express, autodef = true) {
|
|
|
80
168
|
exp.splice(0, exp.length, '');
|
|
81
169
|
e = '';
|
|
82
170
|
}
|
|
83
|
-
if (/\.$/.test(e)
|
|
84
|
-
e = e.replace(/\.$/, '');
|
|
171
|
+
if (/\.$/.test(e)) {
|
|
172
|
+
if (/^[\[\("'`]/.test(s)) e = e.replace(/\.$/, '');
|
|
173
|
+
}
|
|
174
|
+
else if (!cache.length) {
|
|
175
|
+
return exp.push('/' + s);
|
|
85
176
|
}
|
|
86
177
|
e += s;
|
|
87
178
|
exp[exp.length - 1] = e;
|
|
@@ -103,7 +194,7 @@ function main(express, autodef = true) {
|
|
|
103
194
|
var add_punc = function (m) {
|
|
104
195
|
if (exp.length) {
|
|
105
196
|
var temp = createSeek(exp);
|
|
106
|
-
queue.push(
|
|
197
|
+
queue.push(wrapquote ? `(${temp})` : temp, m);
|
|
107
198
|
exp = [];
|
|
108
199
|
} else if (queue.length) {
|
|
109
200
|
queue[queue.length - 1] += m;
|
|
@@ -129,7 +220,6 @@ function main(express, autodef = true) {
|
|
|
129
220
|
isstr = true;
|
|
130
221
|
index++;
|
|
131
222
|
}
|
|
132
|
-
|
|
133
223
|
var str = express.slice(lastIndex, index);
|
|
134
224
|
if (str) {
|
|
135
225
|
add_exp(str);
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
assert(renderExpress("[].a"), "[].a")
|
|
2
2
|
assert(renderExpress("a?b:c"), "a?b:c")
|
|
3
3
|
assert(renderExpress("a?"), "(typeof a==='undefined'||a===null?void 0:a)")
|
|
4
|
-
assert(renderExpress("
|
|
5
|
-
assert(renderExpress("
|
|
4
|
+
assert(renderExpress("b+a?."), "b+(typeof a==='undefined'||a===null?void 0:a)")
|
|
5
|
+
assert(renderExpress("a?.+b"), "(typeof a==='undefined'||a===null?void 0:a)+b")
|
|
6
|
+
assert(renderExpress("a?.()"), "(typeof a==='undefined'||a===null?void 0:a())")
|
|
7
|
+
assert(renderExpress("a.b?.()"), `(function(c,a,_){a=c.b;return a==_?_:a["call"](c)}(a))`)
|
|
8
|
+
assert(renderExpress("a[['a[']][]?.()"), `(function(c,a,_){a=c[];return a==_?_:a["call"](c)}(a[['a[']]))`)
|
|
9
|
+
assert(renderExpress("a?.b?.()"), `(typeof a==='undefined'||a===null?void 0:function(a,c,_){if(a==_)return;c=a,a=c.b;if(a==_)return;a=a["call"](c);return a}(a))`)
|
|
10
|
+
assert(renderExpress("[].a?.()"), `(function(c,a,_){a=c.a;return a==_?_:a["call"](c)}([]))`)// 已支持在?.()的函数中访问this
|
|
11
|
+
assert(renderExpress("[].a?.b?.c?.()"), `(function(a,c,_){if(a==_)return;a=a.b;if(a==_)return;c=a,a=c.c;if(a==_)return;a=a["call"](c);return a}([].a))`)
|
|
6
12
|
assert(renderExpress("a??b"), "(typeof a!=='undefined'&&a!==null?a:b)")
|
|
7
|
-
assert(renderExpress("a?.b??b?.c", false), "(function(b0){b0=a
|
|
13
|
+
assert(renderExpress("a?.b??b?.c", false), "(function(b0){b0=a==null?void 0:a.b;if(b0!=null)return b0;return b==null?void 0:b.c}())")
|
|
8
14
|
|
|
9
|
-
assert(renderExpress("[]?.a"), "(function(a,_){return a
|
|
10
|
-
assert(renderExpress("[]?.()"), "(function(a,_){return a
|
|
11
|
-
assert(renderExpress("[]?.[]"), "(function(a,_){return a
|
|
15
|
+
assert(renderExpress("[]?.a"), "(function(a,_){return a==_?_:a.a}([]))")
|
|
16
|
+
assert(renderExpress("[]?.()"), "(function(a,_){return a==_?_:a()}([]))")
|
|
17
|
+
assert(renderExpress("[]?.[]"), "(function(a,_){return a==_?_:a[]}([]))")
|
|
18
|
+
assert(renderExpress("a['a?.a']"), "a['a?.a']")
|
|
19
|
+
assert(renderExpress("a?.['a?.a']?.b"), "(typeof a==='undefined'||a===null?void 0:function(a,_){if(a==_)return;a=a['a?.a'];if(a==_)return;a=a.b;return a}(a))")
|
|
@@ -41,7 +41,7 @@ class Javascript extends Program {
|
|
|
41
41
|
value_reg = /^(false|true|null|Infinity|NaN|undefined|eval)$/
|
|
42
42
|
transive_reg = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|default|instanceof|throw|extends|import|from)$/
|
|
43
43
|
strapexp_reg = /^(new|void|typeof|delete|class|function|await)/;
|
|
44
|
-
forceend_reg = /^(return|yield|break|continue|debugger)$/;
|
|
44
|
+
forceend_reg = /^(return|yield|break|continue|debugger|async)$/;
|
|
45
45
|
classstrap_reg = /^(class|function|async)$/;
|
|
46
46
|
colonstrap_reg = /^(case|default)$/;
|
|
47
47
|
|
|
@@ -264,21 +264,21 @@ Javascript.prototype.detectLabel = function (o) {
|
|
|
264
264
|
var type = o.type;
|
|
265
265
|
var colonstrap_reg = this.colonstrap_reg;
|
|
266
266
|
var end = o.end;
|
|
267
|
-
|
|
267
|
+
var inExpress = queue.inExpress;
|
|
268
268
|
if (type === SPACE);
|
|
269
269
|
else if (type !== STAMP);
|
|
270
270
|
else if (m === ";") {
|
|
271
271
|
if (last && last.isend === false) last.isend = true;
|
|
272
|
-
|
|
272
|
+
inExpress = false;
|
|
273
273
|
}
|
|
274
274
|
else if (last) check: switch (m) {
|
|
275
275
|
case "?":
|
|
276
|
-
|
|
276
|
+
inExpress = true;
|
|
277
277
|
if (!queue.question) queue.question = 1;
|
|
278
278
|
else queue.question++;
|
|
279
279
|
break;
|
|
280
280
|
case "=":
|
|
281
|
-
|
|
281
|
+
inExpress = true;
|
|
282
282
|
if (last.type === SCOPED && last.entry === "{") {
|
|
283
283
|
if (!last.isObject) {
|
|
284
284
|
setObject(last);
|
|
@@ -290,34 +290,34 @@ Javascript.prototype.detectLabel = function (o) {
|
|
|
290
290
|
last.short = true;
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
|
|
293
|
+
inExpress = true;
|
|
294
294
|
break;
|
|
295
295
|
case ":":
|
|
296
296
|
if (queue.question) {
|
|
297
297
|
queue.question--;
|
|
298
|
-
|
|
298
|
+
inExpress = true;
|
|
299
299
|
break;
|
|
300
300
|
}
|
|
301
301
|
if (queue.isObject) {
|
|
302
302
|
if (last.type === PROPERTY || last.isprop) {
|
|
303
|
-
|
|
303
|
+
inExpress = true;
|
|
304
304
|
break;
|
|
305
305
|
}
|
|
306
306
|
if (last.type === SCOPED && (!last.prev || !last.prev.type === STAMP && last.prev.text === ",")) {
|
|
307
|
-
|
|
307
|
+
inExpress = true;
|
|
308
308
|
}
|
|
309
309
|
break;
|
|
310
310
|
}
|
|
311
311
|
var temp = last;
|
|
312
312
|
while (temp) {
|
|
313
313
|
if (temp.type === STRAP && colonstrap_reg.test(temp.text)) {
|
|
314
|
-
|
|
314
|
+
inExpress = false;
|
|
315
315
|
break check;
|
|
316
316
|
}
|
|
317
317
|
if (!temp.isExpress) break;
|
|
318
318
|
temp = temp.prev;
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
inExpress = false;
|
|
321
321
|
if (last.type & (EXPRESS | STRAP | VALUE | QUOTED)) {
|
|
322
322
|
// label
|
|
323
323
|
last.type = LABEL;
|
|
@@ -327,12 +327,15 @@ Javascript.prototype.detectLabel = function (o) {
|
|
|
327
327
|
}
|
|
328
328
|
break;
|
|
329
329
|
default:
|
|
330
|
-
|
|
330
|
+
inExpress = true;
|
|
331
331
|
}
|
|
332
332
|
else {
|
|
333
|
-
|
|
333
|
+
inExpress = true;
|
|
334
|
+
}
|
|
335
|
+
if (inExpress !== queue.inExpress) {
|
|
336
|
+
o.isExpress = queue.inExpress = inExpress;
|
|
337
|
+
if (o.text === 'async') console.log(o.isExpress, queue.isExpress, 'label');
|
|
334
338
|
}
|
|
335
|
-
o.isExpress = queue.inExpress;
|
|
336
339
|
}
|
|
337
340
|
|
|
338
341
|
Javascript.prototype.setType = function (o) {
|
|
@@ -345,7 +348,7 @@ Javascript.prototype.setType = function (o) {
|
|
|
345
348
|
}
|
|
346
349
|
if (last) {
|
|
347
350
|
if (o.type === STRAP && o.text === "function") {
|
|
348
|
-
if (last.text === 'async') last.type =
|
|
351
|
+
if (last.text === 'async' && !last.isend) last.type = STRAP;
|
|
349
352
|
}
|
|
350
353
|
}
|
|
351
354
|
this.fixType(o);
|
|
@@ -385,7 +388,7 @@ Javascript.prototype.setType = function (o) {
|
|
|
385
388
|
if (o.type === STAMP && o.text === "=>") {
|
|
386
389
|
var pp = last.prev;
|
|
387
390
|
if (pp && pp.type === EXPRESS && pp.text === 'async') {
|
|
388
|
-
pp.type = STRAP;
|
|
391
|
+
if (!pp.isend) pp.type = STRAP;
|
|
389
392
|
}
|
|
390
393
|
}
|
|
391
394
|
}
|
package/coms/compile/Program.js
CHANGED
|
@@ -111,7 +111,7 @@ class Program {
|
|
|
111
111
|
Code = Array;
|
|
112
112
|
transive_reg = /^(new|void|case|break|continue|return|throw|extends|import)$/
|
|
113
113
|
straps = "if,for".split(',');
|
|
114
|
-
forceend_reg = /^(return|break|continue
|
|
114
|
+
forceend_reg = /^(return|break|continue)$/;
|
|
115
115
|
classstrap_reg = /^(class)$/;
|
|
116
116
|
extends_reg = /^(extends)$/;
|
|
117
117
|
spaces = spaceDefined;
|
package/coms/compile/common.js
CHANGED
|
@@ -257,13 +257,14 @@ function snapSentenceHead(o) {
|
|
|
257
257
|
if (pp && pp.type === EXPRESS) pp = pp.prev;
|
|
258
258
|
if (pp && pp.type === STRAP && pp.text === 'function') {
|
|
259
259
|
o = pp;
|
|
260
|
+
pp = pp.prev;
|
|
260
261
|
continue;
|
|
261
262
|
}
|
|
262
263
|
}
|
|
263
264
|
break;
|
|
264
265
|
}
|
|
265
266
|
if (p.type === STRAP) {
|
|
266
|
-
if (/^(?:new|void|typeof|delete|await|var|let|const|class|function)$/.test(p.text)) {
|
|
267
|
+
if (/^(?:new|void|typeof|delete|await|var|let|const|class|function|async)$/.test(p.text)) {
|
|
267
268
|
o = p;
|
|
268
269
|
continue;
|
|
269
270
|
}
|
|
@@ -548,15 +549,16 @@ var createScoped = function (parsed, wash) {
|
|
|
548
549
|
case "static":
|
|
549
550
|
case "function":
|
|
550
551
|
isFunction = true;
|
|
551
|
-
|
|
552
|
-
if (
|
|
552
|
+
var op = o.prev;
|
|
553
|
+
if (op?.type === STRAP && op.text === 'async') {
|
|
553
554
|
isAsync = true;
|
|
555
|
+
o.isExpress = op.isExpress;
|
|
554
556
|
}
|
|
555
557
|
function_obj = o;
|
|
556
558
|
if (o.next.type === STAMP) {
|
|
557
559
|
isAster = true;
|
|
558
560
|
o = o.next;
|
|
559
|
-
o.isExpress =
|
|
561
|
+
o.isExpress = op.isExpress;
|
|
560
562
|
}
|
|
561
563
|
case "catch":
|
|
562
564
|
if (s === 'catch') isCatch = true;
|
|
@@ -1101,10 +1103,11 @@ var createString = function (parsed) {
|
|
|
1101
1103
|
if (keepspace && !opentmp) {
|
|
1102
1104
|
if (patchspace && lasttype !== SPACE && lasttype !== EXPRESS) result.push(" ");
|
|
1103
1105
|
result.push(tmp);
|
|
1106
|
+
if (/^\/\//.test(tmp)) lasttype = COMMENT;
|
|
1104
1107
|
}
|
|
1105
1108
|
break;
|
|
1106
1109
|
case SPACE:
|
|
1107
|
-
if (!autospace || keepspace) {
|
|
1110
|
+
if (!autospace || keepspace || lasttype === COMMENT) {
|
|
1108
1111
|
result.push(o.text);
|
|
1109
1112
|
lasttype = SPACE;
|
|
1110
1113
|
break;
|
|
@@ -5,6 +5,8 @@ function testPickSentence(text, index, except) {
|
|
|
5
5
|
assert(common.createString(common.pickSentence(code[index])), except);
|
|
6
6
|
}
|
|
7
7
|
testPickSentence(`function 九尾妖狐(){}`, 0, "function 九尾妖狐() {}")
|
|
8
|
+
testPickSentence(`async function 九尾妖狐(){}`, 1, "async function 九尾妖狐() {}")
|
|
9
|
+
testPickSentence(`async\r\nfunction 九尾妖狐(){}`, 2, "function 九尾妖狐() {}")
|
|
8
10
|
testPickSentence(`function 九尾妖狐(){}`, 2, "function 九尾妖狐() {}")
|
|
9
11
|
testPickSentence(`a: function 九尾妖狐(){}`, 1, "a: function 九尾妖狐() {}")
|
|
10
12
|
testPickSentence(`a: function 九尾妖狐(){}`, 0, "a: function 九尾妖狐() {}")
|
package/coms/zimoli/data.js
CHANGED
|
@@ -594,7 +594,7 @@ var privates = {
|
|
|
594
594
|
var promise = cachedLoadingPromise[id];
|
|
595
595
|
var temp = JSON.stringify(params);
|
|
596
596
|
var currentTime = +new Date;
|
|
597
|
-
var loading =
|
|
597
|
+
var loading = promise && promise.loading;
|
|
598
598
|
if (!promise || currentTime - promise.time > 60 || temp !== promise.params || promise.search !== search) {
|
|
599
599
|
var promise = new Promise(function (ok, oh) {
|
|
600
600
|
if (headers) {
|
|
@@ -623,6 +623,10 @@ var privates = {
|
|
|
623
623
|
var checked = error_check(data);
|
|
624
624
|
var apiMap = api && api.root;
|
|
625
625
|
var trans = api ? api.transpile : getTranspile(url);
|
|
626
|
+
if (/^\^/.test(selector) && loading.getResponseHeader) {
|
|
627
|
+
data = loading.getResponseHeader(selector.replace(/^\^/, ''));
|
|
628
|
+
selector = '';
|
|
629
|
+
}
|
|
626
630
|
data = transpile(seekResponse(data, selector), trans, apiMap);
|
|
627
631
|
if (isDefined(checked)) {
|
|
628
632
|
return checked;
|
package/coms/zimoli/model.js
CHANGED