efront 4.0.41 → 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.
- package/apps/pivot/log/count.js +2 -2
- package/coms/basic/Table.js +4 -2
- package/coms/basic/analyse_test.js +2 -1
- package/coms/basic/arrayEqual.js +8 -0
- package/coms/{zimoli → basic}/deepEqual.js +0 -17
- package/coms/basic/isSame.js +2 -1
- package/coms/basic/refilm_decode.js +3 -2
- package/coms/basic/refilm_decode_test.js +2 -0
- package/coms/basic/shallowEqual.js +18 -0
- package/coms/basic/str2array.js +5 -0
- package/coms/compile/Program.js +11 -7
- package/coms/compile/common.js +6 -7
- package/coms/compile/formatcode.js +7 -2
- package/coms/compile/scanner2_test.js +13 -1
- package/coms/compile/unstruct_test.js +4 -2
- package/coms/pivot/pedit.js +15 -6
- package/coms/reptile/detectWithExtension.js +36 -0
- package/coms/zimoli/data.js +1 -1
- package/coms/zimoli/getChanges.js +2 -2
- package/coms/zimoli/render.js +2 -2
- package/coms/zimoli/select.js +2 -2
- package/coms/zimoli/table.html +2 -2
- package/coms/zimoli/table.js +1 -1
- package/coms/zimoli/table.less +8 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/readme-en.md +10 -4
- package/readme.md +7 -4
- /package/coms/{zimoli → basic}/deepEqual_test.js +0 -0
package/apps/pivot/log/count.js
CHANGED
package/coms/basic/Table.js
CHANGED
|
@@ -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");
|
|
@@ -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)) {
|
package/coms/basic/isSame.js
CHANGED
|
@@ -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(
|
|
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,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
|
+
}
|
package/coms/compile/Program.js
CHANGED
|
@@ -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
|
|
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
|
}
|
package/coms/compile/common.js
CHANGED
|
@@ -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+)*|[
|
|
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 (
|
|
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)) {
|
|
@@ -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;
|
|
@@ -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"
|
|
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]');
|
package/coms/pivot/pedit.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
function
|
|
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
|
|
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;
|
package/coms/zimoli/data.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
function getChanges(current_props, previous_props) {
|
|
2
|
-
if (!isObject(current_props) && !isObject(previous_props)) return !
|
|
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 (!
|
|
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
|
}
|
package/coms/zimoli/render.js
CHANGED
|
@@ -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 &&
|
|
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 (
|
|
445
|
+
if (shallowEqual(value, oldValue)) return;
|
|
446
446
|
var oldv = oldValue;
|
|
447
447
|
oldValue = value;
|
|
448
448
|
if (isNode(value) || isArray(value)) {
|
package/coms/zimoli/select.js
CHANGED
|
@@ -182,7 +182,7 @@ function select(target, list, removeOnSelect, direction) {
|
|
|
182
182
|
}
|
|
183
183
|
return o.selected;
|
|
184
184
|
});
|
|
185
|
-
if (
|
|
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 (
|
|
201
|
+
if (shallowEqual(allOptions, savedOptions)) return;
|
|
202
202
|
savedOptions = allOptions;
|
|
203
203
|
list = selectList(allOptions, !!target.multiple, !!target.editable);
|
|
204
204
|
setListValue();
|
package/coms/zimoli/table.html
CHANGED
|
@@ -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"
|
|
6
|
-
-else> </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> </template>
|
|
7
7
|
</td>
|
|
8
8
|
<td style="min-width: 0;" draggable="false"> </td>
|
|
9
9
|
</tr>
|
package/coms/zimoli/table.js
CHANGED
|
@@ -527,7 +527,7 @@ function table(elem) {
|
|
|
527
527
|
render(this, $scope, this.$parentScopes.concat(this.$scope));
|
|
528
528
|
$scope.data = Table.from(fields, await data);
|
|
529
529
|
$scope.data.callback = function () {
|
|
530
|
-
|
|
530
|
+
render.digest();
|
|
531
531
|
};
|
|
532
532
|
})
|
|
533
533
|
autodragchildren(
|
package/coms/zimoli/table.less
CHANGED
|
@@ -142,6 +142,7 @@ thead {
|
|
|
142
142
|
position: relative;
|
|
143
143
|
color: #fff;
|
|
144
144
|
background-color: #395268;
|
|
145
|
+
clear: both;
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
}
|
|
@@ -188,6 +189,7 @@ thead {
|
|
|
188
189
|
z-index: 1;
|
|
189
190
|
background: #999;
|
|
190
191
|
color: #fff;
|
|
192
|
+
clear: both;
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
|
|
@@ -212,4 +214,10 @@ thead {
|
|
|
212
214
|
margin-right: 10px;
|
|
213
215
|
vertical-align: middle;
|
|
214
216
|
display: inline-block;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
[type=money],
|
|
220
|
+
[type=number],
|
|
221
|
+
[type=price] {
|
|
222
|
+
float: right;
|
|
215
223
|
}
|