efront 4.35.4 → 4.35.5
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/coms/basic/math.js +7 -1
- package/coms/basic/math.md +11 -0
- package/coms/basic/strings.js +8 -5
- package/coms/compile/Html.js +15 -7
- package/coms/compile/Program.js +3 -1
- package/coms/compile/autoeval.js +2 -2
- package/coms/compile/autoeval_test.js +5 -0
- package/coms/compile/scanner2.js +1 -1
- package/coms/compile//347/264/240/351/246/250.js +4 -4
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/public//346/226/207/344/273/266/347/263/273/347/273/237//344/270/273/351/241/265.jsp +2 -2
package/coms/basic/math.js
CHANGED
|
@@ -137,6 +137,12 @@ var funcmap = {
|
|
|
137
137
|
abs(a) {
|
|
138
138
|
return `<mo>|</mo>${a}<mo>|</mo>`;
|
|
139
139
|
},
|
|
140
|
+
log(x, n) {
|
|
141
|
+
return `<msub><mo>log</mo>${n}</msub>${x}`
|
|
142
|
+
},
|
|
143
|
+
ln(x){
|
|
144
|
+
return `<mo>ln</mo>${x}`
|
|
145
|
+
},
|
|
140
146
|
"div"(...args) {
|
|
141
147
|
return mo3("÷", args);
|
|
142
148
|
},
|
|
@@ -295,7 +301,7 @@ var br = function () {
|
|
|
295
301
|
function toString(obj, p, deep) {
|
|
296
302
|
if (obj instanceof Array) {
|
|
297
303
|
if (deep == 1 && obj.length === 2 && obj[1].tab) {
|
|
298
|
-
return toString(obj[0], 0, deep) +"</mtd><mtd>"+ obj.slice(1, obj.length).map(a => toString(a, 0, 0)).join("</mtd><mtd>");
|
|
304
|
+
return toString(obj[0], 0, deep) + "</mtd><mtd>" + obj.slice(1, obj.length).map(a => toString(a, 0, 0)).join("</mtd><mtd>");
|
|
299
305
|
}
|
|
300
306
|
deep++;
|
|
301
307
|
var args = obj.map(a => toString(a, deep > 1 ? 0 : p, deep));
|
package/coms/basic/math.md
CHANGED
|
@@ -337,6 +337,17 @@ series(公式主体,n=1,+Infinity)
|
|
|
337
337
|
corner(A);
|
|
338
338
|
corner(BAC);
|
|
339
339
|
```
|
|
340
|
+
* 对数
|
|
341
|
+
```mathscript
|
|
342
|
+
log(x,2);
|
|
343
|
+
log(x,e);
|
|
344
|
+
ln(x);
|
|
345
|
+
```
|
|
346
|
+
```math
|
|
347
|
+
log(x,2);
|
|
348
|
+
log(x,e);
|
|
349
|
+
ln(x);
|
|
350
|
+
```
|
|
340
351
|
|
|
341
352
|
## 希腊字母对照表如下
|
|
342
353
|
按此表中的英文单词命名的变量将自动转换为希腊字母
|
package/coms/basic/strings.js
CHANGED
|
@@ -5,6 +5,7 @@ var escapeMap = {
|
|
|
5
5
|
"\b": "\\b",
|
|
6
6
|
"\f": "\\f",
|
|
7
7
|
"\v": "\\u000b",
|
|
8
|
+
"\\": "\\\\",
|
|
8
9
|
"\u2028": "\\u2028",
|
|
9
10
|
"\u2029": "\\u2029",
|
|
10
11
|
};
|
|
@@ -44,7 +45,7 @@ var esc = function (a) {
|
|
|
44
45
|
function uncode(s) {
|
|
45
46
|
return s.replace(/\\u(?:\{[0-9a-f]+\}|[0-9a-f]{4})/ig, esc);
|
|
46
47
|
}
|
|
47
|
-
function kicode(s) {
|
|
48
|
+
function kicode(s, singleSlash = false) {
|
|
48
49
|
var t = [];
|
|
49
50
|
return s.replace(/\\(?:u\{[0-9a-f]+\}|u[0-9a-f]{4}|x[0-9a-f]{2}|([0-7]{1,3}|[\s\S]))/ig, (a, b, i) => {
|
|
50
51
|
if (!b) {
|
|
@@ -63,17 +64,19 @@ function kicode(s) {
|
|
|
63
64
|
}
|
|
64
65
|
if (unescapeMap.hasOwnProperty(a)) return unescapeMap[a];
|
|
65
66
|
if (/^[0-7]+$/.test(b)) return String.fromCharCode(parseInt(b, 8));
|
|
67
|
+
if (b === singleSlash) return b;
|
|
68
|
+
if (singleSlash) return '\\' + b;
|
|
66
69
|
return b;
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
|
-
function decode(s) {
|
|
72
|
+
function decode(s, singleSlash) {
|
|
70
73
|
var r = /^(['"`])([\s\S]*)\1$/.exec(s);
|
|
71
74
|
if (!r) return s;
|
|
72
|
-
return kicode(r[2]);
|
|
75
|
+
return kicode(r[2], singleSlash ? r[1] : null);
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
function recode(s) {
|
|
76
|
-
s = decode(s);
|
|
78
|
+
function recode(s, singleSlash) {
|
|
79
|
+
s = decode(s, singleSlash);
|
|
77
80
|
s = encode(s);
|
|
78
81
|
return s;
|
|
79
82
|
}
|
package/coms/compile/Html.js
CHANGED
|
@@ -133,7 +133,7 @@ class Html extends Javascript {
|
|
|
133
133
|
}
|
|
134
134
|
var property = new Program;
|
|
135
135
|
property.stamps = "=".split('');
|
|
136
|
-
var
|
|
136
|
+
var progExp = new Javascript;
|
|
137
137
|
var replaceISO8859 = function (data) {
|
|
138
138
|
return String(data).replace(/<\!--([\s\S]*)--\>$/g, '$1').replace(/&\w+;/g, a => iso8859[a] || a).replace(/&#(\d+);/g, (_, a) => String.fromCodePoint(a))
|
|
139
139
|
};
|
|
@@ -142,8 +142,8 @@ var parseExpress = function (data, mayberepeat) {
|
|
|
142
142
|
data = `for(var ${data});`;
|
|
143
143
|
}
|
|
144
144
|
else data = "=" + replaceISO8859(data);
|
|
145
|
-
|
|
146
|
-
return
|
|
145
|
+
progExp.lastIndex = 0;
|
|
146
|
+
return progExp.exec(data);
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
var toCamelCase = function (a) {
|
|
@@ -151,8 +151,12 @@ var toCamelCase = function (a) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
var isDynamic = a => /^(on|@|\-|_|\.|#|\:|\+|\*|\?|&|\$|\S+\-)|(@|\-|_|\.|#|\:|\+|\*|\?|&|\$)$/i.test(a);
|
|
154
|
-
|
|
154
|
+
var decode = strings.decode;
|
|
155
|
+
var decode2 = function (s) {
|
|
156
|
+
return decode(s, true);
|
|
157
|
+
}
|
|
155
158
|
Html.prototype.createScoped = function (code) {
|
|
159
|
+
progExp.mindpath = this.mindpath;
|
|
156
160
|
var used = Object.create(null);
|
|
157
161
|
var vars = Object.create(null);
|
|
158
162
|
var rootvars = vars;
|
|
@@ -197,7 +201,7 @@ Html.prototype.createScoped = function (code) {
|
|
|
197
201
|
var nn = c.next.next;
|
|
198
202
|
if (!nn || nn.length > 0) return;
|
|
199
203
|
if (nn.type === EXPRESS || nn.type === QUOTED) {
|
|
200
|
-
rootvars[
|
|
204
|
+
rootvars[decode(createString([nn]))] = true;
|
|
201
205
|
}
|
|
202
206
|
}
|
|
203
207
|
}
|
|
@@ -219,12 +223,14 @@ Html.prototype.createScoped = function (code) {
|
|
|
219
223
|
break;
|
|
220
224
|
}
|
|
221
225
|
if (noTag || !c.text) break;
|
|
222
|
-
var t =
|
|
226
|
+
var t = decode2(c.text);
|
|
223
227
|
if (color.isColor(t)) break;
|
|
224
228
|
var p = c.prev;
|
|
225
229
|
var pp = p && p.prev;
|
|
226
230
|
if (pp && isDynamic(pp.text)) {
|
|
227
231
|
var mayberepeat = p && pp && p.type === STAMP && p.text === "=" && /[\:\-\_@\&\*\?\#\+\.\$](src|repeat|for|each|foreach)$/i.test(pp.text)
|
|
232
|
+
progExp.col = c.col;
|
|
233
|
+
progExp.row = c.row;
|
|
228
234
|
t = parseExpress(t, mayberepeat);
|
|
229
235
|
var s = createScoped(t);
|
|
230
236
|
var envs = s.envs;
|
|
@@ -242,6 +248,8 @@ Html.prototype.createScoped = function (code) {
|
|
|
242
248
|
if (inScript || noTag) break;
|
|
243
249
|
if (c.queue.type === QUOTED) break;
|
|
244
250
|
var t = c.text;
|
|
251
|
+
progExp.col = c.col;
|
|
252
|
+
progExp.row = c.row;
|
|
245
253
|
t = parseExpress(t);
|
|
246
254
|
var s = createScoped(t);
|
|
247
255
|
var envs = s.envs;
|
|
@@ -301,7 +309,7 @@ Html.prototype.createScoped = function (code) {
|
|
|
301
309
|
scoped.envs = envs;
|
|
302
310
|
scoped.vars = vars;
|
|
303
311
|
scoped.used = used;
|
|
304
|
-
|
|
312
|
+
delete progExp.mindpath;
|
|
305
313
|
return scoped;
|
|
306
314
|
};
|
|
307
315
|
Html.prototype.createString = common.createString;
|
package/coms/compile/Program.js
CHANGED
|
@@ -179,6 +179,8 @@ class Program {
|
|
|
179
179
|
lbtype = false;
|
|
180
180
|
keepspace = false;
|
|
181
181
|
lastIndex = 0
|
|
182
|
+
col = 1;
|
|
183
|
+
row = 1;
|
|
182
184
|
detectLabel(o) {
|
|
183
185
|
var queue = o.queue;
|
|
184
186
|
var last = queue.last;
|
|
@@ -413,7 +415,7 @@ class Program {
|
|
|
413
415
|
}
|
|
414
416
|
queue.push(scope);
|
|
415
417
|
};
|
|
416
|
-
var row =
|
|
418
|
+
var row = this.row, colstart = -this.col;
|
|
417
419
|
var cache_stamp = null;
|
|
418
420
|
var powermap = this.powermap;
|
|
419
421
|
var push_stamp = function () {
|
package/coms/compile/autoeval.js
CHANGED
|
@@ -54,7 +54,7 @@ var punc_3 = {
|
|
|
54
54
|
if (s && n1.length + +n2 > 15) {
|
|
55
55
|
return BigInt(n1) << BigInt(n2) + s;
|
|
56
56
|
}
|
|
57
|
-
return (
|
|
57
|
+
return (n1 << n2) + s;
|
|
58
58
|
},
|
|
59
59
|
">"(n1, n2, s) {
|
|
60
60
|
return String(+n1 > +n2);
|
|
@@ -84,7 +84,7 @@ var punc_3 = {
|
|
|
84
84
|
return (n1 & n2) + s;
|
|
85
85
|
},
|
|
86
86
|
"||"(n1, n2, s) {
|
|
87
|
-
return (+
|
|
87
|
+
return (+n1 || +n2) + s;
|
|
88
88
|
},
|
|
89
89
|
"&&"(n1, n2, s) {
|
|
90
90
|
return (+n1 && + n2) + s;
|
|
@@ -86,3 +86,8 @@ tc("Math.log(f) / Math.LN2 / 10 | 0", "Math.log(f) * 0.14426950408889633 | 0");
|
|
|
86
86
|
tc("Math.log(f) / Math.LN2 / 10 * 10 | 0", "Math.log(f) * 1.4426950408889634 | 0");
|
|
87
87
|
tc("Math.log(f) / Math.LN2 / 10 ** 2 | 0", "Math.log(f) * 0.014426950408889633 | 0");
|
|
88
88
|
// tf(path.join(__dirname, "../zimoli/spacechar_test.js"))
|
|
89
|
+
t("1<<0", '1');
|
|
90
|
+
t("1<<3", '8');
|
|
91
|
+
t("(1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)",'1335')
|
|
92
|
+
t("(1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)","7973")
|
|
93
|
+
t("(1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)","21522")
|
package/coms/compile/scanner2.js
CHANGED
|
@@ -71,7 +71,7 @@ var replace_punc = function (a) {
|
|
|
71
71
|
}
|
|
72
72
|
var killcalc = a => replace_punc(createString(a));
|
|
73
73
|
var seprateFunc = function (express) {
|
|
74
|
-
var express = scanner2(express, rarg);
|
|
74
|
+
var express = scanner2(express, rarg, basepath[0] || base || '');
|
|
75
75
|
var sps = [];
|
|
76
76
|
var sp = [];
|
|
77
77
|
for (var cx = 0, dx = express.length; cx < dx; cx++) {
|
|
@@ -109,7 +109,7 @@ var seprateFunc = function (express) {
|
|
|
109
109
|
}
|
|
110
110
|
var splitParams = function (params) {
|
|
111
111
|
if (!params) return [];
|
|
112
|
-
params = scanner2(params, rarg);
|
|
112
|
+
params = scanner2(params, rarg, basepath[0] || base || '');
|
|
113
113
|
var code = params;
|
|
114
114
|
var params = [], p = [];
|
|
115
115
|
for (var cx = 0, dx = code.length; cx < dx; cx++) {
|
|
@@ -125,7 +125,7 @@ var splitParams = function (params) {
|
|
|
125
125
|
return params;
|
|
126
126
|
}
|
|
127
127
|
var createArgMap = function (args, split = ',', equal = ':') {
|
|
128
|
-
if (args) args = scanner2(args, rarg);
|
|
128
|
+
if (args) args = scanner2(args, rarg, basepath[0] || base || "");
|
|
129
129
|
else args = [];
|
|
130
130
|
var map = Object.create(null);
|
|
131
131
|
var o = args.first;
|
|
@@ -727,7 +727,7 @@ var rcss = null;
|
|
|
727
727
|
function 素馨(text, scopeName, compress) {
|
|
728
728
|
if (!rcss) rcss = new 素心;
|
|
729
729
|
rcss.debug = true;
|
|
730
|
-
var code = scanner2(text, rcss);
|
|
730
|
+
var code = scanner2(text, rcss, scopeName || "");
|
|
731
731
|
var { scoped } = code;
|
|
732
732
|
var result = evalscoped(scoped, scopeName);
|
|
733
733
|
var queried = [];
|