efront 4.4.12 → 4.4.14
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 +885 -66
- package/apps/reptile/encode.js +1 -1
- package/coms/basic/#loader.js +4 -4
- package/coms/basic/BigNumber.js +6 -6
- package/coms/basic/BitTree.js +1 -1
- package/coms/basic/Enum.js +1 -1
- package/coms/basic/Matrix.js +1 -1
- package/coms/basic/analyse_test.js +1 -1
- package/coms/basic/assert.js +1 -1
- package/coms/basic/color.js +1 -1
- package/coms/basic/compile.js +1 -1
- package/coms/basic/cross_.js +2 -2
- package/coms/basic/crypt.js +3 -3
- package/coms/basic/decodePack.js +3 -3
- package/coms/basic/deepEqual.js +1 -1
- package/coms/basic/encodeRange_test.js +1 -1
- package/coms/basic/encodeUTF16.js +2 -2
- package/coms/basic/encodeUTF8.js +1 -1
- package/coms/basic/i18n.md +4 -2
- package/coms/basic/parseYML.js +2 -2
- package/coms/basic/refilm.js +2 -2
- package/coms/basic/repeat.js +1 -1
- package/coms/basic/submit_.js +4 -4
- package/coms/basic_/Array2.js +2 -2
- package/coms/basic_/Promise.js +1 -1
- package/coms/basic_/exec_.js +1 -1
- package/coms/compile/Javascript.js +2 -2
- package/coms/compile/Program.js +1 -1
- package/coms/compile/common.js +27 -4
- package/coms/compile/downLevel.js +5 -5
- package/coms/compile/translate.js +29 -11
- package/coms/compile/translate_test.js +8 -0
- package/coms/compile/unstruct.js +9 -4
- package/coms/compile/unstruct_test.js +2 -1
- package/coms/compile/washcode.js +2 -2
- package/coms/docs/execute.js +1 -1
- package/coms/explorer/Explorer.js +6 -6
- package/coms/explorer/context.js +16 -16
- package/coms/explorer/deepcp.js +2 -2
- package/coms/explorer/edit.html +3 -3
- package/coms/frame/chat.html +2 -2
- package/coms/frame/route.js +1 -1
- package/coms/kugou/parseSongsList.js +1 -1
- package/coms/reptile/colored_console.js +8 -2
- package/coms/reptile/cross.js +1 -1
- package/coms/reptile/decodeHttpResponse.js +1 -1
- package/coms/reptile/detectWithExtension.js +1 -1
- package/coms/zimoli/Enum.js +1 -1
- package/coms/zimoli/api.js +19 -19
- package/coms/zimoli/avatarEditor.js +1 -1
- package/coms/zimoli/care.js +3 -3
- package/coms/zimoli/cast.js +1 -1
- package/coms/zimoli/chooseFile.js +2 -2
- package/coms/zimoli/clock.js +1 -1
- package/coms/zimoli/confirm.js +2 -2
- package/coms/zimoli/createElement.js +2 -2
- package/coms/zimoli/cross.js +3 -3
- package/coms/zimoli/css.js +1 -1
- package/coms/zimoli/downloadmap.js +2 -2
- package/coms/zimoli/filterTime.js +1 -1
- package/coms/zimoli/grid.js +4 -4
- package/coms/zimoli/icon.js +1 -1
- package/coms/zimoli/list.js +1 -1
- package/coms/zimoli/mediaDevices.js +1 -1
- package/coms/zimoli/menu.js +1 -1
- package/coms/zimoli/on.js +3 -3
- package/coms/zimoli/overlap_test.js +1 -1
- package/coms/zimoli/popup.js +2 -2
- package/coms/zimoli/render.js +10 -10
- package/coms/zimoli/table.js +1 -1
- package/coms/zimoli/watch.js +1 -1
- package/coms/zimoli/zimoli.js +3 -3
- package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +12 -4
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/coms/kugou/fxPlayer.js +0 -12474
package/apps/reptile/encode.js
CHANGED
package/coms/basic/#loader.js
CHANGED
|
@@ -670,16 +670,16 @@ var initPixelDecoder = function () {
|
|
|
670
670
|
if (pixelDecoder instanceof Function) {
|
|
671
671
|
modules.fromPixel = pixelDecoder;
|
|
672
672
|
modules.freePixel = window.freePixel || function () {
|
|
673
|
-
throw new Error(
|
|
673
|
+
throw new Error(`您在window上实现了pixelDecoder,请手动实现相应的freePixel!`);
|
|
674
674
|
};
|
|
675
675
|
modules.calcPixel = window.calcPixel || function () {
|
|
676
|
-
throw new Error(
|
|
676
|
+
throw new Error(`您在window上实现了pixelDecoder,请手动实现相应的calcPixel!`);
|
|
677
677
|
};
|
|
678
678
|
modules.fromOffset = window.fromOffset || function () {
|
|
679
|
-
throw new Error(
|
|
679
|
+
throw new Error(`您在window上实现了pixelDecoder,请手动实现相应的fromOffset!`);
|
|
680
680
|
};
|
|
681
681
|
modules.freeOffset = window.freeOffset || function () {
|
|
682
|
-
throw new Error(
|
|
682
|
+
throw new Error(`您在window上实现了pixelDecoder,请手动实现相应的freeOffset!`);
|
|
683
683
|
};
|
|
684
684
|
return;
|
|
685
685
|
}
|
package/coms/basic/BigNumber.js
CHANGED
|
@@ -111,8 +111,8 @@ class BigNumber {
|
|
|
111
111
|
if (!system_scale) {
|
|
112
112
|
system_scale = 10;
|
|
113
113
|
}
|
|
114
|
-
if (system_scale === 1) throw new Error(
|
|
115
|
-
if (system_scale < 1) throw new Error(
|
|
114
|
+
if (system_scale === 1) throw new Error(i18n`不支持半年级数数进制!`);
|
|
115
|
+
if (system_scale < 1) throw new Error(i18n`不支持小于1的进位方针!`);
|
|
116
116
|
var BACK_DIGIT = BigNumber.DECIMAL_DIGIT;
|
|
117
117
|
var digit = value.indexOf('.');
|
|
118
118
|
if (digit < 0) digit = 0;
|
|
@@ -153,7 +153,7 @@ class BigNumber {
|
|
|
153
153
|
v = +v;
|
|
154
154
|
}
|
|
155
155
|
else v = vmap[v];
|
|
156
|
-
if (v !== v || v >= system_scale || v !== +v) throw new Error(
|
|
156
|
+
if (v !== v || v >= system_scale || v !== +v) throw new Error(i18n`数据错误!`);
|
|
157
157
|
|
|
158
158
|
if (dotOccurs) {
|
|
159
159
|
num = BigNumber.add(num, BigNumber.div(v, scale, BigNumber.DECIMAL_DIGIT))
|
|
@@ -178,7 +178,7 @@ class BigNumber {
|
|
|
178
178
|
if (收起零) 有效数字位数 = -有效数字位数;
|
|
179
179
|
var zero = system_scale <= 36 ? '0' : '[0]';
|
|
180
180
|
if (!system_scale || system_scale === 10) return this.value || zero;
|
|
181
|
-
if (system_scale <= 1) throw new Error(
|
|
181
|
+
if (system_scale <= 1) throw new Error(i18n`进制错误!`);
|
|
182
182
|
var BACK_DIGIT = BigNumber.DECIMAL_DIGIT;
|
|
183
183
|
if (!有效数字位数) 有效数字位数 = Math.ceil((this.digit || BigNumber.DECIMAL_DIGIT) / Math.log10(system_scale));
|
|
184
184
|
BigNumber.DECIMAL_DIGIT = 有效数字位数 + 10 + system_scale;
|
|
@@ -262,7 +262,7 @@ class BigNumber {
|
|
|
262
262
|
static fix(numstr, fractionDigits) {
|
|
263
263
|
fractionDigits = +fractionDigits || 0;
|
|
264
264
|
if (fractionDigits < 0 || fractionDigits > BigNumber.DECIMAL_DIGIT) {
|
|
265
|
-
throw new Error(`小数位数只能是0和${BigNumber.DECIMAL_DIGIT}之间的数字`);
|
|
265
|
+
throw new Error(i18n`小数位数只能是0和${BigNumber.DECIMAL_DIGIT}之间的数字`);
|
|
266
266
|
}
|
|
267
267
|
return fixde(numstr, fractionDigits, 4);
|
|
268
268
|
}
|
|
@@ -373,7 +373,7 @@ class BigNumber {
|
|
|
373
373
|
}
|
|
374
374
|
// 按整数除法,超出输入的数字的位数之和
|
|
375
375
|
static div(numstr1, numstr2, decimal) {
|
|
376
|
-
if (isEmpty(decimal)) throw new Error(
|
|
376
|
+
if (isEmpty(decimal)) throw new Error(i18n`请输入保留小数的位数!`);
|
|
377
377
|
var [neg1, s11, s12] = prepare(numstr1);
|
|
378
378
|
var [neg2, s21, s22] = prepare(numstr2);
|
|
379
379
|
var d = s12.length + decimal - s22.length;
|
package/coms/basic/BitTree.js
CHANGED
|
@@ -11,7 +11,7 @@ class BitTree extends Array {
|
|
|
11
11
|
if (a === undefined) a = 1;
|
|
12
12
|
for (var cx = 0, dx = arr.length; cx < dx; cx++)arr[cx] = a;
|
|
13
13
|
}
|
|
14
|
-
if (!arr || !arr.length) throw new Error(
|
|
14
|
+
if (!arr || !arr.length) throw new Error(i18n`参数错误!`);
|
|
15
15
|
this.counts = arr;
|
|
16
16
|
this.rebuild();
|
|
17
17
|
}
|
package/coms/basic/Enum.js
CHANGED
package/coms/basic/Matrix.js
CHANGED
|
@@ -390,7 +390,7 @@ function cross(vec1, vec2) {
|
|
|
390
390
|
if (vec1.length !== vec2.length) throw notMatchLength;
|
|
391
391
|
if (vec1.length === 2) return cross2(vec1, vec2);
|
|
392
392
|
if (vec1.length === 3) return cross3(vec1, vec2);
|
|
393
|
-
throw new Error(
|
|
393
|
+
throw new Error(i18n`向量维度不支持!`);
|
|
394
394
|
}
|
|
395
395
|
function 负(a) {
|
|
396
396
|
return -a;
|
|
@@ -36,7 +36,7 @@ function testcode(dir) {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
function analyse_test(text) {
|
|
39
|
-
if (!require) return console.log(
|
|
39
|
+
if (!require) return console.log(i18n`请在electron中打开`);
|
|
40
40
|
fs = require("fs");
|
|
41
41
|
path = require("path");
|
|
42
42
|
if (text) return analyse(text);
|
package/coms/basic/assert.js
CHANGED
|
@@ -10,7 +10,7 @@ else {
|
|
|
10
10
|
var crack = [, ,];
|
|
11
11
|
}
|
|
12
12
|
var dump = function (a, msg) {
|
|
13
|
-
if (a instanceof Object) console.error(
|
|
13
|
+
if (a instanceof Object) console.error(i18n`属性错误`), console.log(msg ? msg + " " : " {\r\n", Object.keys(a).map(k => ` ${k}${gray.join(':')}\r\n ${a[k]}`).join('\r\n') + "\r\n }");
|
|
14
14
|
else if (msg) console.log(msg + ":", a);
|
|
15
15
|
else console.log(a);
|
|
16
16
|
};
|
package/coms/basic/color.js
CHANGED
|
@@ -263,7 +263,7 @@ function doWith(manager, color, ...args) {
|
|
|
263
263
|
var isparsed = color instanceof Array,
|
|
264
264
|
c = isparsed ? color : parse(color);
|
|
265
265
|
if (!c) {
|
|
266
|
-
console.warn(`颜色数据不正确:${color}`);
|
|
266
|
+
console.warn(i18n`颜色数据不正确:${color}`);
|
|
267
267
|
return color;
|
|
268
268
|
}
|
|
269
269
|
c = manager(c, ...args);
|
package/coms/basic/compile.js
CHANGED
package/coms/basic/cross_.js
CHANGED
|
@@ -128,7 +128,7 @@ function createResponse(response, status = 0) {
|
|
|
128
128
|
*/
|
|
129
129
|
function cross_(jsonp, digest = noop, method, url, headers) {
|
|
130
130
|
var originDomain = getDomainPath(url);
|
|
131
|
-
if (!originDomain) throw new Error(
|
|
131
|
+
if (!originDomain) throw new Error(i18n`路径格式错误!`);
|
|
132
132
|
var loaded, errored;
|
|
133
133
|
var onload = function (data) {
|
|
134
134
|
if (!~requests.indexOf(_xhr)) return;
|
|
@@ -217,7 +217,7 @@ function cross_(jsonp, digest = noop, method, url, headers) {
|
|
|
217
217
|
|
|
218
218
|
}
|
|
219
219
|
if (exposeMap["strict-transport-security"] || exposeMap["efront-transport-security"]) {
|
|
220
|
-
if (!/^https\:\/\/|^s\/\//.test(url)) console.warn(
|
|
220
|
+
if (!/^https\:\/\/|^s\/\//.test(url)) console.warn(i18n`请使用https访问如下路径:` + url);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
if (isencrypt && xhr.response) {
|
package/coms/basic/crypt.js
CHANGED
|
@@ -23,7 +23,7 @@ var encrypt = function (data, mask) {
|
|
|
23
23
|
};
|
|
24
24
|
var stringify = function (data, password) {
|
|
25
25
|
if (!password || password.length < 2) {
|
|
26
|
-
throw new Error(
|
|
26
|
+
throw new Error(i18n`请传入更高强度的密码!`);
|
|
27
27
|
}
|
|
28
28
|
data = JSAM.stringify(data);
|
|
29
29
|
var code = calc("password", password) + password;
|
|
@@ -33,11 +33,11 @@ var stringify = function (data, password) {
|
|
|
33
33
|
};
|
|
34
34
|
var parse = function (data, password) {
|
|
35
35
|
var d = data.lastIndexOf('/');
|
|
36
|
-
if (d < 0) throw new Error(
|
|
36
|
+
if (d < 0) throw new Error(i18n`数据异常!`);
|
|
37
37
|
var sign = data.slice(d);
|
|
38
38
|
data = data.slice(0, d);
|
|
39
39
|
var sign0 = calc(data, password);
|
|
40
|
-
if (sign !== sign0) throw new Error(
|
|
40
|
+
if (sign !== sign0) throw new Error(i18n`密码不正确!`);
|
|
41
41
|
var code = calc("password", password) + password;
|
|
42
42
|
data = encrypt(data, code);
|
|
43
43
|
return data;
|
package/coms/basic/decodePack.js
CHANGED
|
@@ -77,7 +77,7 @@ function fromhuff(buff, result = [], scanstart, type) {
|
|
|
77
77
|
"\r\nbitwidth:", t,
|
|
78
78
|
"\r\ncodemap:", map
|
|
79
79
|
);
|
|
80
|
-
throw console.warn(
|
|
80
|
+
throw console.warn(i18n`数据异常!`);
|
|
81
81
|
}
|
|
82
82
|
bitoffset = bitoffset + endflag[1];
|
|
83
83
|
return bitoffset;
|
|
@@ -190,11 +190,11 @@ function unpack(buff) {
|
|
|
190
190
|
result.push(res);
|
|
191
191
|
break;
|
|
192
192
|
default:
|
|
193
|
-
throw new Error(
|
|
193
|
+
throw new Error(i18n`编码异常!`);
|
|
194
194
|
}
|
|
195
195
|
break;
|
|
196
196
|
default:
|
|
197
|
-
throw new Error(
|
|
197
|
+
throw new Error(i18n`数据异常!`);
|
|
198
198
|
}
|
|
199
199
|
} while (byteoffset + 1 < buff.length);
|
|
200
200
|
result = concatByte(result);
|
package/coms/basic/deepEqual.js
CHANGED
|
@@ -8,7 +8,7 @@ var checkMemery = function (msg) {
|
|
|
8
8
|
if (count > inc) {
|
|
9
9
|
inc = (count / ALLOW_CACHE_LENGTH + 1 | 0) * ALLOW_CACHE_LENGTH;
|
|
10
10
|
if (inc >= ALLOW_REST_DEPTH * ALLOW_CACHE_LENGTH) {
|
|
11
|
-
console.warn("
|
|
11
|
+
console.warn(i18n`对象过大,${"deepEqual"}未能完成比对`);
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
console.warn(msg);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function numberUTF16(t, dist = []) {
|
|
2
2
|
if (t > 0x10ffff) {
|
|
3
|
-
throw new Error(
|
|
3
|
+
throw new Error(i18n`编码错误`);
|
|
4
4
|
}
|
|
5
5
|
if (t <= 0xffff) {
|
|
6
6
|
dist.push(t >> 8, t & 0xff);
|
|
@@ -13,7 +13,7 @@ function numberUTF16(t, dist = []) {
|
|
|
13
13
|
}
|
|
14
14
|
function numberUTF16LE(t, dist = []) {
|
|
15
15
|
if (t > 0x10ffff) {
|
|
16
|
-
throw new Error(
|
|
16
|
+
throw new Error(i18n`编码错误`);
|
|
17
17
|
}
|
|
18
18
|
if (t <= 0xffff) {
|
|
19
19
|
dist.push(t & 0xff, t >> 8);
|
package/coms/basic/encodeUTF8.js
CHANGED
package/coms/basic/i18n.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
国际化工具的时的语法如下:
|
|
2
2
|
```javascript
|
|
3
|
-
i18n`中文内容${参数}
|
|
3
|
+
i18n`中文内容${参数}`
|
|
4
4
|
```
|
|
5
5
|
在项目目录存在指定的国际化文件时,efront会自动转换为类似如下版本,具体语言语种及内容以国际化文件为主:
|
|
6
6
|
|
|
7
7
|
```javascript
|
|
8
|
-
i18n(`中文内容${参数}`,`English Content${参数}`)
|
|
8
|
+
i18n(`中文内容${参数}`,`English Content${参数}`);
|
|
9
|
+
// 如果参数中有破坏型的执行体,将转换为如下形式来保证参数中的代码只执行一次
|
|
10
|
+
i18n(()=>`中文内容${参数}`,()=>`English Content${参数}`)()
|
|
9
11
|
```
|
|
10
12
|
国际化文件可以在文档国际化工具中扫描生成。
|
package/coms/basic/parseYML.js
CHANGED
|
@@ -169,13 +169,13 @@ var scan = function (text) {
|
|
|
169
169
|
push();
|
|
170
170
|
break;
|
|
171
171
|
case "]":
|
|
172
|
-
if (jsonlikes[jsonlikes.length - 1] !== "[") console.warn(
|
|
172
|
+
if (jsonlikes[jsonlikes.length - 1] !== "[") console.warn(i18n`数据存在错误!`, jsonlikes, pre);
|
|
173
173
|
if (data) push();
|
|
174
174
|
jsonlikes.pop();
|
|
175
175
|
parents.pop();
|
|
176
176
|
break;
|
|
177
177
|
case "}":
|
|
178
|
-
if (jsonlikes[jsonlikes.length - 1] !== "{") console.warn(
|
|
178
|
+
if (jsonlikes[jsonlikes.length - 1] !== "{") console.warn(i18n`数据存在错误!`, jsonlikes, pre);
|
|
179
179
|
if (prop !== undefined || data) push();
|
|
180
180
|
jsonlikes.pop();
|
|
181
181
|
parents.pop();
|
package/coms/basic/refilm.js
CHANGED
|
@@ -36,12 +36,12 @@ var writeField = refilm.writeField = function (data, field, value, offset = fiel
|
|
|
36
36
|
v.push(value & 0xff);
|
|
37
37
|
value = value >>> 8;
|
|
38
38
|
}
|
|
39
|
-
if (value) throw new Error(
|
|
39
|
+
if (value) throw new Error(i18n`数据过大`);
|
|
40
40
|
value = v;
|
|
41
41
|
}
|
|
42
42
|
else value = [value | 0];
|
|
43
43
|
if (value.length > byteLimit) {
|
|
44
|
-
throw new Error(
|
|
44
|
+
throw new Error(i18n`数据超出大小限制!`);
|
|
45
45
|
}
|
|
46
46
|
var offset = field.offset;
|
|
47
47
|
while (value.length) data[offset++] = value.shift();
|
package/coms/basic/repeat.js
CHANGED
package/coms/basic/submit_.js
CHANGED
|
@@ -49,15 +49,15 @@ function submit(fields, data) {
|
|
|
49
49
|
}
|
|
50
50
|
if (checks.length + select.length + inputs.length) {
|
|
51
51
|
var errors = [];
|
|
52
|
-
if (inputs.length) errors.push(
|
|
53
|
-
if (select.length) errors.push(
|
|
52
|
+
if (inputs.length) errors.push(i18n`请输入` + inputs.map(trimname).join(i18n`、`));
|
|
53
|
+
if (select.length) errors.push(i18n`请选择` + select.map(trimname).join(i18n`、`));
|
|
54
54
|
if (select.id < inputs.id) {
|
|
55
55
|
errors = errors.reverse();
|
|
56
56
|
}
|
|
57
57
|
if (checks.length) {
|
|
58
|
-
errors.push(
|
|
58
|
+
errors.push(i18n`您输入的${checks.map(trimname).join(i18n`、`)}有误`);
|
|
59
59
|
}
|
|
60
|
-
errors = errors.join(
|
|
60
|
+
errors = errors.join(i18n`,`) + i18n`!`;
|
|
61
61
|
throw errors;
|
|
62
62
|
}
|
|
63
63
|
return params;
|
package/coms/basic_/Array2.js
CHANGED
|
@@ -5,7 +5,7 @@ a: if (!setPrototypeOf) {
|
|
|
5
5
|
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
6
6
|
var defineProperty = Object.defineProperty;
|
|
7
7
|
try {
|
|
8
|
-
if (!getOwnPropertyNames) throw
|
|
8
|
+
if (!getOwnPropertyNames) throw i18n`不支持`;
|
|
9
9
|
defineProperty({}, 'o', { value: 0 });
|
|
10
10
|
setPrototypeOf = function (obj, proto) {
|
|
11
11
|
var names = getOwnPropertyNames(proto)
|
|
@@ -22,7 +22,7 @@ a: if (!setPrototypeOf) {
|
|
|
22
22
|
getOwnPropertyNames = null;
|
|
23
23
|
}
|
|
24
24
|
// <!--
|
|
25
|
-
console.error(
|
|
25
|
+
console.error(i18n`当前运行环境使用class extends Array会有难以解决的不兼容性问题,请更换代码的实现方式!`);
|
|
26
26
|
// -->
|
|
27
27
|
setPrototypeOf = function (obj, proto) {
|
|
28
28
|
for (var p in proto) if (hasOwnProperty.call(proto, p) && !(p in obj)) obj[p] = proto[p];
|
package/coms/basic_/Promise.js
CHANGED
|
@@ -33,7 +33,7 @@ if (!Promise) {
|
|
|
33
33
|
t.throwed = true;
|
|
34
34
|
if (!throwed && !PromiseRejectReactions.length) {
|
|
35
35
|
// <!--
|
|
36
|
-
console.warn(
|
|
36
|
+
console.warn(i18n`在异步过程中发现未处理的异常:`, t.ohed[0], t.ohed[1], t.ohed[2]);
|
|
37
37
|
// -->
|
|
38
38
|
requestAnimationFrame(function () {
|
|
39
39
|
throw t.ohed[0];
|
package/coms/basic_/exec_.js
CHANGED
|
@@ -82,7 +82,7 @@ var exec_ = function (args, ok, oh, int) {
|
|
|
82
82
|
case 7: index++; catches.push([index, p]); break; // try catch finally?
|
|
83
83
|
case 8: index++; catches.push([index, p, 1]); break; // try finally
|
|
84
84
|
case 9: return p ? fine() : fina(); // finally
|
|
85
|
-
default: throw console.log(a),
|
|
85
|
+
default: throw console.log(a), i18n`代码异常!`;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
retn();
|
|
@@ -478,7 +478,7 @@ var collectProperty = function (o, text) {
|
|
|
478
478
|
while (n && (n.type !== STAMP || n.text !== ',')) n = n.next;
|
|
479
479
|
var end = n ? q.indexOf(n, start) + 1 : q.length;
|
|
480
480
|
var s = splice(q, start, end - start);
|
|
481
|
-
if (s.length) console.info(`属性<green>${text}</green>被后文覆盖,已移除<yellow>${createString(s)}</yellow>\r\n`);
|
|
481
|
+
if (s.length) console.info(i18n`属性<green>${text}</green>被后文覆盖,已移除<yellow>${createString(s)}</yellow>\r\n`);
|
|
482
482
|
if (p && n) {
|
|
483
483
|
var pp = p.prev;
|
|
484
484
|
n.prev = pp;
|
|
@@ -829,7 +829,7 @@ var removeExport = function (c, i, code) {
|
|
|
829
829
|
return;
|
|
830
830
|
}
|
|
831
831
|
var nn = n.next;
|
|
832
|
-
if (!nn) throw new Error(
|
|
832
|
+
if (!nn) throw new Error(i18n`缺少导出项!`);
|
|
833
833
|
if (nn.type === SCOPED && nn.entry !== '{' && c.prev) {
|
|
834
834
|
if (c.prev.type !== STAMP || c.prev.text !== ';') {
|
|
835
835
|
code.splice(i++, 0, { type: STAMP, text: ';' });
|
package/coms/compile/Program.js
CHANGED
|
@@ -670,7 +670,7 @@ class Program {
|
|
|
670
670
|
if (q.length > 2) {
|
|
671
671
|
ts.push(...q.slice(0, q.length - 2));
|
|
672
672
|
}
|
|
673
|
-
else if (q.length !== 2) throw new Error(
|
|
673
|
+
else if (q.length !== 2) throw new Error(i18n`配置错误!`);
|
|
674
674
|
q = q[q.length - 2];
|
|
675
675
|
}
|
|
676
676
|
if (q instanceof RegExp) {
|
package/coms/compile/common.js
CHANGED
|
@@ -558,7 +558,7 @@ var createScoped = function (parsed, wash) {
|
|
|
558
558
|
if (o.next.type === STAMP) {
|
|
559
559
|
isAster = true;
|
|
560
560
|
o = o.next;
|
|
561
|
-
o.isExpress = op
|
|
561
|
+
o.isExpress = op?.isExpress;
|
|
562
562
|
}
|
|
563
563
|
case "catch":
|
|
564
564
|
if (s === 'catch') isCatch = true;
|
|
@@ -917,7 +917,7 @@ var getDeclared = function (o, kind, queue) {
|
|
|
917
917
|
break;
|
|
918
918
|
default:
|
|
919
919
|
console.log(o);
|
|
920
|
-
throw new Error(
|
|
920
|
+
throw new Error(i18n`代码结构异常`);
|
|
921
921
|
}
|
|
922
922
|
if (!o) break;
|
|
923
923
|
switch (o.type) {
|
|
@@ -932,7 +932,7 @@ var getDeclared = function (o, kind, queue) {
|
|
|
932
932
|
o.prev.equal = o;
|
|
933
933
|
o = o.next;
|
|
934
934
|
var o0 = skipAssignment(o);
|
|
935
|
-
if (isrest) throw
|
|
935
|
+
if (isrest) throw i18n`余集变量不能有默认值`;
|
|
936
936
|
attributes[attributes.length - 1].push(queue, o, o0);
|
|
937
937
|
while (o !== o0) {
|
|
938
938
|
skiped.push(o);
|
|
@@ -1046,7 +1046,7 @@ var createString = function (parsed) {
|
|
|
1046
1046
|
var helpcode = parsed.helpcode;
|
|
1047
1047
|
var express_reg = parsed.program?.express_reg;
|
|
1048
1048
|
if (typeof helpcode === 'string') {
|
|
1049
|
-
if (express_reg && !express_reg.test(helpcode.replace(/[\/\||,]/g, ''))) throw new Error(
|
|
1049
|
+
if (express_reg && !express_reg.test(helpcode.replace(/[\/\||,]/g, ''))) throw new Error(i18n`辅助级别异常:` + debug);
|
|
1050
1050
|
if (/[\/\|,]/i.test(helpcode)) var debug = `(?:${helpcode.replace(/[\/\|,]/g, '|')})`;
|
|
1051
1051
|
else debug = helpcode;
|
|
1052
1052
|
}
|
|
@@ -1374,6 +1374,28 @@ var canbeTemp = function (body, strip = false) {
|
|
|
1374
1374
|
if (!o) return false;
|
|
1375
1375
|
return o.type === EXPRESS && (strip || !/[\.\[]/.test(o.text)) || o.type === VALUE || o.type === QUOTED && !o.length;
|
|
1376
1376
|
};
|
|
1377
|
+
var canbeDuplicate = function (body) {
|
|
1378
|
+
for (var b of body) {
|
|
1379
|
+
switch (b.type) {
|
|
1380
|
+
case EXPRESS:
|
|
1381
|
+
if (/[\.\[]/.test(b.text)) return false;
|
|
1382
|
+
break;
|
|
1383
|
+
case SCOPED:
|
|
1384
|
+
if (b.isObject || b.isClass || b.entry === '[') return false;
|
|
1385
|
+
if (!isEval(b)) return false;
|
|
1386
|
+
if (!canbeTemp(b)) return false;
|
|
1387
|
+
break;
|
|
1388
|
+
case QUOTED:
|
|
1389
|
+
if (b.length && !canbeTemp(b)) return false;
|
|
1390
|
+
break;
|
|
1391
|
+
case STAMP:
|
|
1392
|
+
if (/^(\+\+|\-\-)$|^([^\=\>\<]+|>>>?|<<)?\=$/.test(b.text)) return false;
|
|
1393
|
+
break;
|
|
1394
|
+
case ELEMENT: return false;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
return true;
|
|
1398
|
+
};
|
|
1377
1399
|
var pickArgument = function (o) {
|
|
1378
1400
|
var res = [];
|
|
1379
1401
|
var t = o && o.prev, p = o;
|
|
@@ -1457,6 +1479,7 @@ module.exports = {
|
|
|
1457
1479
|
setqueue,
|
|
1458
1480
|
replace,
|
|
1459
1481
|
canbeTemp,
|
|
1482
|
+
canbeDuplicate,
|
|
1460
1483
|
skipFunction,
|
|
1461
1484
|
isHalfSentence,
|
|
1462
1485
|
splice,
|
|
@@ -4,9 +4,9 @@ var Program = scanner2.Program;
|
|
|
4
4
|
var { STAMP, SCOPED, STRAP, EXPRESS, COMMENT, SPACE, PROPERTY, VALUE, LABEL, QUOTED, snapExpressFoot, isEval, canbeTemp, rename, isHalfSentence, skipFunction, getDeclared, skipAssignment, skipSentenceQueue, 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
|
-
if (cx < 0) throw console.log(splice2.caller, console.format(
|
|
7
|
+
if (cx < 0) throw console.log(splice2.caller, console.format(`\r\n<red2>${i18n`自`}</red2>`), from && createString([from]), console.format(`\r\n<yellow>${i18n`至`}</yellow>`), to && createString([to]), console.format(`\r\n<cyan>${i18n`码列`}</cyan>`), createString(q)), i18n`结构异常`;
|
|
8
8
|
var dx = to ? q.indexOf(to, cx) : q.length;
|
|
9
|
-
if (dx < 0) throw console.log(splice2.caller, console.format(
|
|
9
|
+
if (dx < 0) throw console.log(splice2.caller, console.format(`\r\n<yellow>${i18n`自`}</yellow>`), from && createString([from]), console.format(`\r\n<red2>${i18n`至`}</red2>`), to && createString([to]), console.format(`\r\n<cyan>${i18n`码列`}</cyan>`), createString(q)), i18n`结构异常`;
|
|
10
10
|
return splice(q, cx, dx - cx, ...a);
|
|
11
11
|
};
|
|
12
12
|
var insert1 = function (q, r, ...a) {
|
|
@@ -52,7 +52,7 @@ var killdec = function (queue, i, getobjname, _var = 'var', killobj, islet) {
|
|
|
52
52
|
var [k, v] = d;
|
|
53
53
|
var dp = 0;
|
|
54
54
|
if (typeof k === 'number' && k < 0) {
|
|
55
|
-
if (iter) throw
|
|
55
|
+
if (iter) throw i18n`暂不支持在当前语境读取尾部非剩余元素`;
|
|
56
56
|
dp = 1;
|
|
57
57
|
k = `${tmpname}["length"]>${doged - k - 1}?${tmpname}[${tmpname}["length"] - ${-k}]:undefined`;
|
|
58
58
|
} else {
|
|
@@ -1270,7 +1270,7 @@ var killarg = function (head, body, _getname, setarg = true) {
|
|
|
1270
1270
|
index++;
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
|
-
else throw
|
|
1273
|
+
else throw i18n`参数声明异常!`
|
|
1274
1274
|
if (o && o.type === STAMP) {
|
|
1275
1275
|
if (o.text === ',') {
|
|
1276
1276
|
o = o.next; continue;
|
|
@@ -1589,7 +1589,7 @@ var down = function (scoped) {
|
|
|
1589
1589
|
var body = scoped.body;
|
|
1590
1590
|
if (!body) {
|
|
1591
1591
|
var btemp = scoped.head.next;
|
|
1592
|
-
if (!btemp) throw
|
|
1592
|
+
if (!btemp) throw i18n`语句不完整`;
|
|
1593
1593
|
var btmp2 = skipSentenceQueue(btemp);
|
|
1594
1594
|
body = scoped.body = scanner2('{}')[0];
|
|
1595
1595
|
splice(body, 0, 0, ...splice2(btemp.queue, btemp, btmp2, body));
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
var scanner2 = require("./scanner2");
|
|
2
|
-
var { SCOPED, QUOTED, SCOPED, PROPERTY, STAMP, PIECE, setqueue, splice, relink, number_reg, replace, createString } = require("./common");
|
|
2
|
+
var { SCOPED, QUOTED, SCOPED, PROPERTY, STAMP, PIECE, setqueue, splice, relink, number_reg, replace, canbeDuplicate, createString } = require("./common");
|
|
3
3
|
var strings = require("../basic/strings");
|
|
4
4
|
var program = null;
|
|
5
5
|
var patchTranslate = function (c) {
|
|
6
6
|
if (c.length) {
|
|
7
|
-
|
|
7
|
+
var canbeDup = true;
|
|
8
|
+
c.translate = c.map((o, i) => {
|
|
9
|
+
if (o.type === PIECE) return strings.decode(`\`${o.text}\``);
|
|
10
|
+
if (canbeDup && !canbeDuplicate(o)) canbeDup = false;
|
|
11
|
+
return `$${i + 1 >> 1}`;
|
|
12
|
+
}).join('').replace(/\r\n|\r|\n/g, '\r\n');
|
|
13
|
+
c.nodup = !canbeDup;
|
|
8
14
|
}
|
|
9
15
|
else {
|
|
10
16
|
if (/^['"`]/.test(c.text) && c.text.length > 2) {
|
|
@@ -74,7 +80,7 @@ var ctn = function (tt, t) {
|
|
|
74
80
|
if (a in t) return `\${${a}}`;
|
|
75
81
|
return _;
|
|
76
82
|
}));
|
|
77
|
-
tn[
|
|
83
|
+
(tn[0].type === SCOPED ? tn[0] : tn[1]).forEach(n => {
|
|
78
84
|
if (n.type !== QUOTED || !n.length) return;
|
|
79
85
|
n.forEach((a, i) => {
|
|
80
86
|
if (a.type !== SCOPED) return;
|
|
@@ -91,13 +97,25 @@ function translate([imap, supports], code) {
|
|
|
91
97
|
if (a.start > b.start && a.end < b.end) return -1;
|
|
92
98
|
return 0;
|
|
93
99
|
});
|
|
94
|
-
var getm = function (tt, warn) {
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
var getm = function (tt, nodup, warn) {
|
|
101
|
+
var mq = /^(\s*)([\s\S]*?)(\s*)$/.exec(tt);
|
|
102
|
+
var mq = [mq[1] || '', mq[2], mq[3] || ''];
|
|
103
|
+
var tt = mq[1];
|
|
104
|
+
var wrap = m => {
|
|
105
|
+
mq[1] = m || tt;
|
|
106
|
+
return strings.encode(mq.join(''), '`');
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
var imp = imap[tt];
|
|
110
|
+
if (!imp) {
|
|
97
111
|
if (warn !== false) console.warn(`<yellow>${i18n`国际化翻译缺失:`}</yellow>${tt}`);
|
|
98
|
-
imap[tt] = supports.map(_ => tt);
|
|
112
|
+
imp = imap[tt] = supports.map(_ => tt);
|
|
99
113
|
}
|
|
100
|
-
|
|
114
|
+
if (nodup && imp.length <= 1) nodup = false;
|
|
115
|
+
var mp = nodup ? m => "()=>" + wrap(m) : m => wrap(m);
|
|
116
|
+
var m = `(${imp.map(mp)})`;
|
|
117
|
+
if (nodup) m += '()';
|
|
118
|
+
return m;
|
|
101
119
|
};
|
|
102
120
|
var used = code.used;
|
|
103
121
|
for (var t of texts) {
|
|
@@ -109,8 +127,8 @@ function translate([imap, supports], code) {
|
|
|
109
127
|
p.leave = ")";
|
|
110
128
|
}
|
|
111
129
|
var tt = t.translate;
|
|
112
|
-
var tn = ctn(
|
|
113
|
-
replace(t, tn
|
|
130
|
+
var tn = ctn(getm(tt, t.nodup), t);
|
|
131
|
+
replace(t, ...tn);
|
|
114
132
|
}
|
|
115
133
|
else if (t.transtype === 字段名) {
|
|
116
134
|
var i = t.queue.indexOf(t.prev);
|
|
@@ -138,7 +156,7 @@ function translate([imap, supports], code) {
|
|
|
138
156
|
if (a in t) v = t[a];
|
|
139
157
|
else v = scanner2(JSON.stringify(v));
|
|
140
158
|
}
|
|
141
|
-
else if (k === 'name') v = ctn(
|
|
159
|
+
else if (k === 'name') v = ctn('i18n' + getm(v, t.nodup, t.warn), t);
|
|
142
160
|
else v = scanner2(JSON.stringify(v));
|
|
143
161
|
o.push({ type: PROPERTY, isprop: true, text: JSON.stringify(k) }, { type: STAMP, text: ':' }, ...v, { type: STAMP, text: ',' });
|
|
144
162
|
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var test = function (src, text, expact) {
|
|
2
|
+
var code = scanner2(text);
|
|
3
|
+
translate([src, Object.keys(src)], code);
|
|
4
|
+
assert(code.toString(), expact);
|
|
5
|
+
};
|
|
6
|
+
test({ "a$1b": ["a$1b", "c$1d"] }, 'i18n`a${a}b`', 'i18n(`a${a}b`, `c${a}d`)')
|
|
7
|
+
test({ "a$1b": ["a$1b", "c$1d"] }, 'i18n`a${a++}b`', 'i18n(() => `a${a++}b`, () => `c${a++}d`)()')
|
|
8
|
+
test({ "a$1b": ["c$1d"] }, 'i18n`a${a++}b`', 'i18n(`c${a++}d`)')
|