efront 3.3.5 → 3.4.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.
@@ -0,0 +1,3 @@
1
+ ./aapi/ authorization:
2
+ login: options /::login-:a
3
+ run: options /:::run
@@ -0,0 +1,9 @@
1
+ <div head>
2
+ 请输入服务器密码
3
+ </div>
4
+ <div body>
5
+ <field ng-repeat="f in fields" ng-src="[f,data]"></field>
6
+ </div>
7
+ <div foot>
8
+ <button pending.="pending" type="submit">登录</button>
9
+ </div>
@@ -0,0 +1,29 @@
1
+ var fields = refilm`
2
+ 密码/password* password
3
+ `;
4
+
5
+ function main() {
6
+ var page = view();
7
+ page.innerHTML = login;
8
+ drag.on(page);
9
+ on("append")(page, function () {
10
+ move.bindPosition(page, [.5, .5]);
11
+ });
12
+ renderWithDefaults(page, { fields, data: {}, pending: false });
13
+ on("submit")(page, async function () {
14
+ var { password } = submit(fields, this.$scope.data);
15
+ this.$scope.pending = true;
16
+ page.disabled = true;
17
+ try {
18
+ var info = await data.from("login", {
19
+ a: encode62.timeencode(encode62.geta(password))
20
+ }).loading_promise;
21
+ info = encode62.timeupdate(info);
22
+ data.setSource({ authorization: info });
23
+ go('/home/main')
24
+ } catch {
25
+ }
26
+ this.$scope.pending = false;
27
+ })
28
+ return page;
29
+ }
@@ -0,0 +1,11 @@
1
+ & {
2
+ position: absolute;
3
+ }
4
+
5
+ [foot],
6
+ [head] {
7
+ text-align: center;
8
+ }
9
+ .button{
10
+ padding: 0px 40px;
11
+ }
@@ -0,0 +1,13 @@
1
+ <div>
2
+ 已登录到服务器,您可以进行如下操作
3
+ </div>
4
+ <block>
5
+ <padding>
6
+ 清理服务器缓存 <btn @click="run('clear-cache',this)">清理</btn>
7
+ </padding>
8
+ </block>
9
+ <block>
10
+ <padding>
11
+ 退出登录 <btn @click="logout()">退出</btn>
12
+ </padding>
13
+ </block>
@@ -0,0 +1,22 @@
1
+ function main() {
2
+ var page = div();
3
+ page.innerHTML = template;
4
+ renderWithDefaults(page, {
5
+ status: [],
6
+ async run(id, target) {
7
+ target.setAttribute('pending', '')
8
+ try {
9
+ var info = await data.from("run", {
10
+ run: id
11
+ }).loading_promise;
12
+ if (info) alert(info, 'pass');
13
+ } catch { }
14
+ target.removeAttribute('pending');
15
+ },
16
+ logout() {
17
+ data.setSource('authorization', null);
18
+ go('/auth/login');
19
+ }
20
+ });
21
+ return page;
22
+ }
@@ -0,0 +1,8 @@
1
+ &{
2
+ line-height: 28px;
3
+ }
4
+ btn{
5
+ padding: 0 16px;
6
+ vertical-align: top;
7
+ margin-left: 20px;
8
+ }
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE html>
2
+ <!--
3
+ http://efront.cc
4
+ -->
5
+ <html lang="zh-CN">
6
+
7
+ <head>
8
+ <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
9
+ <meta charset="utf-8" />
10
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11
+ <link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
12
+ <meta name="viewport" content="initial-scale=1,maximum-scale=1,width=device-width" />
13
+ <title>Efront 服务器管控平台</title>
14
+ <script deleteoncompile efrontloader>
15
+ // 若要在开发环境使用内置组件,请保留此script标签中的代码,在编译发布时,这里的代码会自动删除
16
+ </script>
17
+ <style>
18
+ html {
19
+ height: 100%;
20
+ font-family: "SF Pro SC", "SF Pro Text", "SF Pro Icons", "PingFang SC", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
21
+ }
22
+
23
+ *,
24
+ ::before,
25
+ ::after {
26
+ box-sizing: border-box;
27
+ }
28
+
29
+ body {
30
+ border: none;
31
+ margin: 0;
32
+ padding: 0;
33
+ height: 100%;
34
+ overflow: hidden;
35
+ }
36
+ </style>
37
+ </head>
38
+
39
+ <body scroll=no max-render=1440 main-path="/main"></body>
40
+
41
+ </html>
@@ -0,0 +1,13 @@
1
+ if (data.getSource('authorization')) {
2
+ zimoli("/home/main");
3
+ }
4
+ else {
5
+ zimoli("/auth/login");
6
+ }
7
+ data.loadConfig("api.yml");
8
+ setInterval(function () {
9
+ var auth = data.getSource('authorization');
10
+ if (!auth) return;
11
+ var auth1 = encode62.timeupdate(auth);
12
+ if (auth1 !== auth) data.setSource("authorization", auth1);
13
+ }, 2000);
@@ -313,7 +313,7 @@ var loadModule = function (name, then, prebuilds = {}) {
313
313
  readFile(name, saveModule);
314
314
  }
