efront 4.0.40 → 4.0.45

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 (36) hide show
  1. package/apps/pivot/log/count.js +2 -2
  2. package/coms/basic/Table.js +4 -2
  3. package/coms/basic/analyse_test.js +2 -1
  4. package/coms/basic/arrayEqual.js +8 -0
  5. package/coms/basic/decodeGBK.js +14 -1
  6. package/coms/{zimoli → basic}/deepEqual.js +0 -17
  7. package/coms/basic/encodeUTF8.js +1 -0
  8. package/coms/basic/isSame.js +2 -1
  9. package/coms/basic/refilm_decode.js +3 -2
  10. package/coms/basic/refilm_decode_test.js +2 -0
  11. package/coms/basic/shallowEqual.js +18 -0
  12. package/coms/basic/str2array.js +5 -0
  13. package/coms/compile/Javascript.js +31 -15
  14. package/coms/compile/Javascript_test.js +3 -0
  15. package/coms/compile/Program.js +11 -7
  16. package/coms/compile/common.js +6 -8
  17. package/coms/compile/formatcode.js +7 -2
  18. package/coms/compile/patchlist.js +5 -0
  19. package/coms/compile/patchname.js +9 -0
  20. package/coms/compile/scanner2_test.js +13 -1
  21. package/coms/compile/unstruct_test.js +4 -2
  22. package/coms/pivot/pedit.js +15 -6
  23. package/coms/reptile/detectWithExtension.js +36 -0
  24. package/coms/zimoli/data.js +1 -1
  25. package/coms/zimoli/getChanges.js +2 -2
  26. package/coms/zimoli/render.js +2 -2
  27. package/coms/zimoli/select.js +2 -2
  28. package/coms/zimoli/table.html +2 -2
  29. package/coms/zimoli/table.js +1 -1
  30. package/coms/zimoli/table.less +8 -0
  31. package/docs//345/267/245/345/205/267//345/255/227/347/254/246/351/233/206/346/243/200/346/237/245.xht +72 -14
  32. package/package.json +1 -1
  33. package/public/efront.js +1 -1
  34. package/readme-en.md +10 -4
  35. package/readme.md +7 -4
  36. /package/coms/{zimoli → basic}/deepEqual_test.js +0 -0
@@ -1,6 +1,6 @@
1
1
  var fields = refilm`
2
- 路径/path html
3
- 访问量/count
2
+ 访问量/count money/10
3
+ 路径/path html/20
4
4
  `;
