efront 4.0.54 → 4.0.56

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.
@@ -1,15 +1,40 @@
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;}`);
5
+ test(`:root{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
4
6
  test(`:scope{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
5
7
  test(`:scope{--b:--a;--a:1;}a{opacity:--b}`, `a{opacity:1;}`);
6
8
  test(`@a(@p,@b){@p{opacity:@b}}@a(a,1);`, `a{opacity:1;}`);
7
9
  test(`@a(a,1);@a(@p,@b){@p{opacity:@b}}`, `a{opacity:1;}`);
8
- test(`a{ b{a:1}}`,`a b{a:1;}`);
9
- test(`a{ >b{a:1}}`,`a>b{a:1;}`);
10
- test(`a{ &>b{a:1}}`,`a>b{a:1;}`);
11
- test(`a{ &b{a:1}}`,`ab{a:1;}`);
12
- test(`a{ &.b{a:1}}`,`a.b{a:1;}`);
13
- test(`a{ &[b]{a:1}}`,`a[b]{a:1;}`);
14
- test(`a{ &[b]:nth-child(1){a:1}}`,`a[b]:nth-child(1){a:1;}`);
15
- test(`a,b{c{a:1}}`,`a c,b c{a:1;}`);
10
+ test(`a{ b{a:1}}`, `a b{a:1;}`);
11
+ test(`a{ >b{a:1}}`, `a>b{a:1;}`);
12
+ test(`a{ &>b{a:1}}`, `a>b{a:1;}`);
13
+ test(`a{ &b{a:1}}`, `ab{a:1;}`);
14
+ test(`a{ &.b{a:1}}`, `a.b{a:1;}`);
15
+ test(`a{ &[b]{a:1}}`, `a[b]{a:1;}`);
16
+ test(`a{ &[b]:nth-child(1){a:1}}`, `a[b]:nth-child(1){a:1;}`);
17
+ test(`a,b{c{a:1}}`, `a c,b c{a:1;}`);
18
+ test(`@media(){div{a:1}}`, `@media(){div{a:1;}}`);
19
+ test(`@keyframes a{%1{a:1}}`, `@keyframes a{%1{a:1;}}`);
20
+ test(`@media screen and (max-width: 200px){@keyframes a{%1{a:1}}}`, `@media screen and (max-width: 200px){@keyframes a{%1{a:1;}}}`);
21
+ test(`@a:1`, ``);
22
+ test(`@a:1;a{a:@a}`, `a{a:1;}`);
23
+ test(`@a:1;a{@{a}:@a}`, `a{1:1;}`);
24
+ test(`@a:1;a{@a:2;@{a}:@a}`, `a{2:2;}`);
25
+ test(`@a:1;@a{@a:2;@{a}:@a}`, `1{2:2;}`);
26
+ test(`@b(@a:1){@a{a:b}}@b(2)`, `2{a:b;}`);
27
+ test(`@a:1; a{a:@a/2}`, `a{a:0.5;}`);
28
+ test(`.a(){b{a:2}} .a();`, `b{a:2;}`);
29
+ test(`#a(){b{a:2}} #a();`, `b{a:2;}`);
30
+ test(`#a{a:1}`, `#a{a:1;}`);
31
+ test(`#a{}`, ``);
32
+ test(`@a{}`, ``);
33
+ test(`.a{}`, ``);
34
+ test(`a{}`, ``);
35
+ test(`@a: 1,2;each(@a,(){b{a:@value}})`, `b{a:1;}\r\nb{a:2;}`);
36
+ test(`@a(){a:A;b:B} each(@a(),(@v,@k,@i){@{key}@{i}{@{v}:@i}})`, `a1{A:1;}\r\nb2{B:2;}`);
37
+ test(`b{a:darken(#fff,10%)}`, `b{a:#f5f5f5;}`);
38
+ test(`b{a:darken(hsl(90, 80%, 50%), 20%)}`, `b{a:#6cd205;}`);
39
+ test(`b{a:darken(#6cd205, 20%)}`, `b{a:#58be00;}`);
40
+ test(`b{a:darken(#7ff,10%)}`, `b{a:#6df5f5;}`);
@@ -208,6 +208,7 @@ function scan(text, type = "js", lastIndex = 0) {
208
208
  program.Code = Code;
209
209
  program.lastIndex = lastIndex;
210
210
  var res = program.exec(text);
211
+ res.autospace = !program.keepspace;
211
212
  Object.defineProperty(res, "program", { value: program, enumerable: false })
212
213
  return res;
213
214
  }
@@ -148,7 +148,7 @@
148
148
  o.text = keys.map(k => /^\</.test(k) || !k ? k : `<express>${k}</express>`).join(".");
149
149
  break;
150
150
  case STRAP:
151
- if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|await|yield|return)$/.test(text))
151
+ if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|throw|await|yield|return)$/.test(text))
152
152
  o.text = `<flow>${o.text}</flow>`;
