efront 4.21.3 → 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 (96) hide show
  1. package/#/345/233/275/351/231/205/345/214/226.yml +117 -66
  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/parseNumber.js +12 -7
  28. package/coms/basic/percent.js +28 -0
  29. package/coms/basic/refilm.js +24 -5
  30. package/coms/basic/refilm_decode.js +46 -22
  31. package/coms/basic/refilm_decode_test.js +5 -0
  32. package/coms/basic/valid.js +4 -0
  33. package/coms/basic_/&Array.js +64 -49
  34. package/coms/basic_/&extends.js +9 -2
  35. package/coms/compile/Html_test.js +5 -0
  36. package/coms/compile/Javascript.js +13 -3
  37. package/coms/compile/Javascript_test.js +3 -0
  38. package/coms/compile/Program.js +119 -43
  39. package/coms/compile/audit.js +23 -1
  40. package/coms/compile/cloneNode.js +3 -1
  41. package/coms/compile/common.js +7 -1
  42. package/coms/compile/downLevel.js +21 -11
  43. package/coms/compile/downLevel_test.js +52 -14
  44. package/coms/compile/rescan.js +8 -2
  45. package/coms/compile/scanner2.js +53 -7
  46. package/coms/compile/translate.js +1 -1
  47. package/coms/compile/unstruct.js +9 -9
  48. package/coms/crypt/encode62.js +36 -6
  49. package/coms/crypt/encode62_test.js +8 -48
  50. package/coms/explorer/main.less +1 -5
  51. package/coms/frame/chat.js +2 -2
  52. package/coms/frame/left.html +5 -4
  53. package/coms/frame/left.js +1 -0
  54. package/coms/frame/left.less +5 -3
  55. package/coms/frame/payment.js +2 -2
  56. package/coms/pivot/acme2.js +7 -4
  57. package/coms/pivot/left-footer.xht +25 -0
  58. package/coms/pivot/pedit.js +3 -3
  59. package/coms/pivot/plist.js +2 -2
  60. package/coms/pivot/qrcode.xht +3 -0
  61. package/coms/zimoli/XMLHttpRequest.js +16 -13
  62. package/coms/zimoli/container.js +34 -34
  63. package/coms/zimoli/design.html +6 -13
  64. package/coms/zimoli/design.js +49 -13
  65. package/coms/zimoli/design.less +62 -25
  66. package/coms/zimoli/drag.js +8 -3
  67. package/coms/zimoli/encode62.js +40 -12
  68. package/coms/zimoli/lattice.js +0 -1
  69. package/coms/zimoli/list.js +0 -8
  70. package/coms/zimoli/menu.js +29 -5
  71. package/coms/zimoli/model.js +150 -195
  72. package/coms/zimoli/model.less +4 -8
  73. package/coms/zimoli/on.js +14 -12
  74. package/coms/zimoli/padding.less +1 -0
  75. package/coms/zimoli/progbar.xht +9 -8
  76. package/coms/zimoli/prompt.less +0 -3
  77. package/coms/zimoli/render.js +210 -125
  78. package/coms/zimoli/select.js +9 -4
  79. package/coms/zimoli/select.less +3 -14
  80. package/coms/zimoli/selectList.js +5 -1
  81. package/coms/zimoli/selectList.less +3 -0
  82. package/coms/zimoli/table.html +7 -7
  83. package/coms/zimoli/table.js +12 -9
  84. package/coms/zimoli/table.less +5 -0
  85. package/coms/zimoli/user.js +2 -2
  86. package/coms/zimoli/view.js +3 -4
  87. package/coms/zimoli/watch.js +3 -1
  88. package/coms/zimoli/zimoli.js +6 -2
  89. package/coms//350/214/250/350/217/260/tab.js +26 -2
  90. package/coms//350/214/250/350/217/260//346/240/207/347/255/276/345/214/226.js +1 -1
  91. package/coms//350/214/250/350/217/260//347/274/226/350/276/221/346/241/206.xht +183 -20
  92. package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +5 -0
  93. package/package.json +1 -1
  94. package/public/efront.js +1 -1
  95. package/readme-en.md +3 -5
  96. package/readme.md +3 -4
@@ -4,40 +4,80 @@
4
4
  height: 100%;
5
5
  display: block;
6
6
  position: relative;
7
- padding-right: 0 !important;
8
7
  overflow: hidden;
8
+ border-right: 10px solid transparent;
9
+ padding-right: 0 !important;
10
+ background: #f2f4f6;
9
11
  }
10
12
 
11
- .design {
12
- list {
13
- height: 100%;
14
- }
13
+ >[head] {
14
+ background: #fff;
15
+ }
15
16
 
16
- list,
17
- .options {
17
+ design {
18
+ height: 100%;
19
+ }
18
20
 
19
- width: 600px;
20
- margin: 0 auto;
21
+ btn {
22
+ padding: 0 20px;
23
+ }
24
+
25
+ [act] {
26
+ display: block;
27
+ border-radius: 6px;
28
+ border: 1px solid #999;
29
+ padding: 4px 10px;
30
+ height: 60px;
31
+ [a-key] {
32
+ font-family: 20px;
33
+ font-style: italic;
21
34
  }
22
35
  }
23
36
  </style>
24
-
25
- <div head>
26
- 数据配置 - <span -bind="db.name"></span>
27
- </div>
37
+ <xmenu tag head -src="m in menus"></xmenu>
28
38
  <div body>
29
- <field -repeat="f in fields" -src="[f,db]"></field>
39
+ <div config -if="menus[0].actived">
40
+ <field -repeat="f in fields" -src="[f,db]"></field>
41
+ </div>
42
+ <design fields -if="menus[1].actived" _avoid="db.actions" -src="db.fields"></design>
43
+ <lattice actions -src="a in db.actions" -if="menus[2].actived">
44
+ <padding>
45
+ <div act @click="editAction(a)">
46
+ <div a.key?></div>
47
+ <div a.name?></div>
48
+ </div>
49
+ </padding>
50
+ <a insert @click="editAction(null)">添加动作</a>
51
+ </lattice>
30
52
  </div>
31
53
  <div foot>
32
- <button @click="save">保存</button>
54
+ <div style="float: left;">
55
+ ${i18n`数据配置`} - <span -bind="db.name"></span>
56
+ </div>
57
+ <button @click="save">${i18n`保存`}</button>
33
58
  </div>
34
59
  <script>
60
+ view(this);
61
+ var xmenu = menu;
62
+ var btn = button;
63
+ var a = button;
64
+ var menus = refilm`
65
+ 权限管理
66
+ 字段管理
67
+ 动作管理
68
+ `;
35
69
  var fields = refilm`
36
70
  是否公开/open swap`;
37
71
  var [db] = arguments;
72
+ if (!db.fields) {
73
+ var [da1] = await data.from('dbfind', { dbid: db.name, size: 1 });
74
+ db.fields = da1 ? Object.keys(da1).map(k => ({ key: k })) : [];
75
+ }
76
+ var editAction = function (a) {
77
+ popup('#/db/act', [db, a]);
78
+ };
38
79
  var save = async function () {
39
80
  await data.from('dbset', db);
40
81
  history.back();
41
82
  };
42
- console.log(db)
43
83
  </script>
@@ -1,32 +1,31 @@
1
- <div>
2
- 已登录到服务器,您可以进行如下操作
3
- </div>
4
1
  <block>
5
- <padding>
6
- 清理服务器缓存 <btn @click="run('clear-cache',this)">清理</btn>
7
- </padding>
8
2
  </block>
9
3
  <block>
10
4
  <padding>
11
- 重启服务器 <btn @click="run('rehost',this)" type="danger">重启</btn>
5
+ 服务器版本&nbsp;&nbsp;<span -text="String(version)"></span>
6
+ </padding>
7
+ <padding>
8
+ nodejs版本&nbsp;&nbsp;<span -text="String(nodeVersion)"></span>
12
9
  </padding>
13
- </block>
14
- <block>
15
10
  <padding>
16
- 退出登录 <btn @click="logout()">退出</btn>
11
+ 操作系统&nbsp;&nbsp;<span -text="String(platform)"></span>
12
+ </padding>
13
+ <padding>
14
+ 处理器&nbsp;&nbsp;<span -text="String(arch)"></span>
17
15
  </padding>
18
16
  </block>
19
17
  <block>
20
18
  <padding>
21
- 服务器版本&nbsp;&nbsp;<span -text="String(version)"></span>
19
+ 清理服务器缓存 <btn @click="run('clear-cache',this)">清理</btn>
20
+ </padding>
21
+ <padding>
22
+ 重启服务器 <btn @click="run('rehost',this)" confirm type="danger">重启</btn>
22
23
  </padding>
23
24
  </block>
24
25
  <block>
25
26
  <padding>
26
27
  启动时间&nbsp;&nbsp;<span -text="filterTime(hrtime)"></span>
27
28
  </padding>
28
- </block>
29
- <block>
30
29
  <padding>
31
30
  内存 <progbar danger:="memery[0]/memery[1]<.05" :current="memeryUsed" :total="memery[1]"></progbar>
32
31
  <span style="color: #999;">
@@ -8,6 +8,9 @@ function main() {
8
8
  filterTime,
9
9
  memeryUsed: 0,
10
10
  memery: [0, 1],
11
+ platform: '未知',
12
+ arch: '未知',
13
+ nodeVersion: "未知",
11
14
  size,
12
15
  progbar,
13
16
  async run(id) {
@@ -16,12 +19,6 @@ function main() {
16
19
  run: id
17
20
  }).loading_promise;
18
21
  if (info) alert(info, 'pass');
19
- },
20
- async logout() {
21
- data.setSource({});
22
- await user.Logout();
23
- zimoli.switch();
24
- zimoli();
25
22
  }
26
23
  };
27
24
  renderWithDefaults(page, scope);
@@ -29,6 +26,9 @@ function main() {
29
26
  var [mr, mt] = a.memery;
30
27
  scope.memeryUsed = mt - mr;
31
28
  scope.memery = a.memery;
29
+ scope.nodeVersion = a.nodeVersion;
30
+ scope.platform = a.platform;
31
+ scope.arch = a.arch;
32
32
  console.log('status')
33
33
  });
34
34
  return page;
@@ -1,11 +1,20 @@
1
- &{
1
+ & {
2
2
  line-height: 28px;
3
3
  }
4
- progbar{
4
+
5
+ progbar {
5
6
  width: 120px;
6
7
  }
7
- btn{
8
+
9
+ btn {
8
10
  padding: 0 16px;
9
11
  vertical-align: top;
10
12
  margin-left: 20px;
13
+ }
14
+
15
+ padding {
16
+ >span {
17
+ color: #999;
18
+ margin-right: 10px;
19
+ }
11
20
  }
@@ -3,7 +3,7 @@ plist.bind(null, '房间', "room", refilm`
3
3
  / $ ${[{
4
4
  name: "连接",
5
5
  async do(o) {
6
- var linkid = await data.from("room", { id: encode62.timeencode(o.name) });
6
+ var linkid = await data.from("room", { id: encode62.packencode(o.name) });
7
7
  popup("/link/chat", { linkid, name: o.name });
8
8
  }
9
9
  }]}
@@ -65,14 +65,15 @@ setInterval(function () {
65
65
  if (!base.base) return user.token = null;
66
66
  var auth = data.getSource(base.base);
67
67
  if (!auth) return user.token = null;
68
- var auth1 = encode62.timeupdate(auth);
68
+ var auth1 = encode62.packupdate(auth);
69
69
  if (auth1 !== auth) data.setSource(base.base, auth1);
70
70
  user.token = auth1;
71
71
  }, 2000);
72
72
  login();
73
73
  var layer = layer$glance({
74
74
  left: frame$left.bind({
75
- head: await init("left-header")
75
+ head: await init("left-header"),
76
+ foot: await init('left-footer')
76
77
  }),
77
78
  top: frame$top
78
79
  });
@@ -4,7 +4,7 @@ function main(a) {
4
4
  drag.on(page.firstChild, page);
5
5
  resize.on(page);
6
6
  var fields = data.from("params", { key: a.key }, function (a) {
7
- return a ? JSON.parse(encode62.timedecode(a)) : [];
7
+ return a ? JSON.parse(encode62.packdecode(a)) : [];
8
8
  });
9
9
  var taskid = 0;
10
10
  renderWithDefaults(page, {
@@ -23,8 +23,8 @@ function main(a) {
23
23
  this.error = false;
24
24
  var params = JSON.stringify(this.data);
25
25
  try {
26
- var res = await data.from("invoke", { key: a.key, params: encode62.timeencode(params) }, function (a) {
27
- return a ? encode62.timedecode(a) : '完成!';
26
+ var res = await data.from("invoke", { key: a.key, params: encode62.packencode(params) }, function (a) {
27
+ return a ? encode62.packdecode(a) : '完成!';
28
28
  });
29
29
  if (id !== taskid) return;
30
30
  this.output = res;
@@ -24,8 +24,8 @@ function main(task) {
24
24
  cross.addDirect(api.base);
25
25
  await data.from(api, {
26
26
  type: "task",
27
- key: encode62.timeencode(task.key),
28
- value: encode62.timeencode(JSON.stringify(task))
27
+ key: encode62.packencode(task.key),
28
+ value: encode62.packencode(JSON.stringify(task))
29
29
  });
30
30
  finished[h.key] = true;
31
31
  }
@@ -1,7 +1,7 @@
1
1
  var fields = refilm`
2
2
  文件
3
3
  `;
4
- var passport = encode62.timeencode(encode62.decode62(user._passport, user.session));
4
+ var passport = encode62.packencode(encode62.decode62(user._passport, user.session));
5
5
  var pending = [];
6
6
  async function upload(f, dist, token) {
7
7
  var api = await data.getApi("upload");
@@ -94,7 +94,7 @@ function main(path) {
94
94
  var p = this.pathlist.join('/').replace(/^\/+|\/+$/g, '');
95
95
  var bp = p ? base + p + "/" : base;
96
96
  p = p + '/';
97
- return data.from("folder", { opt: 'list', path: encode62.timeencode(p) }, files => {
97
+ return data.from("folder", { opt: 'list', path: encode62.packencode(p) }, files => {
98
98
  if (files) return files.map(f => {
99
99
  var file = new File(f);
100
100
  file.host = base;
@@ -112,22 +112,22 @@ function main(path) {
112
112
  },
113
113
  upload,
114
114
  async delete(path) {
115
- return data.from("folder", { opt: 'del', path: encode62.timeencode(path) })
115
+ return data.from("folder", { opt: 'del', path: encode62.packencode(path) })
116
116
  },
117
117
  async rename(from, to) {
118
- from = encode62.timeencode(from);
119
- to = encode62.timeencode(to);
118
+ from = encode62.packencode(from);
119
+ to = encode62.packencode(to);
120
120
  await data.from("folder", { opt: 'mov', path: from, to }).loading_promise;
121
121
  },
122
122
  async add(name) {
123
- name = encode62.timeencode(name);
123
+ name = encode62.packencode(name);
124
124
  await data.from("folder", { opt: 'add', path: name }).loading_promise;
125
125
  },
126
126
  async mov(from, distpath) {
127
127
  var currentHost = data.getInstance("base").base;
128
128
  if (from.host !== currentHost) return alert("暂不支持跨服务器操作!");
129
- from = encode62.timeencode(from.fullpath);
130
- distpath = encode62.timeencode(distpath);
129
+ from = encode62.packencode(from.fullpath);
130
+ distpath = encode62.packencode(distpath);
131
131
  await data.from("folder", { opt: 'mov', path: from, to: distpath }).loading_promise;
132
132
  }
133
133
  });
@@ -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);
@@ -8,8 +8,13 @@ function xto0(x) {
8
8
 
9
9
  function parseNumber(str) {
10
10
  var s = 10;
11
+ str = str.replace(/\_/g, '');
11
12
  if (!isString(str)) return str;
12
- switch (str.slice(0, 2).toLowerCase()) {
13
+ var num = str.replace(/^[\+\-]+/, '');
14
+ var neg = str.slice(0, str.length - num.length).replace(/\+/g, '').length & 1;
15
+ if (neg) neg = "-";
16
+ else neg = '';
17
+ switch (num.slice(0, 2).toLowerCase()) {
13
18
  case "0x":
14
19
  s = 16;
15
20
  break;
@@ -20,15 +25,15 @@ function parseNumber(str) {
20
25
  s = 2;
21
26
  break;
22
27
  default:
23
- return parseFloat(str);
28
+ return parseFloat(neg + num);
24
29
  }
25
- str = str.slice(2);
26
- if (/x/i.test(str)) {
30
+ num = num.slice(2).replace(/\_/g, '');
31
+ if (/x/i.test(num)) {
27
32
  return bitTest.bind(null,
28
- parseInt(str.replace(/[\s\S]/g, xto0), 2),
29
- parseInt(str.replace(/x/g, '0'), 2)
33
+ parseInt(neg + num.replace(/[\s\S]/g, xto0), 2),
34
+ parseInt(neg + num.replace(/x/g, '0'), 2)
30
35
  );
31
36
  }
32
- return parseInt(str, s);
37
+ return parseInt(neg + num, s);
33
38
  }
34
39
  module.exports = parseNumber
@@ -0,0 +1,28 @@
1
+ function percent(value, compare_value) {
2
+ if (!isFinite(value)) return value;
3
+ value *= 100;
4
+ var fix = 1000000;
5
+ var flag = value;
6
+ if (flag < 0) flag = -flag;
7
+ if (flag > 100);
8
+ else if (flag > 50) flag = 100 - flag;
9
+ if (isFinite(compare_value) && 100 * compare_value !== value) Math.min(Math.abs(value - compare_value), flag);
10
+ switch (Math.log(flag) | 0) {
11
+ case -Infinity:
12
+ case 2:
13
+ case 3:
14
+ case 4:
15
+ fix = 1; break;
16
+ case 1:
17
+ fix = 10; break;
18
+ case 0:
19
+ fix = 100; break;
20
+ case -1:
21
+ fix = 1000; break;
22
+ case -2:
23
+ fix = 10000; break;
24
+ case -3:
25
+ fix = 100000; break;
26
+ }
27
+ return (value * fix | 0) / fix + "%";
28
+ }