efront 4.4.5 → 4.4.8
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/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/compile/unstruct.js +7 -3
- package/coms/compile/unstruct_test.js +5 -4
- 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];
|
|
@@ -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/compile/unstruct.js
CHANGED
|
@@ -608,7 +608,7 @@ var _invoke = function (t, getname) {
|
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
610
|
if (queue.length) {
|
|
611
|
-
queue.push(t);
|
|
611
|
+
if (t.length) queue.push(t);
|
|
612
612
|
flushqueue(result, queue);
|
|
613
613
|
}
|
|
614
614
|
else if (t.length) {
|
|
@@ -617,6 +617,7 @@ var _invoke = function (t, getname) {
|
|
|
617
617
|
t.unshift(...rescan(`${qname}=${qname}`));
|
|
618
618
|
relink(t);
|
|
619
619
|
}
|
|
620
|
+
t = uncurve(t);
|
|
620
621
|
pushstep(result, t);
|
|
621
622
|
}
|
|
622
623
|
if (ret_) patchresult(result, 0);
|
|
@@ -704,7 +705,10 @@ var popexp = function (explist) {
|
|
|
704
705
|
}
|
|
705
706
|
return [asn, n];
|
|
706
707
|
}
|
|
707
|
-
|
|
708
|
+
var uncurve = function (c) {
|
|
709
|
+
if (c.length === 1 && c[0].type === SCOPED && c[0].entry === '(' && canbeOnce(c[0])) c = c[0];
|
|
710
|
+
return c;
|
|
711
|
+
};
|
|
708
712
|
var ternary = function (body, getname, ret) {
|
|
709
713
|
var eqused = 0;
|
|
710
714
|
var getnextname = function (i) {
|
|
@@ -787,7 +791,6 @@ var ternary = function (body, getname, ret) {
|
|
|
787
791
|
explist = [r];
|
|
788
792
|
}
|
|
789
793
|
else {
|
|
790
|
-
if (equals.length && bd.length === 1 && bd[0].type === SCOPED && bd[0].entry === '(' && skipAssignment(bd[0], 0) === bd[0].length) bd = bd[0];
|
|
791
794
|
explist = _express(bd, getnextname, equalsend > skip || ret);
|
|
792
795
|
}
|
|
793
796
|
}
|
|
@@ -840,6 +843,7 @@ var ternary = function (body, getname, ret) {
|
|
|
840
843
|
eq.text = "=";
|
|
841
844
|
}
|
|
842
845
|
else an = n;
|
|
846
|
+
asn = uncurve(asn);
|
|
843
847
|
ass.push(equals[i], ...asn);
|
|
844
848
|
relink(ass);
|
|
845
849
|
if (evals.length) ass[0].set = getnextname(0);
|
|
@@ -39,13 +39,13 @@ test('a * a ?? b * c * c ** d', "_ = a * a; if (_ !== null && _ !== undefined) r
|
|
|
39
39
|
test('a * a && await b*c', "_ = a * a; if (!_) return [2, 0]; _ = b; return [_, 1];\r\n _ = @; _ * c", true);
|
|
40
40
|
test("await a", "_ = a; return [_, 1]", true);
|
|
41
41
|
test("yield a", "return [a, 3]", true);
|
|
42
|
-
test("!a.done&&(b=await a.value)", "_ = !a.done; if (!_) return [2, 0]; _ = a.value; return [_, 1];\r\n _ = @; b = _;
|
|
42
|
+
test("!a.done&&(b=await a.value)", "_ = !a.done; if (!_) return [2, 0]; _ = a.value; return [_, 1];\r\n _ = @; b = _; _", true);
|
|
43
43
|
test("a=1?2:3", `if (false) return [1, 0]; a = 2; return [2, 0];\r\n a = 3; return [1, 0]`)
|
|
44
44
|
test("await a()", "_ = a(); return [_, 1]", true);
|
|
45
45
|
test("yield a()", "_ = a(); return [_, 3]", true);
|
|
46
46
|
test("a = await a()", "_ = a(); return [_, 1];\r\n _ = @; a = _", true);
|
|
47
47
|
test("a = yield a()", "_ = a(); return [_, 3];\r\n _ = @; a = _", true);
|
|
48
|
-
test("(1+ +1)", "_ = 1 + +1;
|
|
48
|
+
test("(1+ +1)", "_ = 1 + +1; _", true);
|
|
49
49
|
test("await a(await b)", "_ = b; return [_, 1];\r\n _ = @; _ = a(_); return [_, 1]", true);
|
|
50
50
|
test("await a(await b).s(await c)", "_ = b; return [_, 1];\r\n _ = @; _ = a(_); _0 = c; return [_0, 1];\r\n _0 = @; _ = _.s(_0); return [_, 1]", true);
|
|
51
51
|
test("a*a + await a(await b).s(await c)", "_ = a * a, _0 = b; return [_0, 1];\r\n _0 = @; _0 = a(_0); _1 = c; return [_1, 1];\r\n _1 = @; _0 = _0.s(_1); return [_0, 1];\r\n _0 = @; _ + _0", true);
|
|
@@ -89,8 +89,8 @@ test("with(a){ a = 1}", `if (_ = with_("a", [a])) _.a = 1; else a = 1;`, true);
|
|
|
89
89
|
test("try{a=2+1}catch(e){return;}", 'return [65537, 7];\r\n a = 2 + 1; return [0, 9];\r\n e = @; return [undefined, 2];\r\n return [1, 9]', true);
|
|
90
90
|
test("try{a=2+1}catch(e){}", 'return [1, 7];\r\n a = 2 + 1; return [0, 9];\r\n return [1, 9]', true);
|
|
91
91
|
test("try{a=2+1}catch(e){a=3}", 'return [65537, 7];\r\n a = 2 + 1; return [0, 9];\r\n e = @; a = 3; return [0, 9];\r\n return [1, 9]', true);
|
|
92
|
-
test("(function(){})", '_ = function () {};
|
|
93
|
-
test("(1+2*function(){}())", '_ = 2 * function () {}(), _ = 1 + _;
|
|
92
|
+
test("(function(){})", '_ = function () {}; _', true);
|
|
93
|
+
test("(1+2*function(){}())", '_ = 2 * function () {}(), _ = 1 + _; _', true);
|
|
94
94
|
test("function a(){}", 'a = function a() {}', true);
|
|
95
95
|
test("if(1) function a(){}", 'if (false) return [1, 0]; a = function a() {}; return [1, 0]', true);
|
|
96
96
|
test("if(1) {function a(){}}", 'if (false) return [1, 0]; a = function a() {}; return [1, 0]', true);
|
|
@@ -153,3 +153,4 @@ test(`c=b+ !a`, "_ = !a, c = b + _");
|
|
|
153
153
|
test(`do {var loadcount = 0;} while (loadcount !== 0);`, `loadcount = 0; _ = loadcount !== 0; if (_) return [0, 0]`);
|
|
154
154
|
unstruct.debug = true; r++;
|
|
155
155
|
test("if(a)try{a}catch{};a;", 'if (!a) return [4, 0]; return [1, 7];\r\n a; return [0, 9];\r\n return [1, 9];\r\n return [1, 0];\r\n a');
|
|
156
|
+
test("url = (o===void 0||o===null?void 0:o.url)", '_ = void 0, _ = o === _; if (_) return [1, 0]; _ = o === null;\r\n if (!_) return [1, 0]; _ = void 0; return [2, 0];\r\n _ = o.url; return [1, 0];\r\n url = _', true);
|
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