153
153
  else o.text = `<strap>${o.text}</strap>`;
154
154
  break;
@@ -20,24 +20,28 @@ var h = function (text) {
20
20
  var p = function (text) {
21
21
  if (text.length) return new Element("p", text);
22
22
  };
23
+ var p2 = function (text) {
24
+ if (text.length) return new Element('div', text);
25
+ }
23
26
  var li = function (c) {
24
27
  var li = new Element(li, c.replace(/^\*\s+|^[\d]+\.\s+/, ''));
25
28
  return li;
26
29
  }
27
30
  var list_elem = null, list_tag;
28
- var list = function (tag, text, li = 'li') {
31
+ var list = function (tag, text, indent, li = 'li') {
29
32
  if (!list_elem || list_tag !== tag || list_elem !== content[content.length - 1]) {
30
33
  list_elem = new Element(tag);
34
+ list_elem.indent = indent;
31
35
  list_tag = tag;
32
36
  content.push(list_elem);
33
37
  }
34
38
  list_elem.appendChild(new Element(li, text.replace(/^\*\s+|^\d+\.\s+/, '')));
35
39
  };
36
- var ul = function (content) {
37
- return list('ul', content);
40
+ var ul = function (content, indent) {
41
+ return list('ul', content, indent);
38
42
  };
39
- var ol = function (content) {
40
- return list('ol', content);
43
+ var ol = function (content, indent) {
44
+ return list('ol', content, indent);
41
45
  };
42
46
  var tr = function (line) {
43
47
  if (/^[\|\-\s]+$/.test(line)) {
@@ -64,22 +68,31 @@ var tr = function (line) {
64
68
  return;
65
69
  }
66
70
  line = line.replace(/^\||\|$/g, '').split("|").map(t => `<td>${t}</td>`).join('');
67
- return list('table', line, 'tr');
71
+ return list('table', line, NaN, 'tr');
68
72
  }
69
73
  function richtext(line) {
70
- line = line.trim();
74
+ var tagIndent = /^\s+/.exec(line);
75
+ if (!tagIndent) tagIndent = 0;
76
+ else tagIndent = tagIndent[0].length;
77
+ line = line.slice(tagIndent);
71
78
  line = line.replace(/\[([\s\S]*?)\](?:\(([\s\S]*?)\))?|<(\w+)>[\s\S]*?<\/\3>/g, function (_, content, href) {
72
79
  if (/^\</.test(_)) return _;
73
80
  if (href) var href1 = ` href=${strings.recode(href)}`;
74
81
  return `<a${href1}>${content || href}</a>`;
75
82
  });
76
83
  var a;
77
- if (/^#/.test(line)) a = h(line);
78
- else if (/^\*\s+/.test(line)) ul(line);
79
- else if (/^\d+\.\s+/.test(line)) ol(line);
84
+ if (/^#/.test(line)) content.push(h(line));
85
+ else if (/^\*\s+/.test(line)) ul(line, tagIndent);
86
+ else if (/^\d+\.\s+/.test(line)) ol(line, tagIndent);
80
87
  else if (/^\|/.test(line)) tr(line);
81
- else a = p(line);
82
- if (a) content.push(a);
88
+ else {
89
+ if (list_elem && list_elem === content[content.length - 1] && list_elem.indent <= tagIndent) {
90
+ list_elem.appendChild(p(line));
91
+ }
92
+ else {
93
+ content.push(p2(line));
94
+ }
95
+ }
83
96
  }
84
97
  /**
85
98
  * @type {Element}
@@ -87,7 +100,7 @@ function richtext(line) {
87
100
  var content;
88
101
  function markdown(text) {
89
102
  var c = content = [];
90
- text.replace(/ *(`+|\*+)(\S[\s\S]*?)\1 */g, function (_, q, c, i) {
103
+ text.replace(/([ \t\v]*)(`+|\*+)(\S[\s\S]*?)\2([ \t\v]*)/g, function (_, s1, q, c, s2, i) {
91
104
  if (/^\*/.test(q)) {
92
105
  var m = q.length;
93
106
  if (m & 1) c = `<i>${c}</i>`;
@@ -96,11 +109,11 @@ function markdown(text) {
96
109
  }
97
110
  _ = codetext.encode(_.trim()).slice(1, -1);
98
111
  if (/[\*#\.]\s/.test(text.slice(i - 1, i + 1))) _ = " " + _;
99
- if (q.length === 1) return `<m>${_}</m>`;
112
+ if (q.length === 1) return `${s1}<m>${_}</m>${s2}`;
100
113
  var t = /^\S+/.exec(c);
101
114
  if (t) t = t[0]; c = c.slice(t.length).replace(/^(\r\n|\r|\n)|\s+$/g, '');
102
115
  try {
103
- return codetext(t, c);
116
+ return s1 + codetext(t, c) + s2;
104
117
  } catch (e) {
105
118
  console.error(e);
106
119
  return c;
@@ -1,6 +1,10 @@
1
1
  & {
2
2
  white-space: nowrap;
3
3
  overflow: auto;
4
+ background: #421;
5
+ border-top: 10px solid #000;
6
+ padding: 20px 40px 60px 40px;
7
+ // perspective: 3000px; 多嵌套一层,不起作用
4
8
  }
5
9
 
6
10
  &>div {
@@ -11,7 +15,11 @@
11
15
  z-index: 2;
12
16
  width: 60px;
13
17
  text-align: center;
14
- color: green;
18
+ text-transform: uppercase;
19
+ font-family: 'Times New Roman', Times, serif;
20
+ font-style: italic;
21
+ font-weight: 900;
22
+ color: #999;
15
23
 
16
24
  &:before {
17
25
  content: "c";
@@ -26,6 +34,32 @@
26
34
 
27
35
  button {
28
36
  pointer-events: all;
37
+ transform-style: preserve-3d;
38
+
39
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
40
+ position: relative;
41
+
42
+ &.hover {
43
+ >.track {
44
+ box-shadow: none;
45
+ background: #fff1;
46
+ }
47
+
48
+ box-shadow: 0 0 12px -4px #0003;
49
+ }
50
+
51
+ &.active {
52
+ z-index: 0;
53
+
54
+ >.track {
55
+ background: #0003;
56
+ background: linear-gradient(0deg, #0003, #0000);
57
+ }
58
+
59
+ transform-origin: 30px -270px -10px;
60
+ transform:rotateX(-7deg);
61
+ }
62
+
29
63
  }
30
64
 
31
65
  &.odd {
@@ -34,10 +68,9 @@
34
68
  margin: 0 2px;
35
69
  width: 56px;
36
70
  background: #fff;
37
- color: #333;
71
+ color: #aaa;
38
72
  height: 280px;
39
73
  padding: 80px 0 0 0;
40
-
41
74
  box-shadow: 0 0 20px -6px rgba(0, 0, 0, .3);
42
75
 
43
76
  span {
@@ -52,7 +85,7 @@
52
85
 
53
86
  button {
54
87
  width: 40px;
55
- margin: 0 10px;
88
+ margin: 10px 10px;
56
89
  box-shadow: 0 0 20px -6px rgba(0, 0, 0, .3);
57
90
 
58
91
  &:nth-child(1) {
@@ -68,7 +101,7 @@
68
101
  color: #fff;
69
102
  height: 120px;
70
103
 
71
- &:nth-child(7n+2) {
104
+ &:nth-child(2) {
72
105
  margin-right: 70px;
73
106
  }
74
107
  }
@@ -8,9 +8,9 @@
8
8
  font-size: 16px;
9
9
  position: relative;
10
10
  min-height: 100px;
11
- padding: 0 0 10px 16px;
11
+ padding: 0 6px 10px 16px;
12
12
  font-family: 宋体;
13
- width: 422px;
13
+ width: 438px;
14
14
 
15
15
  >a {
16
16
  display: inline-block;
@@ -40,7 +40,7 @@
40
40
  word-spacing: 2px;
41
41
  font-size: inherit;
42
42
  line-height: 30px;
43
- margin: 0 0 10px -16px;
43
+ margin: 0 -6px 10px -16px;
44
44
  padding: 0 16px 0 16px;
45
45
  position: sticky;
46
46
  top: 0;
@@ -340,6 +340,17 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
340
340
  offdragend();
341
341
  };
342
342
  var offdragstart = on('dragstart')(targetChild, function () {
343
+ var c = drag.shadow;
344
+ var zIndex = c.style.zIndex - 1;
345
+ var copyZIndex = function (e) {
346
+ e.style.zIndex = zIndex;
347
+ var z = zIndex - 1;
348
+ if (e.with) for (var w of e.with) w.style.zIndex = z;
349
+ };
350
+ if (zIndex > 2) {
351
+ previousElements.forEach(copyZIndex);
352
+ followedElements.forEach(copyZIndex);
353
+ }
343
354
  setOpacity(targetBox, draggingSourceOpacity);
344
355
  });
345
356
  var offdragend = on("dragend")(targetChild, function () {
@@ -350,6 +361,8 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
350
361
  remove(followedElements);
351
362
  previousElements.map(recover);
352
363
  followedElements.map(recover);
364
+ previousElements.splice(0, previousElements.length);
365
+ followedElements.splice(0, followedElements.length);
353
366
  });
354
367
  var offdragmove = on("dragmove")(targetChild, dragmove);
355
368
  }
@@ -1,4 +1,4 @@
1
- var cloneProperties = "fontWeight,fontSize,fontFamily,color,textShadow,opacity,writingMode,blockSize,wordSpacing,letterSpacing,whiteSpace,lineHeight".split(",");// text-node
1
+ var cloneProperties = "fontWeight,fontSize,fontFamily,color,textShadow,opacity,writingMode,blockSize,wordSpacing,letterSpacing,whiteSpace".split(",");// text-node
2
2
  var cloneProperties2 = "position,backdropFilter,filter,float,clear,margin,color,verticalAlign,textAlign,textShadow,opacity,boxShadow,overflow,textOverflow,wordBreak,webkitLineClamp,webkitBoxOrient,writingMode,blockSize,wordSpacing,letterSpacing,textIndent,lineHeight,display,appearance,webkitAppearance,MozAppearance".split(",");// element
3
3
  var pushProperty = function (key, props) {
4
4
  props.split(",").forEach(k => {
@@ -76,6 +76,7 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
76
76
  extraTargets = [];
77
77
  if (target.style) css(target, { zIndex: z });
78
78
  }
79
+ drag.shadow = clone;
79
80
  var [clone_left, clone_top] = getOffset(clone);
80
81
  extraClones = extraTargets.map(toCloneTarget);
81
82
  extraClones.forEach(addZIndex);
@@ -1,5 +1,5 @@
1
1
  & {
2
- height: 100%;
2
+ height: 300px;
3
3
  }
4
4
 
5
5
  &>gallery {
@@ -23,20 +23,22 @@ var getGenerator = function (container, tagName = 'item') {
23
23
  if (container.$generator) return container.$generator;
24
24
  var template = document.createElement(container.tagName);
25
25
  var templates = [];
26
+ var hasAfter = false;
26
27
  for (let a of container.childNodes) {
27
28
  if (a.nodeType === 1 && a.hasAttribute('insert')) {
28
29
  if (!templates.length) a.$isbefore = true;
29
- else a.$isafter = true;
30
+ else { a.$isafter = true; hasAfter = true; }
30
31
  }
31
- else {
32
+ else if (hasAfter);
33
+ else if (a.nodeType === 1 || templates.length) {
32
34
  templates.push(a);
33
35
  }
34
36
  }
37
+ while (templates.length > 1 && templates[templates.length - 1].nodeType !== 1) templates.pop();
35
38
  if (templates.length < container.childNodes.length && templates.length >= 1) {
36
- var c = document.createComment('lattice');
39
+ var c = document.createComment('generator');
37
40
  c.index = null;
38
41
  container.insertBefore(c, templates[0]);
39
- templates.splice(1, templates.length - 1);
40
42
  var paddingCount = [].indexOf.call(container.childNodes, c);
41
43
  container.paddingCount = paddingCount;
42
44
  }
@@ -4,6 +4,7 @@
4
4
  }
5
5
 
6
6
  >lattice {
7
+ max-height: 300px;
7
8
  height: 100%;
8
9
  @mask-color: rgba(0, 0, 0, .4);
9
10
  // background: linear-gradient(45deg, @mask-color, 25%, @mask-color, 25%, rgba(0, 0, 0, 0), 75%, rgba(0, 0, 0, 0), 75%, @mask-color), linear-gradient(135deg, @mask-color, 25%, @mask-color, 25%, rgba(0, 0, 0, 0), 75%, rgba(0, 0, 0, 0), 75%, @mask-color);
@@ -169,9 +169,9 @@ function ylist(container, generator, $Y) {
169
169
  delete childrenMap[offset];
170
170
  }
171
171
  if (last_index > offset) {
172
- if (item.nextElementSibling !== last_item) list.insertBefore(item, last_item);
172
+ if (item.nextElementSibling !== last_item) insertBeforeList(item, last_item);
173
173
  } else {
174
- if (item.previousElementSibling !== item) list.insertBefore(item, getNextSibling(last_item));
174
+ if (item.previousElementSibling !== item) insertBeforeList(item, getNextSibling(last_item));
175
175
  }
176
176
  last_index = offset;
177
177
  item = getNodeTarget(item);
@@ -229,6 +229,17 @@ function ylist(container, generator, $Y) {
229
229
  } while (next.offsetTop === element.offsetTop);
230
230
  return next.offsetTop - element.offsetTop;
231
231
  };
232
+ var insertBeforeList = function (elem, flag) {
233
+ if(flag){
234
+ var w = elem.with;
235
+ if (w) {
236
+ if (w[w.length - 1].nextSibling === flag) return;
237
+ }
238
+ else if (elem.nextSibling === flag) return;
239
+ }
240
+ list.insertBefore(elem, flag);
241
+ if (elem.with) for (var w of elem.with) list.insertBefore(w, flag);
242
+ };
232
243
  var patchBottom = function (deltaY = 0) {
233
244
  var cache_height = list.offsetHeight;
234
245
  var childrenMap = getChildrenMap();
@@ -250,7 +261,7 @@ function ylist(container, generator, $Y) {
250
261
  } else if (!restHeight) {
251
262
  restHeight = cache_height;
252
263
  }
253
- list.insertBefore(item, getNextSibling(last_element));
264
+ insertBeforeList(item, getNextSibling(last_element));
254
265
  }
255
266
  item = getNodeTarget(item);
256
267
  if (!item.offsetHeight) {
@@ -315,7 +326,7 @@ function ylist(container, generator, $Y) {
315
326
  if (!item) {
316
327
  item = createItem(offset);
317
328
  if (!item) break;
318
- list.insertBefore(item, first_element);
329
+ insertBeforeList(item, first_element);
319
330
  item = getNodeTarget(item);
320
331
  scrollTop += flag_element.offsetTop - offsetTop;
321
332
  offsetTop = flag_element.offsetTop;
@@ -648,6 +659,7 @@ function list() {
648
659
  list.clean = function (src, old) {
649
660
  var children = (container || list).childNodes;
650
661
  children = Array.prototype.filter.call(children, c => {
662
+ if (c.index === null) return false;
651
663
  if (isFinite(c.index)) return true;
652
664
  if (c.nodeType === 1 && c.$comment && isFinite(c.$comment.index)) return true;
653
665
  return false;
@@ -7,9 +7,14 @@
7
7
  background-position: 0 0, @background-size/2 @background-size/2;
8
8
  height: 200px;
9
9
  }
10
-
10
+ menu{
11
+ left: 0;
12
+ width: 100%;
13
+ appearance: none;
14
+ display: block;
15
+ }
11
16
  canvas {
12
17
  width: 100%;
13
- height: 100%;
18
+ height: 300px;
14
19
  background-color: #035;
15
20
  }
@@ -4,10 +4,9 @@
4
4
 
5
5
  & {
6
6
  max-height: 500px;
7
- position : fixed;
7
+ position : relative;
8
8
  width : 360px;
9
9
  height : 100%;
10
- padding : 50px 0 0 0;
11
10
  }
12
11
 
13
12
  .device {
package/docs/main.xht CHANGED
@@ -42,7 +42,7 @@
42
42
  content: "样";
43
43
  }
44
44
 
45
- menu {
45
+ :root>menu {
46
46
  margin: 0;
47
47
  width: var(--leftwidth);
48
48
  margin-left: -var(--leftwidth);
package/docs/mark.xht CHANGED
@@ -2,8 +2,52 @@
2
2
  :scope {
3
3
  line-height: 1.8;
4
4
  display: block;
5
- padding: 0 20px;
6
5
  font-family: Times, "宋体", sans-serif;
6
+
7
+ @media screen and (max-width:830px) {
8
+ padding: 20px 40px;
9
+ }
10
+
11
+ @media screen and (min-width:1160px) {
12
+ margin: 20px auto;
13
+ }
14
+
15
+ @media screen and (min-width:830px) {
16
+ max-width: 890px;
17
+ border: 1px solid #000;
18
+ padding: 60px 80px;
19
+ box-shadow: 0 0 20px -6px #0006;
20
+ }
21
+ }
22
+
23
+ code {
24
+ width: 100%;
25
+ }
26
+
27
+ table {
28
+ margin-top: 12px;
29
+ }
30
+
31
+ thead {
32
+ font-weight: 900;
33
+ text-align: center;
34
+
35
+ td {
36
+ border-bottom: 1px solid #000;
37
+ }
38
+ }
39
+
40
+ ol,
41
+ ul {
42
+ padding-left: 20px;
43
+ }
44
+
45
+ h1,
46
+ h2,
47
+ h3,
48
+ h4,
49
+ h5 {
50
+ border-bottom: 1px solid #000;
7
51
  }
8
52
 
9
53
  [type="xml"] stamp,
@@ -54,7 +98,6 @@
54
98
  border-collapse: collapse;
55
99
  border: 1.2px solid #0007;
56
100
  }
57
-
58
101
  </style>
59
102
  <script>
60
103
  var history = [];
@@ -225,7 +225,7 @@
225
225
  if (envs[templateName]) {
226
226
  delete envs[templateName];
227
227
  var template = await cross("get", './components:' + modName + ".html");
228
- codetext = `var ${templateName}={toString(){return \`${template.responseText}\`}};\r\n` + codetext;
228
+ codetext = `var ${templateName}={toString(){return \`${template.responseText.replace(/>\s+</g, '><')}\`}};\r\n` + codetext;
229
229
  }
230
230
  initcode(codetext);
231
231
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.0.54",
3
+ "version": "4.0.56",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {