efront 4.21.4 → 4.22.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 (85) hide show
  1. package/#/345/233/275/351/231/205/345/214/226.yml +24 -0
  2. package/apps/blank/index.html +1 -1
  3. package/apps/index.jsp +76 -27
  4. package/apps/pay/alipay-query.jsp +1 -1
  5. package/apps/pay/alipay.jsp +1 -1
  6. package/apps/pivot/auth/login.js +2 -2
  7. package/apps/pivot/cert/main.xht +18 -5
  8. package/apps/pivot/db/act.xht +53 -0
  9. package/apps/pivot/db/config.xht +56 -16
  10. package/apps/pivot/home/welcome.html +12 -13
  11. package/apps/pivot/home/welcome.js +6 -6
  12. package/apps/pivot/home/welcome.less +12 -3
  13. package/apps/pivot/link/room.js +1 -1
  14. package/apps/pivot/main.js +3 -2
  15. package/apps/pivot/task/invoke.js +3 -3
  16. package/apps/pivot/task/rsync.js +2 -2
  17. package/apps/pivot/wow/root.js +8 -8
  18. package/coms/basic/#loader.js +9 -8
  19. package/coms/basic/Item.js +2 -2
  20. package/coms/basic/Tree.js +14 -2
  21. package/coms/basic/crc.js +5 -1
  22. package/coms/basic/cross_.js +2 -2
  23. package/coms/basic/decode62S.js +44 -0
  24. package/coms/basic/encode62S.js +40 -0
  25. package/coms/basic/encode62S_test.js +18 -0
  26. package/coms/basic/enrich.js +6 -1
  27. package/coms/basic/refilm_decode.js +40 -20
  28. package/coms/basic/refilm_decode_test.js +4 -0
  29. package/coms/basic/valid.js +4 -0
  30. package/coms/basic_/&Array.js +64 -49
  31. package/coms/basic_/&extends.js +9 -2
  32. package/coms/compile/Javascript.js +1 -1
  33. package/coms/compile/audit.js +23 -1
  34. package/coms/compile/cloneNode.js +3 -1
  35. package/coms/compile/downLevel.js +21 -11
  36. package/coms/compile/downLevel_test.js +52 -14
  37. package/coms/compile/rescan.js +8 -2
  38. package/coms/compile/unstruct.js +9 -9
  39. package/coms/crypt/encode62.js +36 -6
  40. package/coms/crypt/encode62_test.js +8 -48
  41. package/coms/explorer/main.less +1 -5
  42. package/coms/frame/chat.js +2 -2
  43. package/coms/frame/left.html +5 -4
  44. package/coms/frame/left.js +1 -0
  45. package/coms/frame/left.less +5 -3
  46. package/coms/frame/payment.js +2 -2
  47. package/coms/pivot/acme2.js +7 -4
  48. package/coms/pivot/left-footer.xht +25 -0
  49. package/coms/pivot/pedit.js +3 -3
  50. package/coms/pivot/plist.js +2 -2
  51. package/coms/pivot/qrcode.xht +3 -0
  52. package/coms/zimoli/XMLHttpRequest.js +2 -2
  53. package/coms/zimoli/container.js +34 -34
  54. package/coms/zimoli/design.html +6 -13
  55. package/coms/zimoli/design.js +49 -13
  56. package/coms/zimoli/design.less +62 -25
  57. package/coms/zimoli/drag.js +8 -3
  58. package/coms/zimoli/encode62.js +40 -12
  59. package/coms/zimoli/lattice.js +0 -1
  60. package/coms/zimoli/list.js +0 -8
  61. package/coms/zimoli/menu.js +29 -5
  62. package/coms/zimoli/model.js +150 -195
  63. package/coms/zimoli/model.less +4 -8
  64. package/coms/zimoli/on.js +14 -12
  65. package/coms/zimoli/padding.less +1 -0
  66. package/coms/zimoli/progbar.xht +9 -8
  67. package/coms/zimoli/prompt.less +0 -3
  68. package/coms/zimoli/render.js +210 -125
  69. package/coms/zimoli/select.js +9 -4
  70. package/coms/zimoli/select.less +3 -14
  71. package/coms/zimoli/selectList.js +5 -1
  72. package/coms/zimoli/selectList.less +3 -0
  73. package/coms/zimoli/table.html +7 -7
  74. package/coms/zimoli/table.js +12 -9
  75. package/coms/zimoli/table.less +5 -0
  76. package/coms/zimoli/user.js +2 -2
  77. package/coms/zimoli/view.js +3 -4
  78. package/coms/zimoli/watch.js +3 -1
  79. package/coms/zimoli/zimoli.js +6 -2
  80. package/coms//350/214/250/350/217/260/tab.js +26 -2
  81. package/coms//350/214/250/350/217/260//346/240/207/347/255/276/345/214/226.js +1 -1
  82. package/coms//350/214/250/350/217/260//347/274/226/350/276/221/346/241/206.xht +183 -20
  83. package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +1 -0
  84. package/package.json +1 -1
  85. package/public/efront.js +1 -1
@@ -29,6 +29,7 @@ var {
29
29
  startPath: efrontPath,
30
30
  pixelDecoder // = d => d / 16 + "rem"
31
31
  } = window;
32
+
32
33
  if (PREVENT_FRAMEWORK_MODE !== false) {
33
34
  var message = '请关闭后重新打开..';
34
35
  try {
@@ -42,6 +43,7 @@ if (PREVENT_FRAMEWORK_MODE !== false) {
42
43
  return;
43
44
  }
44
45
  }
46
+
45
47
  var efront_time = +new Date;
46
48
  var _devicePixelRatio = devicePixelRatio;
47
49
  var request = window.request || function (url, onload, onerror, version) {
@@ -202,7 +204,7 @@ var killCircle = function () {
202
204
  };
203
205
  if (!circle.length) return;
204
206
  while (circle.length) {
205
- var deleted = Object.create(null);
207
+ var deleted = {};
206
208
  var savedLength = circle.length;
207
209
  for (var cx = circle.length - 1; cx >= 0; cx--) {
208
210
  var arg = circle[cx];
@@ -246,7 +248,7 @@ var killCircle = function () {
246
248
  for (var k of module_keys) flushTree(tree, k);
247
249
  }
248
250
  };
249
- var multiModules = Object.create(null);
251
+ var multiModules = {};
250
252
  // -->
251
253
  var hasOwnProperty = {}.hasOwnProperty;
252
254
  "use ./#decrypt.js";
@@ -436,6 +438,7 @@ function Meta(url) {
436
438
  Meta.prototype.resolve = function (url) {
437
439
  return resolve(url, this.url);
438
440
  }
441
+
439
442
  var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
440
443
  var module = {};
441
444
  var exports = module.exports = {};
@@ -487,7 +490,7 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
487
490
  };
488
491
  var result, created;
489
492
  if (prebuilds.init) {
490
- var prebuilds2 = Object.create(null);
493
+ var prebuilds2 = {};
491
494
  for (var k in prebuilds) if (hasOwnProperty.call(prebuilds, k)) prebuilds2[k] = prebuilds[k];
492
495
  prebuilds = prebuilds2;
493
496
  }
@@ -577,11 +580,11 @@ var init = function (url, then, prebuilds, keeppage) {
577
580
  var length = 0;
578
581
  var deep = 0;
579
582
  // <!--
580
- var map = Object.create(null);
583
+ var map = {};
581
584
  map[url] = true;
582
585
  do {
583
586
  deep++;
584
- var rest2 = Object.create(null);
587
+ var rest2 = {};
585
588
  while (rest.length) {
586
589
  var n = rest.pop();
587
590
  var e = loadedModules[n] && loadedModules[n].error;
@@ -869,9 +872,7 @@ var loadResponseTreeFromStorage = preventCodeStorage ? function () { } : functio
869
872
  var version = preLoadVersionTree[responseName];
870
873
  if (!version) return;
871
874
  var responseText = preLoadResponseTree[responseName];
872
- var sum = [];
873
- for (var i in responseText) sum[i] = responseText.charCodeAt(i);
874
- var sum = crc(sum).toString(36);
875
+ var sum = crc.string(responseText).toString(36);
875
876
  if (sum + version.slice(sum.length) === versionTree[responseName])
876
877
  responseTree[responseName] = responseText;
877
878
  // else window.console.log(responseName, sum, version, versionTree[responseName]);
@@ -10,15 +10,15 @@ function pathTo(find, item, path) {
10
10
  if (pathTo(find, m, path)) return path;
11
11
  }
12
12
  }
13
- var id = 0;
14
13
  class Item extends Array {
15
14
  extended = false;
15
+ static id = 0;
16
16
  constructor(value) {
17
17
  super();
18
18
  this.count = 0;//子项中的叶子节点数
19
19
  this.total = 0;//子项中的节点数
20
20
  this.crack = 0;
21
- this.id = ++id;
21
+ this.id = ++Item.id;
22
22
  this.extends(value, false);
23
23
  }
24
24
  extends(value, mark) {
@@ -19,7 +19,7 @@ class Tree extends Array {
19
19
  super();
20
20
  this.root = this;
21
21
  }
22
- static fromData(array) {
22
+ static fromData(array, activeId) {
23
23
  if (array && array.coustructor === Tree) return array;
24
24
  var root = new Tree;
25
25
  root.tab = -Infinity;
@@ -28,15 +28,26 @@ class Tree extends Array {
28
28
  array = array.filter(a => !!a);
29
29
  var active_item = null;
30
30
  var hasIcon = [];
31
+ var actived_item = null;
32
+ Item.id = 0;
31
33
  array.forEach(function (data) {
32
34
  var item = new Item(data);
33
- if (!active_item && item.isActived()) active_item = item;
35
+ if (!active_item) {
36
+ if (item.isActived()) active_item = item;
37
+ }
38
+ if (!actived_item) {
39
+ if (item.id === activeId) actived_item = item;
40
+ }
34
41
  if (data.id) {
35
42
  map[data.id] = item;
36
43
  } else {
37
44
  root.push(item);
38
45
  }
39
46
  });
47
+ if (!active_item && actived_item) {
48
+ actived_item.setActive(true);
49
+ active_item = actived_item;
50
+ }
40
51
  array.forEach(function (data) {
41
52
  if (!data) return;
42
53
  var parent = map[data.parentId];
@@ -87,6 +98,7 @@ class Tree extends Array {
87
98
  root.tab = -Infinity;
88
99
  root.count = 0;
89
100
  root.total = 0;
101
+ Item.id = 0;
90
102
  var path = [root];
91
103
  for (var cx = 0, dx = array.length; cx < dx; cx++) {
92
104
  var arg = array[cx];
package/coms/basic/crc.js CHANGED
@@ -26,7 +26,11 @@ function crc(bstr, seed) {
26
26
  if (i === L) C = C >>> 8 ^ T[(C ^ bstr[i]) & 0xFF];
27
27
  return C ^ -1;
28
28
  }
29
-
29
+ crc.string = function (str) {
30
+ var sum = [];
31
+ for (var i in str) sum[i] = str.charCodeAt(i);
32
+ return crc(sum);
33
+ }
30
34
  var sign = parseInt("-52l3vk", 36);
31
35
  var T = table(sign);
32
36
  module.exports = crc;
@@ -58,7 +58,7 @@ var getCrossUrl = function (domain, headers, encrypt) {
58
58
  });
59
59
  }
60
60
  if (ishttps) domain = b + domain;
61
- if (encrypt) domain = encode62.timeencode(encode62.safeencode(domain, encrypt));
61
+ if (encrypt) domain = encode62.packencode(encode62.safeencode(domain, encrypt));
62
62
  return base + b + domain;
63
63
  };
64
64
  function noop() { }
@@ -506,7 +506,7 @@ function addReform(r) {
506
506
  }
507
507
  function getCode() {
508
508
  return new Promise((ok, oh) => {
509
- this('get', base + "!").then((xhr) => { return ok(encode62.timedecode(xhr.response || xhr.responseText)) }, () => {
509
+ this('get', base + "!").then((xhr) => { return ok(encode62.packdecode(xhr.response || xhr.responseText)) }, () => {
510
510
  return oh(i18n`无法连接可加密的服务器!`);
511
511
  });
512
512
  });
@@ -0,0 +1,44 @@
1
+ var a = 97;
2
+ var z = 122;
3
+ var A = 65;
4
+ var Z = 90;
5
+ var _0 = 48;
6
+ var _9 = 57;
7
+
8
+ var push = function (dist, c) {
9
+ if (c > 0xffff) {
10
+ c -= 0x10000;
11
+ dist.push(String.fromCharCode(0b110110 << 10 | c >> 10 & 0x3ff, 0b110111 << 10 | c & 0x3ff));
12
+ }
13
+ else {
14
+ dist.push(String.fromCharCode(c));
15
+ }
16
+ };
17
+ function decode62S(string) {
18
+ var dist = [];
19
+ var s = 0, i = 1;
20
+ for (var cx = 0, dx = string.length; cx < dx; cx++) {
21
+ var c = string.charCodeAt(cx);
22
+ if (c >= a) {
23
+ if (i > 1) {
24
+ s += (c - a) * i;
25
+ if (s <= z) s -= 26;
26
+ push(dist, s);
27
+ s = 0;
28
+ i = 1;
29
+ }
30
+ else {
31
+ push(dist, c);
32
+ }
33
+ continue;
34
+ }
35
+ if (c >= A) {
36
+ s += (c - A) * i;
37
+ i *= 36;
38
+ continue;
39
+ }
40
+ s += (c - _0 + 26) * i;
41
+ i *= 36;
42
+ }
43
+ return dist.join('');
44
+ }
@@ -0,0 +1,40 @@
1
+ var a_z = 'abcdefghijklmnopqrstuvwxyz';
2
+ var A_0 = a_z.toUpperCase() + '0123456789';
3
+ a_z = a_z.split('');
4
+ A_0 = A_0.split('');
5
+ var a = 97;
6
+ var z = 122;
7
+ var push = function (dist, c) {
8
+ if (c >= a) {
9
+ if (c <= z) return dist.push(a_z[c - a]);
10
+ }
11
+ else {
12
+ c += 26;
13
+ }
14
+ while (c >= 26) {
15
+ var r = c % 36;
16
+ dist.push(A_0[r]);
17
+ c = (c - r) / 36;
18
+ }
19
+ dist.push(a_z[c]);
20
+ }
21
+ function encode62S(string) {
22
+ var dist = [];
23
+ for (var cx = 0, dx = string.length; cx < dx; cx++) {
24
+ var code = string.charCodeAt(cx);
25
+ if (code >> 10 === 0b110110) {
26
+ var code1 = string.charCodeAt(++cx);
27
+ if (code1 >> 10 === 0b110111) {
28
+ push(dist, ((code & 0x3ff) << 10 | (code1 & 0x3ff)) + 0x10000);
29
+ }
30
+ else {
31
+ push(dist, code);
32
+ push(dist, code1);
33
+ }
34
+ }
35
+ else {
36
+ push(dist, code);
37
+ }
38
+ }
39
+ return dist.join('');
40
+ }
@@ -0,0 +1,18 @@
1
+ var test = function (string) {
2
+ var encoded = encode62S(string);
3
+ var decoded = decode62S(encoded);
4
+ var res = assert(decoded, string);
5
+ if (!res) throw new Error("string:" + string + " code:" + string.codePointAt(0) + " packed:" + encoded);
6
+ };
7
+ test('aa')
8
+ test('abc')
9
+ test('aabc')
10
+ test('zaabc')
11
+ test('Azaabc')
12
+ test('aZ')
13
+ test('您好');
14
+ test('😊✔️🛡️⬇️');
15
+ for (var cx = 0, dx = 0x10ffff; cx < dx; cx++) {
16
+ test(String.fromCodePoint(cx))
17
+ test(String.fromCodePoint(cx) + String.fromCodePoint(cx))
18
+ }
@@ -17,8 +17,13 @@ var bindObjK = function (obj, k, resolve, _object) {
17
17
  });
18
18
  };
19
19
  var enrich = function enrich(obj) {
20
- var _promise = Promise.resolve();
21
20
  var _object = Object.create(null);
21
+ try {
22
+ Object.defineProperty({}, 'a', { value: null })
23
+ } catch (e) {
24
+ _object = document.createComment('');
25
+ }
26
+ var _promise = Promise.resolve();
22
27
  var _then = _promise.then;
23
28
  var pthen = function () {
24
29
  var promise = _then.apply(this, arguments);
@@ -1,7 +1,7 @@
1
1
  "use ./KMGT.txt"
2
2
  function scanBlock(piece) {
3
3
  if (!piece) return [];
4
- var reg = /\\[\s\S]|^\s*[#\-]\s*|\s+|"|'/mg;
4
+ var reg = /\\[\s\S]|^\s*[#\-]\s*|\s+|"|'|\^/mg;
5
5
  var res = [];
6
6
  var lastIndex = 0;
7
7
  var save = function (a) {
@@ -18,13 +18,19 @@ function scanBlock(piece) {
18
18
  });
19
19
  res.push(a);
20
20
  };
21
+ var avoid = false;
21
22
  for (var cx = 0, dx = piece.length; cx < dx; cx++) {
22
23
  reg.lastIndex = cx;
23
24
  var m = reg.exec(piece);
24
25
  if (m) {
25
26
  var s = m[0];
26
- if (/^\s+$/.test(s)) {
27
- save(piece.slice(lastIndex, reg.lastIndex));
27
+ if (/^(\s+|\^)$/.test(s)) {
28
+ if (s === '^') {
29
+ avoid = res.length;
30
+ }
31
+ else {
32
+ save(piece.slice(lastIndex, reg.lastIndex));
33
+ }
28
34
  lastIndex = reg.lastIndex;
29
35
  } else if (/^["']$/i.test(s)) {
30
36
  var i = piece.indexOf(s, cx + 1);
@@ -39,6 +45,7 @@ function scanBlock(piece) {
39
45
  break;
40
46
  }
41
47
  }
48
+ if (avoid !== false) res.avoid = avoid;
42
49
  return res;
43
50
  }
44
51
 
@@ -262,7 +269,22 @@ function spreadkey(name) {
262
269
  }
263
270
  return [name, key, needs, holder];
264
271
  }
272
+ function parseOptions(options) {
273
+ if (typeof options === "string" && !/^[\$#]+\d+$/.test(options)) {
274
+ var needUnfold = /^\[|\]$/.test(options);
275
+ options = options.replace(/^\[|\]$/g, '');
276
+ if (needUnfold || /,/.test(options)) options = scanSlant(options, ',');
277
+ else options = scanSlant(options, "");
278
+ if (needUnfold) unfoldOptions(size, options);
279
+ }
280
+ return options;
281
+ }
265
282
  function parse(piece) {
283
+ var avoid1 = null;
284
+ if (piece.avoid != null) {
285
+ avoid1 = piece[piece.avoid];
286
+ piece.splice(piece.avoid, 1);
287
+ }
266
288
  if (/^[\-#]+$/.test(piece[0])) {
267
289
  var piece0 = piece.pop();
268
290
  piece[0] = piece0 + (piece[0] || '').trim();
@@ -293,7 +315,8 @@ function parse(piece) {
293
315
  holder,
294
316
  do: action,
295
317
  editable,
296
- needs, checks, repeat, endwith,
318
+ avoid,
319
+ needs, valid, repeat, endwith,
297
320
  required, inlist, hidden, readonly,
298
321
  delete_onempty, delete_onsubmit,
299
322
  } = name;
@@ -416,18 +439,12 @@ function parse(piece) {
416
439
  } else if (/^[\/]/.test(type)) {
417
440
  type = type.slice(1);
418
441
  }
419
- if (typeof options === "string" && !/^[\$#]+\d+$/.test(options)) {
420
- var editable = false;
421
- if (/^[\+\-\*]|[\+\-\*]$/.test(options)) {
422
- editable = true;
423
- options = options.replace(/^[\+\-\*]|[\+\*\-]$/g, '');
424
- }
425
- var needUnfold = /^\[|\]$/.test(options);
426
- options = options.replace(/^\[|\]$/g, '');
427
- if (needUnfold || /,/.test(options)) options = scanSlant(options, ',');
428
- else options = scanSlant(options, "");
429
- if (needUnfold) unfoldOptions(size, options);
442
+ if (typeof options === 'string' && /^[\+\-\*]|[\+\-\*]$/.test(options)) {
443
+ editable = true;
444
+ options = options.replace(/^[\+\-\*]|[\+\*\-]$/g, '');
430
445
  }
446
+ options = parseOptions(options);
447
+ avoid = parseOptions(avoid1 || avoid);
431
448
  name = is(name);
432
449
  key = is(key);
433
450
  }
@@ -440,8 +457,9 @@ function parse(piece) {
440
457
  name, type, key, value, comment, options,
441
458
  editable,
442
459
  size, unit, ratio, holder,
443
- needs, checks, repeat, endwith,
460
+ needs, valid, repeat, endwith,
444
461
  required, inlist, hidden, readonly,
462
+ avoid,
445
463
  do: action,
446
464
  delete_onempty, delete_onsubmit,
447
465
  };
@@ -481,11 +499,13 @@ function refilm_decode(str) {
481
499
  if (!m) break;
482
500
  var piece = s.slice(lastIndex, m.index);
483
501
  piece = scanBlock(piece);
502
+ if (piece.avoid != null) {
503
+ rest.avoid = rest.length + piece.avoid;
504
+ }
505
+ if (piece) rest.push.apply(rest, piece);
484
506
  if (m[0].length || cx + 1 === dx) {
485
- result.push(rest.concat(piece));
486
- rest.splice(0, rest.length);
487
- } else {
488
- if (piece) rest.push.apply(rest, piece);
507
+ result.push(rest);
508
+ rest = [];
489
509
  }
490
510
  lastIndex = m.index + m[0].length;
491
511
  } while (lastIndex < s.length);
@@ -18,3 +18,7 @@ test(refilm`连城剑法 别名 [唐诗剑法,躺尸剑法]`, ['options', 1, 'na
18
18
  test(refilm`连城剑法 别名 [唐诗剑法,躺尸剑法]`, ['options', 1, 'key'], "躺尸剑法");
19
19
  test(refilm`连城剑法 别名 [唐诗剑法,躺尸剑法]`, ['options', 1, 'value'], 1);
20
20
  test(refilm`连城剑法 别名 [唐诗剑法/0,躺尸剑法/1]`, ['options', 1, 'key'], 1);
21
+ test(refilm`连城剑法 别名 ^[唐诗剑法/0,躺尸剑法/1]`, ['avoid', 1, 'key'], 1);
22
+ test(refilm`连城剑法 别名 [唐诗剑法/0,躺尸剑法/1] ^[a,b]`, ['options', 1, 'key'], 1);
23
+ test(refilm`连城剑法 别名 [唐诗剑法/0,躺尸剑法/1] ^[a,b]`, ['avoid', 1, 'key'], 'b');
24
+ test(refilm`连城剑法 别名 [唐诗剑法/0,躺尸剑法/1] ^${[{ key: 'a' }, { key: 'c' }]}`, ['avoid', 1, 'key'], 'c');
@@ -14,6 +14,10 @@ function valid(field, data) {
14
14
  }
15
15
  return;
16
16
  }
17
+ if (field.avoid) for (var a of field.avoid) {
18
+ if (a === data) continue;
19
+ if (a[field.key] === data[field.key]) return i18n`已存在${field.name}为${data[field.key]}的项`;
20
+ }
17
21
  var tmp = validators[field.type];
18
22
  if (tmp) {
19
23
  var value = data[field.key];
@@ -1,67 +1,82 @@
1
- var hasOwnProperty = {}.__proto__ === Object ? function (k) {
1
+ var hasOwnProperty = {}.__proto__ === Object.prototype ? function (k) {
2
2
  var proto = this.__proto__;
3
3
  return k in this && (!proto || !(k in proto));
4
4
  } : Object.prototype.hasOwnProperty;
5
5
  var setPrototypeOf = Object.setPrototypeOf;
6
+ var wrapMethod = function (f) {
7
+ return function () {
8
+ var res = f.apply(this, arguments);
9
+ setPrototypeOf(res, this.constructor.prototype);
10
+ return res;
11
+ }
12
+ };
6
13
  a: if (!setPrototypeOf) {
7
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
8
- var getOwnPropertyNames = Object.getOwnPropertyNames;
9
- var defineProperty = Object.defineProperty;
10
- try {
11
- if (!getOwnPropertyNames) throw i18n`不支持`;
12
- defineProperty({}, 'o', { value: 0 });
14
+ if ({}.__proto__ === Object.prototype) {
13
15
  setPrototypeOf = function (obj, proto) {
14
- var names = getOwnPropertyNames(proto)
15
- for (var n of names) {
16
- var d = getOwnPropertyDescriptor(proto, n);
17
- defineProperty(obj, n, d);
18
- }
19
- return obj;
16
+ obj.__proto__ = proto;
20
17
  }
21
- break a;
22
- } catch (e) {
23
- getOwnPropertyDescriptor = null;
24
- defineProperty = null;
25
- getOwnPropertyNames = null;
26
18
  }
27
- // <!--
28
- console.error(i18n`当前运行环境使用class extends Array会有难以解决的不兼容性问题,请更换代码的实现方式!`);
29
- // -->
30
- setPrototypeOf = function (obj, proto) {
31
- for (var p in proto) if (hasOwnProperty.call(proto, p) && !(p in obj)) obj[p] = proto[p];
32
- obj.constructor = proto.constructor;
33
- return obj;
19
+ else if (Object.getOwnPropertyDescriptors) {
20
+ setPrototypeOf = function (obj, proto) {
21
+ var descriptors = Object.getOwnPropertyDescriptors(proto);
22
+ Object.defineProperties(obj, descriptors);
23
+ }
34
24
  }
35
- }
36
- var wrapMethod = method => function () {
37
- var res = method.apply(this, arguments);
38
- var res0 = this.constructor.apply(this, []);
39
- res0.length = res.length;
40
- for (var k in res) {
41
- k = +k;
42
- if ((k & 0x7fffffff) !== k) break;
43
- res0[k] = res[k];
25
+ else {
26
+
27
+ if (Object.getOwnPropertyNames) {
28
+ setPrototypeOf = function (obj, proto) {
29
+ var keys = Object.getOwnPropertyNames(proto);
30
+ methods.forEach(k => {
31
+ obj[k] = wrapMethod(proto[k]);
32
+ });
33
+ keys.forEach(k => {
34
+ var dp = Object.getOwnPropertyDescriptor(proto, k);
35
+ Object.defineProperty(obj, k, dp);
36
+ })
37
+ obj.constructor = proto.constructor;
38
+ return obj;
39
+ }
40
+ }
41
+ else {
42
+ // <!--
43
+ console.error(i18n`当前运行环境使用class extends Array会有难以解决的不兼容性问题,请更换代码的实现方式!`);
44
+ // -->
45
+ setPrototypeOf = function (obj, proto) {
46
+ var keys = Object.keys(proto);
47
+ methods.forEach(k => {
48
+ obj[k] = wrapMethod(proto[k]);
49
+ });
50
+ obj.constructor = proto.constructor;
51
+ keys.forEach(k => {
52
+ if (!(k in obj)) obj[k] = proto[k];
53
+ })
54
+ return obj;
55
+ }
56
+ }
44
57
  }
45
- return res0;
46
- };
47
- var map = wrapMethod([].map);
48
- var slice = wrapMethod([].slice);
49
- var filter = wrapMethod([].filter);
50
- var splice = wrapMethod([].splice);
51
- var concat = wrapMethod([].concat);
58
+ }
52
59
 
53
60
  function Array2() {
54
- var proto = this.constructor.prototype;
61
+ var res = Array.apply(this, arguments);
55
62
  /**
56
63
  * @type {PropertyDescriptor}
57
64
  */
58
- if (!hasOwnProperty.call(proto, 'map')) proto.map = map;
59
- if (!hasOwnProperty.call(proto, 'slice')) proto.slice = slice;
60
- if (!hasOwnProperty.call(proto, 'filter')) proto.filter = filter;
61
- if (!hasOwnProperty.call(proto, 'splice')) proto.splice = splice;
62
- if (!hasOwnProperty.call(proto, 'concat')) proto.concat = concat;
63
- var obj = setPrototypeOf(Array.apply(this, arguments), proto);
64
- return obj;
65
+ setPrototypeOf(res, this.constructor.prototype);
66
+ return res;
65
67
  }
68
+ var methods = [
69
+ 'concat',
70
+ 'slice',
71
+ 'splice',
72
+ 'filter',
73
+ 'flat',
74
+ 'flatMap',
75
+ 'map',
76
+ 'toReversed',
77
+ 'toSorted',
78
+ 'toSpliced',
79
+ 'with',
80
+ ].filter(k => k in Array.prototype);
66
81
  Array2.prototype = Array.prototype;
67
82
  return Array2;
@@ -2,14 +2,21 @@ var __static = Object.setPrototypeOf || { __proto__: [] } instanceof Array && fu
2
2
  d.__proto__ = b;
3
3
  } || extend;
4
4
  var setConstructor = Object.defineProperty ? function (a, c) {
5
- Object.defineProperty(a, "constructor", { value: c });
5
+ try {
6
+ Object.defineProperty(a, "constructor", { value: c });
7
+ } catch (e) {
8
+ setConstructor = function (a, c) {
9
+ a.constructor = c;
10
+ };
11
+ setConstructor(a, c);
12
+ }
6
13
  } : function (a, c) {
7
14
  a.constructor = c;
8
15
  };
9
16
  // class A extends B {}
10
17
  function extends_(A, B) {
18
+ A.prototype = B === null ? Object.create(null) : (_ = new B, setConstructor(_, A), _);
11
19
  __static(A, B);
12
- A.prototype = B === null ? Object.create(null) : new (_ = function () { setConstructor(this, A) }, _.prototype = B.prototype, _);
13
20
  var _;
14
21
  }
15
22
  return extends_;
@@ -43,7 +43,7 @@ instanceof`.trim().split(/[,\s]+/);
43
43
  var colonstrap_reg = /^(case|default)$/;
44
44
  class Javascript extends Program {
45
45
  straps = straps;
46
- value_reg = /^(false|true|null|Infinity|NaN|undefined|eval)$/
46
+ value_reg = /^(false|true|null|Infinity|NaN|undefined|eval|this|arguments)$/
47
47
  transive_reg = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|instanceof|throw|extends|import|from)$/
48
48
  strapexp_reg = /^(new|void|typeof|delete|class|function|await)/;
49
49
  forceend_reg = /^(return|yield|break|continue|debugger|async)$/;
@@ -1,4 +1,4 @@
1
- var { STAMP, EXPRESS, STRAP, isHalfSentence, skipAssignment, skipFunction, getDeclared, VALUE, STRAP, SCOPED, QUOTED, snapSentenceHead, pickSentence, createString, getBodyWith, getFuncBody } = require("./common");
1
+ var { STAMP, EXPRESS, STRAP, isHalfSentence, pickArgument, skipAssignment, skipFunction, getDeclared, VALUE, STRAP, SCOPED, QUOTED, snapSentenceHead, pickSentence, createString, getBodyWith, getFuncBody } = require("./common");
2
2
  var addAccessedStart = function (matched, namedMap) {
3
3
  var start = +namedMap["#1"];
4
4
  var body = getBodyWith(matched[0], 'arguments');
@@ -125,6 +125,22 @@ var unMultiple = function (matched) {
125
125
  matched.suggest = `${createString(matched)}{\r\n // 不建议在可并行执行的函数中更改外部变量,以防并发调用时出现异常\r\n // 建议在可并行函数内声明如下变量,并修改用到这些变量的代码\r\n var ${undec.join(',')};\r\n }`;
126
126
  return matched;
127
127
  }
128
+ var checkSpliceSize = function (matched, i) {
129
+ var [m] = matched;
130
+ var argq = m.next;
131
+ if (argq?.type !== SCOPED || argq.entry !== '(') return;
132
+ var o = argq.first;
133
+ while (i-- > 0) {
134
+ o = skipAssignment(o).next;
135
+ }
136
+ var arg3 = pickArgument(o);
137
+ if (arg3.length === 1) {
138
+ var [size] = arg3;
139
+ if (!size.isdigit && !/\.length$/.test(size.text)) {
140
+ matched.suggest = `//第三个参数可能出错\r\n${createString([argq])}`;
141
+ }
142
+ }
143
+ }
128
144
  var suggest = {
129
145
  "while($2[$1++]!==$3)": "while($1<$2.length&&$2[$1++]!==$3)",
130
146
  "while($2[$1]!==$3)$1++": "while($1<$2.length&&$2[$1]!==$3)$1++",
@@ -132,6 +148,12 @@ var suggest = {
132
148
  "for(var $1=#1;$1<arguments.length;$1++)": addAccessedStart,
133
149
  "await": unMultiple,
134
150
  "yield": unMultiple,
151
+ "splice"(matched) {
152
+ checkSpliceSize(matched, 2);
153
+ },
154
+ ".splice"(matched) {
155
+ checkSpliceSize(matched, 1);
156
+ },
135
157
  "arguments"(matched) {
136
158
  var m = matched[0];
137
159
  var body = getBodyWith(m, 'arguments');
@@ -1,7 +1,8 @@
1
1
  var { VALUE, QUOTED, EXPRESS, STRAP, relink } = require("./common");
2
- var cloneNode = function (o) {
2
+ var cloneNode = function (o, keep) {
3
3
  var c = o;
4
4
  if (c instanceof Array && !c.text) {
5
+ if (keep) return c;
5
6
  c = c.map(cloneNode);
6
7
  c.entry = o.entry;
7
8
  c.leave = o.leave;
@@ -12,6 +13,7 @@ var cloneNode = function (o) {
12
13
  relink(c);
13
14
  }
14
15
  else if (typeof c === 'object' && c instanceof Object) {
16
+ if (keep) return c;
15
17
  c = Object.assign({}, c);
16
18
  }
17
19
  else switch (typeof c) {