315
315
  };
316
- var toRem = text => pixelDecoder && typeof text === 'string' ? text.replace(/(\:\s*)?\b((?:\d*\.)?\d+)px(\s*\))?/ig, (m, h, d, quote) => (h || "") + (d !== '1' ? h && quote ? renderPixelRatio * d + "pt" : pixelDecoder(d) : renderPixelRatio > 1 ? ".75pt" : 0.75 / devicePixelRatio + "pt") + (quote || "")) : text;
316
+ var toRem = text => pixelDecoder && typeof text === 'string' ? text.replace(/(\:\s*)?\b((?:\d*\.)?\d+)px(\s*\))?/ig, (m, h, d, quote) => (h || "") + (d !== '1' ? h && quote ? renderPixelRatio * d + "pt" : pixelDecoder(d) : renderPixelRatio > 1 ? ".78pt" : 0.78 / devicePixelRatio + "pt") + (quote || "")) : text;
317
317
  if (document.head) var efrontsign = document.head.lastElementChild.attributes[0];
318
318
  if (efrontsign && /^compiledinfo\-/.test(efrontsign.name)) efrontsign = efrontsign.name.slice(efrontsign.name.indexOf('-') + 1);
319
319
  else efrontsign = '';
@@ -260,8 +260,16 @@ function parse(piece) {
260
260
  }
261
261
  var [name, type, options] = piece, key, repeat;
262
262
  if (piece.length === 1 && isObject(name)) {
263
- var { name, needs, type, key, size, unit, endwith, ratio, value, repeat, comment, options } = name;
263
+ var { name, needs, required, checks, type, key, size, unit, endwith, ratio, value, repeat, comment, options } = name;
264
264
  } else {
265
+ var is_require = a => {
266
+ if (/^\*|\*$/.test(a)) {
267
+ required = true;
268
+ return a.replace(/^\*|\*$/, '');
269
+ }
270
+ return a;
271
+ };
272
+ type = is_require(type);
265
273
  if (typeof name === 'string') {
266
274
  if (!isContainer) {
267
275
  if (!type) {
@@ -362,14 +370,17 @@ function parse(piece) {
362
370
  type = type.slice(1);
363
371
  }
364
372
  if (typeof options === "string") {
373
+ options = is_require(options);
365
374
  var needUnfold = /^\[|\]$/.test(options);
366
375
  options = options.replace(/^\[|\]$/g, '');
367
376
  if (/,/.test(options)) options = scanSlant(options, ',');
368
377
  else options = scanSlant(options, "");
369
378
  if (needUnfold) unfoldOptions(size, options);
370
379
  }
380
+ name = is_require(name);
381
+ key = is_require(key);
371
382
  }
372
- var field = { name, needs, type, key, size, unit, endwith, ratio, value, repeat, comment, options };
383
+ var field = { name, checks, required, needs, type, key, size, unit, endwith, ratio, value, repeat, comment, options };
373
384
  var parent = piecepath[piecepath.length - 1];
374
385
  if (parent) {
375
386
  field.parent = parent;
@@ -23,7 +23,7 @@ var seek = function (object, seeker) {
23
23
  if (isObject(seeker)) {
24
24
  var dist = {};
25
25
  for (var k in seeker) {
26
- var { k: v = k } = seeker;
26
+ var { [k]: v = k } = seeker;
27
27
  var o = seek(object, v);
28
28
  if (o === undefined) return;
29
29
  dist[k] = o;
@@ -0,0 +1,10 @@
1
+ function valid(field, data) {
2
+ var error;
3
+ if (isEmpty(data[field.key])) {
4
+ if (field.required) {
5
+ return "empty";
6
+ }
7
+ return;
8
+ }
9
+ return error;
10
+ }
@@ -0,0 +1,451 @@
1
+ const [
2
+ /*-1 */COMMENT,
3
+ /* 0 */SPACE,
4
+ /* 1 */STRAP,
5
+ /* 2 */STAMP,
6
+ /* 3 */VALUE,
7
+ /* 4 */QUOTED,
8
+ /* 5 */PIECE,
9
+ /* 6 */EXPRESS,
10
+ /* 7 */SCOPED,
11
+ /* 8 */LABEL,
12
+ /* 9 */PROPERTY,
13
+ ] = new Array(20).fill(0).map((_, a) => a - 1);
14
+ var number_reg = /^[\+\-]?(0x[0-9a-f]+|0b\d+|0o\d+|(\d*\.\d+|\d+\.?)(e[\+\-]?\d+|[mn])?)$/i;
15
+ var skipAssignment = function (o) {
16
+ var needpunc = false;
17
+ var o0 = o;
18
+ var qcount = 0;
19
+ loop: while (o) switch (o.type) {
20
+ case STAMP:
21
+ switch (o.text) {
22
+ case ",":
23
+ case ";":
24
+ break loop;
25
+ case "++":
26
+ case "--":
27
+ o = o.next;
28
+ break;
29
+ case "!":
30
+ case "~":
31
+ case "+":
32
+ case "-":
33
+ o = o.next;
34
+ needpunc = false;
35
+ break;
36
+ case "?":
37
+ qcount++;
38
+ needpunc = false;
39
+ o = o.next;
40
+ break;
41
+ case ":":
42
+ qcount--;
43
+ if (qcount < 0) break loop;
44
+ needpunc = false;
45
+ o = o.next;
46
+ break;
47
+ default:
48
+ if (/^[!~\+\-]+$/.test(o.text)) {
49
+ needpunc = false;
50
+ o = o.next;
51
+ break;
52
+ }
53
+ if (!needpunc) break loop;
54
+ needpunc = false;
55
+ o = o.next;
56
+ }
57
+ break;
58
+ case SCOPED:
59
+ if (needpunc && o.entry === "{") break loop;
60
+ o = o.next;
61
+ needpunc = true;
62
+ break;
63
+ case EXPRESS:
64
+ if (/^\.|\.$/.test(o.text)) {
65
+ o = o.next;
66
+ break;
67
+ }
68
+ else if (/^\[/.test(o.text)) {
69
+ needpunc = true;
70
+ o = o.next;
71
+ break;
72
+ }
73
+ case VALUE:
74
+ case QUOTED:
75
+ if (needpunc) break loop;
76
+ needpunc = true;
77
+ o = o.next;
78
+ break;
79
+ case STRAP:
80
+ if (needpunc) {
81
+ if (!/^(in|instanceof)$/.test(o.text)) break loop;
82
+ o = o.next;
83
+ needpunc = false;
84
+ }
85
+ else if (o.text === "class") {
86
+ o = o.next;
87
+ while (o && !o.isClass) o = o.next;
88
+ while (o && o.isClass) o = o.next;
89
+ needpunc = true;
90
+ break;
91
+ }
92
+ else if (o.text === "function") {
93
+ o = o.next;
94
+ if (o && o.type === EXPRESS) o = o.next;
95
+ if (o) o = o.next;
96
+ if (o) o = o.next;
97
+ needpunc = true;
98
+ break;
99
+ }
100
+ else {
101
+ o = o.next;
102
+ needpunc = false;
103
+ }
104
+ break;
105
+ default:
106
+ console.log(o);
107
+ throw new Error('代码结构异常!');
108
+ o = o.next;
109
+ }
110
+ return o;
111
+ };
112
+ var createScoped = function (parsed) {
113
+ var used = Object.create(null); var vars = Object.create(null), lets = vars;
114
+ var scoped = [];
115
+ var run = function (o, id) {
116
+ loop: while (o) {
117
+ var isCatch = false;
118
+ var isFunction = false;
119
+ var isScope = false;
120
+ var isArrow = false;
121
+ switch (o.type) {
122
+ case QUOTED:
123
+ if (o.length) {
124
+ run(o.first);
125
+ }
126
+ break;
127
+ case STAMP:
128
+ break;
129
+ case PROPERTY:
130
+ if (o.next) {
131
+ if (o.next.type !== STAMP || o.next.text !== ",") break;
132
+ }
133
+ case VALUE:
134
+ if (number_reg.test(o.text)) break;
135
+ case EXPRESS:
136
+ if (o.prev && o.prev.type === EXPRESS) {
137
+ if (/\.$/.test(o.prev.text)) break;
138
+ }
139
+ var u = o.text.replace(/^([^\.\[]*)[\s\S]*$/, '$1');
140
+ if (!u) break;
141
+ if (o.next && o.next.type === STAMP && o.next.text === "=>") {
142
+ isScope = true;
143
+ isArrow = true;
144
+ }
145
+ else {
146
+ saveTo(used, u, o);
147
+ }
148
+ break;
149
+ case LABEL:
150
+ var name = o.text;
151
+ name = name.slice(0, name.length - 1);
152
+ vars[name] = true;
153
+ o.kind = "label";
154
+ saveTo(used, name, o);
155
+ break;
156
+
157
+ case STRAP:
158
+ var s = o.text;
159
+ switch (s) {
160
+ case "var":
161
+ case "import":
162
+ var m = vars;
163
+ case "let":
164
+ case "const":
165
+ m = m || lets;
166
+ var [declared, used0, o0, skiped] = getDeclared(o.next, s);
167
+ while (skiped.length) {
168
+ var o1 = run(skiped[0], 0);
169
+ let sindex = skiped.indexOf(o1);
170
+ if (sindex < 0) break;
171
+ skiped.splice(0, sindex + 1);
172
+ }
173
+ o = o0;
174
+ mergeTo(used, used0);
175
+ Object.assign(m, declared);
176
+ continue loop;
177
+ case "function":
178
+ isFunction = true;
179
+ case "catch":
180
+ isCatch = true;
181
+ case "class":
182
+ if (!o.isExpress) {
183
+ o = o.next;
184
+
185
+ if (o.type === EXPRESS) {
186
+ vars[o.text] = true;
187
+ o.kind = isFunction ? 'function' : 'class';
188
+ saveTo(used, o.text, o);
189
+
190
+ o = o.next;
191
+ }
192
+ }
193
+ isScope = true;
194
+ break;
195
+
196
+ }
197
+ break;
198
+ case SCOPED:
199
+ if (o.entry === "(") {
200
+ if (o.next && o.next.type === STAMP && o.next.text === "=>"
201
+ || o.prev && (o.prev.type === PROPERTY || o.prev.isprop)) {
202
+ isArrow = true;
203
+ isScope = true;
204
+ }
205
+ else {
206
+ run(o.first);
207
+ }
208
+ }
209
+ else if (o.entry === "{") {
210
+ isScope = true;
211
+ }
212
+ else {
213
+ run(o.first);
214
+ }
215
+ break;
216
+ }
217
+ if (isScope) {
218
+ var _used = used;
219
+ var _lets = lets;
220
+ var _vars = vars;
221
+ var _scoped = scoped;
222
+ used = Object.create(null);
223
+ lets = Object.create(null);
224
+ vars = Object.create(null);
225
+ scoped = [];
226
+ var isExpress = o.isExpress;
227
+
228
+ if (isFunction || isArrow) {
229
+ scoped.used = used;
230
+ scoped.vars = vars;
231
+ lets = vars;
232
+ if (isFunction) vars.this = true, vars.arguments = true;
233
+ isFunction = true;
234
+ } else {
235
+ vars = _vars;
236
+ scoped.lets = lets;
237
+ scoped.used = used;
238
+ }
239
+ if (isArrow);
240
+ else if (o.isExpress && o.type !== SCOPED) {
241
+ o = o.next;
242
+ if (o.type === EXPRESS) {
243
+ vars[o.text] = true;
244
+ o.kind = isFunction ? 'function' : 'class';
245
+ saveTo(used, o.text, o);
246
+ o = o.next;
247
+ }
248
+ }
249
+ if (!isFunction) while (o.type !== SCOPED) {
250
+ // if (o.next && o.next.type === STAMP && o.next.text === "=>") break;
251
+ o = run(o, 0);
252
+ o = o.next;
253
+ if (!o) break loop;
254
+ }
255
+
256
+ if (o.entry === "(") {
257
+ o.isExpress = isExpress;
258
+ if (isFunction || isCatch) {
259
+ var [declared, used0, o0, skiped] = getDeclared(o.first, 'argument');
260
+ mergeTo(used, used0);
261
+ while (skiped.length) {
262
+ var o1 = run(skiped[0], 0);
263
+ var sindex = skiped.indexOf(o1);
264
+ if (sindex < 0) break;
265
+ skiped.splice(0, sindex + 1);
266
+ }
267
+ Object.assign(isCatch ? lets : vars, declared);
268
+ }
269
+ else {
270
+ run(o.first);
271
+ }
272
+ o = o.next;
273
+ if (!o) break;
274
+ if (o.type === STAMP && o.text === "=>") o = o.next;
275
+ }
276
+ else if (isArrow) {
277
+ vars[o.text] = true;
278
+ o.kind = 'argument';
279
+ saveTo(used, o.text, o);
280
+ o = o.next.next;
281
+ }
282
+ if (!o) break;
283
+ if (o.type === SCOPED && o.entry === "{") {
284
+ o.isExpress = isExpress;
285
+ run(o.first);
286
+ }
287
+ else {
288
+ do {
289
+ if (o.type === STAMP && o.text === ";") break;
290
+ o = run(o, 0);
291
+ var next = o.next;
292
+ if (!next) break;
293
+ var e = o;
294
+ if (o.type === STAMP && /^(\+\+|\-\-)$/.test(o.text) || ~[VALUE, QUOTED, SCOPED].indexOf(o.type) || EXPRESS === o.type && !/\.$/.test(o.text)) {
295
+ if (~[VALUE, QUOTED, PROPERTY, LABEL].indexOf(next.type)) break;
296
+ if (EXPRESS === next.type && !/^\./.test(next.text)) break;
297
+ if (next.type === SCOPED && next.entry === "{") break;
298
+ }
299
+ o = next;
300
+ } while (o);
301
+ }
302
+ var map = isFunction ? vars : lets;
303
+ var keepscope = false;
304
+ for (var k in map) {
305
+ keepscope = true;
306
+ break;
307
+ }
308
+ if (keepscope) {
309
+ for (var k in used) {
310
+ if (!(k in map)) {
311
+ for (var u of used[k]) {
312
+ saveTo(_used, k, u);
313
+ }
314
+ }
315
+ }
316
+ _scoped.push(scoped);
317
+ }
318
+ else {
319
+ mergeTo(_used, used);
320
+ if (scoped.length) _scoped.push(scoped);
321
+ }
322
+ if (vars.this) {
323
+ delete vars.this;
324
+ delete vars.arguments;
325
+ }
326
+ used = _used;
327
+ lets = _lets;
328
+ vars = _vars;
329
+ scoped = _scoped;
330
+ }
331
+ if (id >= 0) break;
332
+ if (o) o = o.next;
333
+ }
334
+ return o;
335
+ };
336
+ run(parsed.first);
337
+ scoped.used = used;
338
+ scoped.vars = vars;
339
+ var envs = Object.create(null);
340
+ for (var u in used) {
341
+ if (!(u in vars)) {
342
+ if (!/^(true|false|null|this|arguments)$/.test(u)) envs[u] = true;
343
+ }
344
+ }
345
+ scoped.envs = envs;
346
+ return scoped;
347
+ };
348
+ var getDeclared = function (o, kind) {
349
+ var declared = Object.create(null), used = Object.create(null); var skiped = [];
350
+ loop: while (o) {
351
+ while (o && o.type === STAMP && o.text === ',') o = o.next;
352
+ if (!o) break;
353
+ if (o.isprop) {
354
+ skiped.push(o);
355
+ if (o.next && o.next.type === STAMP && o.next.text === ":") {
356
+ o = o.next;
357
+ o = o.next;
358
+ }
359
+ }
360
+ switch (o.type) {
361
+ case PROPERTY:
362
+ if (o.next && o.next.type === STAMP && o.next.text === ":") {
363
+ o = o.next.next;
364
+ continue;
365
+ }
366
+ case STRAP:
367
+ case VALUE:
368
+ case EXPRESS:
369
+ var n = o.text.replace(/^\.\.\.|\.\.\.$/g, '');
370
+ declared[n] = true;
371
+ o.kind = kind;
372
+ saveTo(used, n, o);
373
+ o = o.next;
374
+ break;
375
+ case SCOPED:
376
+ var [d, u, _, s] = getDeclared(o.first, kind);
377
+ while (s.length) skiped.push.apply(skiped, s.splice(0, 1024));
378
+ mergeTo(used, u);
379
+ Object.assign(declared, d);
380
+ o = o.next;
381
+ break;
382
+
383
+ default:
384
+ console.log(o);
385
+ throw new Error("代码结构异常");
386
+ }
387
+ if (!o) break;
388
+ switch (o.type) {
389
+ case STRAP:
390
+ if (/^(in|of)$/.test(o.text)) {
391
+ o = o.next;
392
+ var o0 = skipAssignment(o);
393
+ do {
394
+ skiped.push(o);
395
+ o = o.next;
396
+ } while (o !== o0);
397
+ o = o0;
398
+ break;
399
+ }
400
+ break loop;
401
+ case STAMP:
402
+ if (o.text === "=") {
403
+ o = o.next;
404
+ var o0 = skipAssignment(o);
405
+ do {
406
+ skiped.push(o);
407
+ o = o.next;
408
+ } while (o !== o0);
409
+ o = o0;
410
+ break;
411
+ }
412
+ break;
413
+ }
414
+ if (!o) break;
415
+ if (o.type !== STAMP) break;
416
+ if (o.text !== ',') break;
417
+ }
418
+ return [declared, used, o, skiped];
419
+ };
420
+ var saveTo = function (used, k, o) {
421
+ if (!(used[k] instanceof Array)) used[k] = [];
422
+ used[k].push(o);
423
+ };
424
+
425
+ var mergeTo = function (used, used0) {
426
+ for (var k in used0) {
427
+ var v = used0[k];
428
+ for (var s of v) saveTo(used, k, s);
429
+ }
430
+ };
431
+
432
+
433
+ module.exports = {
434
+ /*-1 */COMMENT,
435
+ /* 0 */SPACE,
436
+ /* 1 */STRAP,
437
+ /* 2 */STAMP,
438
+ /* 3 */VALUE,
439
+ /* 4 */QUOTED,
440
+ /* 5 */PIECE,
441
+ /* 6 */EXPRESS,
442
+ /* 7 */SCOPED,
443
+ /* 8 */LABEL,
444
+ /* 9 */PROPERTY,
445
+ number_reg,
446
+ skipAssignment,
447
+ getDeclared,
448
+ createScoped,
449
+ saveTo,
450
+ mergeTo
451
+ };