5
5
  function main() {
6
6
  var page = div();
@@ -56,6 +56,7 @@ class Table extends Array {
56
56
  var searchtext = this.searchText;
57
57
  var fields = this.searchFields ? this.searchFields : this.fields;
58
58
  var power = 0;
59
+ var s = o;
59
60
  if (isNode(o)) {
60
61
  o = extend({
61
62
  name: o.name,
@@ -68,6 +69,7 @@ class Table extends Array {
68
69
  }, o);
69
70
  }
70
71
  else o = isObject(o) ? Object.create(o) : new o.constructor(o);
72
+ o.$origin = s;
71
73
  for (var f of fields) {
72
74
  var name = seek(o, f.key);
73
75
  if (isEmpty(name) || !isString(name)) continue;
@@ -90,14 +92,14 @@ class Table extends Array {
90
92
  this.update();
91
93
  }
92
94
  async update() {
95
+ var origin = this.searched ? this.splice(0, this.length).map(o => o.$origin) : [];
93
96
  this.searched = 0;
94
- this.splice(0, this.length);
95
97
  var source = this.sorted ? this.sorted : this.source;
96
98
  if (!source) return;
97
99
  var searchid = ++this.searchid;
98
100
  this.complete = false;
99
101
  this.coverCount = 0;
100
- if (this.searchText) for (var o of source) {
102
+ if (this.searchText) for (var o of origin.length ? origin.concat(source) : source) {
101
103
  this.addItem(o);
102
104
  if (++this.searched % 600 === 0) {
103
105
  if (isFunction(this.callback)) this.callback();
@@ -1,5 +1,6 @@
1
1
  var require = window.require;
2
2
  var fs, path;
3
+ var document = window.document;
3
4
  function test(url) {
4
5
  var data = fs.readFileSync(url);
5
6
  data = String(data);
@@ -39,7 +40,7 @@ function analyse_test(text) {
39
40
  fs = require("fs");
40
41
  path = require("path");
41
42
  if (text) return analyse(text);
42
- testxml("/book/金山打字");
43
+ if (document) testxml("/book/金山打字");
43
44
  // testcode("/work/efront/coms/basic");
44
45
 
45
46
  testblog("炒面.txt");
@@ -0,0 +1,8 @@
1
+ function sliceEqual(a, b) {
2
+ if (a === b) return true;
3
+ if (a.length !== b.length) return false;
4
+ for (var cx = 0, dx = a.length; cx < dx; cx++) {
5
+ if (!isSame(a[cx], b[cx])) return false;
6
+ }
7
+ return true;
8
+ }
@@ -55,11 +55,24 @@ var ex = [
55
55
  ];
56
56
  var map = [];
57
57
  var inc = 0, codeindex = 0;
58
+ var pam = Object.create(null);
58
59
  while (ex.length) {
59
60
  inc += ex.shift();
60
61
  var tmp = inc + ex.shift();
61
- while (inc <= tmp) map[inc++] = txt[codeindex++];
62
+ while (inc <= tmp) pam[map[inc] = txt[codeindex++]] = inc++;
62
63
  }
64
+ decodeGBK.codeFor = function (string) {
65
+ var dist = [];
66
+ for (var cx = 0, dx = string.length; cx < dx; cx++) {
67
+ var c = pam[string.charAt(cx)] || string.charCodeAt(cx);
68
+ if (c > 0x7f) {
69
+ dist.push(c >> 8, c & 0xff);
70
+ } else {
71
+ dist.push(c);
72
+ }
73
+ }
74
+ return dist;
75
+ };
63
76
 
64
77
  function decodeGBK(buff) {
65
78
  var temp = 0;
@@ -53,23 +53,6 @@ var objectEqual = function (o1, o2, deep) {
53
53
  }
54
54
  return true;
55
55
  };
56
- function shallowEqual(o1, o2) {
57
- // 浅层比对,对内层对象不进行递归比对
58
- if (o1 === o2) return true;
59
- if (isObject(o1) && isObject(o2)) {
60
- var keys1 = Object.keys(o1), keys2 = Object.keys(o2);
61
- if (keys1.length !== keys2.length) return false;
62
- keys1.sort(), keys2.sort();
63
- for (var cx = 0, dx = keys1.length; cx < dx; cx++) {
64
- var key1 = keys1[cx];
65
- var key2 = keys2[cx];
66
- if (key1 !== key2) return false;
67
- if (!singleEqual(o1[key1], o2[key2])) return false;
68
- }
69
- return true;
70
- }
71
- return singleEqual(o1, o2);
72
- }
73
56
  function deepEqual(o1, o2) {
74
57
  if (o1 === o2) return true;
75
58
  if (isObject(o1) && isObject(o2)) {
@@ -52,4 +52,5 @@ function encodeUTF8(string) {
52
52
  }
53
53
  return dist;
54
54
  }
55
+ encodeUTF8.number = numberUTF8;
55
56
  module.exports = encodeUTF8
@@ -1,3 +1,4 @@
1
+ var isNaN = Number.isNaN;
1
2
  function isSame(o1, o2) {
2
- return o1 === o2 || isNumber(o1) && isNumber(o2) && isNaN(o1) && isNaN(o2);
3
+ return o1 === o2 || isNaN(o1) && isNaN(o2);
3
4
  }
@@ -275,13 +275,13 @@ function parse(piece) {
275
275
  }
276
276
  };
277
277
  var is = function (a) {
278
- var reg = /^[\*\+\-\!\-\$&\?\~]|[\*\+\-\!\-\$&\?\~]$/;
278
+ var reg = /^[\*\+\-\!\-&\?\~]|^\$(?!\d)|[\*\+\-\!\-\$&\?\~]$/;
279
279
  if (!reg.test(a)) return a;
280
280
  required = test(/^\*|\*$/, a);
281
281
  if (test(/^[\+]|[\+]$/, a)) inlist = true;
282
282
  if (test(/^[\!]|[\!]$/, a)) inlist = false;
283
283
  hidden = test(/^\-|\-$/, a);
284
- readonly = test(/^[\$&]|[\$&]$/, a);
284
+ readonly = test(/^&|\$(?!\d)|[\$&]$/, a);
285
285
  delete_onempty = test(/^\?|\?$/, a);
286
286
  delete_onsubmit = test(/^\~|\~$/, a);
287
287
  return a.replace(reg, '');
@@ -331,6 +331,7 @@ function parse(piece) {
331
331
  type = d + 'bit/' + t;
332
332
  }
333
333
  var sizematch = /^(\-?\d+|\-?\d*\.\d+)?([YZEPTGMK]i?b?|bytes?|bits?|words?|dword|real[48]|long|B|[^\/]*)([\/]|$|\s|\=)/i.exec(type);
334
+ if (!sizematch[1] && /^\$\d/.test(sizematch[2])) sizematch = null;
334
335
  if (sizematch) {
335
336
  var [size_text, size = 1, unit, eq] = sizematch;
336
337
  if (unit && /^i?b?$/i.test(unit.slice(1))) {
@@ -0,0 +1,2 @@
1
+ var fields = refilm_decode(["启动时间/time $1"]);
2
+ console.log(fields);
@@ -0,0 +1,18 @@
1
+ var singleEqual = isSame;
2
+ function shallowEqual(o1, o2) {
3
+ // 浅层比对,对内层对象不进行递归比对
4
+ if (o1 === o2) return true;
5
+ if (isObject(o1) && isObject(o2)) {
6
+ var keys1 = Object.keys(o1), keys2 = Object.keys(o2);
7
+ if (keys1.length !== keys2.length) return false;
8
+ keys1.sort(), keys2.sort();
9
+ for (var cx = 0, dx = keys1.length; cx < dx; cx++) {
10
+ var key1 = keys1[cx];
11
+ var key2 = keys2[cx];
12
+ if (key1 !== key2) return false;
13
+ if (!singleEqual(o1[key1], o2[key2])) return false;
14
+ }
15
+ return true;
16
+ }
17
+ return singleEqual(o1, o2);
18
+ }
@@ -0,0 +1,5 @@
1
+ var spliter = /\s*[,;\|]\s*/
2
+ module.exports = function (names) {
3
+ if (typeof names === 'string') names = names.split(spliter);
4
+ return names;
5
+ }
@@ -504,7 +504,7 @@ var removeImport = function (c, i, code) {
504
504
  var { used, envs, vars } = code;
505
505
  if (next && next.type !== QUOTED) {
506
506
  var [dec, map, o] = getDeclared(c.next);
507
- if (dec.length !== 1 || !o) throw new Error("代码结构异常!");
507
+ if (!o) throw new Error("代码结构异常!");
508
508
  if (o.type !== STRAP || o.text !== 'from') throw new Error("缺少from语句");
509
509
  var oi = code.indexOf(o, i);
510
510
  }
@@ -534,20 +534,31 @@ var removeImport = function (c, i, code) {
534
534
  relink(q[1]);
535
535
  setqueue(q[1]);
536
536
  if (!dec) return;
537
- var name = dec[0];
537
+ var name = null;
538
538
  var na = dec.attributes[0];
539
539
  o.type = STAMP;
540
540
  o.text = '=';
541
541
  c.text = 'var';
542
- if (typeof name === 'string' && name !== '*') {
543
- if (na[0] !== '*') {
544
- used[name].forEach(u => {
545
- u.text = u.text.replace(/^[^\.\[]+/g, '$&.default');
546
- });
542
+ dec.forEach(function (name1, i) {
543
+ if (typeof name1 === 'string' && name1 !== '*') {
544
+ if (na[i] === '*') {
545
+ if (name) {
546
+ used[name1].forEach(u => {
547
+ u.text = u.text.replace(/^[^\.\[]+/, name);
548
+ });
549
+ }
550
+ else name = name1;
551
+ }
552
+ else {
553
+ if (!name) name = name1;
554
+ used[name1].forEach(u => {
555
+ compile$patchname(name, u, ".default");
556
+ });
557
+ }
547
558
  }
548
- }
549
- else {
550
- var name = strings.decode(q[1].last.text)
559
+ })
560
+ if (!name) {
561
+ name = strings.decode(q[1].last.text)
551
562
  .replace(/\.[^\.\/\\]+$/, '')
552
563
  .split(/[\/\\\:\{\}\[\]\.\+\-\*\/\!\~\|\:;,'"`\(\)\>\<\?\^%&\s]+/)
553
564
  .filter(a => !!a).pop();
@@ -557,16 +568,19 @@ var removeImport = function (c, i, code) {
557
568
  name = name.replace(/\d+$/, '') + ++id;
558
569
  }
559
570
  used[name] = [];
560
- if (dec[0] !== "*") dec[0].forEach((dn, i) => {
561
- var da = dec[0].attributes[i];
571
+ }
572
+ dec.forEach(function (d) {
573
+ if (d instanceof Array) d.forEach((dn, i) => {
574
+ var da = d.attributes[i][0];
562
575
  if (used[dn]) used[dn].forEach(u => {
563
- u.text = name + da[0];
576
+ if (used[name].indexOf(u) >= 0) return;
577
+ patchname(name, u, da);
564
578
  used[name].push(u);
565
579
  });
566
580
  delete used[dn];
567
581
  delete vars[dn];
568
582
  });
569
- }
583
+ });
570
584
  var u = { type: EXPRESS, text: name };
571
585
  code.splice(i + 1, oi - i - 1, u);
572
586
  used[name].push(u);
@@ -628,7 +642,9 @@ var removeExport = function (c, i, code) {
628
642
  var nn = n.next;
629
643
  var d = nn.text;
630
644
  if (used[d]) used[d].forEach(a => {
631
- if (!a.kind) a.text = `exports.` + a.text;
645
+ if (!a.kind) {
646
+ patchname('exports.', a);
647
+ }
632
648
  });
633
649
  delete used[d];
634
650
  delete envs[d];
@@ -6,6 +6,9 @@ var testFix = function (a, e) {
6
6
  }
7
7
  testFix(`import a from "a";console.log(a)`, 'var a = require("a"); console.log(a.default)');
8
8
  testFix(`import {a} from "a";console.log(a)`, 'var a1 = require("a"); console.log(a1.a)');
9
+ testFix(`import a,{a as b} from "a";console.log(a,b)`, 'var a = require("a"); console.log(a.default, a.a)');
10
+ testFix(`import * as a,{a as b},c from "a";console.log(a,b,c)`, 'var a = require("a"); console.log(a, a.a, a.default)');
11
+ testFix(`import * as a,{a as b},c from "a";console.log(a,...b,...c)`, 'var a = require("a"); console.log(a, ...a.a, ...a.default)');
9
12
  testFix(`console.log(import("a"))`, 'console.log(require("a"))');
10
13
  testFix(`import("a")`, 'require("a")');
11
14
  testFix(`import "windows.inc"`, 'require("windows.inc")');
@@ -153,6 +153,7 @@ class Program {
153
153
  extends_reg = /^(extends)$/;
154
154
  spaces = spaceDefined;
155
155
  nocase = false
156
+ keepspace = false;
156
157
  lastIndex = 0
157
158
  compile(s) {
158
159
  return s.replace(/\\[\s\S]|[\[\]\(\)\{\}\+\.\-\*\?\$\^\|\\\/ ]/g, function (m) {
@@ -192,7 +193,7 @@ class Program {
192
193
  var last = queue.last;
193
194
  Object.defineProperty(scope, 'queue', { value: queue, enumerable: false, configurable: true });
194
195
  scope.prev = last;
195
- if (scope.type !== COMMENT && scope.type !== SPACE) {
196
+ if (!(scope.type & (COMMENT | SPACE))) {
196
197
  var keeplast = program.setType(scope) === false;
197
198
  if (keeplast) {
198
199
  if (queue.last !== last) last = queue.last;
@@ -237,12 +238,7 @@ class Program {
237
238
  }
238
239
  }
239
240
  var last = queue.last;
240
- if (type === SPACE) {
241
- if (last && last.isend === false) {
242
- last.isend = true;
243
- queue.inExpress = false;
244
- }
245
- }
241
+ if (type === SPACE);
246
242
  else if (type !== STAMP);
247
243
  else if (m === ";") {
248
244
  if (last && last.isend === false) last.isend = true;
@@ -526,8 +522,16 @@ class Program {
526
522
  m = m.replace(/^[^\r\n\u2028\u2029]+/, '').replace(/\r\n|\r|\n|\u2028|\u2029/g, "\r\n");
527
523
  row += m.replace(/[^\r\n]+/g, '').length >> 1;
528
524
  colstart = match.index + m.replace(/[^\r\n]+$/, '').length - 1;
525
+ var last = queue.last;
526
+ if (last && last.isend === false) {
527
+ last.isend = true;
528
+ queue.inExpress = false;
529
+ }
529
530
  save(SPACE);
530
531
  }
532
+ else {
533
+ if (this.keepspace) save(SPACE);
534
+ }
531
535
  lasttype = SPACE;
532
536
  continue;
533
537
  }
@@ -13,7 +13,7 @@ const [
13
13
  /*1024 */PROPERTY,
14
14
  ] = new Array(20).fill(0).map((_, a) => 1 << a);
15
15
  // --------------//1//2/////////////////////////22/////////////2//2//3//4/////4////////3/////3//////3//3//////3///////211/////////////2//////2//////1///
16
- var number_reg = /^(?:(?:0x[0-9a-f]+|0b\d+|0o\d+)(?:_[0-9a-f]+)*|(?:(?:(?:\d+_)*\d+|\d*)\.\d+(?:_\d+)*|(?:\d+_)*\d+\.?))(?:e[\+\-]?\d+(?:_\d+)*|[mn])?$/i;
16
+ var number_reg = /^(?:(?:0x[0-9a-f]+|0b\d+|0o\d+)(?:_[0-9a-f]+)*|(?:(?:(?:\d+_)*\d+|\d*)\.\d+(?:_\d+)*|(?:\d+_)*\d+\.?))(?:e[\+\-]?\d+(?:_\d+)*|[mniul]|ll)?$/i;
17
17
  var equal_reg = /^(?:[\+\-\*\/~\^&\|%]|\*\*|>>>?|<<)?\=$|^(?:\+\+|\-\-)$/;
18
18
  var skipAssignment = function (o, cx) {
19
19
  var next = arguments.length === 1 ? function () {
@@ -132,6 +132,7 @@ var skipAssignment = function (o, cx) {
132
132
  next();
133
133
  }
134
134
  else if (o.text === 'else') {
135
+ if (ifdeep <= 0) break loop;
135
136
  ifdeep--;
136
137
  needpunc = false;
137
138
  next();
@@ -140,7 +141,6 @@ var skipAssignment = function (o, cx) {
140
141
  if (o.text === 'if') ifdeep++;
141
142
  next();
142
143
  next();
143
- break;
144
144
  }
145
145
  else if (o.text === 'do') {
146
146
  next();
@@ -151,14 +151,12 @@ var skipAssignment = function (o, cx) {
151
151
  next();
152
152
  if (o.type === STRAP && o.text === 'await') next();
153
153
  next();
154
- break;
155
154
  }
156
155
  else if (o.text === "class") {
157
156
  next();
158
157
  while (o && !o.isClass) next();
159
158
  while (o && o.isClass) next();
160
159
  needpunc = true;
161
- break;
162
160
  }
163
161
  else if (o.text === "function") {
164
162
  next();
@@ -167,7 +165,6 @@ var skipAssignment = function (o, cx) {
167
165
  if (o) next();
168
166
  if (o) next();
169
167
  needpunc = true;
170
- break;
171
168
  }
172
169
  else if (o.text === 'debugger') {
173
170
  next();
@@ -1005,6 +1002,7 @@ var createString = function (parsed) {
1005
1002
  var keepspace = parsed.keepspace !== false;
1006
1003
  var helpcode = parsed.helpcode;
1007
1004
  var lasttype = SPACE;
1005
+ var uncomment = parsed.comment === false;
1008
1006
  var result = [], cacheresult, finalresult = result;
1009
1007
  var helpcolor = parsed.keepcolor === false;
1010
1008
  var run = (o, i, a) => {
@@ -1022,8 +1020,9 @@ var createString = function (parsed) {
1022
1020
  switch (o.type) {
1023
1021
  case COMMENT:
1024
1022
  // 每一次要远行,我都不得不对自己的物品去粗取精。取舍之间,什么重要,什么不是那么重要,都有了一道明显的分界线。
1023
+ if (uncomment) break;
1025
1024
  var tmp = o.text, opentmp = false;
1026
- if (!keepspace || helpcode) {
1025
+ if (helpcode) {
1027
1026
  if (/^\/[\/\*]\s*\<\!--/.test(tmp)) {
1028
1027
  opentmp = true;
1029
1028
  if (/^\/\*/.test(tmp)) opentmp = 2;
@@ -1102,7 +1101,7 @@ var createString = function (parsed) {
1102
1101
  default:
1103
1102
  if (o instanceof Object) {
1104
1103
  if (o.prev && o.prev.type === EXPRESS && o.type === EXPRESS && (/^[\.\[]/.test(o.text) || /\.$/.test(o.prev.text)));
1105
- else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE) & o.type) {
1104
+ else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
1106
1105
  result.push(" ");
1107
1106
  }
1108
1107
  else if (o.prev && o.type === STAMP && !/^([,;])$/.test(o.text)) {
@@ -1265,7 +1264,6 @@ var canbeTemp = function (body, strip = false) {
1265
1264
  return o.type === EXPRESS && (strip || !/[\.\[]/.test(o.text)) || o.type === VALUE || o.type === QUOTED && !o.length;
1266
1265
  };
1267
1266
 
1268
-
1269
1267
  module.exports = {
1270
1268
  /* 1 */COMMENT,
1271
1269
  /* 2 */SPACE,
@@ -14,7 +14,7 @@ function format(code, step) {
14
14
  var lowspace = rest.pop();
15
15
  var cp = code.prev;
16
16
  var cpp = cp && cp.prev;
17
- if(cpp && cpp.type === STRAP && cpp.text==="switch"){
17
+ if (cpp && cpp.type === STRAP && cpp.text === "switch") {
18
18
  lowspace += step;
19
19
  }
20
20
  var space = lowspace + step;
@@ -37,10 +37,15 @@ function format(code, step) {
37
37
  code.push({ type: SPACE, text: lowspace });
38
38
  }
39
39
  }
40
+ if (breakline && e.type === STAMP) {
41
+ if (e.text === ':' && !e.inExpress) {
42
+ if (code[code.length - 1].type === SPACE) code.pop();
43
+ }
44
+ }
40
45
  code.push(e);
41
46
  if (e.type === SCOPED) rest.push(space, e);
42
47
  }
43
- if (breakline && (e.type === STAMP && /^[,;]$/.test(e.text) || !code.isClass && !code.isObject)) hasCommaBefore = !code.isObject && e.text === ',', code.push({ type: SPACE, text: hasCommaBefore ? deepspace: space });
48
+ if (breakline && (e.type === STAMP && /^[,;]$/.test(e.text) || !code.isClass && !code.isObject)) hasCommaBefore = !code.isObject && e.text === ',', code.push({ type: SPACE, text: hasCommaBefore ? deepspace : space });
44
49
  }
45
50
  if (breakline) {
46
51
  var hasspaceend = code[code.length - 1].type === SPACE;
@@ -0,0 +1,5 @@
1
+ var patchlist = function (prefix, list, alias) {
2
+ for (var o of list) {
3
+ patchname(prefix, o, alias);
4
+ }
5
+ };
@@ -0,0 +1,9 @@
1
+ var patchname = function (prefix, node, alias) {
2
+ var t = node.text;
3
+ var hasdot = /^\.\.\./.test(t);
4
+ if (hasdot) t = t.slice(3);
5
+ if (alias) t = t.replace(/^[^\.\[]+/, alias);
6
+ t = prefix + t;
7
+ if (hasdot) t = "..." + t;
8
+ node.text = t;
9
+ };
@@ -111,6 +111,16 @@ function testUnicode() {
111
111
  var m = scanner(`\\u{0042}\\u0042=1`);
112
112
  console.log(m.toString())
113
113
  }
114
+ function testComment() {
115
+ var m = scanner(`SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */`);
116
+ console.log(m[m.length - 1].type === common.COMMENT);
117
+ m.comment = false;
118
+ console.log(common.createString(m));
119
+ }
120
+ function testQuote() {
121
+ var m = scanner(`(sizeof(("table")) / sizeof(("table")[0]))`);
122
+ console.log(m.toString());
123
+ }
114
124
  Program.debug = true;
115
125
  // testSpeed();
116
126
  // testVariables();
@@ -124,6 +134,8 @@ Program.debug = true;
124
134
  // testJsxOnlyHtml();
125
135
  // testSpaceLess();
126
136
  // testArrow();
127
- testUnicode();
137
+ // testUnicode();
138
+ // testComment();
139
+ testQuote();
128
140
  // var typescript = require("../typescript/index");
129
141
  // typescript.transpile(data.toString(), { noEmitHelpers: true });
@@ -40,7 +40,7 @@ test('a * a && await b*c', "_ = a * a; if (!_) return [2, 0]; _ = b; return [_,
40
40
  test("await a", "_ = a; return [_, 1]", true);
41
41
  test("yield a", "return [a, 3]", true);
42
42
  test("!a.done&&(b=await a.value)", "_ = !a.done; if (!_) return [2, 0]; _ = a.value; return [_, 1];\r\n _ = @; b = _; (_)", true);
43
- test("a=1?2:3",`if (false) return [1, 0]; a = 2; return [2, 0];\r\n a = 3; return [1, 0]`)
43
+ test("a=1?2:3", `if (false) return [1, 0]; a = 2; return [2, 0];\r\n a = 3; return [1, 0]`)
44
44
  test("await a()", "_ = a(); return [_, 1]", true);
45
45
  test("yield a()", "_ = a(); return [_, 3]", true);
46
46
  test("a = await a()", "_ = a(); return [_, 1];\r\n _ = @; a = _", true);
@@ -120,4 +120,6 @@ test("menus[0].name+='aaa'", "_ = menus[0]; _0 = _.name + 'aaa'; _.name = _0", t
120
120
  test("menus[a+b].name+='aaa'", "_ = a + b; _ = menus[_]; _0 = _.name + 'aaa'; _.name = _0", true);
121
121
  test("menus[a+b]()", "_ = a + b; menus[_]()", true);
122
122
  test(`switch(a){default: a;case 1:b;}`, 'if (a === 1) return [2, 0]; return [1, 0];\r\n a; return [1, 0];\r\n b; return [1, 0]', true);
123
- test("loop:{a=b;if(a) continue loop}", "a = b; if (a) return [0, 0]", true);
123
+ test("loop:{a=b;if(a) continue loop}", "a = b; if (a) return [0, 0]", true);
124
+ test("if(a)try{}finally{}else a;", 'if (!a) return [4, 0]; return [1, 8];\r\nreturn [0, 9];\r\nreturn [1, 9];\r\nreturn [2, 0];\r\na; return [1, 0]')
125
+ test("if(a)try{}finally{}else;", 'if (!a) return [4, 0]; return [1, 8];\r\nreturn [0, 9];\r\nreturn [1, 9];\r\nreturn [1, 0]');
@@ -1,13 +1,22 @@
1
- function main(title, type, params, idkey = params.fields[0].key) {
1
+ function send(type, key, value, origin) {
2
+ return data.from(origin ? "edit" : "add", {
3
+ type,
4
+ key: encode62.timeencode(key),
5
+ value: encode62.timeencode(JSON.stringify(value)),
6
+ }).loading_promise;
7
+ }
8
+ function pedit(title, type, params, idkey = params.fields[0].key) {
2
9
  return frame$edit(title, {
3
10
  submit(a, fields) {
4
11
  a = submit(fields, a);
5
- return data.from(params.data ? "edit" : "add", {
6
- type,
7
- key: encode62.timeencode(a[idkey]),
8
- value: encode62.timeencode(JSON.stringify(a)),
9
- }).loading_promise;
12
+ return send(type, a[idkey], a, params.data);
10
13
  },
11
14
 
12
15
  }, params);
16
+ }
17
+ pedit.create = function (type, key, value) {
18
+ return send(type, key, value, false);
19
+ }
20
+ pedit.update = function (type, key, value) {
21
+ return send(type, key, value, true);
13
22
  }
@@ -0,0 +1,36 @@
1
+ var path = require("path");
2
+ var fs = require("fs").promises;
3
+ var str2array = require("../basic/str2array");
4
+ async function detectWithExtension(filenames, extensions = [""], folders = [""]) {
5
+ if (typeof filenames === 'string') filenames = str2array(filenames);
6
+ if (typeof extensions === 'string') extensions = str2array(extensions);
7
+ if (typeof folders === 'string') folders = str2array(folders);
8
+ if (extensions === null) {
9
+ extensions = [""];
10
+ }
11
+ if (folders === null) folders = [""];
12
+ extensions = [].concat(extensions);
13
+ filenames = filenames.map(f => efront$$split(f).join('/')).map(filename => {
14
+ var tempname = filename.replace(/[#\?][\s\S]*$/, '');
15
+ var params = filename.slice(tempname.length);
16
+ return [tempname, params];
17
+ });
18
+
19
+ var findedFolder = null;
20
+ for (var folder of folders) for (var [tempname, params] of filenames) for (var ext of extensions) {
21
+ var f = tempname + ext;
22
+ if (folder) f = path.join(folder, f);
23
+ f = path.normalize(f);
24
+ try {
25
+ var stats = await fs.stat(f);
26
+ if (stats.isFile()) {
27
+ f = await fs.realpath(f);
28
+ return f + params;
29
+ }
30
+ if (!findedFolder) findedFolder = f + params;
31
+ } catch { }
32
+ }
33
+ if (!findedFolder) throw new Error(`路径<gray>${filenames}</gray>不存在`);
34
+ return findedFolder;
35
+ }
36
+ module.exports = detectWithExtension;
@@ -936,7 +936,7 @@ var data = {
936
936
  var promise1 = instance.loading_promise;
937
937
  if (promise1) {
938
938
  var params = promise1.params;
939
- if (deepEqual.shallow(params1, params)) {
939
+ if (shallowEqual(params1, params)) {
940
940
  return instance;
941
941
  }
942
942
  }
@@ -1,11 +1,11 @@
1
1
  function getChanges(current_props, previous_props) {
2
- if (!isObject(current_props) && !isObject(previous_props)) return !deepEqual.shallow(current_props, previous_props);
2
+ if (!isObject(current_props) && !isObject(previous_props)) return !shallowEqual(current_props, previous_props);
3
3
  var changes = null;
4
4
  if (!isObject(current_props)) current_props = Object.create(null), changes = {};
5
5
  if (!isObject(previous_props)) previous_props = Object.create(null), changes = {};
6
6
  keys(previous_props, current_props).forEach(function (key) {
7
7
  if (key.charAt(0) === "$") return;
8
- if (!deepEqual.shallow(current_props[key], previous_props[key])) {
8
+ if (!shallowEqual(current_props[key], previous_props[key])) {
9
9
  if (!changes) changes = {};
10
10
  changes[key] = { previous: previous_props[key], current: current_props[key] };
11
11
  }
@@ -216,7 +216,7 @@ var createRepeat = function (search, id = 0) {
216
216
  var result = getter(this);
217
217
  var origin = result;
218
218
  result = extend(result instanceof Array ? [] : {}, result);
219
- if (savedOrigin === origin && deepEqual.shallow(savedValue, result)) return;
219
+ if (savedOrigin === origin && shallowEqual(savedValue, result)) return;
220
220
  var changes = getChanges(result, savedValue);
221
221
  if (!changes) return;
222
222
  savedValue = result;
@@ -442,7 +442,7 @@ var createBinder = function (binder) {
442
442
  var oldValue;
443
443
  this.renders.push(function () {
444
444
  var value = getter(this);
445
- if (deepEqual.shallow(value, oldValue)) return;
445
+ if (shallowEqual(value, oldValue)) return;
446
446
  var oldv = oldValue;
447
447
  oldValue = value;
448
448
  if (isNode(value) || isArray(value)) {
@@ -182,7 +182,7 @@ function select(target, list, removeOnSelect, direction) {
182
182
  }
183
183
  return o.selected;
184
184
  });
185
- if (deepEqual.shallow(lastSelected, selected)) return;
185
+ if (shallowEqual(lastSelected, selected)) return;
186
186
  lastSelected = selected;
187
187
  if (hasIcon) {
188
188
  var icon = selected.length === 1 && selected[0].getAttribute('icon');
@@ -198,7 +198,7 @@ function select(target, list, removeOnSelect, direction) {
198
198
  };
199
199
  var initList = function () {
200
200
  var allOptions = [].concat.apply([], target.querySelectorAll("option"));
201
- if (deepEqual.shallow(allOptions, savedOptions)) return;
201
+ if (shallowEqual(allOptions, savedOptions)) return;
202
202
  savedOptions = allOptions;
203
203
  list = selectList(allOptions, !!target.multiple, !!target.editable);
204
204
  setListValue();
@@ -2,8 +2,8 @@
2
2
  <tr inline-block #adapter thead @mounted="resizeT(this)">
3
3
  <td draggable="false" fixed row-index>${i18n`序号`}</td>
4
4
  <td fixed:="f.fixed" -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i
5
- -if="f.icon" -class="f.icon"></i><span -if="f.name" -html="f.name"></span><template
6
- -else>&nbsp;</template>
5
+ -if="f.icon" -class="f.icon"></i><span -if="f.name" -html="f.name"
6
+ type@="typeof f.type==='string'?f.type:''"></span><template -else>&nbsp;</template>
7
7
  </td>
8
8
  <td style="min-width: 0;" draggable="false">&nbsp;</td>
9
9
  </tr>