efront 4.0.57 → 4.0.58

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.
@@ -384,7 +384,7 @@ Javascript.prototype.setType = function (o) {
384
384
  }
385
385
  }
386
386
  if (o.type === STAMP) {
387
- if (!last || last.type & (STAMP | STRAP)) {
387
+ if (!last || last.type & (STAMP | STRAP) || last.type === SCOPED && /^[\{\[]$/.test(last.entry) && !last.isExpress) {
388
388
  o.unary = /^[^=;,\*]$|.[^\=\>\<\|\&\^]$/.test(o.text);
389
389
  }
390
390
  }
@@ -404,7 +404,7 @@ var createScoped = function (parsed, wash) {
404
404
  var function_obj = null;
405
405
  if (o.type === STAMP && equal_reg.test(o.text)) {
406
406
  var p = snapExpressHead(o.prev);
407
- if (!p || p.type & (STRAP | STAMP)) {
407
+ if (!p || p.type & (STRAP | STAMP) || !p.isExpress) {
408
408
  let n = o.next;
409
409
  if (n && n.type & (EXPRESS | VALUE)) {
410
410
  n.equal = o;
@@ -1,7 +1,11 @@
1
- var { STAMP, PROPERTY, SCOPED, VALUE, EXPRESS, QUOTED, SPACE, COMMENT, createString } = require("./common");
1
+ var { STAMP, PROPERTY, SCOPED, VALUE, EXPRESS, QUOTED, SPACE, COMMENT, createString: _createString, splice } = require("./common");
2
+ var createString = function (a) {
3
+ a.autospace = false;
4
+ return _createString(a);
5
+ };
2
6
  class Richarg extends Program {
3
7
  straps = ["and"];
4
- stamps = ',:;'.split("");
8
+ stamps = ',:;>+~&!/'.split("");
5
9
  quotes = this.quotes.slice(0, 2).concat();
6
10
  keepspace = true;
7
11
  scopes = [["(", ")"], ["{", "}"]];
@@ -9,49 +13,87 @@ class Richarg extends Program {
9
13
 
10
14
  var rarg = new Richarg;
11
15
  rarg.quotes.push(["url(", ")"]);
12
- var killcalc = a => createString(a).replace(/((?:[\+\-]+)?(?:\d+(?:\.\d*)?|\.\d+))\s*(px|%|pt|cm|mm|r?em)?\s*([\/\*]\s*|[\+\-]\s+)((?:[\+\-]+)?(?:\d+(?:\.\d*)?|\.\d+))(px|%|pt|cm|mm|r?em)?/ig, function (_, d1, p1 = '', c, d2, p2 = '') {
13
- d1 = eval(d1);
14
- d2 = eval(d2);
15
- if (!p2) {
16
- if (c === '*') {
17
- return d1 * d2 + p1;
18
- }
19
- if (c === '/') {
20
- return d1 / d2 + p1;
21
- }
22
- }
23
- else if (p1 === p2) {
24
- if (c === "+") {
25
- return (+d1 + +d2) + p1;
26
- }
27
- if (c === '-') {
28
- return (d1 - d2) + p1;
29
- }
30
- }
31
- return _;
32
- });
16
+ var numberReg = /((?:[\+\-]+)?(?:\d+(?:\.\d*)?|\.\d+))(?:\s*(px|%|pt|pc|in|cm|mm|r?em|deg|rad|vw|vh|%))?/;
17
+ var replaceHReg = new RegExp(numberReg.source + /\s*([\/\*])\s*/.source + numberReg.source, 'gi');
18
+ var replaceLReg = new RegExp(numberReg.source + /(\s*[\+\-]\s+|[\+\-])/.source + numberReg.source, 'gi');
19
+ var replaceTReg = new RegExp(numberReg.source + /\s*[\/\*\+\-]\s*/.source + numberReg.source, 'i');
20
+ var remove_quote = a => a.replace(/~\s*(['"`])((?:\\[\s\S]|[^'"`\\])*?)\1/g, '$2');
21
+ var replace_punc = function (a) {
22
+ if (typeof a !== "string") return a;
23
+ a = remove_quote(a);
24
+ if (/\(/.test(a)) return a;
25
+ do {
26
+ var replaced = false;
27
+ a = a.replace(replaceHReg, function (_, d1, p1, c, d2, p2) {
28
+ if (!p2 || !p1) {
29
+ p1 = p1 || p2 || '';
30
+ d1 = eval(d1);
31
+ d2 = eval(d2);
32
+ if (c === '*') {
33
+ replaced = true;
34
+ return d1 * d2 + p1;
35
+ }
36
+ if (c === '/') {
37
+ replaced = true;
38
+ return d1 / d2 + p1;
39
+ }
40
+ }
41
+ return _;
42
+ });
43
+ } while (replaced);
44
+ do {
45
+ var replaced = false;
46
+ a = a.replace(replaceLReg, function (_, d1, p1 = '', c, d2, p2 = '') {
47
+ if (p1 === p2) {
48
+ d1 = eval(d1);
49
+ d2 = eval(d2);
50
+ c = c.trim();
51
+ if (c === "+") {
52
+ replaced = true;
53
+ return (+d1 + +d2) + p1;
54
+ }
55
+ if (c === '-') {
56
+ replaced = true;
57
+ return (d1 - d2) + p1;
58
+ }
59
+ }
60
+ return _;
61
+ });
62
+ } while (replaced);
63
+ return a;
64
+ }
65
+ var killcalc = a => replace_punc(createString(a));
33
66
  var seprateFunc = function (express) {
34
67
  var express = scanner2(express, rarg);
35
68
  var sps = [];
36
69
  var sp = [];
37
- sp.autospace = false;
38
70
  for (var cx = 0, dx = express.length; cx < dx; cx++) {
39
71
  var o = express[cx];
40
72
  if (o.type === SCOPED && o.entry === '(') {
41
- if (!sp.length) continue;
42
73
  var p = sp[sp.length - 1];
43
- if (p.type & (EXPRESS | PROPERTY)) {
74
+ if (!p) {
75
+ sp.push(o);
76
+ sps.push(killcalc(sp));
77
+ sp.splice(0, sp.length);
78
+ }
79
+ else if (p.type & (EXPRESS | PROPERTY)) {
44
80
  sp.pop();
45
81
  if (sp.length) sps.push(killcalc(sp));
46
82
  sp.splice(0, sp.length, p, o);
47
83
  sps.push(createString(sp));
48
84
  sp.splice(0, sp.length);
49
85
  }
86
+ else {
87
+ sps.push(killcalc(sp));
88
+ sp.splice(0, sp.length, o);
89
+ sps.push(createString(sp));
90
+ sp.splice(0, sp.length);
91
+ }
50
92
  }
51
- else if (o.type === QUOTED) {
93
+ else if (o.type === QUOTED && !/^['"`]/.test(o.text)) {
52
94
  if (sp.length) sps.push(killcalc(sp));
53
95
  sp.splice(0, sp.length);
54
- sps.push(createString([o]));
96
+ sps.push(o.text);
55
97
  }
56
98
  else sp.push(o);
57
99
  }
@@ -61,21 +103,18 @@ var seprateFunc = function (express) {
61
103
  var splitParams = function (params) {
62
104
  if (!params) return [];
63
105
  params = scanner2(params, rarg);
64
- var o = params.first;
65
- var params = [];
66
- while (o) {
67
- var p = [];
68
- while (o) {
69
- if (o.type === STAMP && o.text === ',') {
70
- o = o.next;
71
- break;
72
- }
73
- p.push(o);
74
- o = o.next;
106
+ var code = params;
107
+ var params = [], p = [];
108
+ for (var cx = 0, dx = code.length; cx < dx; cx++) {
109
+ var o = code[cx];
110
+ if (o.type === STAMP && o.text === ',') {
111
+ params.push(createString(p));
112
+ p = [];
113
+ continue;
75
114
  }
76
- p.autospace = false;
77
- params.push(createString(p));
115
+ p.push(o);
78
116
  }
117
+ if (p.length) params.push(createString(p));
79
118
  return params;
80
119
  }
81
120
  var createArgMap = function (args, split = ',', equal = ':') {
@@ -107,6 +146,10 @@ var createArgMap = function (args, split = ',', equal = ':') {
107
146
  };
108
147
 
109
148
  var macros = Object.create(null);
149
+ macros.calc = function (a) {
150
+ if (replaceTReg.test(a)) return `calc(${a})`;
151
+ return a;
152
+ };
110
153
  macros.range = function () {
111
154
  if (arguments.length === 1) {
112
155
  return ArrayFill(arguments[0], 0).map((a, i) => i + 1);
@@ -161,6 +204,9 @@ var wrapColor = function (f) {
161
204
  return f;
162
205
  }
163
206
  }
207
+ macros[""] = function (a) {
208
+ return a;
209
+ };
164
210
  macros.saturate = wrapColor(color.strurate);
165
211
  macros.desaturate = wrapColor(color.desaturate);
166
212
  macros.lighten = wrapColor(color.lighten);
@@ -230,7 +276,7 @@ macros.each = function (list, body) {
230
276
 
231
277
  class Richcss extends Program {
232
278
  straps = ["and"];
233
- stamps = `;:`.split("");
279
+ stamps = `;:,>+~&!/`.split("");
234
280
  quotes = rarg.quotes;
235
281
  keepspace = true;
236
282
  scopes = [["{", "}"], ["(", ")"]]
@@ -245,42 +291,21 @@ Richcss.prototype.setType = function (o) {
245
291
  o.type = PROPERTY;
246
292
  return;
247
293
  }
294
+ if (p.type === PROPERTY && o.type !== STAMP && o.type !== SCOPED) {
295
+ o.type = PROPERTY;
296
+ return;
297
+ }
248
298
  }
249
299
  if (!p) return;
250
- var q = o.queue;
251
- if (o.type & (PROPERTY | EXPRESS) && p && p === q[q.length - 1] && p.type & (PROPERTY | EXPRESS)) {
252
- return false;
253
- }
254
300
  if (o.type === SCOPED && o.entry === "{") {
255
301
  if (p && p.type & (PROPERTY | EXPRESS) && /@$/.test(p.text)) {
256
302
  return false;
257
303
  }
258
- var pps = [];
259
- while (p && !(p.type === STAMP && p.text === ';' || p.type === SCOPED)) {
260
- pps.push(p);
304
+ while (p && (p.type !== SCOPED || p.entry !== "{") && (p.type !== STAMP || p.text !== ';')) {
305
+ p.isprop = true;
306
+ if (p.type !== SCOPED) p.type = PROPERTY;
261
307
  p = p.prev;
262
308
  }
263
- if (pps.length > 1) {
264
- var i = q.lastIndexOf(p = pps.pop());
265
- q.splice(i + 1, q.length);
266
- p.type = PROPERTY;
267
- p.end = pps[0].end;
268
- q.last = p;
269
- return;
270
- }
271
- }
272
- if (!q.entry && o.type !== SCOPED) {
273
- var p = q.last;
274
- if (p && p.type === STAMP && p.text === ':') {
275
- if (p.keep) return;
276
- }
277
- else if (o.type === STAMP && o.text === ':') {
278
- if (p.type & (EXPRESS | PROPERTY)) {
279
- o.keep = true;
280
- return;
281
- }
282
- }
283
- if (o.type === STAMP && o.text !== ";") return false;
284
309
  }
285
310
  };
286
311
 
@@ -309,7 +334,10 @@ Richcss.prototype.createScoped = function (code) {
309
334
  for (var cx = 0, dx = code.length; cx < dx; cx++) {
310
335
  var o = code[cx];
311
336
  if (o && (o.type & (SPACE | COMMENT) || o.type === STAMP && o.text === ';')) continue;
312
- if (o.type !== PROPERTY) throw new Error("结构异常");
337
+ if (o.type !== PROPERTY) {
338
+ console.log(createString([o]), o.type, createString(code))
339
+ throw new Error("结构异常");
340
+ }
313
341
  var p = [], v = [];
314
342
  while (o && (o.type !== SCOPED || o.entry !== "{")) {
315
343
  if (o.type === STAMP) break;
@@ -336,10 +364,9 @@ Richcss.prototype.createScoped = function (code) {
336
364
  }
337
365
  o = n;
338
366
  }
339
- else if (o) {
367
+ else if (o && o.type === SCOPED) {
340
368
  v = run(o);
341
369
  }
342
- p.autospace = false;
343
370
  var pj = createString(p).trim();
344
371
  if (!propmap[pj]) propmap[pj] = [];
345
372
  var vs = [];
@@ -377,7 +404,9 @@ var fixBase = function (b, a) {
377
404
  if (presets.test(a)) a = `@{${a}}`;
378
405
  var replaced = false;
379
406
  return b.split(/\s*,\s*/).map(b => {
380
- var a1 = a.replace(/(:scope|&)/g, function (match) {
407
+ b = b.replace(/^(&|\:scope|\:root)\s*/g, "");
408
+ if (!b) return a;
409
+ var a1 = a.replace(/&|\:scope|\:root/g, function (match) {
381
410
  replaced = true;
382
411
  return b;
383
412
  });
@@ -391,19 +420,12 @@ var fixBase = function (b, a) {
391
420
  }).join(",");
392
421
  }).join(",");
393
422
  }
394
- function evalscoped(scoped, scopeNames, base = '') {
423
+ function evalscoped(scoped, base = '') {
395
424
  var smaps = scoped.maps;
396
- var root = smaps[":root"], scope = smaps[":scope"], and = smaps["&"];
425
+ var root = smaps[":root"], scope = smaps[":scope"];
397
426
  var vars = extend(Object.create(null), scoped.vars);
398
427
  if (root) root.forEach(r => extend(vars, r.vars));
399
428
  if (scope) scope.forEach(s => extend(vars, s.vars));
400
- if (and) and.forEach(s => extend(vars, s.vars));
401
- scopeNames.forEach(s => {
402
- var ss = smaps[s];
403
- if (ss) ss.forEach(s => {
404
- extend(vars, s.vars), s.rooted = true;
405
- })
406
- });
407
429
  var vlist = [vars];
408
430
  var mlist = [macros];
409
431
  var clist = [smaps];
@@ -435,10 +457,9 @@ function evalscoped(scoped, scopeNames, base = '') {
435
457
  });
436
458
  };
437
459
  var evalproc = function (k, retnoparam) {
438
- var match = (retnoparam !== false ? /^([^\(\)\s,;:]+)(?:\s*\(([\s\S]*)\))$/ : /^([^\(\)\s,;:]+)(?:\s*\(([\s\S]*)\))?$/).exec(k);
460
+ var match = (retnoparam !== false ? /^([^\(\)\s,;:]*)(?:\s*\(([\s\S]*)\))$/ : /^([^\(\)\s,;:]+)(?:\s*\(([\s\S]*)\))?$/).exec(k);
439
461
  if (!match) return calcvars(k);
440
462
  var [, name, params] = match;
441
- params = splitParams(params);
442
463
  var method = getFromScopeList(name, mlist);
443
464
  if (!isFunction(method)) {
444
465
  if (/^@/.test(name)) return calcvars(k);
@@ -454,7 +475,8 @@ function evalscoped(scoped, scopeNames, base = '') {
454
475
  }
455
476
  else return k;
456
477
  };
457
- params = params.map(evalproc);
478
+ params = splitParams(params);
479
+ params = params.map(evalproc).map(replace_punc);
458
480
  return method.apply(null, params);
459
481
  };
460
482
 
@@ -464,7 +486,6 @@ function evalscoped(scoped, scopeNames, base = '') {
464
486
  if (!match) continue;
465
487
  if (presets.test(match[1])) continue;
466
488
  var [, name, args] = match;
467
- p.base = base;
468
489
  args = createArgMap(args);
469
490
  p.args = args;
470
491
  p.reg = new RegExp(args.join("|") + /|@\{[^\}@]+\}/.source, 'g');
@@ -475,6 +496,7 @@ function evalscoped(scoped, scopeNames, base = '') {
475
496
  });
476
497
  methods[name] = function () {
477
498
  var valueMap = Object.create(null);
499
+ this.base = p.base || base;
478
500
  vlist.push(valueMap);
479
501
  var argDefaults = this.args.defaults;
480
502
  this.args.forEach((k, i) => {
@@ -492,7 +514,7 @@ function evalscoped(scoped, scopeNames, base = '') {
492
514
  });
493
515
  var vars = this.vars;
494
516
  if (vars) Object.keys(vars).forEach(k => {
495
- valueMap[k] = replace(calcvars(vars[k]));
517
+ valueMap[k] = seprateFunc(replace(calcvars(vars[k]))).map(evalproc).join('');
496
518
  });
497
519
  var body = evalthis(this);
498
520
  var rest = body.rest.map(a => a.map(replace));
@@ -519,7 +541,7 @@ function evalscoped(scoped, scopeNames, base = '') {
519
541
  else if (p.length) {
520
542
  k = calcvars(k);
521
543
  p = calcvars(p.join(" "));
522
- p = seprateFunc(p).map(evalproc).join('');
544
+ p = replace_punc(seprateFunc(p).map(evalproc).join(''));
523
545
  result.push(k, ":", p, ';');
524
546
  }
525
547
  else {
@@ -543,21 +565,8 @@ function richcss(text, scopeName, compress) {
543
565
  if (!rcss) rcss = new Richcss;
544
566
  rcss.debug = true;
545
567
  var code = scanner2(text, rcss);
546
- var scopeNames = [];
547
- if (scopeName) code.forEach(c => {
548
- if (c.type === PROPERTY) {
549
- var replaced = false;
550
- c.text = c.text.replace(/\:(scope|root)|&/g, function () {
551
- replaced = true;
552
- return scopeName;
553
- });
554
- if (replaced) {
555
- scopeNames.push(c.text);
556
- }
557
- }
558
- })
559
568
  var { scoped } = code;
560
- var result = evalscoped(scoped, scopeNames, scopeName);
569
+ var result = evalscoped(scoped, scopeName);
561
570
  var queried = [];
562
571
  var getquried = function () {
563
572
  if (!queried.length) return "";
@@ -574,7 +583,7 @@ function richcss(text, scopeName, compress) {
574
583
  a = a.replace(/@\{(@[^\}]*)\}\s*/g, function (_, q) {
575
584
  ats.push(q);
576
585
  return ''
577
- }).replace(/~\s*(['"`])((?:\\[\s\S]|[^'"`\\])*?)\1/g, '$2');
586
+ });
578
587
  if (!a) return '';
579
588
  var atk = ats.join(';');
580
589
  if (queried.key !== atk) {
@@ -1,7 +1,7 @@
1
1
  var test = function (data, expect) {
2
2
  assert(richcss(data), expect);
3
3
  };
4
- test(`&{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
4
+ test(`&{--a:1;a{opacity:--a}}`, `a{opacity:1;}`);
5
5
  test(`:root{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
6
6
  test(`:scope{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
7
7
  test(`:scope{--b:--a;--a:1;}a{opacity:--b}`, `a{opacity:1;}`);
@@ -25,6 +25,20 @@ test(`@a:1;a{@a:2;@{a}:@a}`, `a{2:2;}`);
25
25
  test(`@a:1;@a{@a:2;@{a}:@a}`, `1{2:2;}`);
26
26
  test(`@b(@a:1){@a{a:b}}@b(2)`, `2{a:b;}`);
27
27
  test(`@a:1; a{a:@a/2}`, `a{a:0.5;}`);
28
+ test(`@a:1; a{a:(@a/2)}`, `a{a:0.5;}`);
29
+ test(`@a:1; a{a:(@a/2)+1}`, `a{a:1.5;}`);
30
+ test(`@a:1; a{a:(@a/2) + 1}`, `a{a:1.5;}`);
31
+ test(`@a:1px; a{a:(@a/2) +1px}`, `a{a:0.5px +1px;}`);
32
+ test(`@a:1px; a{a:(@a/2) -1px}`, `a{a:0.5px -1px;}`);
33
+ test(`@a:1px; a{a:(@a/2)-1px}`, `a{a:-0.5px;}`);
34
+ test(`@a:1px; a{a:1px+ (@a/2)}`, `a{a:1.5px;}`);
35
+ test(`&{a:calc(100% - 1px)}`, `&{a:calc(100% - 1px);}`);
36
+ test(`&{a:calc(~"100% - 1px")}`, `&{a:calc(100% - 1px);}`);
37
+ test(`&{a:calc(~"100vw - 1px")}`, `&{a:calc(100vw - 1px);}`);
38
+ test(`&{a:calc(~"100px - 1px")}`, `&{a:99px;}`);
39
+ test(`&{a:url(~"100px - 1px")}`, `&{a:url(100px - 1px);}`);
40
+ test(`&{a:url("100px - 1px")}`, `&{a:url("100px - 1px");}`);
41
+ test(`&{a:calc(100px - 1px)}`, `&{a:99px;}`);
28
42
  test(`.a(){b{a:2}} .a();`, `b{a:2;}`);
29
43
  test(`#a(){b{a:2}} #a();`, `b{a:2;}`);
30
44
  test(`#a{a:1}`, `#a{a:1;}`);
@@ -38,3 +52,14 @@ test(`b{a:darken(#fff,10%)}`, `b{a:#f5f5f5;}`);
38
52
  test(`b{a:darken(hsl(90, 80%, 50%), 20%)}`, `b{a:#6cd205;}`);
39
53
  test(`b{a:darken(#6cd205, 20%)}`, `b{a:#58be00;}`);
40
54
  test(`b{a:darken(#7ff,10%)}`, `b{a:#6df5f5;}`);
55
+
56
+ test(`:not(a):not(b){c:d}`, `:not(a):not(b){c:d;}`);
57
+ assert(richcss(`:not(a):not(b){c:d}`, 'abc'), `abc :not(a):not(b){c:d;}`);
58
+ assert(richcss(`&:not(a):not(b){c:d}`, 'abc'), `abc:not(a):not(b){c:d;}`);
59
+ assert(richcss(`:scope{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
60
+ assert(richcss(`:root{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
61
+ assert(richcss(`&{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
62
+ assert(richcss(`:root>a{&:not(a):not(b){c:d}}`, '.abc-'), `.abc->a:not(a):not(b){c:d;}`);
63
+ assert(richcss(`a>:root{&:not(a):not(b){c:d}}`, '.abc-'), `a>.abc-:not(a):not(b){c:d;}`);
64
+
65
+ assert(richcss(`.a (){ &:after{abc:1}} .b{.a();}`, '.abc-'), `.abc- .b:after{abc:1;}`);
@@ -167,11 +167,13 @@
167
167
  }
168
168
  var typescript = new compile$Javascript;
169
169
  typescript.straps = typescript.straps.concat("interface", "implements", "declare", "module", "readonly", "enum");
170
+ var js = new compile$Javascript;
171
+ js.keepspace = true;
170
172
  var codesupports = {
171
173
  javascript(a, blink) {
172
174
  if (blink) var index = a.indexOf(blink);
173
175
  if (index >= 0) a = a.slice(0, index) + a.slice(index + 1);
174
- var c = compile$scanner2(a);
176
+ var c = compile$scanner2(a, js);
175
177
  if (index >= 0) {
176
178
  var patched = patchBlink(c, index, blink);
177
179
  }
@@ -1,6 +1,7 @@
1
- *{
1
+ * {
2
2
  box-sizing: border-box;
3
3
  }
4
+
4
5
  & {
5
6
  background: #fff;
6
7
  display: inline-block;
@@ -8,9 +9,10 @@
8
9
  font-size: 16px;
9
10
  position: relative;
10
11
  min-height: 100px;
11
- padding: 0 6px 10px 16px;
12
+ padding: 0 4px 10px 16px;
12
13
  font-family: 宋体;
13
- width: 438px;
14
+ width: 440px;
15
+ border: 1.2px solid #000;
14
16
 
15
17
  >a {
16
18
  display: inline-block;
@@ -40,10 +42,11 @@
40
42
  word-spacing: 2px;
41
43
  font-size: inherit;
42
44
  line-height: 30px;
43
- margin: 0 -6px 10px -16px;
45
+ margin: 0 -4px 10px -16px;
44
46
  padding: 0 16px 0 16px;
45
47
  position: sticky;
46
48
  top: 0;
49
+ text-transform: uppercase;
47
50
  background: #333;
48
51
  content: "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f";
49
52
  display: block;
@@ -12,12 +12,12 @@ function main() {
12
12
  var page = div();
13
13
  page.innerHTML = template;
14
14
  var data = random([{
15
- name: '一级目录',
15
+ name: '${inc} 一级目录',
16
16
  children: [{
17
- name: "二级目录",
17
+ name: "${inc} 二级目录",
18
18
  children: [
19
19
  {
20
- name: "三级目录"
20
+ name: "${inc} 三级目录"
21
21
  }
22
22
  ]
23
23
  }]
@@ -2,5 +2,5 @@ ylist{
2
2
  height: 100%!important;
3
3
  }
4
4
  &{
5
- height: 100%;
5
+ height: 300px;
6
6
  }
@@ -13,7 +13,7 @@ function singleSource(_, type) {
13
13
 
14
14
  }
15
15
  }
16
- function random(source, decimal) {
16
+ function random(source, decimal, ...deeprand) {
17
17
  if (!source) {
18
18
  if (arguments.length > 1) {
19
19
  return random(arguments[Math.random() * arguments.length | 0]);
@@ -45,8 +45,10 @@ function random(source, decimal) {
45
45
  return random(source[Math.random() * source.length | 0]);
46
46
  } else {
47
47
  var dst = [];
48
- for (var cx = 0, dx = decimal > 1 ? decimal : Math.random() * 10 + 50; cx < dx; cx++) {
49
- dst.push(random(source[source.length * Math.random() | 0]))
48
+ for (var cx = 0, dx = decimal > 0 ? decimal | 0 : Math.random() * 10 | 1; cx < dx; cx++) {
49
+ var arg = deeprand;
50
+ if (!arg.length) arg = [[0, Math.random() * 2 | 0, Math.random() * 5 | 0, Math.random() * 10 | 0, Math.random() * 20 | 0, Math.random() * 50 | 0, Math.random() * 100 | 0][Math.random() * 7 | 0]];
51
+ dst.push(random(source[source.length * Math.random() | 0], ...arg))
50
52
  }
51
53
  return dst;
52
54
  }
@@ -58,7 +60,7 @@ function random(source, decimal) {
58
60
  var dst = {};
59
61
  for (var k in source) {
60
62
  var v = source[k];
61
- dst[k] = v[0] instanceof Object ? random(v, 1) : random(v, 0);
63
+ dst[k] = v[0] instanceof Object ? random(v, decimal) : random(v, 0);
62
64
  }
63
65
  return dst;
64
66
  }
@@ -214,7 +214,7 @@
214
214
  }
215
215
  }
216
216
  else {
217
- if (code.isExpressQueue()) codetext = "return " + codetext;
217
+ if (code.isExpressQueue()) codetext = "return " + codetext.trim();
218
218
  else if (vars.main) codetext += '\r\nreturn main';
219
219
  else if (vars.Main) codetext += '\r\nreturn Main';
220
220
  else if (vars.MAIN) codetext += "\r\nreturn MAIN";
@@ -365,7 +365,7 @@
365
365
  var code = compile$scanner2(codetext);
366
366
  var envs = code.envs;
367
367
  var argNames = Object.keys(envs);
368
- var args = await Promise.all(argNames.map(a => init(a + "*" + live, null, { ["init*" + live]: init, ["put*" + live]: put, ["zimoli*" + live]: zimoli, ["appendChild*" + live]: appendChild, ["remove*" + live]: remove })));
368
+ var args = await Promise.all(argNames.map(a => init(a + "*" + live, null, { ["init*" + live]: init, ["put*" + live]: put, ["zimoli*" + live]: zimoli, ["appendChild*" + live]: appendChild, ["remove*" + live]: remove, ["render*" + live]: render })));
369
369
  var func = createFunction("", codetext, argNames, code.async, code.yield);
370
370
  var res = func.apply(window, args);
371
371
  if (isFunction(res)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.0.57",
3
+ "version": "4.0.58",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {
@@ -10,7 +10,7 @@
10
10
  "efront": "public/efront.js"
11
11
  },
12
12
  "scripts": {
13
- "prepack": "node tools/build-efront.js --uplevel --node --deno",
13
+ "prepack": "node tools/build-efront.js --uplevel --node --deno --no-target",
14
14
  "start": "efront ./efront/ --libs=typescript,esprima,escodegen,esmangle,pngjs,less-node"
15
15
  },
16
16
  "repository": {