efront 3.34.12 → 3.35.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.
Files changed (81) hide show
  1. package/apps/moue/content//344/275/240/345/245/275/344/270/226/347/225/214.vue +21 -0
  2. package/apps/moue/content//344/275/240/345/245/275/345/274/200/345/217/221/350/200/205.html +1 -0
  3. package/apps/moue/{home/index.js → content//344/275/240/345/245/275/345/274/200/345/217/221/350/200/205.js} +4 -2
  4. package/apps/moue/content//344/275/240/345/245/275/345/274/200/345/217/221/350/200/205.less +4 -0
  5. package/apps/moue/home/index2.vue +97 -18
  6. package/apps/moue/index.html +1 -1
  7. package/coms/basic/ArrayFill.md +9 -0
  8. package/coms/basic/awaitable.md +10 -0
  9. package/coms/basic/backEach.md +7 -0
  10. package/coms/basic/combine.md +23 -0
  11. package/coms/basic/renderExpress.js +3 -2
  12. package/coms/basic/wait.js +5 -0
  13. package/coms/basic_/readme.md +5 -4
  14. package/coms/compile/#/350/257/264/346/230/216.md +1 -0
  15. package/coms/compile/Html.js +263 -0
  16. package/coms/compile/Html_test.js +5 -0
  17. package/coms/compile/Javascript.js +627 -0
  18. package/coms/compile/Program.js +666 -0
  19. package/coms/compile/autoenum.js +179 -0
  20. package/coms/compile/autoenum_test.js +17 -0
  21. package/coms/compile/autoeval.js +50 -0
  22. package/coms/compile/autoeval_test.js +28 -0
  23. package/coms/compile/autoiota.js +121 -0
  24. package/coms/compile/breakcode.js +83 -0
  25. package/coms/compile/common.js +1063 -0
  26. package/coms/compile/downLevel.js +901 -0
  27. package/coms/compile/downLevel_test.js +111 -0
  28. package/coms/compile/formatcode.js +57 -0
  29. package/coms/compile/iso8859.js +9 -0
  30. package/coms/compile/iso8859_test.js +2 -0
  31. package/coms/compile/keywords.js +6 -0
  32. package/coms/compile/namelist.js +154 -0
  33. package/coms/compile/namelist_test.js +7 -0
  34. package/coms/compile/polyfill.js +31 -0
  35. package/coms/compile/required.js +20 -0
  36. package/coms/compile/richcss.js +237 -0
  37. package/coms/compile/richcss_test.js +7 -0
  38. package/coms/compile/scanner.js +653 -0
  39. package/coms/compile/scanner2.js +202 -0
  40. package/coms/compile/scanner2_test.js +110 -0
  41. package/coms/compile/scanner_test.js +10 -0
  42. package/coms/compile/unstruct.js +712 -0
  43. package/coms/compile/unstruct_test.js +54 -0
  44. package/coms/compile/washcode.js +237 -0
  45. package/coms/compile/washcode_test.js +17 -0
  46. package/coms/docs/helps.js +71 -0
  47. package/coms/docs/markdown.js +248 -0
  48. package/coms/frame/route.js +1 -1
  49. package/coms/reptile/colored_console.js +2 -1
  50. package/coms/zimoli/cless.js +1 -0
  51. package/coms/zimoli/css.js +1 -9
  52. package/coms/zimoli/html.js +1 -1
  53. package/coms/zimoli/menu.js +1 -1
  54. package/coms/zimoli/menuItem.html +1 -1
  55. package/coms/zimoli/menuItem.js +1 -1
  56. package/coms/zimoli/render.js +14 -3
  57. package/coms/zimoli/text.js +1 -1
  58. package/coms/zimoli/tree.js +2 -4
  59. package/coms/zimoli/zimoli.js +39 -12
  60. package/docs/compare.md +5 -5
  61. package/docs/components.jsp +24 -0
  62. package/docs/index.html +18 -26
  63. package/docs/main.xht +207 -0
  64. package/docs/mark.xht +171 -0
  65. package/docs/version.jsp +3 -0
  66. package/docs/welcome.jsp +8 -0
  67. package/docs//345/221/275/344/273/244.xht +100 -0
  68. package/docs//347/211/210/346/234/254/350/257/264/346/230/216.md +9 -0
  69. package/docs//347/273/204/344/273/266.xht +111 -0
  70. package/package.json +1 -1
  71. package/public/efront.js +1 -1
  72. package/readme.md +8 -11
  73. package/apis/docs/getAllComponents.js +0 -69
  74. package/apps/moue/home/index.html +0 -1
  75. package/apps/moue/home/index.less +0 -0
  76. package/docs/data/iconfont-kugou.eot +0 -0
  77. package/docs/data/iconfont-kugou.otf +0 -0
  78. package/docs/data/iconfont-kugou.ttf +0 -0
  79. package/docs/data/iconfont-kugou.woff +0 -0
  80. package/docs/data/web.xml +0 -4742
  81. package/docs/main.js +0 -17
@@ -0,0 +1,111 @@
1
+ var downLevel = require("./downLevel");
2
+ // 声明及解构
3
+ assert(downLevel(`const`), 'var');
4
+ assert(downLevel(`let`), 'var');
5
+ assert(downLevel(`var`), 'var');
6
+ assert(downLevel(`const a,b,c`), 'var a, b, c');
7
+ assert(downLevel(`let a,b,c`), 'var a, b, c');
8
+ assert(downLevel(`var a;{let a,b,c}`), 'var a; { var a0 = undefined, b = undefined, c = undefined }');
9
+ assert(downLevel(`var {a,b,c}`), 'var a, b, c');
10
+ assert(downLevel(`let {a,b,c}`), 'var a, b, c');
11
+ assert(downLevel(`const {a,b,c}`), 'var a, b, c');
12
+ assert(downLevel(`var [a,b,c]`), 'var a, b, c');
13
+ assert(downLevel(`var [a,b,c];`), 'var a, b, c;');
14
+ assert(downLevel(`var [a,b,c],{d,e,f};`), 'var a, b, c, d, e, f;');
15
+ assert(downLevel(`var {1:a}`), 'var a');
16
+ assert(downLevel(`var {c:a}`), 'var a');
17
+ assert(downLevel(`var {a}=b`), 'var a = b.a');
18
+ assert(downLevel(`var {a}=1`), 'var a = 1 .a');
19
+ assert(downLevel(`var {a}=1.1`), 'var a = 1.1 .a');
20
+ assert(downLevel(`var {c:a}=b`), 'var a = b.c');
21
+ assert(downLevel(`var {"c":a}=b`), 'var a = b["c"]');
22
+ assert(downLevel(`var {1:a}=b`), 'var a = b[1]');
23
+ assert(downLevel(`var [,a]=b`), 'var a = b[1]');
24
+ assert(downLevel(`var {[c]:a}=b`), 'var a = b[c]');
25
+ assert(downLevel(`var {1:a}=b`), 'var a = b[1]');
26
+ assert(downLevel(`var {.1:a}=b`), 'var a = b[.1]');
27
+ assert(downLevel(`var {a,[a]:c}=b`), 'var a = b.a, c = b[a]');
28
+ assert(downLevel(`var {a}=a`), 'var a = a.a');
29
+ assert(downLevel(`var {a,b}=a`), 'var _ = a, a = a.a, b = _.b');
30
+ assert(downLevel(`var {a:{a:{a}}}=b`), 'var a = b.a.a.a');
31
+ assert(downLevel(`var {a,[a]:c}={}`), 'var _ = {}, a = _.a, c = _[a]');
32
+ assert(downLevel(`={a,[a]:c}={}`), '= _ = {}, a = _.a, c = _[a]');
33
+ assert(downLevel(`function (){var [a]=a;}`), "function () { var a = a[0]; }")
34
+ // 参数解构
35
+ assert(downLevel(`function ([a]){}`), "function (arg) { var a = arg[0]; }")
36
+ assert(downLevel(`function ([a],b){}`), "function (arg0, b) { var a = arg0[0]; }")
37
+ assert(downLevel(`function ([a],{b}){}`), "function (arg0, arg1) { var a = arg0[0], b = arg1.b; }")
38
+ assert(downLevel(`function (){var {a},{b};}`), "function () { var a, b; }")
39
+ assert(downLevel(`function (){var {a}=a,{b}=a;}`), "function () { var a = a.a, b = a.b; }")
40
+ assert(downLevel(`function (a=b){}`), "function (a) { if (a === undefined) a = b; }")
41
+ assert(downLevel(`function (a=b,[c],d,e=f){}`), "function (a, arg1, d, e) { if (a === undefined) a = b; var c = arg1[0]; if (e === undefined) e = f; }")
42
+ assert(downLevel(`function (arg1=b,[c],d,e=f){}`), "function (arg1, arg2, d, e) { if (arg1 === undefined) arg1 = b; var c = arg2[0]; if (e === undefined) e = f; }")
43
+ // class降级
44
+ assert(downLevel(`class a {}`), "function a() {}")
45
+ assert(downLevel(`class a {a=1}`), "function a() { this.a = 1 }")
46
+ assert(downLevel(`class a {a=1; b(){}}`), "function a() { this.a = 1; }; a.prototype.b = function () {}")
47
+ assert(downLevel(`=class a {a=1; b(){}}`), "= function (a) { a.prototype.b = function () {}; return a }(function a() { this.a = 1; })")
48
+ assert(downLevel(`class a {static b(){}}`), "function a() {}; a.b = function () {}")
49
+ assert(downLevel(`class a extends b{}`), "function a() {}; extends_(a, b)");
50
+ assert(downLevel(`class a extends class b{}{}`), "var a = function (b, a) { extends_(a, b); return a }(function b() {}, function a() {})");
51
+ assert(downLevel(`class a {get a(){}}`), `function a() {}; Object.defineProperty(a.prototype, "a", { get: function () {} })`);
52
+ assert(downLevel(`class a {set a(){}}`), `function a() {}; Object.defineProperty(a.prototype, "a", { set: function () {} })`);
53
+ assert(downLevel(`class a {get a(){}; get b(){}; set a(){}}`), `function a() {}; Object.defineProperty(a.prototype, "a", { get: function () {}, set: function () {} }); Object.defineProperty(a.prototype, "b", { get: function () {} });`);
54
+ assert(downLevel(`class a {set a(){}; get b(){}; set a(){}}`), `function a() {}; Object.defineProperty(a.prototype, "a", { set: function () {}, set: function () {} }); Object.defineProperty(a.prototype, "b", { get: function () {} });`);
55
+ // 属性降级
56
+ assert(downLevel(`={[a]:b}`), `= (_ = {}, _[a] = b, _)`);
57
+ assert(downLevel(`={a:1,[a]:1}`), `= (_ = { a: 1 }, _[a] = 1, _)`);
58
+ assert(downLevel(`={a,[a]:1}`), `= (_ = {}, _.a = a, _[a] = 1, _)`);
59
+ assert(downLevel(`={[a]:{[b]:1}}`), `= (_ = {}, _[a] = (_0 = {}, _0[b] = 1, _0), _)`);
60
+ assert(downLevel(`={[a]:{[b]:{[c]:1}}}`), `= (_ = {}, _[a] = (_0 = {}, _0[b] = (_1 = {}, _1[c] = 1, _1), _0), _)`);
61
+ assert(downLevel(`={[a]:{[b]:{[c]:1}},[b]:{[a]:1})}`), `= (_ = {}, _[a] = (_0 = {}, _0[b] = (_1 = {}, _1[c] = 1, _1), _0), _[b] = (_0 = {}, _0[a] = 1, _0), _)`);
62
+ // 对象展开
63
+ assert(downLevel(`={...a}`), `= extend({}, a)`);
64
+ assert(downLevel(`={...{a:1}}`), `= extend({}, { a: 1 })`);
65
+ assert(downLevel(`={...a,...c}`), `= extend({}, a, c)`);
66
+ assert(downLevel(`={...a,b}`), `= (_ = extend({}, a), _.b = b, _)`);
67
+ assert(downLevel(`={...a,b,...c}`), `= (_ = extend({}, a), _.b = b, extend(_, c), _)`);
68
+ assert(downLevel(`={...a,...c,b}`), `= (_ = extend({}, a, c), _.b = b, _)`);
69
+ assert(downLevel(`={...{},...c,b}`), `= (_ = extend({}, {}, c), _.b = b, _)`);
70
+ assert(downLevel(`={a(){},get c(){},b}`), `= (_ = {}, _.a = function () {}, Object.defineProperty(_, "c", { get: function () {} }), _.b = b, _)`);
71
+ assert(downLevel(`=[...a]`), `= Array.prototype.slice.call(a)`)
72
+ assert(downLevel(`=[...a,...b]`), `= (slice_ = Array.prototype.slice).call(a).concat(slice_.call(b))`)
73
+ assert(downLevel(`=[a,...b]`), `= [a].concat(Array.prototype.slice.call(b))`)
74
+ assert(downLevel(`=[a,...b,...c]`), `= [a].concat((slice_ = Array.prototype.slice).call(b), slice_.call(c))`)
75
+ assert(downLevel(`=[a,b,...c]`), `= [a, b].concat(Array.prototype.slice.call(c))`)
76
+ assert(downLevel(`=[a,b,...c,d]`), `= [a, b].concat(Array.prototype.slice.call(c), [d])`)
77
+ assert(downLevel(`=[a,b,...c,d,e,f]`), `= [a, b].concat(Array.prototype.slice.call(c), [d, e, f])`)
78
+ assert(downLevel(`=[a,b,...c,d,e,f,...g]`), `= [a, b].concat((slice_ = Array.prototype.slice).call(c), [d, e, f], slice_.call(g))`)
79
+ assert(downLevel(`=[a,b,...c,d,...e]`), `= [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e))`)
80
+ assert(downLevel(`a(...b)`), `a.apply(null, b)`)
81
+ assert(downLevel(`a(...b,...c)`), `a.apply(null, (slice_ = Array.prototype.slice).call(b).concat(slice_.call(c)))`)
82
+ assert(downLevel(`a(...b,c)`), `a.apply(null, Array.prototype.slice.call(b).concat([c]))`)
83
+ assert(downLevel(`a(b,...c)`), `a.apply(null, [b].concat(Array.prototype.slice.call(c)))`)
84
+ assert(downLevel(`a(a,b,...c,d,...e)`), `a.apply(null, [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e)))`)
85
+ assert(downLevel(`a.call(a,b,...c,d,...e)`), `a.call.apply(a, [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e)))`)
86
+ assert(downLevel(`a.b(a,b,...c,d,...e)`), `a.b.apply(a, [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e)))`)
87
+ assert(downLevel(`[].b(a,b,...c,d,...e)`), `(_ = []).b.apply(_, [a, b].concat((slice_ = Array.prototype.slice).call(c), [d], slice_.call(e)))`)
88
+ assert(downLevel(`a(...b).c(...d)`), `(_ = a.apply(null, b)).c.apply(_, d)`)
89
+ assert(downLevel(`a(...b).c(...d).e(...f)`), `(_ = (_ = a.apply(null, b)).c.apply(_, d)).e.apply(_, f)`)
90
+ // 对象收集
91
+ assert(downLevel(`function (a,...b){}`), "function (a) { var b = Array.prototype.slice.call(arguments, 1); }")
92
+ assert(downLevel(`function (a,...b,c){}`), "function (a, c) { var b = Array.prototype.slice.call(arguments, 1, -1); c = arguments.length > 1 ? arguments[arguments.length - 1] : undefined; }")
93
+ assert(downLevel(`function (a,...,c){}`), "function (a, c) { c = arguments.length > 1 ? arguments[arguments.length - 1] : undefined; }")
94
+ assert(downLevel(`function (a,...b,b){}`), "function (a, b) { b = arguments.length > 1 ? arguments[arguments.length - 1] : undefined; }")
95
+ assert(downLevel(`(a)=>k`), "function (a) { return k }")
96
+ assert(downLevel(`(...a) => k`), "function () { var a = Array.prototype.slice.call(arguments, 0); return k }")
97
+ assert(downLevel(`for(var o of os)`), "for (var _ = 0; _ < os.length && (o = os[_], true); _++)")
98
+ assert(downLevel(`for(var [a] of os)`), "for (var _ = 0; _ < os.length && (a = os[_][0], true); _++)")
99
+ assert(downLevel(`for(var [a,b] of os)`), "for (var _ = 0; _ < os.length && (_0 = os[_], a = _0[0], b = _0[1], true); _++)")
100
+ assert(downLevel(`[...a]=a`), "a = Array.prototype.slice.call(a, 0)")
101
+ assert(downLevel(`[c,...a]=a`), "c = a[0], a = Array.prototype.slice.call(a, 1)")
102
+ assert(downLevel(`[...a]=a`), "a = Array.prototype.slice.call(a, 0)")
103
+ assert(downLevel(`[...a,c]=a`), "_ = a, a = Array.prototype.slice.call(a, 0, -1), c = _.length > 1 ? _[_.length - 1] : undefined")
104
+ assert(downLevel(`{...a,c}=a`), `c = a.c, a = rest_(a, ["c"])`)
105
+ assert(downLevel(`{c,...a}=a`), `c = a.c, a = rest_(a, ["c"])`)
106
+ assert(downLevel(`{c,[c]:b,...a}=a`), `c = a.c, b = a[c], a = rest_(a, ["c", c])`)
107
+ assert(downLevel(`async function(){}`), `function(){return Promise.resolve()}`)
108
+ assert(downLevel(`async function(a){await a}`), `function(a){return Promise.resolve(a)}`)
109
+ assert(downLevel(`async function(a){await a,await b}`), `function(a){return async_(function(){return a},function(){return b}})`)
110
+ assert(downLevel(`async function(){await a,await b}`), `function(){return async_(function(){return a},function(){return b}})`)
111
+ assert(downLevel(`async function(a){ if(c)await a}`), `function(){return Promise.resolve(a).then(b)}`)
@@ -0,0 +1,57 @@
1
+ var {
2
+ SCOPED,
3
+ STAMP,
4
+ STRAP,
5
+ SPACE,
6
+ relink,
7
+ } = require("./common");
8
+ var { createExpressList } = require("./washcode")
9
+ function format(code, step) {
10
+ if (!code.length) return;
11
+ var rest = ["\r\n", code];
12
+ while (rest.length > 0) {
13
+ var code = rest.pop();
14
+ var lowspace = rest.pop();
15
+ var cp = code.prev;
16
+ var cpp = cp && cp.prev;
17
+ if(cpp && cpp.type === STRAP && cpp.text==="switch"){
18
+ lowspace += step;
19
+ }
20
+ var space = lowspace + step;
21
+ if (code.length === 0) continue;
22
+ var explist = createExpressList(code);
23
+ var breakline = explist.length > 1 && (code.isObject || !code.entry || code.entry === "{");
24
+ code.splice(0, code.length);
25
+ if (breakline) code.push({ type: SPACE, text: space });
26
+ if (breakline) var deepspace = space + step;
27
+ else var deepspace = space, space = lowspace;
28
+ var hasCommaBefore = false;
29
+ for (var exp of explist) {
30
+ for (var e of exp) {
31
+ if (breakline && e.type === STRAP) {
32
+ if (/^(else|catch|finally)/.test(e.text)) {
33
+ code.push({ type: SPACE, text: space });
34
+ }
35
+ else if (/^(case|default)$/.test(e.text)) {
36
+ if (code[code.length - 1].type === SPACE) code.pop();
37
+ code.push({ type: SPACE, text: lowspace });
38
+ }
39
+ }
40
+ code.push(e);
41
+ if (e.type === SCOPED) rest.push(space, e);
42
+ }
43
+ if (breakline && (e.type === STAMP && /^[,;]$/.test(e.text) || !code.isClass && !code.isObject)) hasCommaBefore = !code.isObject && e.text === ',', code.push({ type: SPACE, text: hasCommaBefore ? deepspace: space });
44
+ }
45
+ if (breakline) {
46
+ var hasspaceend = code[code.length - 1].type === SPACE;
47
+ code.splice(code.length - hasspaceend, +hasspaceend, { type: SPACE, text: lowspace });
48
+ }
49
+ relink(code);
50
+ }
51
+ }
52
+ module.exports = function (code, tabSize) {
53
+ format(code, new Array(tabSize + 1).join(" "));
54
+ code.keepspace = true;
55
+ code.helpcode = true;
56
+ return code;
57
+ };
@@ -0,0 +1,9 @@
1
+ "use ../../data/iso8859_1.txt";
2
+ var iso8859_map = Object.create(null);
3
+ if (typeof iso8859_1 === 'string') for (let r of iso8859_1.split(/[\r\n]+/)) {
4
+ r = r.split(/\t+/);
5
+ var c = r.pop();
6
+ var d = r.pop();
7
+ iso8859_map[d] = String.fromCharCode(+c.slice(2, -1));
8
+ }
9
+ module.exports = iso8859_map;
@@ -0,0 +1,2 @@
1
+ var iso = require("./iso8859");
2
+ console.log(iso);
@@ -0,0 +1,6 @@
1
+ var keyword = `NaN Infinity break do in typeof case else instanceof var let catch export new void class extends return while const finally super with continue for switch yield debugger function this default if throw delete import try enum await null true false arguments eval`;
2
+ var keywords = {};
3
+ keyword.split(/\s+/g).forEach(function (key) {
4
+ keywords[key] = true;
5
+ });
6
+ module.exports = keywords;
@@ -0,0 +1,154 @@
1
+ var js_keywords = `
2
+ if,in,do,
3
+ var,for,new,try,let,
4
+ this,else,case,void,with,enum,elif,from,
5
+ async,while,break,catch,throw,const,yield,class,await
6
+ return,typeof,delete,switch,export,import,
7
+ default,finally,extends,
8
+ function,continue,debugger,Infinity,abstract,nonlocal,
9
+ null|true|false|NaN|Infinity|undefined|arguments
10
+ instanceof,implements
11
+ `;
12
+ var c_java_go_python = `
13
+ go,or,as,is,
14
+ len,map,int,and,
15
+ make,func,goto,chan,type,sync,byte,char,long,auto,pass,open
16
+ label,purge,stack,
17
+ defer,range,final,float,short,super,union,model,
18
+ global,assert,except,lambda,
19
+ inline,select,struct,public,native,static,strict,throws,double,extern,signed,sizeof
20
+ package,private,boolean,
21
+ typedef
22
+ interface,transient,
23
+ fullthrough
24
+ synchronized
25
+ _Bool,_Complex,_Imaginary
26
+ _Alignas,_Alignof,_Atomic,_Static_assert,_Noreturn,_Thread_local,_Generic
27
+ False,None,True
28
+ strictfp,volatile,unsigned,restrict,
29
+ `
30
+
31
+ var others = `
32
+ fi,md,rd,rm,cd,ls
33
+ rem,
34
+ ren,
35
+ clc,cld,cli,chs,cls,dir,
36
+ cmp
37
+ ins,
38
+ dec,inc,pop,ptr,
39
+ seg,set,
40
+ lea
41
+ shl,shr
42
+ cat
43
+ popa,popf,fstp,fist,fadd,fsub,fmul,fdiv,fild
44
+ endp,ends,proc,idiv,imul,
45
+ call,chcp,
46
+ code,data,even,
47
+ loop,push,
48
+ test,find,
49
+ open,
50
+ exit,
51
+ move,
52
+ copy,
53
+ echo,
54
+ help,
55
+ type,
56
+ popd,
57
+ more,
58
+ wmic,
59
+ setx
60
+ clear,print,
61
+ pushd,
62
+ assoc,ftype,mkdir,xcopy,
63
+ enter,bound,cupid,group,raise,start,local
64
+ subst,
65
+ title,
66
+ fistp,fiadd,fisub,fimul,fidiv,
67
+ rename,
68
+ assume,offset,
69
+ segment,startup,
70
+ template
71
+ `;
72
+ var keywords = [js_keywords, c_java_go_python, others].join("|").trim().split(/[,\r\n\s\|]+/).join("|");
73
+ keywords = new RegExp(`^(${keywords})$`, 'i');
74
+ var source = `abcdefghijklmnopqrstuvwxyz`;
75
+ source += source.toUpperCase() + "_$";
76
+ var number = source + '0123456789';
77
+ // source += "ªµºΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψω";
78
+ source += function () {
79
+ var reg = /\xAA\xB5\xBA\xC0-\xD5\xD8-\xF2\xF8-\u02af\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA/;
80
+ var dist = [];
81
+ reg.source.replace(/\\[xu]([0-9a-f]+)(?:\-\\[xu]([0-9a-f]+))?/ig, function (_, a, b) {
82
+ a = parseInt(a, 16);
83
+ if (!b) {
84
+ dist.push(a);
85
+ return;
86
+ }
87
+ b = parseInt(b, 16);
88
+ while (a <= b) dist.push(a++);
89
+ });
90
+ return String.fromCharCode.apply(String, dist);
91
+ }();
92
+ var source_length = source.length;
93
+ var counts = [
94
+ source_length,
95
+ source_length * 64,
96
+ source_length * 64 * 64,
97
+ source_length * 64 * 64 * 64,
98
+ source_length * 64 * 64 * 64 * 64
99
+ ];
100
+ function create(n, length) {
101
+ var rest = [];
102
+ while (length > 0) {
103
+ rest[length] = (number[n & 0b111111]);
104
+ length--;
105
+ n = n >>> 6;
106
+ }
107
+ rest[0] = source[n];
108
+ return rest.join("");
109
+ }
110
+ var preventList = function (k) {
111
+ for (var i = this.length - 1; i >= 0; i--) {
112
+ if (k in this[i]) return true;
113
+ }
114
+ return false;
115
+ };
116
+ var preventObject = function (k) {
117
+ return k in this;
118
+ };
119
+ var preventNull = function () { return false };
120
+ function namelist(count, prevent, skip) {
121
+ var dist = [];
122
+ if (!prevent) prevent = preventNull;
123
+ else if (prevent instanceof Array) prevent = preventList.bind(prevent);
124
+ else prevent = preventObject.bind(prevent);
125
+ var skip0 = skip;
126
+ for (var cy = 0, dy = counts.length; cy < dy; cy++) {
127
+ if (count <= 0) break;
128
+ var limit = counts[cy];
129
+ if (skip >= limit) {
130
+ skip -= limit;
131
+ continue;
132
+ }
133
+ if (skip) count += skip;
134
+ count -= limit;
135
+ for (var cx = skip | 0, dx = count < 0 ? limit + count : limit; cx < dx; cx++) {
136
+ var a = create(cx, cy);
137
+ if (keywords.test(a) || prevent(a)) {
138
+ if (dx < limit) {
139
+ dx++;
140
+ count++;
141
+ } else {
142
+ count++;
143
+ }
144
+ } else {
145
+ dist.push(a);
146
+ }
147
+ }
148
+ skip0 += dx - skip;
149
+ skip = 0;
150
+ }
151
+ dist.skip = skip0;
152
+ return dist;
153
+ }
154
+ module.exports = namelist;
@@ -0,0 +1,7 @@
1
+ var namelist = require("./namelist");
2
+ var start = new Date;
3
+ namelist(1000000, {});
4
+ var a = namelist(600, {});
5
+ var a = namelist(60, { A: true, _: true, a: 1, s: 1, b: 1, m: 1, aa: 1, a_: 1 });
6
+ console.log(a);
7
+ console.log("生成1百万个变量名,耗时",new Date - start);
@@ -0,0 +1,31 @@
1
+ var { SCOPED } = require("./common");
2
+ var backEach = require("../basic/backEach");
3
+
4
+ var polyfills = Object.assign(Object.create(null), {
5
+ "Object.assign": 'extend'
6
+ });
7
+ var polyfill = function (o, i, used) {
8
+ var v = o.text;
9
+ if (v in polyfills) {
10
+ var p = polyfills[v];
11
+ var n = o.next;
12
+ if (n && n.type === SCOPED && n.entry === '(') {
13
+ if (!this.used[p]) {
14
+ this.used[p] = [];
15
+ this.envs[p] = true;
16
+ }
17
+ o.text = p;
18
+ this.used[p].push(o);
19
+ used.splice(i, 1);
20
+ }
21
+ }
22
+ };
23
+
24
+ module.exports = function (body) {
25
+ var envs = body.envs;
26
+ if (envs.Object) {
27
+ backEach(body.used.Object, polyfill, body);
28
+ if (!body.used.Object.length) delete body.used.Object, delete body.envs.Object;
29
+ }
30
+ return body;
31
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var scanner2 = require("../compile/scanner2");
3
+ var strings = require("../basic/strings");
4
+ function getRequired(data) {
5
+ var code = scanner2(data);
6
+ var { used, envs } = code;
7
+ if (envs.require) var require = used.require;
8
+ if (require instanceof Array) require.map(r => {
9
+ if (r.next && r.next.type === code.SCOPED) {
10
+ var s = r.next;
11
+ var f = s.first;
12
+ if (f && f.type === code.QUOTED && !f.length && /^[`'"]/.test(f.text)) {
13
+ return strings.decode(f.text);
14
+ }
15
+ }
16
+ })
17
+ else require = [];
18
+ return require;
19
+ }
20
+ module.exports = getRequired;
@@ -0,0 +1,237 @@
1
+ var { STAMP, PROPERTY, SCOPED, VALUE, EXPRESS, QUOTED, createString } = require("./common");
2
+ class Richcss extends Program {
3
+ straps = [];
4
+ stamps = `;:`.split("");
5
+ quotes = this.quotes.slice(0, 2);
6
+ scopes = [["{", "}"]]
7
+ }
8
+ Richcss.prototype.setType = function (o) {
9
+ var p = o.prev;
10
+ if (o.type !== SCOPED) {
11
+ if (!p || p.type === STAMP && p.text === ";" || p.type === SCOPED) {
12
+ o.type = PROPERTY;
13
+ return;
14
+ }
15
+ }
16
+ if (!p) return;
17
+ var q = o.queue;
18
+ if (o.type === SCOPED && o.entry === "{") {
19
+ if (p.type & (PROPERTY | EXPRESS) && /@$/.test(p.text)) {
20
+ return false;
21
+ }
22
+ var pps = [];
23
+ while (p && !(p.type === STAMP && p.text === ';' || p.type === SCOPED)) {
24
+ pps.push(p);
25
+ p = p.prev;
26
+ }
27
+ if (pps.length > 1) {
28
+ var i = q.lastIndexOf(p = pps.pop());
29
+ q.splice(i + 1, q.length, o);
30
+ p.next = o;
31
+ p.type = PROPERTY;
32
+ p.end = pps[0].end;
33
+ o.prev = p;
34
+ q.last = o;
35
+ return false;
36
+ }
37
+ }
38
+ if (!q.entry && o.type !== SCOPED) {
39
+ if (o.type !== STAMP || o.text !== ";") return false;
40
+ }
41
+ };
42
+ Richcss.prototype.createScoped = function (code) {
43
+ var run = function (o) {
44
+ var props = Object.create(null);
45
+ var values = null;
46
+ loop: while (o) {
47
+ switch (o.type) {
48
+ case PROPERTY:
49
+ var p = [];
50
+ while (o && !(o.type & (STAMP | SCOPED))) {
51
+ p.push(o.text);
52
+ o = o.next;
53
+ }
54
+ props[p.join(" ")] = values = [];
55
+ if (!o) break loop;
56
+ if (o.type === STAMP) break;
57
+ continue;
58
+ case STAMP:
59
+ if (o.text === ';') break;
60
+ case EXPRESS:
61
+ case VALUE:
62
+ case QUOTED:
63
+ values.push(o.text);
64
+ break;
65
+ case SCOPED:
66
+ var s = run(o.first);
67
+ var vars = null, used = null;
68
+ for (var k in s) {
69
+ var v = s[k];
70
+ if (/^\-\-/.test(k)) {
71
+ if (!vars) vars = {};
72
+ vars[k] = v.join(" ");
73
+ }
74
+ else {
75
+ if (!used) used = [];
76
+ used[k] = v;
77
+ }
78
+ }
79
+ values.used = used;
80
+ values.vars = vars;
81
+
82
+ }
83
+ o = o.next;
84
+ }
85
+ return props;
86
+ };
87
+ return run(code.first);
88
+ };
89
+ Richcss.prototype.createString = createString;
90
+ var getFromScopeList = function (name, varsList, value) {
91
+ for (var cx = varsList.length - 1; cx >= 0; cx--) {
92
+ var o = varsList[cx];
93
+ if (name in o) return o[name];
94
+ }
95
+ return value;
96
+ }
97
+ var fixBase = function (b, a) {
98
+ return a.split(/,\s*/).map(a => {
99
+ var replaced = false;
100
+ a = a.replace(/(:scope|&)/g, function (match) {
101
+ replaced = true;
102
+ return b;
103
+ });
104
+ if (!replaced) {
105
+ if (/^[>~+]/.test(a)) {
106
+ a = b + a;
107
+ }
108
+ else a = b + " " + a;
109
+ }
110
+ return a;
111
+ }).join(",");
112
+ }
113
+ function evalscoped(scoped, scopeNames, base = '') {
114
+ var root = scoped[":root"], scope = scoped[":scope"];
115
+ var vars = Object.create(null);
116
+ if (root) extend(vars, root.vars);
117
+ if (scope) extend(vars, scope.vars);
118
+ scopeNames.forEach(s => {
119
+ var ss = scoped[s];
120
+ if (ss) extend(vars, ss.vars), ss.rooted = true;
121
+ });
122
+ var vlist = [vars];
123
+ var mlist = [];
124
+ var initvars = function (vars) {
125
+ var queue = [];
126
+ for (var k in vars) {
127
+ var v = vars[k];
128
+ while (/^\-\-/.test(v)) {
129
+ if (queue.indexOf(v) >= 0) throw `变量环形引用,无法初始化:${queue}`;
130
+ queue.push(v);
131
+ v = getFromScopeList(v, vlist);
132
+ }
133
+ vars[k] = v;
134
+ }
135
+ };
136
+ initvars(vars);
137
+ var eval2 = function (props) {
138
+ var rest = [];
139
+ var result = [];
140
+ var methods = {};
141
+ mlist.push(methods);
142
+ var evalthis = function (p) {
143
+ if (p.vars) vlist.push(p.vars);
144
+ initvars(p.vars);
145
+ var temp = base;
146
+ base = p.base;
147
+ var res = eval2(p.used);
148
+ base = temp;
149
+ if (p.vars) vlist.pop();
150
+ return res;
151
+ };
152
+ var calcvars = function (v) {
153
+ return v.replace(/(^|\s|[\]\)\(\[\-\+\*\/])(?:var\s*\(([\s\S]*?)\)|(--[^\s]+))/g, function (m, q, a, b) {
154
+ return q + getFromScopeList(b || a.trim(), vlist, m.slice(q.length));
155
+ });
156
+ };
157
+ for (var k in props) {
158
+ var p = props[k];
159
+ if (p.used) {
160
+ var match = /^(@[^\s,]+)\s*\(\s*(@[^\s,]+\s*(?:,\s*@[^\s,]+\s*)*)?\)/.exec(k);
161
+ if (!match) continue;
162
+ p.base = base;
163
+ var [, name, args] = match;
164
+ args = args.split(",").map(a => a.trim());
165
+ p.args = args;
166
+ p.reg = new RegExp(args.join("|"), 'g');
167
+ methods[name] = function () {
168
+ var body = evalthis(this);
169
+ var valueMap = {};
170
+ this.args.forEach((a, i) => {
171
+ valueMap[a] = arguments[i];
172
+ })
173
+ var replace = text => text.replace(this.reg, function (name) {
174
+ if (name in valueMap) return valueMap[name];
175
+ return name;
176
+ });
177
+ var rest = body.rest.map(a => a.map(replace));
178
+ var body = body.map(replace);
179
+ body.rest = rest;
180
+ return body;
181
+ }.bind(p);
182
+ delete props[k];
183
+ }
184
+ }
185
+ for (var k in props) {
186
+ var p = props[k];
187
+ if (p.used) {
188
+ if (base && !p.rooted) p.base = fixBase(base, k);
189
+ else p.base = k;
190
+ var value = evalthis(p);
191
+ if (value.rest.length) rest = rest.concat(value.rest);
192
+ if (value.length) rest.push([p.base, '{', value.join(""), "}"]);
193
+ }
194
+ else if (p.length) {
195
+ result.push(k, ":", calcvars(p.join(" ")), ';');
196
+ }
197
+ else {
198
+ k = calcvars(k);
199
+ var match = /^(@\S+)\s*\(([\s\S]*)\)$/.exec(k);
200
+ if (!match) continue;
201
+ var [, name, params] = match;
202
+ params = params.split(",").map(a => a.trim());
203
+ var method = getFromScopeList(name, mlist);
204
+ if (!isFunction(method)) throw `函数未定义:${name}`;
205
+ var res = method.apply(null, params);
206
+ if (res.rest.length) rest = rest.concat(res.rest);
207
+ if (res.length) result = result.concat(res);
208
+ }
209
+ }
210
+ mlist.pop();
211
+ result.rest = rest;
212
+ return result;
213
+ }
214
+ var result = eval2(scoped, [vars]);
215
+ return result;
216
+ }
217
+ var rcss = null;
218
+ function richcss(text, scopeName, compress) {
219
+ if (!rcss) rcss = new Richcss;
220
+ var code = scanner2(text, rcss);
221
+ var scopeNames = [];
222
+ if (scopeName) code.forEach(c => {
223
+ if (c.type === PROPERTY) {
224
+ var replaced = false;
225
+ c.text = c.text.replace(/\:(scope|root)/g, function () {
226
+ replaced = true;
227
+ return scopeName;
228
+ });
229
+ if (replaced) {
230
+ scopeNames.push(c.text);
231
+ }
232
+ }
233
+ })
234
+ var { scoped } = code;
235
+ var result = evalscoped(scoped, scopeNames, scopeName);
236
+ return result.rest.map(a => a.join("")).concat(result).join(compress ? "" : "\r\n");
237
+ }
@@ -0,0 +1,7 @@
1
+ var test = function (data, expect) {
2
+ assert(richcss(data), expect);
3
+ };
4
+ test(`:scope{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
5
+ test(`:scope{--b:--a;--a:1;}a{opacity:--b}`, `a{opacity:1;}`);
6
+ test(`@a(@p,@b){@p{opacity:@b}}@a(a,1);`, `a{opacity:1;}`);
7
+ test(`@a(a,1);@a(@p,@b){@p{opacity:@b}}`, `a{opacity:1;}`);