efront 4.35.8 → 4.36.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.
@@ -34,6 +34,16 @@
34
34
  }
35
35
  </div>
36
36
  </p>
37
+ <p>
38
+ <h2>
39
+ 求根公式
40
+ </h2>
41
+ <div>
42
+ ${
43
+ math`x=(-b+-sqrt(b**2-4*a*c))/(2*a)`
44
+ }
45
+ </div>
46
+ </p>
37
47
  <p>
38
48
  ${
39
49
  math`cos(theta,2)*E+(1 - cos(theta))*K'*K+sin(theta)*[0,-K_2,K_1;K_2,0,-K_0;-K_1,K_0,0]`
@@ -272,28 +272,26 @@ var getComment = function (piece) {
272
272
  return '';
273
273
  };
274
274
  function spreadkey(name) {
275
- if (/^\([\s\S]*\)$/.test(name) && /,/.test(name)) {
276
- var [, name, rest_piece] = /^([\s\S]*?),([^\]]*)$/.exec(name.slice(1, name.length - 1));
275
+ var repeat = /^\[/.test(name) ? true : void 0;
276
+ if (/^\([\s\S]*\)$|^\[[\s\S]*\]$/.test(name)) {
277
+ name = name.slice(1, name.length - 1);
278
+ if (/,/.test(name)) var [, name, rest_piece] = /^([\s\S]*?),([^\]]*)$/.exec(name);
277
279
  }
278
- if (/^\[[\s\S]*\]$/.test(name)) {
279
- repeat = true;
280
- name = name.replace(/^\[|\]$/g, '');
281
- if (/\,/.test(name)) {
282
- var commaindex = name.indexOf(",");
283
- var endwith = parseKV(name.slice(commaindex + 1));
280
+ if (repeat) {
281
+ if (rest_piece) {
282
+ var endwith = parseKV(rest_piece);
284
283
  endwith = parseValue(endwith);
285
- name = name.slice(0, commaindex);
286
284
  }
287
285
  }
288
286
  var [name, key, holder] = scanSlant(name, '/', 0, name.length + 1);
289
- if (rest_piece) {
287
+ if (!repeat && rest_piece) {
290
288
  if (rest_piece && !/=/.test(rest_piece)) {
291
289
  var needs = { [key || name]: parseValue(rest_piece) };
292
290
  } else {
293
291
  var needs = scanNeeds(rest_piece);
294
292
  }
295
293
  }
296
- return [name, key, needs, holder];
294
+ return [name, key, needs, holder, repeat, endwith];
297
295
  }
298
296
  function parseOptions(size, options) {
299
297
  if (typeof options === "string" && !/^[\$&]+\d+$/.test(options)) {
@@ -394,7 +392,7 @@ function parse(piece) {
394
392
  last_type = type;
395
393
  }
396
394
  }
397
- [name, key, needs, holder] = spreadkey(name);
395
+ [name, key, needs, holder, repeat, endwith] = spreadkey(name);
398
396
  if (key === undefined && !/^(title|label|headline)$/i.test(type)) key = name;
399
397
  }
400
398
  var value = /\/?\=([^\/\\]+)/.exec(type);
@@ -405,10 +403,10 @@ function parse(piece) {
405
403
  if (d & 0b111 === 0) type = (d >>> 3) + 'byte/' + t;
406
404
  else type = d + 'bit/' + t;
407
405
  }
408
- var sizematch = /^(\-?\d+|\-?\d*\.\d+)?([YZEPTGMK]i?b?|bytes?|bits?|words?|dword|real[48]|long|B|[^\/]*)([\/]|$|\s|\=)/i.exec(type);
406
+ var sizematch = !/^\:/.test(type) && /^(\-?\d+|\-?\d*\.\d+)?([YZEPTGMK]i?b?|bytes?|bits?|words?|dword|real[48]|long|B|[^\/]*)([\/]|$|\s|\=)/i.exec(type);
409
407
  if (!sizematch[1] && /^\$\d/.test(sizematch[2])) sizematch = null;
410
408
  if (sizematch) {
411
- var [size_text, size = 1, unit, eq] = sizematch;
409
+ var [size_text, size, unit, eq] = sizematch;
412
410
  if (unit && /^i?b?$/i.test(unit.slice(1))) {
413
411
  let ratio = KMGT.indexOf(unit.toUpperCase().charAt(0));
414
412
  size *= Math.pow(1024, ratio + 1);
@@ -470,7 +468,7 @@ function parse(piece) {
470
468
  var size = /^\:[^\/\:\-\,\/]+/.exec(type)[0];
471
469
  type = type.slice(size.length + 1);
472
470
  if (!type) {
473
- type = size.slice(1);
471
+ type = "bytes";
474
472
  }
475
473
  } else if (/^[\/]/.test(type)) {
476
474
  type = type.slice(1);
@@ -485,9 +483,9 @@ function parse(piece) {
485
483
  key = is(key);
486
484
  }
487
485
  else if (typeof name === 'string') {
488
- [name, key = name, needs, holder] = spreadkey(name);
486
+ [name, key = name, needs, holder, repeat, endwith] = spreadkey(name);
489
487
  }
490
- if (typeof size === 'string') size = parseFloat(size);
488
+ if (typeof size === 'string' && !/^\:/.test(size)) size = parseFloat(size);
491
489
  if (unit === type) unit = '';
492
490
  var field = {
493
491
  name, type, key, value, comment, options,
@@ -504,7 +502,11 @@ function parse(piece) {
504
502
  };
505
503
  var parent = piecepath[piecepath.length - 1];
506
504
  if (parent) {
507
- field.parent = parent;
505
+ Object.defineProperty(field, 'parent', {
506
+ value: parent,
507
+ configurable: true,
508
+ enumerable: false
509
+ });
508
510
  if (parent.options) {
509
511
  parent.options.push(field);
510
512
  } else {
@@ -106,7 +106,6 @@ var getUnaryRest = function (buff, index, flag) {
106
106
  var binc = index * 8;
107
107
  var savedb = binc;
108
108
  do {
109
-
110
109
  var i = binc / 8 | 0;
111
110
  var b = binc - i * 8;
112
111
  if (i >= buff.length) break;
@@ -127,7 +126,7 @@ var readFromIndex = function (data, index, offset) {
127
126
  byteOffset++;
128
127
  bitOffset = 8 - bitOffset;
129
128
  }
130
- var bytes = data.slice(byteIndex, byteOffset);
129
+ var bytes = data.subarray(byteIndex, byteOffset);
131
130
  if (bitOffset > 0 || bitIndex > 0) bytes = bytes.map(copy);
132
131
  if (bitOffset > 0) {
133
132
  bytes[bytes.length - 1] = bytes[bytes.length - 1] >> bitOffset << bitOffset;
@@ -139,7 +138,7 @@ var readFromIndex = function (data, index, offset) {
139
138
  bytes[bytes.length - 1] = bytes[bytes.length - 1] << bitIndex;
140
139
  }
141
140
  if (bitIndex + bitOffset >= 8) {
142
- bytes = bytes.slice(0, bytes.length - 1);
141
+ bytes = bytes.subarray(0, bytes.length - 1);
143
142
  }
144
143
  return bytes;
145
144
  };
@@ -232,13 +231,13 @@ function refilm_parse(data, start = 0) {
232
231
  bytes = readFromIndex(data, index, offset);
233
232
  value = bufferToUTF8String(bytes, 0);
234
233
  }
235
- else if (/^(small|little|small-end|litte-end|end)$/i.test(field.type)) {
234
+ else if (/^(small|little|small-end|litte-end|end|le)\d*$/i.test(field.type)) {
236
235
  value = numberFromSmallEnd(value);
237
236
  }
238
237
  else if (/^(string|str)$/i.test(field.type)) {
239
238
  value = bufferToUTF8String(value);
240
239
  }
241
- else if (/^num$|^number$|^int$|^integer$|^float$|^uint$/i.test(field.type)) {
240
+ else if (/^(num|number|int|integer|float|uint|double|real)\d*$/i.test(field.type)) {
242
241
  value = numberFromBuffer(value, 0, field.size * field.ratio * 8);
243
242
  }
244
243
  else if (/^bool$|^boolean$/i.test(field.type)) {
@@ -248,7 +247,7 @@ function refilm_parse(data, start = 0) {
248
247
  value = 1 + numberFromBuffer(value, 0, field.size * field.ratio * 8);
249
248
  }
250
249
  else {
251
- value = bytes.map(copy);
250
+ value = bytes;
252
251
  }
253
252
  index = offset;
254
253
  }
@@ -268,7 +267,7 @@ function refilm_parse(data, start = 0) {
268
267
  };
269
268
  var readone = function (field) {
270
269
  var inc = 0;
271
- var value = read(field, inc);
270
+ var value = read(field, field.repeat && inc);
272
271
  if (field.repeat) {
273
272
  var result = [value];
274
273
  var { size } = field;
@@ -10,8 +10,17 @@ var escapeMap = {
10
10
  };
11
11
  var unescapeFun = a => escapeMap[a];
12
12
  var unescapeUnc = function (a) {
13
- if (escapeMap.hasOwnProperty(a)) return escapeMap[a];
14
- var code = a.charCodeAt(0).toString(16);
13
+ if (a.length !== 1) a: {
14
+ var a1 = a[1];
15
+ if (escapeMap.hasOwnProperty(a1)) {
16
+ return escapeMap[a1];
17
+ }
18
+ var code = a1.charCodeAt(0);
19
+ if (code <= 0x001f || code >= 0x80) break a;
20
+ return a;
21
+ }
22
+ else if (escapeMap.hasOwnProperty(a)) return escapeMap[a];
23
+ else var code = a.charCodeAt(0).toString(16);
15
24
  switch (code.length) {
16
25
  case 1:
17
26
  return "\\u000" + code;
@@ -27,9 +36,13 @@ var unescapeMap = {
27
36
  };
28
37
  for (var k in escapeMap) unescapeMap[escapeMap[k]] = k;
29
38
  var unescapeReg = new RegExp(`[${Object.keys(escapeMap).map(a => escapeMap[a]).join('')}]`, 'g');
39
+ function escape(str) {
40
+ str = str.replace(/\\[\s\S]|[\r\n\t\v\f\u0008\u0000-\u001f\u007f-\uffff]/g, unescapeUnc);
41
+ return str;
42
+ }
30
43
  function encode(str, q = "\"", escapeUnicode = true) {
31
44
  str = str.replace(new RegExp(`[\\\\${q}]`, 'g'), "\\$&");
32
- if (escapeUnicode) str = str.replace(/[\r\n\t\v\f\u0008\u0000-\u001f\u007f-\uffff]/g, unescapeUnc);
45
+ if (escapeUnicode) str = escape(str);
33
46
  else str = str.replace(unescapeReg, unescapeFun);
34
47
  return q + str + q;
35
48
  }
@@ -73,10 +86,34 @@ function decode(s, singleSlash) {
73
86
  if (!r) return s;
74
87
  return kicode(r[2], singleSlash ? r[1] : null);
75
88
  }
76
-
89
+ var forbiddens = {
90
+ "极兔与狗": "jtexpress.cn",
91
+ "狗府与狗共": "gov.cn",
92
+ "淘宝与狗": "taobao.com",
93
+ "支付宝与狗": "alipay.com",
94
+ "华为与狗": "huawei.com",
95
+ "京东与狗": "jd.com",
96
+ "美团与狗": "meituan.com",
97
+ "美团公司与狗": "sankuai.com",
98
+ "腾讯与狗": "tencent.com",
99
+ "QQ团队与狗": "qq.com",
100
+ "微信团队与狗": "wechat.com",
101
+ };
102
+ var regs = recode.name === 'recode' ? [] : Object.keys(forbiddens).map(k => {
103
+ var r = forbiddens[k];
104
+ r = new RegExp("(?:^|\\:|\\/\\/|\\.)" + escapeRegExp(r) + "(\\/|$\\:)", 'i');
105
+ r.name = k;
106
+ return r;
107
+ });
77
108
  function recode(s, singleSlash) {
78
109
  s = decode(s, singleSlash);
79
- s = encode(s);
110
+ for (var r of regs) {
111
+ if (r.test(s)) {
112
+ s = r.name + "不得使用";
113
+ console.error(s);
114
+ }
115
+ }
116
+ s = encode(s, '"', false);
80
117
  return s;
81
118
  }
82
- export { encode, decode, recode, kicode, uncode };
119
+ export { encode, decode, recode, escape, kicode, uncode };
@@ -25,7 +25,7 @@ var scan_number = function (str, start) {
25
25
  return false;
26
26
  };
27
27
  var scan_null = function (str, start) {
28
- var reg = /null|false|true|\-?Infinity/g;
28
+ var reg = /null|false|true|\-?Infinity|NaN/g;
29
29
  reg.lastIndex = start;
30
30
  var match = reg.exec(str);
31
31
  if (match && match.index === start) {
@@ -45,6 +45,9 @@ var scan_null = function (str, start) {
45
45
  case "-":
46
46
  data = -Infinity;
47
47
  break;
48
+ case "N":
49
+ data = NaN;
50
+ break;
48
51
  }
49
52
  return reg.lastIndex;
50
53
  }
@@ -129,6 +132,7 @@ var _safeparse = function (str, start) {
129
132
  case "f":
130
133
  case "t":
131
134
  case "I":
135
+ case "N":
132
136
  start = scan_null(str, start);
133
137
  break;
134
138
  default:
@@ -135,7 +135,27 @@ var property = new Program;
135
135
  property.stamps = "=".split('');
136
136
  var progExp = new Javascript;
137
137
  var replaceISO8859 = function (data) {
138
- return String(data).replace(/<\!--([\s\S]*)--\>$/g, '$1').replace(/&\w+;/g, a => iso8859[a] || a).replace(/&#(\d+);/g, (_, a) => String.fromCodePoint(a))
138
+ return String(data)
139
+ .replace(/<\!--([\s\S]*)--\>$/g, '$1')
140
+ .replace(/&\w+;/g, a => iso8859[a] || a)
141
+ .replace(/&#([0-9a-f]+);/ig, (_, x, a) => {
142
+ if (x) switch (x) {
143
+ case "u":
144
+ a = parseInt(a, 16);
145
+ break;
146
+ case "x":
147
+ a = parseInt(a, 16);
148
+ break;
149
+ case "b":
150
+ a = parseInt(a, 2);
151
+ break;
152
+ case "o":
153
+ a = parseInt(a, 8);
154
+ break;
155
+ }
156
+ else a = +a;
157
+ return String.fromCodePoint(a);
158
+ });
139
159
  };
140
160
  var parseExpress = function (data, mayberepeat) {
141
161
  if (mayberepeat && /\s+(in|of)\s+/.test(data)) {
@@ -1031,7 +1031,9 @@ class Program {
1031
1031
  else if (type_reg.test(m)) {
1032
1032
  last.istype = true;
1033
1033
  }
1034
- if (this.transive_reg.test(m)) {
1034
+ var power = powermap[m];
1035
+ last.unary = power >= powermap.new;
1036
+ if (this.transive_reg.test(m) || power >= 0) {
1035
1037
  last.transive = queue.inExpress = true;
1036
1038
  }
1037
1039
  else {
@@ -1079,8 +1081,12 @@ class Program {
1079
1081
 
1080
1082
  if (scope_entry[m]) scope: {
1081
1083
  if (stamp_reg.test(m)) {
1084
+ if (cache_stamp) {
1085
+ if (cache_stamp.text + m in powermap) break scope;
1086
+ push_stamp();
1087
+ }
1082
1088
  var last = queue.last;
1083
- if (last) {
1089
+ if (last && last.type & ~(STAMP | STRAP) && !last.ion) {
1084
1090
  if (last.isExpress && !last.istype) break scope;
1085
1091
  }
1086
1092
  }
@@ -1099,7 +1105,7 @@ class Program {
1099
1105
  if (last.type !== STAMP || last.text !== "=>") {
1100
1106
  var classed = queue.classed;
1101
1107
  var clsd = classed.pop();
1102
- scope.isClass = true;
1108
+ scope.isClass = /^(class|interface)$/.test(clsd);
1103
1109
  if (!classed.length) queue.classed = null;
1104
1110
  scope.istype = clsd !== 'class';
1105
1111
  scope.extend += extends_reg.test(last.text);
@@ -287,6 +287,21 @@ var getContitionHeadBeforeScoped = function (p, nodo) {
287
287
  return getIfElseHead(pp);
288
288
  }
289
289
  };
290
+ var getClassHeadBeforeScoped = function (p) {
291
+ var i = 0;
292
+ while (p && p.isClass) {
293
+ p = p.prev;
294
+ i++;
295
+ }
296
+ while (p && i > 0) {
297
+ var o = p;
298
+ if (p.type === STRAP && /^(class|interface)$/.test(p.text)) {
299
+ i--;
300
+ }
301
+ p = p.prev;
302
+ }
303
+ return o;
304
+ }
290
305
  var getFunctionHeadBeforeScoped = function (p) {
291
306
  var pp = getprev(p);
292
307
  if (pp && pp.type === EXPRESS) pp = getprev(pp);
@@ -1282,9 +1297,25 @@ var getSemicolonBetween = function (prev, next) {
1282
1297
  }
1283
1298
  return;
1284
1299
  }
1300
+ if (prev.brace) {
1301
+ if (pp.type === SCOPED && pp.entry === '(' ||
1302
+ pp.type === STAMP && pp.text === '=>'
1303
+ ) pp = getFunctionHeadBeforeScoped(pp);
1304
+ else if (prev.isClass) {
1305
+ pp = getClassHeadBeforeScoped(prev);
1306
+ }
1307
+ else pp = null;
1308
+ if (pp) pp = getprev(pp);
1309
+ if (!pp) return;
1310
+ if (pp.type === STAMP && (
1311
+ !/^([,;]|\+\+|\-\-)$/.test(pp.text)
1312
+ || pp.unary
1313
+ ) || pp.type === STRAP && pp.transive && !pp.isend) return ';';
1314
+ return;
1315
+ }
1285
1316
  if (prev.type === STRAP) {
1286
1317
  if ((STRAP | EXPRESS | VALUE | QUOTED) & next.type) return " ";
1287
- if (next.type === LABEL) return ";";
1318
+ if (next.type === LABEL) return /^(do|else|try|catch|finally)$/.test(prev.text) ? " " : ";";
1288
1319
  }
1289
1320
  }
1290
1321
  var needBreakBetween = function (prev, next) {
@@ -1475,7 +1506,7 @@ var createString = function (parsed) {
1475
1506
  var prev = getprev(o);
1476
1507
  if (patchspace && !intag && prev && o.type !== QUOTED && (lasttype === STAMP && !prev.unary && !prev.needle
1477
1508
  || lasttype & ~(SPACE | STAMP | COMMENT) && o.brace
1478
- || lasttype === STRAP && !/^(this|arguments|import)$/.test(prev.text)
1509
+ || lasttype === STRAP && !/^(this|arguments|import)$/.test(prev.text) && (!prev.unary || o.brace)
1479
1510
  )) result.push(" ");
1480
1511
  result.push(o.entry);
1481
1512
  if (o.length > 0) {
@@ -1554,6 +1585,10 @@ var createString = function (parsed) {
1554
1585
  lasttype = o.type;
1555
1586
  };
1556
1587
  parsed.forEach(run);
1588
+ var pend = parsed[parsed.length - 1];
1589
+ if (pend?.type === COMMENT && /^\/\//.test(pend.text)) {
1590
+ finalresult.push('\r\n');
1591
+ }
1557
1592
  return finalresult.join("");
1558
1593
  }
1559
1594
  var rename = function (used, from, to) {
@@ -60,3 +60,51 @@ assert(common.number_reg.test("1.1920928955078125e-07F"), true)
60
60
  assert(new RegExp(common.number_reg.source.replace(/^\^|\$$/g, ''), 'ig').exec("00080000h"), ["00080000h"])
61
61
  assert(new RegExp(common.number_reg.source.replace(/^\^|\$$/g, ''), 'ig').exec("2A3h"), ["2A3h"])
62
62
  assert(new RegExp(common.number_reg.source.replace(/^\^|\$$/g, ''), 'ig').exec("1.1920928955078125e-07F"), ["1.1920928955078125e-07F"])
63
+ function testCrateString(text, want = text) {
64
+ var code = scanner2(text);
65
+ code.keepspace = false;
66
+ var res = common.createString(code);
67
+ assert(res, want);
68
+ }
69
+ testCrateString('else\r\na:{break a}', 'else a:{break a}')
70
+ testCrateString('do\r\na:{break a}', 'do a:{break a}')
71
+ testCrateString('try\r\na:{break a}', 'try a:{break a}')
72
+ testCrateString('finally\r\na:{break a}', 'finally a:{break a}')
73
+ testCrateString('catch\r\na:{break a}', 'catch a:{break a}')
74
+ testCrateString(
75
+ 'a = function () {}\r\n a: do { break a } white(true)',
76
+ 'a=function(){};a:do{break a}white(true)'
77
+ )
78
+ testCrateString(
79
+ 'function a() {}\r\nreturn',
80
+ 'function a(){}return'
81
+ )
82
+ testCrateString(
83
+ 'a = function () {}()\r\n return',
84
+ 'a=function(){}();return'
85
+ )
86
+ testCrateString(
87
+ 'a = class{}\r\n return',
88
+ 'a=class{};return'
89
+ )
90
+ testCrateString(
91
+ 'class a{}\r\n return',
92
+ 'class a{}return'
93
+ )
94
+ testCrateString(
95
+ 'class a extends class b{}{}\r\n return',
96
+ 'class a extends class b{}{}return'
97
+ )
98
+ testCrateString(
99
+ 'new class a extends class b{}{}\r\n return',
100
+ 'new class a extends class b{}{};return'
101
+ )
102
+ testCrateString(
103
+ 'new class a extends function b(){}{}\r\n return',
104
+ 'new class a extends function b(){}{};return'
105
+ )
106
+ testCrateString(
107
+ 'new class a extends()=>{}{}\r\n return',
108
+ 'new class a extends()=>{}{};return'
109
+ )
110
+ testCrateString('if(true){}a:do{break a}white(true)')
@@ -0,0 +1,13 @@
1
+ function till(kill, i, arr) {
2
+ var s = kill = "_" + i + kill.replace(/[&\^%\?@#\\]/g, '_');
3
+ var i = 1;
4
+ while (kill in this) {
5
+ kill = s + "_" + i++;
6
+ }
7
+ return kill;
8
+ }
9
+ module.exports = function nametill(names, prevent) {
10
+ prevent = Object.create(prevent);
11
+ names.forEach(n => prevent[n] = true);
12
+ return names.map(till, prevent);
13
+ }
@@ -12,7 +12,7 @@ var powermap = {
12
12
  'instanceof,in,==,>=,<=,>,<,!=,!==,===,!in,!instanceof'/* 6 */,
13
13
  '>>,>>>,<<'/* 7 */, '+,-'/* 8 */, '*,/,%,\\'/* 9 */, '**'/* 10 */,
14
14
  '++,--'/* 11 */,
15
- "typeof,await,yield,delete,void,..."/*12*/,
15
+ "typeof,import,await,yield,delete,void,..."/*12*/,
16
16
  "',!,~,#,new"/* 13 */,
17
17
  "::,?.,->,."/*14*/,
18
18
  ].forEach((pp, i) => {
@@ -4,6 +4,7 @@ var createShortList = function (keys, prevent) {
4
4
  return createShortName(keys.length, prevent);
5
5
  };
6
6
  var renameHashName = require("./nametill");
7
+ var renameBothName = require('./namekill');
7
8
  var createNameList = createShortList;
8
9
  var Html = require("./Html");
9
10
  var Javascript = require("./Javascript");
@@ -190,11 +191,16 @@ class Code extends Array {
190
191
  createNameList = createShortList;
191
192
  }
192
193
  // 压缩
193
- press(keepspace) {
194
+ press(keepspace, pressMethod) {
194
195
  this.keepspace = keepspace;
195
196
  this.pressed = true;
196
197
  this.helpcode = false;
197
- compress(this.scoped);
198
+ if (pressMethod < 0) {
199
+ createNameList = renameBothName;
200
+ compress(this.scoped);
201
+ createShortList = createShortList;
202
+ }
203
+ else compress(this.scoped);
198
204
  return this;
199
205
  }
200
206
  getNodeAt(row, col) {