efront 4.0.13 → 4.0.16
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/#/345/233/275/351/231/205/345/214/226.yml +574 -1
- package/apps/drequest/index.html +10 -0
- package/coms/basic/#loader.js +2 -1
- package/coms/basic/YAML.js +3 -3
- package/coms/basic/parseYML.js +4 -1
- package/coms/basic/parseYML_test.js +3 -1
- package/coms/basic/strings.js +22 -15
- package/coms/basic_/readme-en.md +112 -0
- package/coms/basic_/readme.md +1 -1
- package/coms/compile/common.js +1 -0
- package/coms/compile/downLevel.js +8 -4
- package/coms/compile/translate.js +3 -3
- package/coms/compile/unstruct.js +44 -26
- package/coms/compile/unstruct_test.js +3 -1
- package/coms/docs/helps.js +69 -65
- package/coms/zimoli/data.js +10 -10
- package/coms/zimoli/on.js +3 -4
- package/coms/zimoli/table.html +4 -4
- package/docs/compare-en.md +327 -0
- package/docs/components.jsp +1 -1
- package/docs/main.xht +18 -18
- package/docs/version-desc.md +11 -0
- package/docs/welcome.jsp +1 -1
- package/docs//345/221/275/344/273/244.xht +12 -6
- package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +54 -53
- package/docs//345/267/245/345/205/267//345/255/227/347/254/246/351/233/206/346/243/200/346/237/245.xht +7 -7
- package/docs//347/273/204/344/273/266.xht +12 -12
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme-en.md +168 -0
- package/readme.md +16 -7
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# efront compatibility instructions
|
|
2
|
+
* The code for the directory `coms/basic_` is all non-standard implementations. If you want to be compatible with lower versions of the runtime environment, try to avoid using advanced features as much as possible
|
|
3
|
+
* 3.x and previous versions of `efront` used `typescript` for code downgrade, so the description of some issues in the following text may accidentally harm `typescript`, so it's not surprising.
|
|
4
|
+
* The syntax that is known to differ from advanced versions after conversion to lower version code is as follows:
|
|
5
|
+
1. ```javascript
|
|
6
|
+
class ... extends Array {...}
|
|
7
|
+
```
|
|
8
|
+
Because if one level of prototype is added, the characteristics of the array will disappear, and `efront` has not yet implemented a perfect downgrade plan, and the possibility of future implementation is also unlikely. After similar statements are converted by `typescript`, the newly defined methods will be lost. `efront` uses `class extends Array2 {...}` will be replaced, and `Array2` will mount the defined method to the newly generated object.
|
|
9
|
+
|
|
10
|
+
2. ```javascript
|
|
11
|
+
import(...)
|
|
12
|
+
```
|
|
13
|
+
The result imported with `import (...)`, efront will not actively wrap a layer of Promise. If you use `await` in the root scope of the module, the returned result is an instance of `Promise`. Otherwise, what you export in the imported file will be the result of this `import(...)`. If you are unsure about the content of the imported file and do not blindly use methods such as `import(...).then (...)`, you can use `await import(...)` to wait for the import to complete.
|
|
14
|
+
3. ```javascript
|
|
15
|
+
(function (a){
|
|
16
|
+
if (a === void 0) a = 1;
|
|
17
|
+
a = 1;
|
|
18
|
+
console.log(arguments[0])// 1
|
|
19
|
+
}(0));
|
|
20
|
+
(function (a){"use strict"
|
|
21
|
+
if (a === void 0) a = 1;
|
|
22
|
+
a = 1;
|
|
23
|
+
console.log(arguments[0])// 0
|
|
24
|
+
}(0));
|
|
25
|
+
(function (a = 1){
|
|
26
|
+
a = 1;
|
|
27
|
+
console.log(arguments[0])// 0
|
|
28
|
+
}(0));
|
|
29
|
+
```
|
|
30
|
+
`arguments` that are not in strict mode and do not have default values will be changed by statements in the code, while the other two cases will not. When the `efront` and `typescript` move the default value assignment statement into the function body, they do not handle this detail, that is, the original read-only `arguments` may be changed by the statement inside the function. Some of the components provided in efront may also have issues that prevent them from being downgraded for use. If you find any related issues, please feel free to provide feedback to me and I will handle them as soon as possible.
|
|
31
|
+
|
|
32
|
+
4. ```javascript
|
|
33
|
+
async function () {
|
|
34
|
+
await ...;
|
|
35
|
+
arguments;
|
|
36
|
+
}
|
|
37
|
+
// 或
|
|
38
|
+
function* (){
|
|
39
|
+
yield ...;
|
|
40
|
+
arguments;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
After converting these two types of new functions with `typescript`, the content of the `arguments` object is incorrect. This is not a difficult problem to solve, it should just be a problem that `typescript` has discovered but is unwilling to solve. During downgrade compilation, use variable renaming to temporarily replace the `arguments` in the code to make its content consistent with the native high-level code.
|
|
44
|
+
|
|
45
|
+
5. ```javascript
|
|
46
|
+
Object.keys
|
|
47
|
+
Object.create
|
|
48
|
+
Array.prototype.map
|
|
49
|
+
Array.prototype.forEach
|
|
50
|
+
Array.prototype.filter
|
|
51
|
+
Array.prototype.indexOf
|
|
52
|
+
String.prototype.trim// Inconsistent implementation in different support environments, and inconsistent understanding of whitespace by major manufacturers
|
|
53
|
+
Function.prototype.bind
|
|
54
|
+
```
|
|
55
|
+
The above methods are supported by the `ie9+` series of browsers, but not by the 'ie8' and the following versions. If the `--no-polyfill` parameter is not specified, the methods provided in `[]map.js` will be used to patch during the downgrade compile time. These methods will be initialized when the loader detects that the browser does not support `[].map`
|
|
56
|
+
|
|
57
|
+
1. ```javascript
|
|
58
|
+
Array.prototype.fill
|
|
59
|
+
Array(3).fill(0) // Similar to this will become a constant array of [0,0,0]
|
|
60
|
+
var [a,b,c]=Array(3).fill(0).map((_,i)=>i+1) // Similar to those used to generate constants and assign values, they will directly become assignment statements: var a=1,b=2,c=3
|
|
61
|
+
Array(3).fill(a)// A statement similar to ArrayFill(3, a) will replace a very large quantity like this
|
|
62
|
+
```
|
|
63
|
+
`Array(...).fill(...).map(...)` is often used by `efront` developers to generate self increasing assignment sequences, and not all runtime environments support it. Therefore, several other writing methods that explicitly use `Array.prototype.fill` will be replaced. For the sake of the performance of the Object code, this replacement must be executed before the automatic constant. Therefore, the switch `polyfill` is no longer supported. If you want to turn off, please use the parameter `--no-autoeval` to turn off the automatic constant function together.
|
|
64
|
+
|
|
65
|
+
2. ```javascript
|
|
66
|
+
Object.assign
|
|
67
|
+
```
|
|
68
|
+
Object.assign and `ie` series browsers are not supported. Because they are often used by `efront` developers, during the downgrade Compile time period, if the '--no-polyfill' parameter is not specified, `efront` will be processed as a substitute [extend](../basic/extend.js)
|
|
69
|
+
|
|
70
|
+
3. ```javascript
|
|
71
|
+
Promise
|
|
72
|
+
Promise.prototype.then
|
|
73
|
+
Promise.prototype.catch
|
|
74
|
+
Promise.all
|
|
75
|
+
Promise.race
|
|
76
|
+
Promise.reject
|
|
77
|
+
Promise.resolve
|
|
78
|
+
```
|
|
79
|
+
The `Promise` object is also not supported by the IE series of browsers. The `Promise` implemented by `efront` is not consistent with the native features and is only replaced when the runtime environment does not support it. For example, the execution order of methods triggered by `.then` and `setTimeout` may differ from the advanced runtime environment, but they will also remain executed in the current context before executing the relevant statements. The `Promise` related methods not mentioned above are not supported, such as `Promise.prototype.finally`. If you use these missing features, you can only implement them yourself or find similar [core js](https://github.com/zloirock/core-js). The library is filled with
|
|
80
|
+
|
|
81
|
+
4. ```javascript
|
|
82
|
+
obj.if
|
|
83
|
+
obj.catch
|
|
84
|
+
obj.for
|
|
85
|
+
```
|
|
86
|
+
Similar to this. As the attribute name is the same as the Reserved word of 'js', the browser such as `ie6` will report an error, but you can use it safely in the environment provided by `efront`. Because `efront` itself will process statements that retrieve attributes.
|
|
87
|
+
|
|
88
|
+
1. There are some features in `IE8` and below browsers that are different from modern 'js' standards, and the components provided by `efront` may not be compatible. When developing applications for such environments, it is important to avoid using them.
|
|
89
|
+
```javascript
|
|
90
|
+
Object.defineProperty(...);
|
|
91
|
+
({
|
|
92
|
+
get a(){},
|
|
93
|
+
set a(){}
|
|
94
|
+
});
|
|
95
|
+
class {
|
|
96
|
+
get a(){}
|
|
97
|
+
set a(){}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
`IE8` and below browsers do not support `Object.defineProperty` well or at all, and there is currently no compatibility solution for `efront` to implement this type of function. If you want to be compatible with the corresponding environment, please temporarily avoid using related statements and do not use libraries that use these features.
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
Array.prototype.slice.call(objNodeList,...)
|
|
104
|
+
```
|
|
105
|
+
`IE8` and below browsers do not support dom objects such as 'NodeList' to call, and the current `efront` and previously used `typescript` conversion code do not handle this detail. Therefore, do not use high-level syntax such as `[...aaa]`, `{...aaa}` , and `function (...args) {}` in dom operation related statements temporarily to avoid problems with the converted code.
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
var div = document.createElement("div");
|
|
109
|
+
div.innerHTML = `<abcd><span></span></abcd>`;
|
|
110
|
+
console.log(div.innerHTML); // <SPAN></SPAN>
|
|
111
|
+
```
|
|
112
|
+
`IE8` and below browsers cannot correctly set custom labels through the `innerHTML` attribute, and most of the components provided by `efront` use this feature. In the `efront` example project, [ie8.js](../../apps/kugou/ie8.js) can achieve the adaptation of setting `innerHTML` on `ie8`, but it cannot guarantee the normal style. For browsers under `ie7` and below, do not use the components related to elements provided by `efront` temporarily.
|
package/coms/basic_/readme.md
CHANGED
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
```javascript
|
|
98
98
|
Array.prototype.slice.call(objNodeList,...)
|
|
99
99
|
```
|
|
100
|
-
`ie8`及以下浏览器不支持call`NodeList`等dom对象,而当前`efront
|
|
100
|
+
`ie8`及以下浏览器不支持call`NodeList`等dom对象,而当前`efront`和之前内部使用的`typescript`转换的代码都没有处理这一细节,所以暂时不要在dom操作相关的语句中使用类似`[...aaa]`,`{...aaa}`,`function(...args){}`的高级语法,以避免转换后的代码出问题。
|
|
101
101
|
```javascript
|
|
102
102
|
var div = document.createElement("div");
|
|
103
103
|
div.innerHTML = `<abcd><span></span></abcd>`;
|
package/coms/compile/common.js
CHANGED
|
@@ -753,6 +753,7 @@ var createScoped = function (parsed, wash) {
|
|
|
753
753
|
if (scoped.length) _scoped.push(scoped);
|
|
754
754
|
}
|
|
755
755
|
if (isArrow) {
|
|
756
|
+
scoped.isArrow = true;
|
|
756
757
|
if (!thisscope.insett && used.this) thisscope.insett = true;
|
|
757
758
|
if (!argscope.inseta && used.arguments) argscope.inseta = true;
|
|
758
759
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var scanner2 = require("./scanner2");
|
|
2
2
|
var strings = require("../basic/strings");
|
|
3
3
|
var Program = scanner2.Program;
|
|
4
|
-
var { STAMP, SCOPED, STRAP, EXPRESS, COMMENT, SPACE, PROPERTY, VALUE, LABEL, QUOTED, rename, getDeclared, skipAssignment, createScoped, createString, splice, relink, snapExpressHead } = require("./common");
|
|
4
|
+
var { STAMP, SCOPED, STRAP, EXPRESS, COMMENT, SPACE, PROPERTY, VALUE, LABEL, QUOTED, rename, getDeclared, skipAssignment, createScoped, createString, splice, relink, snapExpressHead, needBreakBetween } = require("./common");
|
|
5
5
|
var splice2 = function (q, from, to, ...a) {
|
|
6
6
|
var cx = q.indexOf(from);
|
|
7
7
|
if (cx < 0) throw console.log(splice2.caller, console.format('\r\n<red2>自</red2>'), from && createString([from]), console.format('\r\n<yellow>至</yellow>'), to && createString([to]), console.format(`\r\n<cyan>码列</cyan>`), createString(q)), '结构异常';
|
|
@@ -652,10 +652,14 @@ var killspr = function (body, i, _getobjname, killobj) {
|
|
|
652
652
|
var cx = body.lastIndexOf(r, i);
|
|
653
653
|
var dx = body.indexOf(p, cx) + 1;
|
|
654
654
|
var h1 = h[h.length - 1];
|
|
655
|
+
var h0 = h[0];
|
|
656
|
+
if (r.prev && needBreakBetween(r.prev, r)) {
|
|
657
|
+
h.unshift({ type: STAMP, text: ';' });
|
|
658
|
+
}
|
|
655
659
|
splice(h1, h1.length, 0, ...splice(body, cx, dx - cx, ...h));
|
|
656
660
|
i += cx - dx + h.length;
|
|
657
661
|
if (p.type === EXPRESS && !p.text) {
|
|
658
|
-
var cx =
|
|
662
|
+
var cx = h0.lastIndexOf(p);
|
|
659
663
|
if (cx >= 0) splice(h1, cx, 1);
|
|
660
664
|
}
|
|
661
665
|
}
|
|
@@ -1326,13 +1330,13 @@ var down = function (scoped) {
|
|
|
1326
1330
|
};
|
|
1327
1331
|
|
|
1328
1332
|
var markcodes = [];
|
|
1329
|
-
if (scoped.isfunc && scoped.used.this && (funcMark || scoped.insett)) {
|
|
1333
|
+
if (scoped.isfunc && scoped.used.this && (funcMark && !scoped.isArrow || scoped.insett)) {
|
|
1330
1334
|
let tn = _getname("this_");
|
|
1331
1335
|
rename(scoped.used, "this", tn);
|
|
1332
1336
|
scoped.used.this.forEach(o => o.origin = 'this');
|
|
1333
1337
|
markcodes.push(`${tn}=this`);
|
|
1334
1338
|
}
|
|
1335
|
-
if (scoped.isfunc && scoped.used.arguments && (funcMark || scoped.inseta)) {
|
|
1339
|
+
if (scoped.isfunc && scoped.used.arguments && (funcMark && !scoped.isArrow || scoped.inseta)) {
|
|
1336
1340
|
let an = _getname("arguments_");
|
|
1337
1341
|
scoped.used.arguments.forEach(o => o.origin = 'arguments');
|
|
1338
1342
|
rename(scoped.used, "arguments", an);
|
|
@@ -4,11 +4,11 @@ var strings = require("../basic/strings");
|
|
|
4
4
|
var program = null;
|
|
5
5
|
var patchTranslate = function (c) {
|
|
6
6
|
if (c.length) {
|
|
7
|
-
c.translate = c.map((o, i) => o.type === PIECE ? strings.decode(`\`${o.text}\``) : `$${i + 1 >> 1}`).join('');
|
|
7
|
+
c.translate = c.map((o, i) => o.type === PIECE ? strings.decode(`\`${o.text}\``) : `$${i + 1 >> 1}`).join('').replace(/\r\n|\r|\n/g, '\r\n');
|
|
8
8
|
}
|
|
9
9
|
else {
|
|
10
10
|
if (/^['"`]/.test(c.text) && c.text.length > 2) {
|
|
11
|
-
var text = strings.decode(c.text);
|
|
11
|
+
var text = strings.decode(c.text).replace(/\r\n|\r|\n/g, '\r\n');
|
|
12
12
|
c.translate = text;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -89,7 +89,7 @@ function translate([imap, supports], code) {
|
|
|
89
89
|
var getm = function (tt) {
|
|
90
90
|
tt = tt.trim();
|
|
91
91
|
if (!imap[tt]) {
|
|
92
|
-
console.warn(`<yellow
|
|
92
|
+
console.warn(`<yellow>${i18n`国际化翻译缺失:`}</yellow>${tt}`);
|
|
93
93
|
imap[tt] = supports.map(_ => tt);
|
|
94
94
|
}
|
|
95
95
|
return imap[tt].map(m => strings.encode(m || tt, '`'));
|
package/coms/compile/unstruct.js
CHANGED
|
@@ -21,7 +21,8 @@ var _break = function (body, cx, result, iscontinue) {
|
|
|
21
21
|
var s;
|
|
22
22
|
for (var cx = labels.length - 1; cx >= 0; cx--) {
|
|
23
23
|
var b = labels[cx];
|
|
24
|
-
if (b.type === LABEL && b.text === label) {
|
|
24
|
+
if (b.type === LABEL && b.text === label + ":") {
|
|
25
|
+
if (!s) s = b;
|
|
25
26
|
if (!b.breaks) b.breaks = [];
|
|
26
27
|
var _b = scanner2('return []');
|
|
27
28
|
_b.ret_ = -1;
|
|
@@ -440,7 +441,14 @@ var isEvalScope = function (o) {
|
|
|
440
441
|
return o === h;
|
|
441
442
|
}
|
|
442
443
|
return false;
|
|
443
|
-
}
|
|
444
|
+
};
|
|
445
|
+
var ispropcall = function (o) {
|
|
446
|
+
var n = o.next;
|
|
447
|
+
if (!n || n.type !== SCOPED && n.entry !== '(') return false;
|
|
448
|
+
if (o.type === EXPRESS && snapExpressHead(o) !== o) return true;
|
|
449
|
+
if (o.type === SCOPED && o.entry === '[' && snapExpressHead(o) !== o) return true;
|
|
450
|
+
return false;
|
|
451
|
+
};
|
|
444
452
|
var _invoke = function (t, getname) {
|
|
445
453
|
var nameindex = 0;
|
|
446
454
|
var getdeepname = function (deep = 0) {
|
|
@@ -521,7 +529,7 @@ var _invoke = function (t, getname) {
|
|
|
521
529
|
for (var c of cache) pushstep(result, c);
|
|
522
530
|
cache = [];
|
|
523
531
|
var n = o.next;
|
|
524
|
-
if (n && !needbreak(n)) {
|
|
532
|
+
if (n && !needbreak(n) && !ispropcall(o)) {
|
|
525
533
|
var h = snapExpressHead(o);
|
|
526
534
|
var hx = t.lastIndexOf(h, cx);
|
|
527
535
|
var fs = splice(t, hx, cx + 1 - hx, { type: EXPRESS, text: getname(nameindex) });
|
|
@@ -975,7 +983,7 @@ var getblock = function (body, cx) {
|
|
|
975
983
|
return b;
|
|
976
984
|
};
|
|
977
985
|
var labels = [];
|
|
978
|
-
var scopes = [];
|
|
986
|
+
var scopes = [null];
|
|
979
987
|
var isbreak = function (o) {
|
|
980
988
|
if (o.type !== STRAP) return false;
|
|
981
989
|
return /^(break|continue)$/.test(o.text) ||
|
|
@@ -993,6 +1001,24 @@ var ifpatch = function (result, autoskip) {
|
|
|
993
1001
|
re.ifbrk = autoskip !== undefined;
|
|
994
1002
|
pushstep(result, re);
|
|
995
1003
|
};
|
|
1004
|
+
var poplabel = function (result) {
|
|
1005
|
+
if (!labels.length) return;
|
|
1006
|
+
var e = labels.pop();
|
|
1007
|
+
if (e.breaks) {
|
|
1008
|
+
while (e.breaks.length) {
|
|
1009
|
+
var b = e.breaks.pop();
|
|
1010
|
+
var end = b;
|
|
1011
|
+
for (var cx = result.length - 1; cx >= 0; cx--) {
|
|
1012
|
+
var r = result[cx];
|
|
1013
|
+
if (r.indexOf(b) >= 0) { break }
|
|
1014
|
+
}
|
|
1015
|
+
if (cx < 0) throw console.log(result.map(r => createString(r)), e.text, createString([b.prev, b])), "break语句异常";
|
|
1016
|
+
end.push({ type: VALUE, text: b.continue ? b.continue.contat - cx : result.length - cx }, { type: STAMP, text: "," }, { type: VALUE, text: "0" });
|
|
1017
|
+
relink(end);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
|
|
996
1022
|
function toqueue(body, getname, ret = false, result = []) {
|
|
997
1023
|
var retn = false;
|
|
998
1024
|
var uniftop = function () {
|
|
@@ -1022,23 +1048,9 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
1022
1048
|
toqueue(block, getname, true, result);
|
|
1023
1049
|
return result[result.length - 1];
|
|
1024
1050
|
};
|
|
1025
|
-
var
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
if (e.breaks) {
|
|
1029
|
-
while (e.breaks.length) {
|
|
1030
|
-
var b = e.breaks.pop();
|
|
1031
|
-
var end = b;
|
|
1032
|
-
for (var cx = result.length - 1; cx >= 0; cx--) {
|
|
1033
|
-
var r = result[cx];
|
|
1034
|
-
if (r.indexOf(b) >= 0) { break }
|
|
1035
|
-
}
|
|
1036
|
-
if (cx < 0) throw console.log(result.map(r => createString(r)), e.text, createString([b.prev, b])), "break语句异常";
|
|
1037
|
-
end.push({ type: VALUE, text: b.continue ? b.continue.contat - cx : result.length - cx }, { type: STAMP, text: "," }, { type: VALUE, text: "0" });
|
|
1038
|
-
relink(end);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1051
|
+
var _poplabel = function () {
|
|
1052
|
+
poplabel(result);
|
|
1053
|
+
}
|
|
1042
1054
|
var cx = 0, bx = 0;
|
|
1043
1055
|
var iftop = null;
|
|
1044
1056
|
var brk = function (text, YIELD) {
|
|
@@ -1062,12 +1074,17 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
1062
1074
|
var e = labels[labels.length - 1];
|
|
1063
1075
|
if (e.type !== LABEL) break;
|
|
1064
1076
|
if (scopes.lastIndexOf(e.scope) >= 0) break;
|
|
1065
|
-
|
|
1077
|
+
_poplabel();
|
|
1066
1078
|
}
|
|
1067
1079
|
|
|
1068
1080
|
if (o.type === LABEL) {
|
|
1069
1081
|
o.scope = scopes[scopes.length - 1];
|
|
1070
1082
|
labels.push(o);
|
|
1083
|
+
var next = o.next;
|
|
1084
|
+
if (next && next.type === SCOPED && next.entry === '{') {
|
|
1085
|
+
ifpatch(result);
|
|
1086
|
+
o.contat = result.length;
|
|
1087
|
+
}
|
|
1071
1088
|
bx = ++cx;
|
|
1072
1089
|
continue;
|
|
1073
1090
|
}
|
|
@@ -1111,28 +1128,28 @@ function toqueue(body, getname, ret = false, result = []) {
|
|
|
1111
1128
|
if (o.text === 'for') {
|
|
1112
1129
|
labels.push(o);
|
|
1113
1130
|
cx = _for(body, cx, unblock, result);
|
|
1114
|
-
|
|
1131
|
+
_poplabel();
|
|
1115
1132
|
bx = cx;
|
|
1116
1133
|
continue;
|
|
1117
1134
|
}
|
|
1118
1135
|
if (o.text === 'while') {
|
|
1119
1136
|
labels.push(o);
|
|
1120
1137
|
cx = _while(body, cx, unblock, result);
|
|
1121
|
-
|
|
1138
|
+
_poplabel();
|
|
1122
1139
|
bx = cx;
|
|
1123
1140
|
continue;
|
|
1124
1141
|
}
|
|
1125
1142
|
if (o.text === 'do') {
|
|
1126
1143
|
labels.push(o);
|
|
1127
1144
|
cx = _do(body, cx, unblock, result);
|
|
1128
|
-
|
|
1145
|
+
_poplabel();
|
|
1129
1146
|
bx = cx;
|
|
1130
1147
|
continue;
|
|
1131
1148
|
}
|
|
1132
1149
|
if (o.text === 'switch') {
|
|
1133
1150
|
labels.push(o);
|
|
1134
1151
|
cx = _switch(body, cx, unblock, result, getname);
|
|
1135
|
-
|
|
1152
|
+
_poplabel();
|
|
1136
1153
|
bx = cx;
|
|
1137
1154
|
continue;
|
|
1138
1155
|
}
|
|
@@ -1230,6 +1247,7 @@ module.exports = function (body, newname, ret) {
|
|
|
1230
1247
|
return tmpnames[i];
|
|
1231
1248
|
};
|
|
1232
1249
|
var res = toqueue(body, getname, false);
|
|
1250
|
+
while (labels.length) poplabel(res);
|
|
1233
1251
|
ret_ = ret0;
|
|
1234
1252
|
return res;
|
|
1235
1253
|
};
|
|
@@ -100,4 +100,6 @@ test("while(a){if(b){if(c);else d;continue;}}", 'if (!a) return [4, 0]; if (!b)
|
|
|
100
100
|
test("/*abc*/", '/*abc*/', true);
|
|
101
101
|
test("//aaa", '//aaa', true);
|
|
102
102
|
test("menus[0].name+='aaa'", "_ = menus[0]; _0 = _.name + 'aaa'; _.name = _0", true);
|
|
103
|
-
test("menus[a+b].name+='aaa'", "_ = a + b; _ = menus[_]; _0 = _.name + 'aaa'; _.name = _0", true);
|
|
103
|
+
test("menus[a+b].name+='aaa'", "_ = a + b; _ = menus[_]; _0 = _.name + 'aaa'; _.name = _0", true);
|
|
104
|
+
test("menus[a+b]()", "_ = a + b; menus[_]()", true);
|
|
105
|
+
test("loop:{a=b;if(a) continue loop}", "a = b; if (a) return [0, 0]", true);
|
package/coms/docs/helps.js
CHANGED
|
@@ -1,71 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
// <!--
|
|
2
|
+
if (typeof i18n === "undefined") i18n = a => a;
|
|
3
|
+
// -->
|
|
2
4
|
var helps = [
|
|
3
|
-
"f
|
|
4
|
-
"f
|
|
5
|
-
"f
|
|
6
|
-
"f
|
|
7
|
-
"f
|
|
8
|
-
"m
|
|
9
|
-
"m
|
|
10
|
-
"m
|
|
11
|
-
"m
|
|
12
|
-
"q
|
|
13
|
-
"a
|
|
14
|
-
"a
|
|
15
|
-
"a
|
|
16
|
-
"a
|
|
17
|
-
"q
|
|
18
|
-
"a
|
|
19
|
-
"a
|
|
20
|
-
"a
|
|
21
|
-
"a
|
|
22
|
-
"a
|
|
23
|
-
"z
|
|
24
|
-
"q
|
|
25
|
-
"z
|
|
26
|
-
"
|
|
27
|
-
"a
|
|
28
|
-
"z
|
|
29
|
-
"z
|
|
30
|
-
"z
|
|
31
|
-
"z
|
|
32
|
-
"k
|
|
33
|
-
"k
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
5
|
+
["f", i18n`显示版本号`, "version", "-v", "--version"],
|
|
6
|
+
["f", i18n`显示efront的安装路径`, "path", "--path"],
|
|
7
|
+
["f", i18n`显示帮助信息`, "help", "-h", "--help", "help COMMAND", "-h COMMAND", "--help COMMAND"],
|
|
8
|
+
["f", i18n`启动文档服务器`, "docs"],
|
|
9
|
+
["f", i18n`查看efront自身占用的内存`, "memery", "memory", "-m", "--memery", "--memory"],
|
|
10
|
+
["m", i18n`启动示例项目服务器`, "demo", "demo SRCNAME"],
|
|
11
|
+
["m", i18n`创建应用,项目目录允许创建第二个应用`, "init", "from SRCNAME", "init APPNAME", "init APPNAME from SRCNAME", "from SRCNAME init APPNAME"],
|
|
12
|
+
["m", i18n`创建简单应用,独占项目目录的单应用`, "create", "simple", "create|simple from SRCNAME", "create|simple APPNAME", "create|simple APPNAME from APPNAME"],
|
|
13
|
+
["m", i18n`创建空应用`, "blank", "simple", "from blank", "simple from blank"],
|
|
14
|
+
["q", i18n`自动识别环境并启动开发环境服务器`, "live", "lives", "live HTTP_PORT", "live HTTP_PORT HTTPS_PORT", "lives HTTPS_PORT", "lives HTTPS_PORT HTTP_PORT"],
|
|
15
|
+
["a", i18n`在项目文件夹启动生产环境服务器`, "start", "starts", "start HTTP_PORT", "start HTTP_PORT HTTPS_PORT", "starts HTTPS_PORT", "starts HTTPS_PORT HTTP_PORT"],
|
|
16
|
+
["a", i18n`在项目文件夹启动开发环境服务器`, "dev", "devs", "test", "dev|test HTTP_PORT", "dev|test HTTP_PORT HTTPS_PORT", "devs|tests HTTPS_PORT", "devs|tests HTTPS_PORT HTTP_PORT"],
|
|
17
|
+
["a", i18n`在当前文件夹启动服务器`, "server", "serve|serv|http HTTP_PORT HTTPS_PORT", "serve|serv|http HTTP_PORT", "https HTTPS_PORT HTTP_PORT", "https HTTPS_PORT", "HTTP_PORT HTTPS_PORT", "HTTP_PORT", ""],
|
|
18
|
+
["a", i18n`显示本机ip地址`, "ip", "-ip", "--ip"],
|
|
19
|
+
["q", i18n`编译项目`, "public", "publish", "build", "release"],
|
|
20
|
+
["a", i18n`监测文件变化,自动编译更新的部分并输出到指定目录`, "watch"],
|
|
21
|
+
["a", i18n`关闭efront服务器`, "kill HTTP_PORT|HTTPS_PORT", "close HTTP_PORT|HTTPS_PORT"],
|
|
22
|
+
["a", i18n`连接一台efront服务器,取得连接号`, "link ADDRESS"],
|
|
23
|
+
["a", i18n`用一个连接号登录本机的efront服务器,接收并打印消息`, "care ADDRESS", "care ADDRESS LINKID"],
|
|
24
|
+
["a", i18n`向一个连接号发送消息`, "cast ADDRESS LINKID MESSAGE"],
|
|
25
|
+
["z", i18n`检查文件或文件夹中的外部变量`, "check FILEPATH"],
|
|
26
|
+
["q", i18n`执行按efront方式加载的代码`, "run CODEFILE", "CODEFILE"],
|
|
27
|
+
["z", i18n`查找含有指定的外部变量的文件`, "find VARIABLE", "find VARIABLE FILEPATH"],
|
|
28
|
+
["-", i18n`从指定路径创建压缩文件`, "pack PUBLIC_PATH PACKAGE_PATH"],
|
|
29
|
+
["a", i18n`对json数据进行签名`, "sign JSON_PATH SIGNNAME"],
|
|
30
|
+
["z", i18n`根据模块的搜索路径查找真实路径`, "detect MODULE_PATH"],
|
|
31
|
+
["z", i18n`格式化代码`, "format MODULE_PATH TARGET_PATH TABSIZE"],
|
|
32
|
+
["z", i18n`导出与指定的对象路径关联的代码`, "pick MODULE_PATH TARGET_PATH KEYPATH"],
|
|
33
|
+
["z", i18n`清理代码,删除已声明未使用的代码`, "wash MODULE_PATH TARGET_PATH"],
|
|
34
|
+
["k", i18n`设置环境变量`, "setenv --NAME1=VALUE1 --NAME2=VALUE2", "setenv NAME VALUE", "set --NAME1=VALUE1", "set --NAME="],
|
|
35
|
+
["k", i18n`列出已配置的环境变量`, "listenv", "env"],
|
|
36
|
+
["-", i18n`创建国际化文案表`, "translate APPNAME"],
|
|
37
|
+
["-", i18n`将指定的路径添加到可执行文件的扫描路径`, "pathx PATHNAME"],
|
|
38
|
+
["-", i18n`从可执行文件的扫描路径中移除指定的路径`, "pathxrm PATHNAME"],
|
|
39
|
+
["-", i18n`设置远程访问的密码`, "password"],
|
|
40
|
+
["-", i18n`创建windows平台的一键安装包`, "packwin|packexe PUBLIC_PATH PACKAGE_PATH"],
|
|
41
|
+
["-", i18n`从压缩文件提取源文件`, "unpack PACKAGE_PATH PUBLIC_PATH"]
|
|
40
42
|
];
|
|
41
|
-
helps.forEach((
|
|
42
|
-
var [info, ...
|
|
43
|
-
|
|
44
|
-
var hide = type === "-";
|
|
45
|
-
info = info.slice(1);
|
|
46
|
-
var help = { info, type, hide, commands: _commands, cmds: _commands };
|
|
47
|
-
helps[cx] = help;
|
|
43
|
+
helps.forEach((h, cx) => {
|
|
44
|
+
var [type, info, ...cmds] = h;
|
|
45
|
+
helps[cx] = { type, info, cmds, commands: cmds, hide: type === '-' };
|
|
48
46
|
});
|
|
47
|
+
|
|
49
48
|
var topics = {
|
|
50
|
-
COMMAND:
|
|
51
|
-
APPNAME:
|
|
52
|
-
SRCNAME: "
|
|
53
|
-
HTTP_PORT:
|
|
54
|
-
HTTPS_PORT:
|
|
55
|
-
VARIABLES:
|
|
56
|
-
ADDRESS:
|
|
57
|
-
LINKID:
|
|
58
|
-
MESSAGE:
|
|
59
|
-
PUBLIC_PATH:
|
|
60
|
-
PACKAGE_PATH:
|
|
61
|
-
JSON_PATH:
|
|
62
|
-
SIGNNAME:
|
|
63
|
-
FILEPATH:
|
|
64
|
-
CODEFILE:
|
|
65
|
-
MODULE_PATH:
|
|
66
|
-
TARGET_PATH:
|
|
67
|
-
KEYPATH:
|
|
68
|
-
TABSIZE:
|
|
49
|
+
COMMAND: [i18n`命令名`],
|
|
50
|
+
APPNAME: [i18n`您的应用名`],
|
|
51
|
+
SRCNAME: [i18n`源项目`, "blank", "kugou", "pivot"],
|
|
52
|
+
HTTP_PORT: [i18n` http端口`, 80],
|
|
53
|
+
HTTPS_PORT: [i18n` https端口`, 443],
|
|
54
|
+
VARIABLES: [i18n`变量名`],
|
|
55
|
+
ADDRESS: [i18n`efront服务器地址`],
|
|
56
|
+
LINKID: [i18n`efront服务器提供的连接号`],
|
|
57
|
+
MESSAGE: [i18n`文本消息`],
|
|
58
|
+
PUBLIC_PATH: [i18n`软件发布目录`],
|
|
59
|
+
PACKAGE_PATH: [i18n`安装包的路径`],
|
|
60
|
+
JSON_PATH: [i18n`json文件所在的路径`],
|
|
61
|
+
SIGNNAME: [i18n`签名`],
|
|
62
|
+
FILEPATH: [i18n`文件或文件夹的路径`],
|
|
63
|
+
CODEFILE: [i18n`代码文件的路径`],
|
|
64
|
+
MODULE_PATH: [i18n`源文件的模糊路径`],
|
|
65
|
+
TARGET_PATH: [i18n`目标文件的模糊路径`],
|
|
66
|
+
KEYPATH: [i18n`对象的属性路径`],
|
|
67
|
+
TABSIZE: [i18n`缩进空格数`]
|
|
69
68
|
};
|
|
70
|
-
|
|
69
|
+
Object.keys(topics).forEach(k => {
|
|
70
|
+
var v = topics[k];
|
|
71
|
+
if (v.length === 2) v.default = v.pop();
|
|
72
|
+
else if (v.length > 2) v.default = v[1];
|
|
73
|
+
})
|
|
74
|
+
topics.VARIABLES.push(...Object.keys(topics));
|
|
71
75
|
module.exports = { helps, topics };
|
package/coms/zimoli/data.js
CHANGED
|
@@ -360,7 +360,7 @@ var parseData = function (sourceText) {
|
|
|
360
360
|
sourceText = parseYML(sourceText);
|
|
361
361
|
}
|
|
362
362
|
} catch (e) {
|
|
363
|
-
throw
|
|
363
|
+
throw i18n`数据无法解析`;
|
|
364
364
|
}
|
|
365
365
|
return sourceText;
|
|
366
366
|
};
|
|
@@ -422,7 +422,7 @@ function createApiMap(data) {
|
|
|
422
422
|
fixApi(api, href);
|
|
423
423
|
if (hasOwnProperty.call(apiMap, api.id)) {
|
|
424
424
|
const lastApi = apiMap[api.id];
|
|
425
|
-
console.warn(`多次设置的id相同的api:%c${api.id}`, 'color:red');
|
|
425
|
+
console.warn(i18n`多次设置的id相同的api:%c${api.id}`, 'color:red');
|
|
426
426
|
console.log(`[${api.name}](${lastApi.method} ${api.url})\r\n 被 [${api.name}](${lastApi.method} ${lastApi.url}) 覆盖`);
|
|
427
427
|
}
|
|
428
428
|
apiMap[api.id] = api;
|
|
@@ -534,7 +534,7 @@ var privates = {
|
|
|
534
534
|
}
|
|
535
535
|
if (lacks.length) {
|
|
536
536
|
|
|
537
|
-
console.log(`跳过了缺少参数的请求:${api.id} ${api.name} ${api.url}\r\n缺少参数:${lacks.join(', ')}`);
|
|
537
|
+
console.log(i18n`跳过了缺少参数的请求:${api.id} ${api.name} ${api.url}\r\n缺少参数:${lacks.join(', ')}`);
|
|
538
538
|
return false;
|
|
539
539
|
}
|
|
540
540
|
}
|
|
@@ -544,7 +544,7 @@ var privates = {
|
|
|
544
544
|
return this.getConfigPromise().then((apiMap) => {
|
|
545
545
|
serviceId = serviceId.replace(/[\?\:][\s\S]*$/, "");
|
|
546
546
|
const api = apiMap[serviceId];
|
|
547
|
-
if (!api) throw new Error(`没有找到对应的接口 id ${serviceId}.`);
|
|
547
|
+
if (!api) throw new Error(i18n`没有找到对应的接口 id ${serviceId}.`);
|
|
548
548
|
return extend({}, api, { root: apiMap });
|
|
549
549
|
});
|
|
550
550
|
},
|
|
@@ -632,7 +632,7 @@ var privates = {
|
|
|
632
632
|
getConfigPromise() {
|
|
633
633
|
if (!configPormise) {
|
|
634
634
|
if (!_configfileurl) {
|
|
635
|
-
throw new Error(
|
|
635
|
+
throw new Error(i18n`没有指定配置文件的路径,请使用data.loadConfig加载配置`);
|
|
636
636
|
}
|
|
637
637
|
var p = this.loadIgnoreConfig('get', _configfileurl);
|
|
638
638
|
p.loading.abort = function () { };
|
|
@@ -652,7 +652,7 @@ var getInstanceId = function () {
|
|
|
652
652
|
var error_report = isProduction ? alert : function (error, type) {
|
|
653
653
|
error_report = alert;
|
|
654
654
|
error_report(error, type);
|
|
655
|
-
console.info("
|
|
655
|
+
console.info(i18n`已使用默认的报错工具,您可以使用 ${"data.setReporter(error_reporter,error_finder)"} 替换! 本信息在仅在开发环境显示。`);
|
|
656
656
|
};
|
|
657
657
|
|
|
658
658
|
var error_check = function (data) { };
|
|
@@ -714,8 +714,8 @@ var unbindInstance = function (instanceId, callback) {
|
|
|
714
714
|
delete instanceListenerMap[instanceId];
|
|
715
715
|
}
|
|
716
716
|
};
|
|
717
|
-
var OUTDATE = new Error(
|
|
718
|
-
var ABORTED = new Error(
|
|
717
|
+
var OUTDATE = new Error(i18n`请求被覆盖`);
|
|
718
|
+
var ABORTED = new Error(i18n`请求已取消`);
|
|
719
719
|
var data = {
|
|
720
720
|
decodeStructure,
|
|
721
721
|
encodeStructure,
|
|
@@ -881,7 +881,7 @@ var data = {
|
|
|
881
881
|
},
|
|
882
882
|
asyncInstance(sid, params, parse) {
|
|
883
883
|
// 不同参数的请求互不影响
|
|
884
|
-
if (typeof sid !== "string") throw new Error(
|
|
884
|
+
if (typeof sid !== "string") throw new Error(i18n`serviceId 只能是字符串`);
|
|
885
885
|
var id = parse instanceof Function || params ? getInstanceId() : 0;
|
|
886
886
|
if (id) this.removeInstance(id);
|
|
887
887
|
var response = this.getInstance(id || sid);
|
|
@@ -1133,7 +1133,7 @@ var data = {
|
|
|
1133
1133
|
},
|
|
1134
1134
|
rebuildInstance(instance, data, old = instance) {
|
|
1135
1135
|
if (instance === data) return;
|
|
1136
|
-
if (!isObject(instance)) throw new Error(
|
|
1136
|
+
if (!isObject(instance)) throw new Error(i18n`只支持object类型的数据!`);
|
|
1137
1137
|
if (!isObject(data)) data = { data }, data.toString = data.valueOf = toDataString;
|
|
1138
1138
|
if (instance instanceof Array) instance.splice(0, instance.length);
|
|
1139
1139
|
var sample = new LoadingArray;
|
package/coms/zimoli/on.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
if (document.efronton) return document.efronton;
|
|
3
|
-
var is_addEventListener_enabled =
|
|
3
|
+
var is_addEventListener_enabled = !!window.addEventListener;
|
|
4
4
|
// Edg 禁用passive原因:无滚动条的元素上纵向滚动时触发整个页面回弹
|
|
5
5
|
// Chrome 禁用passive原因:无滚动条的元素上横向滚动触发浏览器导航
|
|
6
6
|
var supportPassive = false, preventPassive = /Edg|Chrome/.test(navigator.userAgent);
|
|
@@ -270,9 +270,8 @@ var remove = function (k, hk, [eventtypes, handler, context]) {
|
|
|
270
270
|
element[hk] = null;
|
|
271
271
|
if (element.removeEventListener) {
|
|
272
272
|
element.removeEventListener(k, hs.h, getListenerOption(eventtypes, k));
|
|
273
|
-
} else {
|
|
274
|
-
if (element["on" + k] === hs.h) element["on" + k] = null;
|
|
275
273
|
}
|
|
274
|
+
if (element["on" + k] === hs.h) element["on" + k] = null;
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
};
|
|
@@ -427,7 +426,7 @@ var invoke = function (event, type, pointerType) {
|
|
|
427
426
|
|
|
428
427
|
(function () {
|
|
429
428
|
var pointeractive = null;
|
|
430
|
-
if ("onpointerdown" in
|
|
429
|
+
if ("onpointerdown" in document || document.efronton) return;
|
|
431
430
|
var getPointerType = function (event) {
|
|
432
431
|
return event.type.replace(/(start|move|end|cancel|down|up|leave|out|over|enter)$/i, '');
|
|
433
432
|
};
|