efront 4.0.58 → 4.1.1
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 +238 -4
- package/coms/compile/Javascript.js +5 -5
- package/coms/compile/Program.js +1 -1
- package/coms/compile/autoenum.js +92 -56
- package/coms/compile/autoenum_test.js +1 -0
- package/coms/compile/common.js +34 -6
- package/coms/compile/scanner2.js +1 -1
- package/coms/compile/unstruct.js +3 -1
- package/coms/compile/unstruct_test.js +4 -1
- package/coms/compile/{richcss.js → /347/264/240/351/246/250.js} +18 -15
- package/coms/compile/{richcss_test.js → /347/264/240/351/246/250_test.js} +12 -9
- package/coms/docs/codetext.xht +1 -0
- package/coms/zimoli/icon.js +1 -0
- package/docs/version-desc.md +2 -0
- package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +1 -1
- package/docs//345/267/245/345/205/267//346/225/260/345/200/274/346/215/242/347/256/227.xht +14 -14
- package/docs//347/211/210/346/234/254/350/257/264/346/230/216.md +2 -0
- package/docs//347/273/204/344/273/266.xht +1 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
|
@@ -3,7 +3,7 @@ var createString = function (a) {
|
|
|
3
3
|
a.autospace = false;
|
|
4
4
|
return _createString(a);
|
|
5
5
|
};
|
|
6
|
-
class
|
|
6
|
+
class 素玉 extends Program {
|
|
7
7
|
straps = ["and"];
|
|
8
8
|
stamps = ',:;>+~&!/'.split("");
|
|
9
9
|
quotes = this.quotes.slice(0, 2).concat();
|
|
@@ -11,7 +11,7 @@ class Richarg extends Program {
|
|
|
11
11
|
scopes = [["(", ")"], ["{", "}"]];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
var rarg = new
|
|
14
|
+
var rarg = new 素玉;
|
|
15
15
|
rarg.quotes.push(["url(", ")"]);
|
|
16
16
|
var numberReg = /((?:[\+\-]+)?(?:\d+(?:\.\d*)?|\.\d+))(?:\s*(px|%|pt|pc|in|cm|mm|r?em|deg|rad|vw|vh|%))?/;
|
|
17
17
|
var replaceHReg = new RegExp(numberReg.source + /\s*([\/\*])\s*/.source + numberReg.source, 'gi');
|
|
@@ -125,7 +125,7 @@ var createArgMap = function (args, split = ',', equal = ':') {
|
|
|
125
125
|
var args = [];
|
|
126
126
|
while (o) {
|
|
127
127
|
if (!(o.type & (PROPERTY | EXPRESS))) {
|
|
128
|
-
throw new Error(
|
|
128
|
+
throw new Error(i18n`参数异常!`);
|
|
129
129
|
}
|
|
130
130
|
var k = o.text;
|
|
131
131
|
args.push(k);
|
|
@@ -174,7 +174,7 @@ macros.range = function () {
|
|
|
174
174
|
}
|
|
175
175
|
return result;
|
|
176
176
|
}
|
|
177
|
-
throw new Error(
|
|
177
|
+
throw new Error(i18n`range参数错误:` + arguments);
|
|
178
178
|
};
|
|
179
179
|
macros.extract = function (list, index) {
|
|
180
180
|
if (typeof list === 'string') list = list.split(',');
|
|
@@ -223,10 +223,10 @@ macros.grayluma = wrapColor(color.grayluma);
|
|
|
223
223
|
macros.fade = wrapColor(color.fade);
|
|
224
224
|
macros.each = function (list, body) {
|
|
225
225
|
var match = /^(?:\s*[#\.]?\(([\s\S]*?)\))?\s*\{([\s\S]*)\}$/.exec(body);
|
|
226
|
-
if (!match) throw new Error(
|
|
226
|
+
if (!match) throw new Error(i18n`each参数异常!`);
|
|
227
227
|
var [_, args, content] = match;
|
|
228
228
|
if (!content) return;
|
|
229
|
-
content =
|
|
229
|
+
content = 素馨(content);
|
|
230
230
|
if (args) args = args.split(",").map(a => a.trim());
|
|
231
231
|
else args = [];
|
|
232
232
|
if (args.length < 1) args.push("@value");
|
|
@@ -274,7 +274,7 @@ macros.each = function (list, body) {
|
|
|
274
274
|
};
|
|
275
275
|
|
|
276
276
|
|
|
277
|
-
class
|
|
277
|
+
class 素心 extends Program {
|
|
278
278
|
straps = ["and"];
|
|
279
279
|
stamps = `;:,>+~&!/`.split("");
|
|
280
280
|
quotes = rarg.quotes;
|
|
@@ -284,7 +284,7 @@ class Richcss extends Program {
|
|
|
284
284
|
|
|
285
285
|
var presets = /^@(media|keyframes|layer|import|namespace|page|property|suppports|font-face|document|counter-style|charset|color-profile|container|font-feature-values|font-palette-values)(\s|\(|$)/i;
|
|
286
286
|
|
|
287
|
-
|
|
287
|
+
素心.prototype.setType = function (o) {
|
|
288
288
|
var p = o.prev;
|
|
289
289
|
if (o.type !== SCOPED) {
|
|
290
290
|
if (!p || p.type === STAMP && p.text === ";" || p.type === SCOPED && p.entry === '{') {
|
|
@@ -309,7 +309,7 @@ Richcss.prototype.setType = function (o) {
|
|
|
309
309
|
}
|
|
310
310
|
};
|
|
311
311
|
|
|
312
|
-
|
|
312
|
+
素心.prototype.createScoped = function (code) {
|
|
313
313
|
var setVarsUsed = function (s) {
|
|
314
314
|
var vars = null, used = null;
|
|
315
315
|
for (var cx = s.length - 1; cx >= 0; cx--) {
|
|
@@ -336,7 +336,7 @@ Richcss.prototype.createScoped = function (code) {
|
|
|
336
336
|
if (o && (o.type & (SPACE | COMMENT) || o.type === STAMP && o.text === ';')) continue;
|
|
337
337
|
if (o.type !== PROPERTY) {
|
|
338
338
|
console.log(createString([o]), o.type, createString(code))
|
|
339
|
-
throw new Error(
|
|
339
|
+
throw new Error(i18n`结构异常`);
|
|
340
340
|
}
|
|
341
341
|
var p = [], v = [];
|
|
342
342
|
while (o && (o.type !== SCOPED || o.entry !== "{")) {
|
|
@@ -383,7 +383,7 @@ Richcss.prototype.createScoped = function (code) {
|
|
|
383
383
|
};
|
|
384
384
|
return run(code);
|
|
385
385
|
};
|
|
386
|
-
|
|
386
|
+
素心.prototype.createString = createString;
|
|
387
387
|
var getFromScopeList = function (name, varsList, value = name) {
|
|
388
388
|
name = name.replace(/^@\{\s*(\S*)\s*\}$/g, '@$1');
|
|
389
389
|
var queue = [];
|
|
@@ -398,7 +398,8 @@ var getFromScopeList = function (name, varsList, value = name) {
|
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
400
|
return value;
|
|
401
|
-
}
|
|
401
|
+
};
|
|
402
|
+
var removeSelectorSpace = a => a.trim().replace(/\s*([\+~\>])\s*/g, "$1");
|
|
402
403
|
var fixBase = function (b, a) {
|
|
403
404
|
return a.split(/,\s*/).map(a => {
|
|
404
405
|
if (presets.test(a)) a = `@{${a}}`;
|
|
@@ -411,7 +412,7 @@ var fixBase = function (b, a) {
|
|
|
411
412
|
return b;
|
|
412
413
|
});
|
|
413
414
|
if (!replaced) {
|
|
414
|
-
if (/^[
|
|
415
|
+
if (/^[\>~\+]/.test(a) || /[\>~\+]$/.test(b)) {
|
|
415
416
|
a1 = b + a;
|
|
416
417
|
}
|
|
417
418
|
else a1 = b + " " + a;
|
|
@@ -421,6 +422,7 @@ var fixBase = function (b, a) {
|
|
|
421
422
|
}).join(",");
|
|
422
423
|
}
|
|
423
424
|
function evalscoped(scoped, base = '') {
|
|
425
|
+
base = removeSelectorSpace(base);
|
|
424
426
|
var smaps = scoped.maps;
|
|
425
427
|
var root = smaps[":root"], scope = smaps[":scope"];
|
|
426
428
|
var vars = extend(Object.create(null), scoped.vars);
|
|
@@ -530,6 +532,7 @@ function evalscoped(scoped, base = '') {
|
|
|
530
532
|
if (p.isMethod) continue;
|
|
531
533
|
if (p.used) {
|
|
532
534
|
k = calcvars(k);
|
|
535
|
+
k = removeSelectorSpace(k);
|
|
533
536
|
if (base && !p.rooted) p.base = fixBase(base, k);
|
|
534
537
|
else p.base = presets.test(k) ? `@{${k}}` : k;
|
|
535
538
|
if (p.vars) vlist.push(p.vars);
|
|
@@ -561,8 +564,8 @@ function evalscoped(scoped, base = '') {
|
|
|
561
564
|
return result;
|
|
562
565
|
}
|
|
563
566
|
var rcss = null;
|
|
564
|
-
function
|
|
565
|
-
if (!rcss) rcss = new
|
|
567
|
+
function 素馨(text, scopeName, compress) {
|
|
568
|
+
if (!rcss) rcss = new 素心;
|
|
566
569
|
rcss.debug = true;
|
|
567
570
|
var code = scanner2(text, rcss);
|
|
568
571
|
var { scoped } = code;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var test = function (data, expect) {
|
|
2
|
-
assert(
|
|
2
|
+
assert(素馨(data), expect);
|
|
3
3
|
};
|
|
4
4
|
test(`&{--a:1;a{opacity:--a}}`, `a{opacity:1;}`);
|
|
5
5
|
test(`:root{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
|
|
@@ -54,12 +54,15 @@ test(`b{a:darken(#6cd205, 20%)}`, `b{a:#58be00;}`);
|
|
|
54
54
|
test(`b{a:darken(#7ff,10%)}`, `b{a:#6df5f5;}`);
|
|
55
55
|
|
|
56
56
|
test(`:not(a):not(b){c:d}`, `:not(a):not(b){c:d;}`);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
assert(
|
|
61
|
-
assert(
|
|
62
|
-
assert(
|
|
63
|
-
assert(
|
|
57
|
+
test(`a>{b{a:b}}`, `a>b{a:b;}`);
|
|
58
|
+
test(`a >{b{a:b}}`, `a>b{a:b;}`);
|
|
59
|
+
test(`a{>b{a:b}}`, `a>b{a:b;}`);
|
|
60
|
+
assert(素馨(`:not(a):not(b){c:d}`, 'abc'), `abc :not(a):not(b){c:d;}`);
|
|
61
|
+
assert(素馨(`&:not(a):not(b){c:d}`, 'abc'), `abc:not(a):not(b){c:d;}`);
|
|
62
|
+
assert(素馨(`:scope{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
|
|
63
|
+
assert(素馨(`:root{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
|
|
64
|
+
assert(素馨(`&{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
|
|
65
|
+
assert(素馨(`:root>a{&:not(a):not(b){c:d}}`, '.abc-'), `.abc->a:not(a):not(b){c:d;}`);
|
|
66
|
+
assert(素馨(`a>:root{&:not(a):not(b){c:d}}`, '.abc-'), `a>.abc-:not(a):not(b){c:d;}`);
|
|
64
67
|
|
|
65
|
-
assert(
|
|
68
|
+
assert(素馨(`.a (){ &:after{abc:1}} .b{.a();}`, '.abc-'), `.abc- .b:after{abc:1;}`);
|
package/coms/docs/codetext.xht
CHANGED
|
@@ -173,6 +173,7 @@
|
|
|
173
173
|
javascript(a, blink) {
|
|
174
174
|
if (blink) var index = a.indexOf(blink);
|
|
175
175
|
if (index >= 0) a = a.slice(0, index) + a.slice(index + 1);
|
|
176
|
+
js.keepspace = !!blink;
|
|
176
177
|
var c = compile$scanner2(a, js);
|
|
177
178
|
if (index >= 0) {
|
|
178
179
|
var patched = patchBlink(c, index, blink);
|
package/coms/zimoli/icon.js
CHANGED
package/docs/version-desc.md
CHANGED
|
@@ -9,3 +9,5 @@
|
|
|
9
9
|
3.x With a self built grammar parser, `efront` no longer relies on `esprima`, `esmangle`, and `escodegen`. The self compilation time has gradually decreased from the original 10 minute Github workflow to about 2 minutes.
|
|
10
10
|
|
|
11
11
|
4.0 No longer relying on `typescript` (nearly 170000 lines of source code), the compilation speed has increased by four times, the memory usage has been reduced to 1/8 of the original, and the self compilation time on GitHub has also been reduced to about 15 seconds.
|
|
12
|
+
|
|
13
|
+
4.1 No longer relying on `less-node` or `pngjs`, while the `less-node` is replaced with [suxin](https://www.npmjs.com/package/suxin) from `efront`.
|
|
@@ -6,37 +6,37 @@
|
|
|
6
6
|
var _value = 0;
|
|
7
7
|
var parseFloat = (a, b) => new BigNumber(a, b);
|
|
8
8
|
var value = {
|
|
9
|
-
get
|
|
9
|
+
get [i18n`十进制`]() {
|
|
10
10
|
return _value;
|
|
11
11
|
},
|
|
12
|
-
set
|
|
12
|
+
set [i18n`十进制`](v) {
|
|
13
13
|
_value = parseFloat(v)
|
|
14
14
|
},
|
|
15
|
-
get
|
|
15
|
+
get [i18n`十六进制`]() {
|
|
16
16
|
return _value.toString(16);
|
|
17
17
|
},
|
|
18
|
-
set
|
|
18
|
+
set [i18n`十六进制`](v) {
|
|
19
19
|
_value = parseFloat(v, 16);
|
|
20
20
|
},
|
|
21
|
-
get
|
|
21
|
+
get [i18n`二进制`]() {
|
|
22
22
|
return _value.toString(2);
|
|
23
23
|
},
|
|
24
|
-
set
|
|
24
|
+
set [i18n`二进制`](v) {
|
|
25
25
|
_value = parseFloat(v, 2);
|
|
26
26
|
},
|
|
27
|
-
get
|
|
27
|
+
get [i18n`八进制`]() {
|
|
28
28
|
return _value.toString(8)
|
|
29
29
|
},
|
|
30
|
-
set
|
|
30
|
+
set [i18n`八进制`](v) {
|
|
31
31
|
_value = parseFloat(v, 8)
|
|
32
32
|
},
|
|
33
|
-
get
|
|
33
|
+
get [i18n`三十六进制`]() {
|
|
34
34
|
return _value.toString(36);
|
|
35
35
|
},
|
|
36
|
-
set
|
|
36
|
+
set [i18n`三十六进制`](v) {
|
|
37
37
|
_value = parseFloat(v, 36);
|
|
38
38
|
},
|
|
39
|
-
get
|
|
39
|
+
get [i18n`浮点数机器码`]() {
|
|
40
40
|
var v = +_value;
|
|
41
41
|
var s = /^-/.test(v);
|
|
42
42
|
if (s) v = -v;
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
v = s << 31 | i << 23 | v & 0x7fffff;
|
|
47
47
|
return [v >> 24 & 0xff, v >> 16 & 0xff, v >> 8 & 0xff, v & 0xff].map(hex).join('');
|
|
48
48
|
},
|
|
49
|
-
set
|
|
49
|
+
set [i18n`浮点数机器码`](v) {
|
|
50
50
|
v = parseInt(v, 16);
|
|
51
51
|
var s = v >> 31;
|
|
52
52
|
var i = v >> 23 & 0xff;
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
if (s) v = -v;
|
|
57
57
|
_value = v;
|
|
58
58
|
},
|
|
59
|
-
get
|
|
59
|
+
get [i18n`双精度机器码`]() {
|
|
60
60
|
var s = /^-/.test(_value);
|
|
61
61
|
var v = window.parseFloat(_value);
|
|
62
62
|
if (s) v = -v;
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
v >> 8 & 0xff, v & 0xff
|
|
73
73
|
].map(hex).join('');
|
|
74
74
|
},
|
|
75
|
-
set
|
|
75
|
+
set [i18n`双精度机器码`](v) {
|
|
76
76
|
var s = parseInt(v[0], 16) >> 3;
|
|
77
77
|
var i = parseInt(v.slice(0, 3), 16) & 0x7ff;
|
|
78
78
|
v = parseInt(v.slice(3), 16);
|
|
@@ -9,3 +9,5 @@
|
|
|
9
9
|
3.x版本 `efront`拥有自建的语法解析器,不再依赖`esprima`、`esmangle`、`escodegen`,自我编译耗时由原来的10分钟github工作流,逐步减少到2分钟左右。
|
|
10
10
|
|
|
11
11
|
4.0版本 不再依赖`typescipt`(近17万行源码),编译速度再次提升4倍,占用内存减少到原来的1/8,github上自我编译时间也减少到15秒左右。
|
|
12
|
+
|
|
13
|
+
4.1版本 不再依赖`less-node`和`pngjs`,其中`less-node` 由`efront`自建的css工具[素馨](https://www.npmjs.com/package/suxin)代替。
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
var cssWrap = `css-` + +new Date;
|
|
201
201
|
if (scope.doc.test.indexOf(lessName) >= 0) {
|
|
202
202
|
lessData = await cross("get", "./components:" + modName + ".less");
|
|
203
|
-
lessData = compile
|
|
203
|
+
lessData = compile$素馨(lessData.responseText, "." + cssWrap);
|
|
204
204
|
if (code.isExpressQueue()) {
|
|
205
205
|
codetext = `return cless(${codetext},\`${lessData}\`,"${cssWrap}")`;
|
|
206
206
|
}
|