efront 4.30.3 → 4.31.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.
@@ -81,7 +81,9 @@ var fixElement = function (o) {
81
81
  }
82
82
  ps = ps.slice(cx);
83
83
  if (!ps.length);
84
- else if (ps.length === 1) push(ps[0]);
84
+ else if (ps.length === 1) {
85
+ push(ps[0]);
86
+ }
85
87
  else {
86
88
  ps.type = QUOTED;
87
89
  ps.entry = '"';
@@ -91,9 +93,22 @@ var fixElement = function (o) {
91
93
  })
92
94
  }
93
95
  else {
96
+ if (a.type === QUOTED) {
97
+ if (a.length === 1 && a[0].type === PIECE) {
98
+ a = new Node({
99
+ type: QUOTED,
100
+ start: a.start,
101
+ end: a.end,
102
+ col: a.col,
103
+ row: a.row,
104
+ text: createString([a]),
105
+ });
106
+ }
107
+ }
94
108
  push(a);
95
109
  }
96
110
  });
111
+ relink(attributes);
97
112
  o.attributes = attributes;
98
113
  }
99
114
 
@@ -115,10 +130,10 @@ var replaceISO8859 = function (data) {
115
130
  return String(data).replace(/<\!--([\s\S]*)--\>$/g, '$1').replace(/&\w+;/g, a => iso8859[a] || a).replace(/&#(\d+);/g, (_, a) => String.fromCodePoint(a))
116
131
  };
117
132
  var parseExpress = function (data, mayberepeat) {
118
- data = "=" + replaceISO8859(data);
119
133
  if (mayberepeat && /\s+(in|of)\s+/.test(data)) {
120
- data = data.split(/\s+(in|of)\s+/).pop();
134
+ data = `for(var ${data});`;
121
135
  }
136
+ else data = "=" + replaceISO8859(data);
122
137
  p.lastIndex = 0;
123
138
  return p.exec(data);
124
139
  };
@@ -127,11 +142,12 @@ var toCamelCase = function (a) {
127
142
  return a.replace(/\-([\s\S])/g, (_, a) => a.toUpperCase());
128
143
  }
129
144
 
130
- class Node { }
145
+ var isDynamic = a => /^(on|@|\-|_|\.|#|\:|\+|\*|\?|&|\$|\S+\-)|(@|\-|_|\.|#|\:|\+|\*|\?|&|\$)$/i.test(a);
131
146
 
132
147
  Html.prototype.createScoped = function (code) {
133
148
  var used = Object.create(null);
134
149
  var vars = Object.create(null);
150
+ var rootvars = vars;
135
151
  var scriptNodes = [], styleNodes = [], tempNodes = [];
136
152
  var inScript = false;
137
153
  var noTag = true;
@@ -144,11 +160,13 @@ Html.prototype.createScoped = function (code) {
144
160
  if (!/^(script|style)$/i.test(c.tagName)) {
145
161
  fixElement(c);
146
162
  noTag = false;
163
+ var _vars = vars;
164
+ vars = Object.create(_vars);
147
165
  if (c.attributes) c.attributes.forEach(run);
148
166
  noTag = true;
149
167
  if (!used[v]) used[v] = [];
150
- used[v].push(c);
151
168
  c.forEach(run);
169
+ vars = _vars;
152
170
  }
153
171
  else {
154
172
  if (c.tagName === 'SCRIPT') {
@@ -171,18 +189,18 @@ Html.prototype.createScoped = function (code) {
171
189
  var nn = c.next.next;
172
190
  if (!nn || nn.length > 0) return;
173
191
  if (nn.type === EXPRESS || nn.type === QUOTED) {
174
- vars[strings.decode(createString([nn]))] = true;
192
+ rootvars[strings.decode(createString([nn]))] = true;
175
193
  }
176
194
  }
177
195
  }
178
196
  else {
179
197
  if (/^\#/.test(c.text)) {
180
198
  var id = c.text.slice(1);
181
- vars[toCamelCase(id)] = true;
199
+ rootvars[toCamelCase(id)] = true;
182
200
  }
183
201
  else if (/\#$/.test(c.text)) {
184
202
  var id = c.text.slice(0, c.text.length - 1);
185
- vars[toCamelCase(id)] = true;
203
+ rootvars[toCamelCase(id)] = true;
186
204
  }
187
205
  }
188
206
  break;
@@ -195,22 +213,33 @@ Html.prototype.createScoped = function (code) {
195
213
  }
196
214
  if (noTag || !c.text) break;
197
215
  var t = strings.decode(c.text);
198
- var p = t.prev;
216
+ var p = c.prev;
199
217
  var pp = p && p.prev;
200
- var mayberepeat = p && pp && p.type === STAMP && p.text === "=" && /\-(src|repeat|for|each|foreach)$/i.test(pp.text)
201
- t = parseExpress(t, mayberepeat);
202
- var envs = createScoped(t).envs;
203
- for (var k in envs) {
204
- if (!used[k]) used[k] = [];
218
+ if (pp && isDynamic(pp.text)) {
219
+ var mayberepeat = p && pp && p.type === STAMP && p.text === "=" && /[\:\-\_@\&\*\?\#\+\.\$](src|repeat|for|each|foreach)$/i.test(pp.text)
220
+ t = parseExpress(t, mayberepeat);
221
+ var s = createScoped(t);
222
+ var envs = s.envs;
223
+ for (var k in s.vars) vars[k] = true;
224
+ for (var k in envs) {
225
+ if (!vars[k]) {
226
+ if (!used[k]) used[k] = [];
227
+ used[k].push(...s.used[k]);
228
+ }
229
+ }
205
230
  }
206
231
  break;
207
232
  case EXPRESS:
208
233
  if (inScript || noTag) break;
209
234
  var t = c.text;
210
235
  t = parseExpress(t);
211
- var envs = createScoped(t).envs;
236
+ var s = createScoped(t);
237
+ var envs = s.envs;
212
238
  for (var k in envs) {
213
- if (!used[k]) used[k] = [];
239
+ if (!vars[k]) {
240
+ if (!used[k]) used[k] = [];
241
+ used[k].push(...s.used[k]);
242
+ }
214
243
  }
215
244
  break;
216
245
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  var strings = require("../basic/strings");
3
3
  var Program = require("./Program");
4
+ var Node = require("./Node");
4
5
  var backEach = require("../basic/backEach");
5
6
  var parseNumber = require('../basic/parseNumber');
6
7
  var removeFromList = require("../basic/removeFromList");
@@ -359,7 +360,7 @@ var scan = function (data) {
359
360
  return js.exec(data);
360
361
  };
361
362
  var detourTemplate = function (raw, params) {
362
- var spliter = { text: ",", type: STAMP };
363
+ var spliter = new Node({ text: ",", type: STAMP });
363
364
  var template = scan(`&extend([],{["raw"]:[]})`);
364
365
  rootenvs["&extend"] = true;
365
366
  var str0 = template[1].first;
@@ -692,7 +693,7 @@ var removeImport = function (c, i, code) {
692
693
  delete vars[dn];
693
694
  });
694
695
  });
695
- var u = { type: EXPRESS, text: name };
696
+ var u = new Node({ type: EXPRESS, text: name });
696
697
  _splice_keepspace(code, i + 1, oi - i - 1, u);
697
698
  used[name].push(u);
698
699
  return u;
@@ -0,0 +1,59 @@
1
+ var defineProperty = Object.defineProperty;
2
+ var typemap = require('./const.mjs');
3
+ var types = Object.create(null);
4
+ Object.keys(typemap).map(k => {
5
+ var v = typemap[k];
6
+ types[v] = k;
7
+ })
8
+ function Node(o) {
9
+ var t = this instanceof Node ? this : o;
10
+ if (debug && t instanceof Array) array_props.forEach(def, t);
11
+ if (t === o) o = arguments[1];
12
+ if (debug && o) {
13
+ node_props.forEach(k => {
14
+ t[k] = o[k];
15
+ });
16
+ t[types[o.type]] = o.text;
17
+ }
18
+ else Object.assign(t, o);
19
+ return t;
20
+ }
21
+ var node_props = [
22
+ "next", "prev", "queue", "type", "text",
23
+ "istype", 'isend', "isdigit",
24
+ "tack", "refs", "maped", 'called',
25
+ "col", "row", "start", "end", "isExpress"
26
+ ];
27
+ var array_props = [
28
+ "next", "prev", "queue",
29
+ "col", "row", "start", "end",
30
+ "isExpress", "inExpress",
31
+ "type", "inTag",
32
+ "last", "first",
33
+ ];
34
+ var debug = false;
35
+ defineProperty(Node, 'debug', {
36
+ get() {
37
+ return debug;
38
+ },
39
+ set(v) {
40
+ debug = !!v;
41
+ node_props.forEach(debug ? def : del, Node.prototype);
42
+ }
43
+ });
44
+ var def = function (k) {
45
+ var k1 = Symbol(k);
46
+ defineProperty(this, k, {
47
+ configurable: true, enumerable: false,
48
+ get() {
49
+ return this[k1];
50
+ },
51
+ set(v) {
52
+ defineProperty(this, k1, { configurable: true, writable: true, enumerable: false, value: v })
53
+ }
54
+ });
55
+ };
56
+ var del = function (k) {
57
+ delete this[k];
58
+ };
59
+ module.exports = Node;
@@ -19,6 +19,7 @@ const {
19
19
  } = require("./common");
20
20
  var combine = require("../basic/combine");
21
21
  var sortRegster = require("../basic/sortRegister");
22
+ var Node = require("./Node");
22
23
  var createQuotedMap = function (entry) {
23
24
  var map = {};
24
25
  var end = {};
@@ -38,7 +39,7 @@ var createQuotedMap = function (entry) {
38
39
  var stringsFromRegExp = function (reg) {
39
40
  // 只处理有限长度无嵌套无分支的表达式
40
41
  var source = reg.source;
41
- var queue = [];
42
+ var queue = Node([]);
42
43
  for (var cx = 0, dx = source.length; cx < dx; cx++) {
43
44
  var s = source[cx];
44
45
  if (source[cx] === "\\") {
@@ -81,12 +82,12 @@ var setObject = function (o) {
81
82
  continue;
82
83
  }
83
84
  if (m.type === LABEL) {
84
- o.splice(cx, 0, o[++cx].prev = m.next = m.next.prev = {
85
+ o.splice(cx, 0, o[++cx].prev = m.next = m.next.prev = new Node({
85
86
  prev: m,
86
87
  text: ':',
87
88
  type: STAMP,
88
89
  next: m.next,
89
- });
90
+ }));
90
91
  m.type = PROPERTY;
91
92
  m.text = m.text.replace(/\:$/, '');
92
93
  m.isprop = true;
@@ -108,6 +109,7 @@ var setObject = function (o) {
108
109
  var spaceDefined = require("../basic/spaces");
109
110
 
110
111
  var powermap = require("./powermap");
112
+
111
113
  class Program {
112
114
  quotes = [
113
115
  [/'/, /'/, /\\[\s\S]/],
@@ -310,7 +312,7 @@ class Program {
310
312
  if (!this.entry_reg) this.commit();
311
313
  var index = this.lastIndex;
312
314
  this.lastIndex = text.length;
313
- var parents = [];
315
+ var parents = Node([]);
314
316
  var lasttype;
315
317
  var Code = this.Code;
316
318
  var queue = new Code();
@@ -352,7 +354,7 @@ class Program {
352
354
  if (scope.text) setRows(scope.text);
353
355
  }
354
356
  var last = queue.last;
355
- Object.defineProperty(scope, 'queue', { value: queue, enumerable: false, configurable: true });
357
+ scope.queue = queue;
356
358
  scope.prev = last;
357
359
  if (!(scope.type & (COMMENT | SPACE))) {
358
360
  var keeplast = program.setType(scope) === false;
@@ -473,7 +475,7 @@ class Program {
473
475
  return;
474
476
  }
475
477
 
476
- var scope = {
478
+ var scope = new Node({
477
479
  type,
478
480
  start,
479
481
  end,
@@ -481,7 +483,7 @@ class Program {
481
483
  col: start - colstart,
482
484
  isExpress: queue.inExpress,
483
485
  text: m
484
- };
486
+ });
485
487
  lasttype = type;
486
488
  if (type === STAMP) {
487
489
  cache_stamp = scope;
@@ -512,7 +514,7 @@ class Program {
512
514
  if (queue.tag_entry !== qtag) return;
513
515
  var p = queue;
514
516
  var pi = parents.length;
515
- var ps = [];
517
+ var ps = Node([]);
516
518
  for (var cx = 0, dx = parents.length; cx < dx; cx++) {
517
519
  if (parents[cx].tag) break;
518
520
  }
@@ -523,7 +525,7 @@ class Program {
523
525
  if (!p.tag) {
524
526
  if (queue.waitTag) return;
525
527
  pi++;
526
- var scope = [];
528
+ var scope = Node([]);
527
529
  scope.entry = queue.tag_entry;
528
530
  scope.tag_leave = queue.tag_leave;
529
531
  scope.tag = tag;
@@ -586,13 +588,13 @@ class Program {
586
588
  return istype;
587
589
  };
588
590
  var undefTag = () => {
589
- var scope = {
591
+ var scope = new Node({
590
592
  type: STAMP,
591
593
  text: queue.entry,
592
594
  col: queue.col,
593
595
  row: queue.row,
594
596
  start: queue.start,
595
- };
597
+ });
596
598
  if (queue[0]) {
597
599
  queue.splice(0, queue.length);
598
600
  start = index = queue[0].start;
@@ -646,7 +648,7 @@ class Program {
646
648
  return false;
647
649
  };
648
650
  var push_quote = function () {
649
- var scope = [];
651
+ var scope = Node([]);
650
652
  scope.entry = m;
651
653
  scope.type = SCOPED;
652
654
  scope.inExpress = true;
@@ -765,7 +767,7 @@ class Program {
765
767
  if (mi === 0) {
766
768
  if (queue.waitTag) continue;
767
769
  push_piece();
768
- var scope = [];
770
+ var scope = Node([]);
769
771
  scope.entry = m;
770
772
  scope.type = QUOTED;
771
773
  if (queue.istype) scope.istype = queue.istype;
@@ -805,7 +807,7 @@ class Program {
805
807
  }
806
808
  if (queue.tag && !queue.inTag) continue;
807
809
  push_piece();
808
- var scope = [];
810
+ var scope = Node([]);
809
811
  scope.entry = m;
810
812
  if (queue.istype) scope.istype = true;
811
813
  scope.type = QUOTED;
@@ -901,7 +903,7 @@ class Program {
901
903
  break;
902
904
  }
903
905
  }
904
- var scope = [];
906
+ var scope = Node([]);
905
907
  scope.type = iscomment ? COMMENT : QUOTED;
906
908
  if (isTypeTag && scope.type === QUOTED) scope.istype = isTypeTag;
907
909
  scope.isExpress = queue.inExpress;
@@ -1048,7 +1050,7 @@ class Program {
1048
1050
  if (last.isExpress && !last.istype) break scope;
1049
1051
  }
1050
1052
  }
1051
- var scope = [];
1053
+ var scope = Node([]);
1052
1054
  scope.entry = m;
1053
1055
  scope.type = SCOPED;
1054
1056
  scope.start = match.index;
@@ -1,4 +1,5 @@
1
1
  var { VALUE, QUOTED, EXPRESS, STRAP, relink } = require("./common");
2
+ var Node = require("./Node");
2
3
  var cloneNode = function (o, keep) {
3
4
  var c = o;
4
5
  if (c instanceof Array && !c.text) {
@@ -14,14 +15,14 @@ var cloneNode = function (o, keep) {
14
15
  }
15
16
  else if (typeof c === 'object' && c instanceof Object) {
16
17
  if (keep) return c;
17
- c = Object.assign({}, c);
18
+ c = new Node(c);
18
19
  }
19
20
  else switch (typeof c) {
20
- case "number": case "bigint": c = { type: VALUE, isdigit: c === c, text: String(c) }; break;
21
- case "boolean": case "undefined": c = { type: VALUE, text: String(c) }; break;
22
- case "regexp": c = { type: QUOTED, text: String(c) }; break;
21
+ case "number": case "bigint": c = new Node({ type: VALUE, isdigit: c === c, text: String(c) }); break;
22
+ case "boolean": case "undefined": c = new Node({ type: VALUE, text: String(c) }); break;
23
+ case "regexp": c = new Node({ type: QUOTED, text: String(c) }); break;
23
24
  case "string": c = scanner2(c); break;
24
- default: if (c === null) c = { type: VALUE, text: String(c) };
25
+ default: if (c === null) c = new Node({ type: VALUE, text: String(c) });
25
26
  }
26
27
  return c;
27
28
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const [
2
+ import {
3
3
  /* 1 */COMMENT,
4
4
  /* 2 */SPACE,
5
5
  /* 4 */STRAP,
@@ -12,7 +12,7 @@ const [
12
12
  /* 512 */LABEL,
13
13
  /*1024 */PROPERTY,
14
14
  /*2048 */ELEMENT,
15
- ] = new Array(20).fill(0).map((_, a) => 1 << a);
15
+ } from "./const.mjs";
16
16
  // --------------//1//2/////////////////////////22/////////////2//2//3//4/////4////////3/////3//////3//3//////3///////211/////////////2//////2//////1///
17
17
  var number_reg = /^(?:(?:0x[0-9a-f]+|0b[01]+|0o?[0-7]+)(?:_[0-9a-f]+)*|(?:(?:(?:\d+_)*\d+|\d*)\.\d+(?:_\d+)*|(?:\d+_)*\d+\.?))(?:e[\+\-]?\d+(?:_\d+)*|[hijklmnu]+)?/i;
18
18
  var equal_reg = /^(?:[\+\-\*\/~\^&\|%]|\*\*|>>>?|<<)?\=$|^(?:\+\+|\-\-)$/;
@@ -8,7 +8,7 @@ var powermap = {
8
8
 
9
9
  [
10
10
  '=,+=,-=,*=,/=,%=,|=,&=,^=,||=,&&=,??=,<<=,>>=,>>>=,**=,~=,:=,?,:,=>'/* 1 */,
11
- '&&,||,^^,??'/* 4 */, '&,|,^'/* 5 */,
11
+ '&&,||,^^,??'/* 3 */, '|,^'/* 4 */, '&'/*5*/,
12
12
  'instanceof,in,==,>=,<=,>,<,!=,!==,===,!in,!instanceof'/* 6 */,
13
13
  '>>,>>>,<<'/* 7 */, '+,-'/* 8 */, '*,/,%'/* 9 */, '**'/* 10 */,
14
14
  '++,--'/* 11 */,
@@ -12,6 +12,7 @@ function test(codetext, expect, ret = false) {
12
12
  test('var o = loaded[f.name] = f.isFile() ? new File(p, rebuild, limit) : new Directory(p, rebuild, limit)', "_ = f.name; _0 = f.isFile(); if (!_0) return [1, 0]; _0 = new File(p, rebuild, limit); loaded[_] = _0; o = _0; return [2, 0];\r\n _0 = new Directory(p, rebuild, limit); loaded[_] = _0; o = _0; return [1, 0]");
13
13
  test('a+b', "a + b");
14
14
  test('var a = b', "a = b");
15
+ test('a | c & b', "_ = c & b, a | _");
15
16
  test('a + !c', "_ = !c, a + _");
16
17
  test('a + b * c', "_ = b * c, a + _");
17
18
  test('a + b * !c', "_ = !c, _ = b * _, a + _");
@@ -12,8 +12,10 @@ var reshape = function () {
12
12
  paddingLeft: left,
13
13
  paddingTop: ""
14
14
  });
15
+ this.removeAttribute('break');
15
16
  }
16
17
  else {
18
+ this.setAttribute('break', '');
17
19
  var top = head.offsetHeight + 1;
18
20
  css(head, {
19
21
  marginRight: '',
@@ -27,7 +29,6 @@ var reshape = function () {
27
29
  }
28
30
  if (!body) body = head;
29
31
  if (foot && body) {
30
- console.log(foot)
31
32
  var right = foot.offsetWidth + 1;
32
33
  if (isInlineBlock && right < (this.break || body.offsetWidth >> 2)) {
33
34
  css(foot, {
@@ -6,9 +6,11 @@
6
6
  padding: 8px 0;
7
7
  border-bottom: 1px solid #0001;
8
8
  }
9
- &:empty{
9
+
10
+ &:empty {
10
11
  display: none;
11
12
  }
13
+
12
14
  >.head,
13
15
  >.foot {
14
16
  padding: 2px 16px;
@@ -60,9 +62,12 @@ model {
60
62
  margin: 10px 0;
61
63
  }
62
64
 
65
+ &:not(input, textarea, .input, select, .select) {
66
+ padding: 2px 16px;
67
+ }
68
+
63
69
  min-height: 30px;
64
70
  vertical-align: top;
65
- padding: 2px 16px;
66
71
  height: 100%;
67
72
  display: inline-block;
68
73
  width: 100%;
@@ -30,13 +30,21 @@ var fixContainer = function (elem, ipt) {
30
30
  move.fixPosition(elem);
31
31
  };
32
32
  function prompt() {
33
- var msg = i18n`请输入`, check, ipt;
33
+ var msg, check, ipt;
34
34
  var opts = [];
35
35
  var submit = null;
36
36
  var wrap = false;
37
37
  var value = '';
38
+ var attrs = {
39
+ type: null,
40
+ max: null,
41
+ min: null,
42
+ step: null,
43
+ maxLength: null,
44
+ };
38
45
  for (var arg of arguments) {
39
46
  if (isNode(arg)) ipt = arg;
47
+ else if (msg && typeof arg === 'string' || typeof arg === 'integer') value = arg;
40
48
  else if (typeof arg === 'string') msg = arg;
41
49
  else if (isArray(arg)) opts = arg;
42
50
  else if (isFunction(arg) || arg instanceof RegExp) check = arg;
@@ -46,9 +54,13 @@ function prompt() {
46
54
  if (isFunction(arg.submit)) submit = arg;
47
55
  if (isString(arg.msg || arg.title)) msg = arg.msg || arg.title;
48
56
  if (isHandled(arg.value)) value = arg.value;
57
+ for (var k in attrs) {
58
+ if (k in arg) attrs[k] = arg[k];
59
+ }
49
60
  if (arg.multiple || arg.wrap) wrap = true;
50
61
  }
51
62
  }
63
+ if (!msg) msg = i18n`请输入`;
52
64
  if (!ipt) {
53
65
  if (wrap) {
54
66
  ipt = document.createElement('div');
@@ -61,6 +73,9 @@ function prompt() {
61
73
  else {
62
74
  ipt.setAttribute('textarea', '');
63
75
  }
76
+ for (var k in attrs) {
77
+ if (isHandled(attrs[k])) ipt.setAttribute(k, attrs[k]);
78
+ }
64
79
  var tip = document.createElement("tip");
65
80
  var buttons = [isNode(opts[0]) ? opts[0] : button(opts[0] || i18n`确认`), isNode(opts[1]) ? opts[1] : button(opts[1] || i18n`取消`, 'white')];
66
81
  var getValue = () => isFunction(ipt.getValue) ? ipt.getValue() : ipt.value;
@@ -133,7 +133,7 @@ var buildDate = function (date) {
133
133
  var src = m2n(srcCount + 1, 1);
134
134
  var last_month = getDay(year, month, 1);
135
135
  var last_month_count = getDatesCount(year, month - 1);
136
- var last_src = m2n(last_month_count, last_month_count + 1 - last_month);
136
+ var last_src = m2n(last_month_count + 1, last_month_count + 2 - last_month );
137
137
  var next_month = 6 - (src.length + last_src.length - 1) % 7;
138
138
  var next_src = m2n(next_month + 1, 1);
139
139
  var title_src = '一二三四五六日',