efront 3.34.11 → 3.35.0

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 (76) 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 +1 -1
  12. package/coms/basic/wait.js +5 -0
  13. package/coms/basic_/readme.md +27 -9
  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 +594 -0
  18. package/coms/compile/Program.js +664 -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/transition.js +4 -4
  59. package/coms/zimoli/tree.js +2 -2
  60. package/coms/zimoli/zimoli.js +39 -12
  61. package/docs/compare.md +5 -5
  62. package/docs/components.jsp +17 -0
  63. package/docs/index.html +16 -26
  64. package/docs/main.xht +182 -0
  65. package/docs/mark.xht +166 -0
  66. package/docs/welcome.jsp +7 -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 +87 -0
  70. package/package.json +1 -1
  71. package/public/efront.js +1 -1
  72. package/readme.md +6 -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/main.js +0 -17
@@ -0,0 +1,179 @@
1
+ var { skipAssignment, snapSentenceHead, EXPRESS, SCOPED, QUOTED, VALUE, STRAP, STAMP, number_reg, createString } = require("./common");
2
+ var strings = require("../basic/strings");
3
+
4
+ var createRefId = function (o) {
5
+ var ids = [], refs = [];
6
+ var g = o;
7
+ o.refs = refs;
8
+ while (o) {
9
+ if (o.type === SCOPED) {
10
+ if (o.entry !== '[') break;
11
+ var t = o.last;
12
+ if (!t) throw new Error("格式错误");
13
+ if (t.type === QUOTED) {
14
+ if (!t.length) {
15
+ if (/\.|^#/.test(t.text)) {
16
+ ids.push(`[${t.text}]`);
17
+ }
18
+ else {
19
+ ids.push(strings.decode(t.text));
20
+ }
21
+ }
22
+ else {
23
+ ids.push("[*]");
24
+ break;
25
+ }
26
+ }
27
+ }
28
+ else if (o.type === EXPRESS) {
29
+ var t = o.text.replace(/^\.\.\.|\.\.\.$/g, "").replace(/^[^\.\[]+/, '');
30
+ t.replace(/[^\.\[]+|\[[\s\S]*?\]/g, function (m) {
31
+ if (/^\[/.test(m)) {
32
+ ids.push(strings.decode(m.slice(1, -1)));
33
+ }
34
+ else {
35
+ ids.push("." + m);
36
+ }
37
+ })
38
+ }
39
+ else {
40
+ break;
41
+ }
42
+ var n = o.next;
43
+ refs.push(o);
44
+ if (!n) break;
45
+ if (n.type === EXPRESS && !/\.$/.test(o.text) && !/^[\.\[]/.test(n.text)) break;
46
+ o = n;
47
+ }
48
+ if (o && o.type === SCOPED && o.entry === '(') {
49
+ g.called = true;
50
+ }
51
+ return ids.join('');
52
+ }
53
+ var maplist = function (u) {
54
+ var map = Object.create(null);
55
+ for (var o of u) {
56
+ var r = createRefId(o);
57
+ if (!map[r]) {
58
+ map[r] = [];
59
+ map[r].wcount = 0;
60
+ map[r].ccount = 0;
61
+ }
62
+ map[r].push(o);
63
+ if (o.equal || o.kind) map[r].wcount++;
64
+ if (o.called) map[r].ccount++;
65
+ }
66
+ return map;
67
+ }
68
+ function createRefMap(scoped) {
69
+ var { used } = scoped;
70
+ var refs = Object.create(null);
71
+ for (var k in used) refs[k] = maplist(used[k]);
72
+ scoped.forEach(createRefMap);
73
+ return scoped.refs = refs;
74
+ }
75
+ function removeRefs(o) {
76
+ var refs = o.refs;
77
+ if (!refs || !refs.length) return;
78
+ var q = o.queue;
79
+ var start = q.indexOf(o) + 1;
80
+ var r = refs[refs.length - 1];
81
+ var end = q.indexOf(r) + 1;
82
+ q.splice(start, end - start);
83
+ o.next = r.next;
84
+ if (o.next) o.next.prev = o;
85
+ }
86
+
87
+ function inCondition(o) {
88
+ // 只检查一级
89
+ var incondition = false;
90
+ while (o && o.prev) {
91
+ o = snapSentenceHead(o);
92
+ var p = o.prev;
93
+ if (!p) break;
94
+ if (p.type === SCOPED) {
95
+ if (p.entry !== "(") break;
96
+ if (!p.prev) break;
97
+ var pp = p.prev;
98
+ if (pp.type === STRAP) {
99
+ if (/^(?:if|for|with)$/.test(pp.text)) {
100
+ incondition = true;
101
+ break;
102
+ }
103
+ if (/^(?:while)$/.test(pp.text)) {
104
+ var ppp = pp.prev;
105
+ if (!ppp || !ppp.prev) {
106
+ incondition = true;
107
+ break;
108
+ }
109
+ var pppp = ppp.prev;
110
+ if (pppp.type === STRAP && pppp.text === "do") break;
111
+ incondition = true;
112
+ break;
113
+ }
114
+ }
115
+ break;
116
+ }
117
+ if (p.type === STAMP) {
118
+ if (p.text === ";") break;
119
+ o = p.prev;
120
+ continue;
121
+ }
122
+ break;
123
+ }
124
+ return incondition;
125
+
126
+ }
127
+
128
+ function enumref(scoped) {
129
+ if (scoped.isfunc) {
130
+ var { refs } = scoped;
131
+ for (var k in refs) {
132
+ var rs = refs[k];
133
+ for (var rk in rs) {
134
+ var os = rs[rk];
135
+ if (os.wcount !== 1 || os.length < 2) continue;
136
+ var eq = null;
137
+ loop: for (var o of os) {
138
+ if (o.equal) {
139
+ if (o.equal.text !== '=') break;
140
+ if (o.queue.kind) break;
141
+ if (o.queue !== scoped.body) break;
142
+ if (inCondition(o)) break;
143
+ o = o.equal.next;
144
+ var n = skipAssignment(o);
145
+ var exps = [];
146
+ do {
147
+ exps.push(o);
148
+ o = o.next;
149
+ } while (o && o !== n);
150
+ if (exps.length !== 1) break loop;
151
+ eq = exps[0];
152
+ if (eq.type !== VALUE || !eq.isdigit) {
153
+ eq = null;
154
+ }
155
+ }
156
+ else {
157
+ if (!eq) break;
158
+ o.type = eq.type;
159
+ o.isdigit = true;
160
+ o.text = eq.text;
161
+ removeRefs(o);
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
167
+ scoped.forEach(enumref)
168
+ }
169
+
170
+ function atuoenum(scoped) {
171
+ createRefMap(scoped);
172
+ enumref(scoped);
173
+ }
174
+ var exports = module.exports = function main(code) {
175
+ atuoenum(code.scoped)
176
+ return code;
177
+ }
178
+ exports.createRefId = createRefId;
179
+ exports.createRefMap = createRefMap;
@@ -0,0 +1,17 @@
1
+ var scanner2 = require("./scanner2");
2
+ var { createString } = require("./common");
3
+ var autoenum = require("./autoenum");
4
+ var t = function (str, want) {
5
+ var code = scanner2(str)
6
+ var code = autoenum(code);
7
+ var result = createString(code);
8
+ assert(result, want);
9
+ }
10
+ t("var a=1;console.log(a)", "var a = 1; console.log(1)");
11
+ t("a.b = 2;console.log(a.b)", "a.b = 2; console.log(2)");
12
+ t("a/*a*/.b = 2;console.log(a.b)", "a/*a*/.b = 2; console.log(2)");
13
+ t("a.b = 2;console.log(a/*aaaa*/.b)", "a.b = 2; console.log(2)");
14
+ t("a.b = 2;console.log(/*bbbb*/a.b)", "a.b = 2; console.log(/*bbbb*/2)");
15
+ t("var {a=1};console.log(a)", "var { a = 1 }; console.log(a)");
16
+ t("if(c) a=1;console.log(a)", "if (c) a = 1; console.log(a)");
17
+ // t(fs.readFileSync(path.join(__dirname,"../zimoli/spacechar_test.js")).toString())
@@ -0,0 +1,50 @@
1
+ var { skipAssignment, createString, QUOTED, STAMP, SCOPED, VALUE, SPACE, COMMENT, relink } = require("./common");
2
+
3
+ var calculate = function (body) {
4
+ for (var cx = 0; cx < body.length; cx) {
5
+ var o = body[cx];
6
+ while (o && (o.type & (SPACE | COMMENT) || o.type === STAMP && /^[,;:]$/.test(o.text))) o = body[++cx];
7
+ if (!o) break;
8
+ var ox = cx;
9
+ var ex = skipAssignment(body, cx++);
10
+ cx = ex;
11
+ var ignore = false;
12
+ for (var cy = ox; cy < ex; cy++) {
13
+ var o = body[cy];
14
+ if (o.type & (SCOPED | QUOTED) && o.length) {
15
+ calculate(o);
16
+ if (o.type === SCOPED && o.entry === '(') {
17
+ var p = o.prev;
18
+ if (!p || p.type === STAMP || p.type === VALUE && p.isdigit) {
19
+ if (o.last.type === VALUE && o.last.isdigit) {
20
+ if ((o.first === o.last)) {
21
+ o.type = VALUE;
22
+ o.text = o.last.text;
23
+ o.isdigit = true;
24
+ }
25
+ else if (o.first.next === o.last && o.first.type === STAMP && /^[+-~]+$/.test(o.first.text)) {
26
+ o.type = VALUE;
27
+ o.text = eval(o.first.text + o.last.text);
28
+ o.isdigit = true;
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ if (!(o.type & (STAMP | VALUE | SPACE | COMMENT))) ignore = true;
35
+ else if (o.type === VALUE && !o.isdigit) ignore = true;
36
+ }
37
+ if (ignore || ex - ox < 3) continue;
38
+ var o = body[ox];
39
+ o.text = eval(createString(body.slice(ox, ex)));
40
+ cx = ox + 1;
41
+ body.splice(cx, ex - cx);
42
+ }
43
+ relink(body);
44
+ return body;
45
+ };
46
+
47
+ module.exports = function autoeval(body) {
48
+ calculate(body);
49
+ return body;
50
+ }
@@ -0,0 +1,28 @@
1
+ var { createString } = require("./common");
2
+ var autoeval = require("./autoeval");
3
+ var autoenum = require("./autoenum");
4
+ var scanner2 = require("./scanner2");
5
+ var t = function (str, want) {
6
+ var code = scanner2(str);
7
+ code = autoenum(code);
8
+ code = autoeval(code);
9
+ var result = createString(code);
10
+ assert(result, want);
11
+ };
12
+ var tf = function (fullpath) {
13
+ var data = fs.readFileSync(fullpath).toString()
14
+ t(data, data);
15
+ }
16
+ t("1+1", "2");
17
+ t("1+3", "4");
18
+ t("(1+3)", "4");
19
+ t("(-1)*(1+3)", "-4");
20
+ t("(-+-+-1)*(1+3)", "-4");
21
+ t("(~1)*(1+3)", "-8");
22
+ t("(1*-1)+(1+3)", "3");
23
+ t("1+(1+3)", "5");
24
+ t("a(1+3)", "a(4)");
25
+ t("(1+3,5,3+4)", "(4, 5, 7)");
26
+ t("(1>>3,5,3+4)", "(0, 5, 7)");
27
+ t("a=1,b=2;(a|b)&c", "a = 1, b = 2; 3 & c");
28
+ // tf(path.join(__dirname, "../zimoli/spacechar_test.js"))
@@ -0,0 +1,121 @@
1
+ var { skipAssignment, createString, createScoped, relink, STRAP, STAMP, SCOPED, EXPRESS, VALUE, SPACE, COMMENT } = require("./common");
2
+ var backEach = require("../basic/backEach");
3
+ var scanner2 = require("./scanner2");
4
+
5
+ var removeNew = function (a, ai) {
6
+ var p = a.prev;
7
+ if (p && p.type === STRAP && p.text === 'new') {
8
+ ai = a.queue.lastIndexOf(p, ai);
9
+ a.queue.splice(ai, 1);
10
+ }
11
+ return ai;
12
+ };
13
+ var assignIota = function (v) {
14
+ var p = v.prev;
15
+ if (!p || p.type !== STAMP || p.text !== '=') return;
16
+ var pp = p.prev;
17
+ if (!pp || pp.type !== SCOPED || pp.entry !== '[') return;
18
+ var ppp = pp.prev;
19
+ if (ppp) if (ppp.type !== STRAP || !/^(var|let|const)$/.test(ppp.text)) return;
20
+ var o = skipAssignment(v);
21
+ if (v.next !== o) return;
22
+ var vmap = [];
23
+ var i = 0;
24
+ for (var va of v) {
25
+ if (va.type === STAMP && va.text === ',') {
26
+ i++;
27
+ continue;
28
+ }
29
+ if (!vmap[i]) vmap[i] = [];
30
+ vmap[i].push(va);
31
+ }
32
+ var ppmap = [];
33
+ var ppval = [];
34
+ var pptmp = null;
35
+ var i = 0;
36
+ for (var ppa of pp) {
37
+ if (ppa.type === SPACE || ppa.type === COMMENT) continue;
38
+ if (ppa.type === STAMP) {
39
+ if (ppa.text === ',') {
40
+ if (pptmp && pptmp.length) {
41
+ ppval[i] = pptmp;
42
+ }
43
+ i++;
44
+ pptmp = null;
45
+ continue;
46
+ }
47
+ if (!pptmp && ppa.text === '=') {
48
+ pptmp = [];
49
+ continue;
50
+ }
51
+ }
52
+ if (pptmp) pptmp.push(pp);
53
+ else {
54
+ if (!ppmap[i]) ppmap[i] = [];
55
+ ppmap[i].push(ppa);
56
+ }
57
+ }
58
+ if (pptmp && pptmp.length) ppval[i] = pptmp;
59
+ var res = [];
60
+ ppmap.forEach((ppm, i) => {
61
+ if (!ppm) return;
62
+ var eq = { type: STAMP, text: '=' };
63
+ if (vmap[i]) res.push(...ppm, eq, ...vmap[i]);
64
+ else if (ppval[i]) res.push(...ppm, eq, ...ppval[i]);
65
+ else res.push(...ppm);
66
+ res.push({ type: STAMP, text: "," });
67
+ });
68
+ res.pop();
69
+ var ppi = p.queue.indexOf(pp);
70
+ var vi = p.queue.indexOf(v, ppi);
71
+ p.queue.splice(ppi, vi - ppi + 1, ...res);
72
+ relink(p.queue);
73
+ }
74
+ var arrayFillMap = function (a, i, as) {
75
+ if (a.text !== 'Array' || !a.next) return;
76
+ var n = a.next;
77
+ if (!n || n.type !== SCOPED || n.entry !== '(') return;
78
+ var nn = n.next;
79
+ if (!nn || nn.type !== EXPRESS || nn.text !== ".fill") return;
80
+ var nnn = nn.next;
81
+ if (!nnn || nnn.type !== SCOPED || nnn.entry !== '(') return;
82
+ var mn = nnn.next;
83
+ var f = n.first;
84
+ var mnn = mn.next;
85
+ if (!f || f.type !== VALUE || !f.isdigit ||
86
+ !mn || mn.type !== EXPRESS || mn.text !== '.map' ||
87
+ !mnn || mnn.type !== SCOPED || mnn.entry !== "(" ||
88
+ Object.keys(createScoped(mnn).used).length > 0) {
89
+ var ni = a.queue.indexOf(n);
90
+ var nnni = a.queue.indexOf(nnn, ni);
91
+ if (!f) {
92
+ a.queue.splice(n + 1, nnni - ni);
93
+ relink(a.queue);
94
+ return;
95
+ }
96
+ a.queue.splice(ni, nnni - ni);
97
+ nnn.unshift({ type: STAMP, text: ',' });
98
+ nnn.unshift.apply(nnn, n);
99
+ a.text = "ArrayFill";
100
+ as.splice(i, 1);
101
+ if (!this.envs.ArrayFill) this.envs.ArrayFill = true;
102
+ if (!this.used.ArrayFill) this.used.ArrayFill = [];
103
+ this.used.ArrayFill.push(a);
104
+ relink(nnn);
105
+ relink(a.queue);
106
+ return;
107
+ }
108
+ var ai = a.queue.indexOf(a);
109
+ ai = removeNew(a, ai);
110
+ var mnni = a.queue.indexOf(mnn, ai);
111
+ var value = createString(a.queue.splice(ai, mnni + 1 - ai));
112
+ as.splice(i, 1);
113
+ a.queue.splice(ai, 0, scanner2(JSON.stringify(eval(value)))[0]);
114
+ relink(a.queue);
115
+ assignIota(a.queue[ai]);
116
+ };
117
+ module.exports = function (body) {
118
+ var envs = body.envs;
119
+ if (envs.Array) backEach(body.used.Array, arrayFillMap, body);
120
+ return body;
121
+ };
@@ -0,0 +1,83 @@
1
+ var scanner = require("./scanner");
2
+ var keywords = require("./keywords");
3
+ var strings = require("../basic/strings");
4
+ var hasOwnProperty = {}.hasOwnProperty;
5
+ var getReadableKey = function ($key, value) {
6
+ value = value.replace(/-->/g, '--\\>');
7
+ if (!/^[a-z][\w\$]*$/i.test($key)) {
8
+ $key = $key.replace(/[^\w\$]+/g, '_');
9
+ if ($key.length > 20) $key = $key.slice(0, 4) + $key.slice(-20);
10
+ }
11
+ $key = $key.replace(/(\d\.?)px/ig, "$1_px");
12
+ var id = 0;
13
+ while (($key in paramsMap) && paramsMap[$key] !== value || $key in keywords) {
14
+ $key = $key.replace(/\d+$/, '') + ++id;
15
+ }
16
+ if (!hasOwnProperty.call(paramsMap, $key)) {
17
+ paramsMap[$key] = value;
18
+ }
19
+ return $key;
20
+ };
21
+ var setMatchedConstString = function (k, p, f) {
22
+ if (/^(['"`])user?\s+(strict|asm|strip)\1$/i.test(k)) return k;
23
+ if (k.length < 3) return k;
24
+ k = strings.decode(k);
25
+ k = strings.encode(k);
26
+ var $key = "str_" + k.replace(/^(['"])([\s\S]*)\1$/g, '$2');
27
+ return getReadableKey($key, k);
28
+ };
29
+ var setMatchedConstRegExp = function (k, p, f) {
30
+ var $key = "reg_" + k.replace(/^\/([\s\S]*)\/(\w*)$/g, '$1_$2');
31
+ return getReadableKey($key, k);
32
+ };
33
+ var padStart = function (block) {
34
+ var m = module_string.charAt(block.start - 1);
35
+ return m && !/^[\[\(\s]$/.test(m) ? " " : '';
36
+ };
37
+ var padEnd = function (block) {
38
+ var m = module_string.charAt(block.end);
39
+ return m && !/^[\[\(\.\s\,\;\]\)]$/.test(m) ? " " : '';
40
+ }
41
+ var trimStringLiteral = function (block) {
42
+ var block_string = module_string.slice(block.start, block.end);
43
+ if (block.type === block.single_quote_scanner || block.type === block.double_quote_scanner) {
44
+ return padStart(block) + setMatchedConstString(block_string) + padEnd(block);
45
+ }
46
+ if (block.type === block.regexp_quote_scanner) {
47
+ return padStart(block) + setMatchedConstRegExp(block_string) + padEnd(block);
48
+ }
49
+ if (block.type === block.template_quote_scanner) {
50
+ var { start, end } = block;
51
+ if (block.children) {
52
+ var res = [];
53
+ for (var c of block.children) {
54
+ res.push(
55
+ module_string.slice(start, c.start),
56
+ trimStringLiteral(c).trim()
57
+ );
58
+ start = c.end;
59
+ }
60
+ res.push(module_string.slice(start, end));
61
+ return res.join('');
62
+ }
63
+ }
64
+ return block_string;
65
+ };
66
+ var paramsMap = Object.create(null);
67
+ var module_string = '';
68
+ function breakcode(data, args) {
69
+ if (!args) return [data];
70
+ module_string = data;
71
+ Object.keys(args).forEach(function (key) {
72
+ paramsMap[key] = true;
73
+ });
74
+ var code_blocks = scanner(module_string);
75
+ module_string = code_blocks.map(trimStringLiteral).join("");
76
+ var res = Object.keys(paramsMap).filter(k => !hasOwnProperty.call(args, k));
77
+ var val = res.map(k => paramsMap[k]);
78
+ paramsMap = Object.create(null);
79
+ data = module_string;
80
+ module_string = '';
81
+ return [data, res, val];
82
+ }
83
+ module.exports = breakcode;