efront 3.8.2 → 3.9.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.
- package/apps/pivot/api.yml +2 -0
- package/apps/pivot/task/invoke.html +17 -0
- package/apps/pivot/task/invoke.js +29 -0
- package/apps/pivot/task/invoke.less +10 -0
- package/apps/pivot/task/list.js +9 -1
- package/coms/basic/loader.js +8 -6
- package/coms/basic/refilm_decode.js +1 -1
- package/coms/basic/renderExpress.js +101 -0
- package/coms/compile/common.js +53 -5
- package/coms/compile/scanner2.js +73 -16
- package/coms/frame/edit.html +1 -1
- package/coms/zimoli/colorlabel.less +1 -1
- package/coms/zimoli/colorpicker.js +3 -1
- package/coms/zimoli/getName.js +9 -0
- package/coms/zimoli/getValue.js +10 -3
- package/coms/zimoli/model.js +17 -1
- package/coms/zimoli/prepare.js +1 -0
- package/coms/zimoli/radio.js +3 -3
- package/coms/zimoli/render.js +3 -15
- package/coms/zimoli/table.html +1 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/apps/pivot/api.yml
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<div head>
|
|
2
|
+
<span -text="task.name"></span>
|
|
3
|
+
(<span -text="task.key"></span>)
|
|
4
|
+
<close @click="remove()"></close>
|
|
5
|
+
</div>
|
|
6
|
+
<div body>
|
|
7
|
+
<div class="left">
|
|
8
|
+
<field -repeat="f in fields" -src="[f,data]"></field>
|
|
9
|
+
<pre -text="task.code"></pre>
|
|
10
|
+
</div>
|
|
11
|
+
<div class="right">
|
|
12
|
+
<pre -text="output"></pre>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div foot>
|
|
16
|
+
<btn @click="run">执行</btn>
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function main(a) {
|
|
2
|
+
var page = view();
|
|
3
|
+
page.innerHTML = template;
|
|
4
|
+
drag.on(page.firstChild, page);
|
|
5
|
+
var fields = data.from("params", { key: a.key }, function (a) {
|
|
6
|
+
return JSON.parse(encode62.timedecode(a));
|
|
7
|
+
});
|
|
8
|
+
var taskid = 0;
|
|
9
|
+
renderWithDefaults(page, {
|
|
10
|
+
remove() {
|
|
11
|
+
remove(page);
|
|
12
|
+
},
|
|
13
|
+
data: {},
|
|
14
|
+
fields: fields,
|
|
15
|
+
task: a,
|
|
16
|
+
output: '',
|
|
17
|
+
async run() {
|
|
18
|
+
var id = ++taskid;
|
|
19
|
+
var params = JSON.stringify(this.data);
|
|
20
|
+
var res = await data.from("invoke", { key: a.key, params: encode62.timeencode(params) }, function (a) {
|
|
21
|
+
return encode62.timedecode(a);
|
|
22
|
+
});
|
|
23
|
+
console.log(res);
|
|
24
|
+
if (id !== taskid) return;
|
|
25
|
+
this.output = res;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return page;
|
|
29
|
+
}
|
package/apps/pivot/task/list.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
plist.bind(null, '任务管理', "task", refilm`
|
|
2
2
|
*任务ID/key 100
|
|
3
3
|
*任务名/name 100
|
|
4
|
-
|
|
4
|
+
*是否启用/status radio [不启用,启用]
|
|
5
5
|
任务代码/code text
|
|
6
|
+
执行/ - ${[{
|
|
7
|
+
when(o) {
|
|
8
|
+
return o.status === 1;
|
|
9
|
+
},
|
|
10
|
+
name: "执行", do(o) {
|
|
11
|
+
popup("/task/invoke", o);
|
|
12
|
+
}
|
|
13
|
+
}]}
|
|
6
14
|
`, '/task/edit');
|
package/coms/basic/loader.js
CHANGED
|
@@ -154,8 +154,8 @@ var readFile = function (names, then) {
|
|
|
154
154
|
tryload();
|
|
155
155
|
|
|
156
156
|
};
|
|
157
|
-
var createFunction = function (name, body, args) {
|
|
158
|
-
return window.eval(`[function/*${name}*/(${args || ''}){\r\n${body}\r\n}][0]`);
|
|
157
|
+
var createFunction = function (name, body, args, isAsync, isYield) {
|
|
158
|
+
return window.eval(`[${isAsync ? 'async ' : ''}function${isYield ? "*" : ""}/*${name}*/(${args || ''}){\r\n${body}\r\n}][0]`);
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
var FILE_NAME_REG = /^https?\:|\.(html?|css|asp|jsp|php)$/i;
|
|
@@ -269,13 +269,13 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
269
269
|
flushTree(loadedModules, key);
|
|
270
270
|
return;
|
|
271
271
|
}
|
|
272
|
-
var [argNames, body, args, required, strs] = getArgs(data);
|
|
272
|
+
var [argNames, body, args, required, strs, isAsync, isYield] = getArgs(data);
|
|
273
273
|
if (isProduction) {
|
|
274
274
|
strs = strs.map ? strs.map(toRem) : strs;
|
|
275
275
|
} else {
|
|
276
276
|
body = toRem(body);
|
|
277
277
|
}
|
|
278
|
-
var mod = createFunction(name, body, argNames);
|
|
278
|
+
var mod = createFunction(name, body, argNames, isAsync, isYield);
|
|
279
279
|
if (!mod) console.log(name, mod);
|
|
280
280
|
mod.args = args;
|
|
281
281
|
mod.argNames = argNames;
|
|
@@ -399,8 +399,10 @@ var getArgs = function (text) {
|
|
|
399
399
|
} else {
|
|
400
400
|
functionBody = text;
|
|
401
401
|
}
|
|
402
|
+
var [, isAsync, isYield] = /^(@?)(\*?)/.exec(functionBody);
|
|
403
|
+
if (isAsync || isYield) functionBody = functionBody.slice(+!!isAsync + +!!isYield);
|
|
402
404
|
functionBody = functionBody.replace(/^(?:\s*(["'])user? strict\1;?[\r\n]*)*/i, "\"use strict\";\r\n");
|
|
403
|
-
return [argNames || [], functionBody, args || [], required || '', strs || []];
|
|
405
|
+
return [argNames || [], functionBody, args || [], required || '', strs || [], !!isAsync, !!isYield];
|
|
404
406
|
};
|
|
405
407
|
var get_relatives = function (name, required, prefix = "") {
|
|
406
408
|
var required_base = name.replace(/[^\/\$]+$/, "");
|
|
@@ -505,7 +507,7 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
|
505
507
|
result = res;
|
|
506
508
|
created = true;
|
|
507
509
|
_ok(res);
|
|
508
|
-
}
|
|
510
|
+
});
|
|
509
511
|
if (created) return result;
|
|
510
512
|
return promise;
|
|
511
513
|
});
|
|
@@ -320,7 +320,7 @@ function parse(piece) {
|
|
|
320
320
|
name = name.slice(0, commaindex);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
[name, key] = scanSlant(name, '/');
|
|
323
|
+
[name, key] = scanSlant(name, '/', 0, name.length + 1);
|
|
324
324
|
if (key === undefined && !/^(title|label|headline)$/i.test(type)) key = name;
|
|
325
325
|
}
|
|
326
326
|
if (/^[a-z\d]+\/?\d+$/i.test(type)) {
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
function createSeek(express) {
|
|
2
|
+
var dist;
|
|
3
|
+
express.forEach(function (search) {
|
|
4
|
+
if (dist) {
|
|
5
|
+
if (/[\=]/.test(dist)) dist = `(${dist})`;
|
|
6
|
+
dist = `${dist}!==void 0&&${dist}!==null?${dist}${search}:''`
|
|
7
|
+
} else {
|
|
8
|
+
dist = search;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return dist;
|
|
12
|
+
}
|
|
13
|
+
function main(express) {
|
|
14
|
+
if (!/\?\s*\.(?=[^\d])/.test(express)) return express;
|
|
15
|
+
var reg = /\\[\s\S]|\?\s*(\.(?!\d))|[\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<~\{\}\[\]\(\)'"`\s]/g;
|
|
16
|
+
var cache = [], queue = [];
|
|
17
|
+
var exp = [];
|
|
18
|
+
var instr = false;
|
|
19
|
+
var lastIndex = 0;
|
|
20
|
+
var add_exp = function (s) {
|
|
21
|
+
if (!exp.length) exp.push(s);
|
|
22
|
+
else {
|
|
23
|
+
var e = exp[exp.length - 1];
|
|
24
|
+
if (!/[\.]\s*$/.test(e) && !/^\s*[\.'"`\[\(]/.test(s)) {
|
|
25
|
+
queue.push(createSeek(exp));
|
|
26
|
+
exp.splice(0, exp.length, '');
|
|
27
|
+
e = '';
|
|
28
|
+
}
|
|
29
|
+
if (/\.$/.test(e) && /^[\[\("'`]/.test(s)) {
|
|
30
|
+
e = e.replace(/\.$/, '');
|
|
31
|
+
}
|
|
32
|
+
e += s;
|
|
33
|
+
exp[exp.length - 1] = e;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var push_quote = function (m) {
|
|
37
|
+
add_exp(m);
|
|
38
|
+
cache.push(queue, exp);
|
|
39
|
+
queue = [];
|
|
40
|
+
exp = [];
|
|
41
|
+
};
|
|
42
|
+
var pop_quote = function (m) {
|
|
43
|
+
add_punc('');
|
|
44
|
+
exp = cache.pop();
|
|
45
|
+
var e = queue.join("") + m;
|
|
46
|
+
exp[exp.length - 1] += e;
|
|
47
|
+
queue = cache.pop();
|
|
48
|
+
};
|
|
49
|
+
var add_punc = function (m) {
|
|
50
|
+
if (exp.length) {
|
|
51
|
+
var temp = createSeek(exp);
|
|
52
|
+
queue.push(exp.length > 1 ? `(${temp})` : temp, m);
|
|
53
|
+
exp = [];
|
|
54
|
+
} else if (queue.length) {
|
|
55
|
+
queue[queue.length - 1] += m;
|
|
56
|
+
} else {
|
|
57
|
+
queue.push(m);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
do {
|
|
62
|
+
var match = reg.exec(express);
|
|
63
|
+
if (!match) break;
|
|
64
|
+
var index = match.index;
|
|
65
|
+
var m = match[0];
|
|
66
|
+
var isstr = false;
|
|
67
|
+
if (/['"`\/]/.test(m)) {
|
|
68
|
+
if (instr === m) instr = false;
|
|
69
|
+
else if (!instr) instr = m;
|
|
70
|
+
}
|
|
71
|
+
if (instr) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (/['"`\/\s]/.test(m)) {
|
|
75
|
+
isstr = true;
|
|
76
|
+
index++;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var str = express.slice(lastIndex, index);
|
|
80
|
+
if (str) {
|
|
81
|
+
add_exp(str);
|
|
82
|
+
}
|
|
83
|
+
lastIndex = match.index + m.length;
|
|
84
|
+
if (match[1]) {
|
|
85
|
+
exp.push(match[1]);
|
|
86
|
+
}
|
|
87
|
+
else if (/[\[\{\(]/.test(m)) {
|
|
88
|
+
push_quote(m);
|
|
89
|
+
}
|
|
90
|
+
else if (/[\]\}\)]/.test(m)) {
|
|
91
|
+
pop_quote(m);
|
|
92
|
+
}
|
|
93
|
+
else if (!isstr) {
|
|
94
|
+
add_punc(m);
|
|
95
|
+
}
|
|
96
|
+
} while (true);
|
|
97
|
+
var s = express.slice(lastIndex);
|
|
98
|
+
if (s) add_exp(s);
|
|
99
|
+
add_punc('');
|
|
100
|
+
return queue.join("");
|
|
101
|
+
}
|
package/coms/compile/common.js
CHANGED
|
@@ -91,6 +91,7 @@ var skipAssignment = function (o) {
|
|
|
91
91
|
}
|
|
92
92
|
else if (o.text === "function") {
|
|
93
93
|
o = o.next;
|
|
94
|
+
if (o && o.type === STAMP) o = o.next;
|
|
94
95
|
if (o && o.type === EXPRESS) o = o.next;
|
|
95
96
|
if (o) o = o.next;
|
|
96
97
|
if (o) o = o.next;
|
|
@@ -111,7 +112,8 @@ var skipAssignment = function (o) {
|
|
|
111
112
|
};
|
|
112
113
|
var createScoped = function (parsed) {
|
|
113
114
|
var used = Object.create(null); var vars = Object.create(null), lets = vars;
|
|
114
|
-
var scoped = [];
|
|
115
|
+
var scoped = [], funcbody = scoped;
|
|
116
|
+
scoped.isfunc = true;
|
|
115
117
|
var run = function (o, id) {
|
|
116
118
|
loop: while (o) {
|
|
117
119
|
var isCatch = false;
|
|
@@ -119,6 +121,7 @@ var createScoped = function (parsed) {
|
|
|
119
121
|
var isScope = false;
|
|
120
122
|
var isArrow = false;
|
|
121
123
|
var isDeclare = false;
|
|
124
|
+
var isYield = false;
|
|
122
125
|
switch (o.type) {
|
|
123
126
|
case QUOTED:
|
|
124
127
|
if (o.length) {
|
|
@@ -144,6 +147,7 @@ var createScoped = function (parsed) {
|
|
|
144
147
|
if (/^\.\.\./.test(u)) u = u.slice(3);
|
|
145
148
|
var u = u.replace(/^([^\.\[]*)[\s\S]*$/, '$1');
|
|
146
149
|
if (!u) break;
|
|
150
|
+
if (u === 'yield') funcbody.yield = false;
|
|
147
151
|
if (o.next && o.next.type === STAMP && o.next.text === "=>") {
|
|
148
152
|
isScope = true;
|
|
149
153
|
isArrow = true;
|
|
@@ -163,6 +167,24 @@ var createScoped = function (parsed) {
|
|
|
163
167
|
case STRAP:
|
|
164
168
|
var s = o.text;
|
|
165
169
|
switch (s) {
|
|
170
|
+
case "await":
|
|
171
|
+
funcbody.async = funcbody.await = true;
|
|
172
|
+
break;
|
|
173
|
+
case "yield":
|
|
174
|
+
if (!funcbody.yield) {
|
|
175
|
+
var next = o.next;
|
|
176
|
+
if (next) {
|
|
177
|
+
|
|
178
|
+
if (next.type === STAMP && !/[~!,;:]+$/.test(next.text)
|
|
179
|
+
|| next.type === STRAP && /in|of|as|from|instanceof/.test(next.text)
|
|
180
|
+
|| next.type === EXPRESS && /^\./.test(next.text)
|
|
181
|
+
) {
|
|
182
|
+
funcbody.yield = false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
saveTo(used, 'yield', o);
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
166
188
|
case "as":
|
|
167
189
|
case "from":
|
|
168
190
|
break;
|
|
@@ -185,6 +207,10 @@ var createScoped = function (parsed) {
|
|
|
185
207
|
continue loop;
|
|
186
208
|
case "function":
|
|
187
209
|
isFunction = true;
|
|
210
|
+
if (o.next.type === STAMP) {
|
|
211
|
+
isYield = true;
|
|
212
|
+
o = o.next;
|
|
213
|
+
}
|
|
188
214
|
case "catch":
|
|
189
215
|
isCatch = true;
|
|
190
216
|
case "class":
|
|
@@ -207,11 +233,18 @@ var createScoped = function (parsed) {
|
|
|
207
233
|
break;
|
|
208
234
|
case SCOPED:
|
|
209
235
|
if (o.entry === "(") {
|
|
210
|
-
if (o.next && o.next.type === STAMP && o.next.text === "=>"
|
|
211
|
-
|| o.prev && (o.prev.type === PROPERTY || o.prev.isprop)) {
|
|
236
|
+
if (o.next && o.next.type === STAMP && o.next.text === "=>") {
|
|
212
237
|
isArrow = true;
|
|
213
238
|
isScope = true;
|
|
214
239
|
}
|
|
240
|
+
else if (o.prev && (o.prev.type === PROPERTY || o.prev.isprop)) {
|
|
241
|
+
isFunction = true;
|
|
242
|
+
isScope = true;
|
|
243
|
+
var pp = o.prev.prev;
|
|
244
|
+
if (pp && pp.type === STAMP && pp.isprop) {
|
|
245
|
+
isYield = true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
215
248
|
else {
|
|
216
249
|
run(o.first);
|
|
217
250
|
}
|
|
@@ -239,8 +272,13 @@ var createScoped = function (parsed) {
|
|
|
239
272
|
scoped.used = used;
|
|
240
273
|
scoped.vars = vars;
|
|
241
274
|
lets = vars;
|
|
242
|
-
if (isFunction)
|
|
275
|
+
if (isFunction) {
|
|
276
|
+
vars.this = true, vars.arguments = true;
|
|
277
|
+
scoped.yield = isYield;
|
|
278
|
+
}
|
|
279
|
+
scoped.isfunc = true;
|
|
243
280
|
isFunction = true;
|
|
281
|
+
funcbody = scoped;
|
|
244
282
|
} else {
|
|
245
283
|
vars = _vars;
|
|
246
284
|
scoped.lets = lets;
|
|
@@ -333,6 +371,10 @@ var createScoped = function (parsed) {
|
|
|
333
371
|
delete vars.this;
|
|
334
372
|
delete vars.arguments;
|
|
335
373
|
}
|
|
374
|
+
if (_scoped.isfunc && !funcbody.yield) {
|
|
375
|
+
if (used.yield) _scoped.yield = false;
|
|
376
|
+
funcbody = _scoped;
|
|
377
|
+
}
|
|
336
378
|
used = _used;
|
|
337
379
|
lets = _lets;
|
|
338
380
|
vars = _vars;
|
|
@@ -352,6 +394,12 @@ var createScoped = function (parsed) {
|
|
|
352
394
|
if (!/^(true|false|null|this|arguments)$/.test(u)) envs[u] = true;
|
|
353
395
|
}
|
|
354
396
|
}
|
|
397
|
+
if (vars.yield) scoped.yield = false;
|
|
398
|
+
if (scoped.yield !== false && envs.yield) {
|
|
399
|
+
scoped.yield = true;
|
|
400
|
+
delete envs.yield;
|
|
401
|
+
delete used.yield;
|
|
402
|
+
}
|
|
355
403
|
scoped.envs = envs;
|
|
356
404
|
return scoped;
|
|
357
405
|
};
|
|
@@ -377,7 +425,7 @@ var getDeclared = function (o, kind) {
|
|
|
377
425
|
}
|
|
378
426
|
case PROPERTY:
|
|
379
427
|
if (o.next) {
|
|
380
|
-
if (o.next.type === STAMP && o.next.text === ":") {
|
|
428
|
+
if (o.next.type === STAMP && o.next.text === ":" || o.next.type === STRAP && o.next.text === "as") {
|
|
381
429
|
o = o.next.next;
|
|
382
430
|
continue;
|
|
383
431
|
}
|
package/coms/compile/scanner2.js
CHANGED
|
@@ -26,6 +26,7 @@ var needBreak = function (prev, next) {
|
|
|
26
26
|
if (prev.type === EXPRESS && /\.$/.test(prev.text)) return;
|
|
27
27
|
if (next.type === EXPRESS && /^\./.test(next.text)) return;
|
|
28
28
|
if (next.type === PROPERTY) return ";";
|
|
29
|
+
if (next.type === STAMP && next.text === "*") return ";";
|
|
29
30
|
if (
|
|
30
31
|
[EXPRESS, VALUE, QUOTED].indexOf(prev.type) >= 0
|
|
31
32
|
|| prev.type === STAMP && /^(\+\+|\-\-)$/.test(prev.text)
|
|
@@ -104,6 +105,7 @@ var insertAfter = function (o) {
|
|
|
104
105
|
for (var o of os) {
|
|
105
106
|
prev.next = o;
|
|
106
107
|
o.prev = prev;
|
|
108
|
+
Object.defineProperty(o, 'queue', { value: queue });
|
|
107
109
|
prev = o;
|
|
108
110
|
}
|
|
109
111
|
if (next) {
|
|
@@ -213,13 +215,13 @@ var detour = function (o, ie) {
|
|
|
213
215
|
}
|
|
214
216
|
if (!/^\[/.test(o.text) && o.queue.isClass) {
|
|
215
217
|
if (o.text === 'constructor') break;
|
|
216
|
-
if (o.text === 'get') console.log(o.text, o.type, o.next);
|
|
217
218
|
var text = strings.encode(strings.decode(o.text));
|
|
218
219
|
if (o.prev) {
|
|
219
220
|
var prev = o.prev;
|
|
220
221
|
if (prev && prev.type === PROPERTY && /^(get|set|static|async)$/.test(prev.text)) {
|
|
221
222
|
prev = prev.prev;
|
|
222
223
|
}
|
|
224
|
+
if (prev && prev.type === STAMP && prev.isprop) prev = prev.prev;
|
|
223
225
|
if (prev && (prev.type !== STAMP || prev.text !== ';')) insertAfter(prev, { text: ';', type: STAMP });
|
|
224
226
|
}
|
|
225
227
|
o.text = `[${text}]`;
|
|
@@ -315,7 +317,7 @@ class Program extends Array {
|
|
|
315
317
|
if (!o.prev || o.prev.text !== 'for') result.pop();
|
|
316
318
|
}
|
|
317
319
|
if (o.leave === "}" && (!o.next || o.next.type !== PIECE) && o[o.length - 1].type !== SPACE) {
|
|
318
|
-
result.push(" ");
|
|
320
|
+
if (!this.pressed) result.push(" ");
|
|
319
321
|
}
|
|
320
322
|
}
|
|
321
323
|
result.push(o.leave);
|
|
@@ -339,7 +341,7 @@ class Program extends Array {
|
|
|
339
341
|
) result.push(";");
|
|
340
342
|
}
|
|
341
343
|
else if (!/^(\+\+|\-\-)$/.test(o.text)) {
|
|
342
|
-
if (!this.pressed) result.push(" ");
|
|
344
|
+
if (!this.pressed && lasttype !== SPACE) result.push(" ");
|
|
343
345
|
}
|
|
344
346
|
}
|
|
345
347
|
result.push(o.text);
|
|
@@ -363,6 +365,15 @@ class Program extends Array {
|
|
|
363
365
|
get used() {
|
|
364
366
|
return this.scoped.used;
|
|
365
367
|
}
|
|
368
|
+
get yield() {
|
|
369
|
+
return this.scoped.yield;
|
|
370
|
+
}
|
|
371
|
+
get async() {
|
|
372
|
+
return this.scoped.async;
|
|
373
|
+
}
|
|
374
|
+
get await() {
|
|
375
|
+
return this.scoped.await;
|
|
376
|
+
}
|
|
366
377
|
get scoped() {
|
|
367
378
|
if (this._scoped) return this._scoped;
|
|
368
379
|
return this._scoped = createScoped(this);
|
|
@@ -446,15 +457,20 @@ class Javascript {
|
|
|
446
457
|
var origin = queue;
|
|
447
458
|
var queue_push = function (scope) {
|
|
448
459
|
var last = queue.lastUncomment;
|
|
449
|
-
if (
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
scope.
|
|
460
|
+
if (queue.isObject || queue.isClass) {
|
|
461
|
+
if (~[VALUE, QUOTED].indexOf(scope.type)) {
|
|
462
|
+
scope.isprop = isProperty();
|
|
463
|
+
}
|
|
464
|
+
else if (scope.type === SCOPED && scope.entry === '[') {
|
|
465
|
+
if (queue.isObject) scope.isprop = isProperty();
|
|
466
|
+
if (queue.isClass) scope.isprop = !last || last.isprop || last.type === STAMP && last.text === ';';
|
|
467
|
+
}
|
|
468
|
+
else if (scope.type === STAMP) {
|
|
469
|
+
scope.isprop = scope.text === "*" && isProperty();
|
|
470
|
+
}
|
|
471
|
+
else if (scope.type === PROPERTY) {
|
|
472
|
+
scope.isprop = true;
|
|
473
|
+
}
|
|
458
474
|
}
|
|
459
475
|
if (scope.type !== COMMENT && scope.type !== SPACE) {
|
|
460
476
|
Object.defineProperty(scope, 'queue', { value: queue });
|
|
@@ -655,10 +671,14 @@ class Javascript {
|
|
|
655
671
|
var prev = queue.lastUncomment;
|
|
656
672
|
if (queue.isObject) {
|
|
657
673
|
if (!prev || prev.type === STAMP && prev.text === ",") return true;
|
|
674
|
+
if (prev.type === STAMP && prev.isprop) return true;
|
|
658
675
|
}
|
|
659
676
|
if (queue.isClass) {
|
|
660
677
|
if (!prev) return true;
|
|
661
|
-
if (prev.type === STAMP)
|
|
678
|
+
if (prev.type === STAMP) {
|
|
679
|
+
if (prev.isprop) return true;
|
|
680
|
+
return /^(\+\+|\-\-|;)$/.test(prev.text);
|
|
681
|
+
}
|
|
662
682
|
if (prev.type === EXPRESS && !/\.$/.test(prev.text)) return true;
|
|
663
683
|
if (~[SCOPED, VALUE, QUOTED, PROPERTY].indexOf(prev.type)) return true;
|
|
664
684
|
}
|
|
@@ -770,7 +790,7 @@ class Javascript {
|
|
|
770
790
|
}
|
|
771
791
|
if (this.space_reg.test(m)) {
|
|
772
792
|
if (/[\r\n\u2028\u2029]/.test(m)) {
|
|
773
|
-
colstart = match.index +
|
|
793
|
+
colstart = match.index + 1;
|
|
774
794
|
m = m.replace(/^[^\r\n\u2028\u2029]+/, '').replace(/\r\n|\r|\n|\u2028|\u2029/g, "\r\n");
|
|
775
795
|
row += m.replace(/[^\r\n]+/, '').length >> 1;
|
|
776
796
|
save(SPACE);
|
|
@@ -790,7 +810,43 @@ class Javascript {
|
|
|
790
810
|
queue.inExpress = false;
|
|
791
811
|
}
|
|
792
812
|
}
|
|
793
|
-
|
|
813
|
+
if (m === 'yield') {
|
|
814
|
+
var temp = queue;
|
|
815
|
+
var type = STRAP;
|
|
816
|
+
var last = queue.lastUncomment;
|
|
817
|
+
if (queue.entry === '[' || queue.isClass || queue.isObject || last && (last.type === STAMP && (
|
|
818
|
+
queue[queue.length - 1].type !== SPACE && /^(\+\+|\-\-)$/.test(last.text)
|
|
819
|
+
|| !/^(>>>?=|<<=|[^><!=]=|[,;])/.test(last.text)
|
|
820
|
+
) || last.type === STRAP)) {
|
|
821
|
+
type = EXPRESS;
|
|
822
|
+
}
|
|
823
|
+
if (type === STRAP) while (temp) {
|
|
824
|
+
if (temp.entry != "{" || !temp.prev || temp.prev.type !== SCOPED || temp.prev.entry !== '(') {
|
|
825
|
+
temp = temp.queue;
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
828
|
+
var pp = temp.prev.prev;
|
|
829
|
+
var isprop = pp.isprop;
|
|
830
|
+
if (pp && pp.type === EXPRESS || pp.isprop) pp = pp.prev;
|
|
831
|
+
if (!pp || pp.type === STRAP && !/^function$/.test(pp.text)) {
|
|
832
|
+
temp = temp.queue;
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
if (pp.type === STAMP && pp.text === "*" && (pp.isprop || pp.prev && pp.prev.type === STRAP && pp.prev.text === "function")) {
|
|
836
|
+
type = STRAP;
|
|
837
|
+
break;
|
|
838
|
+
}
|
|
839
|
+
if (isprop || pp.type === STRAP && pp.text === "function") {
|
|
840
|
+
type = EXPRESS;
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
temp = temp.queue;
|
|
844
|
+
}
|
|
845
|
+
save(type);
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
save(STRAP);
|
|
849
|
+
}
|
|
794
850
|
continue;
|
|
795
851
|
}
|
|
796
852
|
if (this.value_reg.test(m) || this.number_reg.test(m)) {
|
|
@@ -828,7 +884,8 @@ class Javascript {
|
|
|
828
884
|
else scope.isObject = !/^(;|\+\+|\-\-|=>)$/.test(last.text);
|
|
829
885
|
}
|
|
830
886
|
else if (last.type === STRAP) {
|
|
831
|
-
if (queue[queue.length - 1].type === SPACE && /^(return|
|
|
887
|
+
if (queue[queue.length - 1].type === SPACE && /^(return|yield)$/.test(last.text));
|
|
888
|
+
else if (/^export$/.test(last.text));
|
|
832
889
|
else scope.isObject = queue.inExpress;
|
|
833
890
|
}
|
|
834
891
|
}
|
package/coms/frame/edit.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<span v-text="origin?'修改':'添加'"></span><span -text="title"></span>
|
|
3
3
|
</div>
|
|
4
4
|
<div body>
|
|
5
|
-
<field v-if="!f.
|
|
5
|
+
<field v-if="!f.hidden" -repeat="f in fields" ng-src="[f,data]"></field>
|
|
6
6
|
</div>
|
|
7
7
|
<div foot>
|
|
8
8
|
<btn @click="remove()" class="white">取消</btn>
|
|
@@ -2,7 +2,8 @@ function main(element = document.createElement("div")) {
|
|
|
2
2
|
element.innerHTML = colorpicker;
|
|
3
3
|
var saved_value;
|
|
4
4
|
var selector = element.firstChild;
|
|
5
|
-
|
|
5
|
+
var pad = colorpad();
|
|
6
|
+
select(selector, pad, false, 'y');
|
|
6
7
|
render(element, {
|
|
7
8
|
a: button,
|
|
8
9
|
colorlabel,
|
|
@@ -25,6 +26,7 @@ function main(element = document.createElement("div")) {
|
|
|
25
26
|
element.setValue = function (value) {
|
|
26
27
|
element.value = value;
|
|
27
28
|
cast(selector, value);
|
|
29
|
+
pad.setValue(value);
|
|
28
30
|
};
|
|
29
31
|
return element;
|
|
30
32
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
2
|
+
function getName(o) {
|
|
3
|
+
if (hasOwnProperty.call(o, 'toString')) return o.toString();
|
|
4
|
+
if ("name" in o) return o.name;
|
|
5
|
+
if ("label" in o) return o.label;
|
|
6
|
+
if ("value" in o) return o.value;
|
|
7
|
+
if (hasOwnProperty.call(o, 'valueOf')) return o.valueOf();
|
|
8
|
+
return o;
|
|
9
|
+
}
|
package/coms/zimoli/getValue.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return
|
|
1
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
2
|
+
function getValue(o = this) {
|
|
3
|
+
if (!o) return o;
|
|
4
|
+
if (isFunction(o.getValue)) return o.getValue();
|
|
5
|
+
if (hasOwnProperty.call(o, 'valueOf')) return o.valueOf();
|
|
6
|
+
if ("key" in o) return o.key;
|
|
7
|
+
if ("value" in o) return o.value;
|
|
8
|
+
if (hasOwnProperty.call(o, 'toString')) return o.toString();
|
|
9
|
+
if (!isEmpty(o.id)) return o.id;
|
|
10
|
+
return o;
|
|
4
11
|
}
|
package/coms/zimoli/model.js
CHANGED
|
@@ -12,6 +12,7 @@ var rebuildOptions = function () {
|
|
|
12
12
|
var new_options = seek(data, options_from);
|
|
13
13
|
if (new_options !== options) {
|
|
14
14
|
field.options = new_options;
|
|
15
|
+
delete field.optionsMap;
|
|
15
16
|
render.refresh();
|
|
16
17
|
}
|
|
17
18
|
};
|
|
@@ -198,7 +199,22 @@ function main(elem) {
|
|
|
198
199
|
elem.innerHTML = '<span ng-bind=get()></span>';
|
|
199
200
|
render(elem, {
|
|
200
201
|
get() {
|
|
201
|
-
|
|
202
|
+
var value = seek(data, field.key);
|
|
203
|
+
if (field.options) {
|
|
204
|
+
if (!field.optionsMap) {
|
|
205
|
+
var map = Object.create(null);
|
|
206
|
+
for (var o of field.options) {
|
|
207
|
+
var v = getValue(o);
|
|
208
|
+
map[v] = o;
|
|
209
|
+
}
|
|
210
|
+
field.optionsMap = map;
|
|
211
|
+
}
|
|
212
|
+
var map = field.optionsMap;
|
|
213
|
+
if (value in map) {
|
|
214
|
+
value = getName(map[value]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return value;
|
|
202
218
|
}
|
|
203
219
|
});
|
|
204
220
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
zimoli.prepare;
|
package/coms/zimoli/radio.js
CHANGED
|
@@ -18,18 +18,18 @@ function main(elem = document.createElement("radio-group")) {
|
|
|
18
18
|
options,
|
|
19
19
|
select(a) {
|
|
20
20
|
this.options.active = a;
|
|
21
|
-
elem.value = a
|
|
21
|
+
elem.value = getValue(a);
|
|
22
22
|
dispatch(elem, 'change');
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
if (elem.value) {
|
|
25
|
+
if (!isEmpty(elem.value)) {
|
|
26
26
|
elem.setValue(elem.value);
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
elem.setValue = function (key) {
|
|
30
30
|
var { options } = this.$scope;
|
|
31
31
|
if (!(options instanceof Array)) return;
|
|
32
|
-
var index = options.map(a => a
|
|
32
|
+
var index = options.map(a => getValue(a)).indexOf(key);
|
|
33
33
|
options.active = options[index];
|
|
34
34
|
};
|
|
35
35
|
return elem;
|