efront 4.10.0 → 4.10.2

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,5 +1,5 @@
1
1
 
2
- var { STRAP, SCOPED, ELEMENT, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE } = compile$common;
2
+ var { STRAP, SCOPED, ELEMENT, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE, needhead_reg } = compile$common;
3
3
  var predefs = Object.create(null);
4
4
  predefs.module = true;
5
5
  predefs.exports = true;
@@ -10,36 +10,70 @@ var codecolor = function (c, encode) {
10
10
  var envs = c.envs;
11
11
  var deep = 0;
12
12
  var used = c.used;
13
+ var scoped = c.scoped;
14
+ var setdefs = function (scoped) {
15
+ var { used } = scoped;
16
+ for (var k in used) {
17
+ var isdef = false;
18
+ for (var o of used[k]) {
19
+ if (o.next?.needle) {
20
+ isdef = true;
21
+ break;
22
+ }
23
+ }
24
+ if (isdef) {
25
+ for (var o of used[k]) {
26
+ o.isdef = true;
27
+ }
28
+ }
29
+ }
30
+ scoped.forEach(setdefs);
31
+ };
32
+ setdefs(scoped);
33
+ var isConstValue = () => false;
34
+ if (c.program) {
35
+ var { strap_reg, value_reg } = c.program;
36
+ isConstValue = a => strap_reg.test(a) || value_reg.test(a);
37
+ };
38
+ var isInvoke = function (o) {
39
+ var o = o.next;
40
+ if (o?.type === EXPRESS && needhead_reg.test(o.text)) o = o.next;
41
+ if (o?.type === ELEMENT && o.istype) o = o.next;
42
+ if (o?.type === STAMP && o.needle) o = o.next;
43
+ if (o?.type === SCOPED && o.entry === "(") return true;
44
+ return false;
45
+ }
13
46
  var setExpress = function (o, label) {
14
47
  if (!o.text) return;
15
48
  var keys = o.text.split(".");
16
- var next = o.next;
17
- if (next && next.type === SCOPED && next.entry === '(') {
18
- if (!/^\</.test(keys[keys.length - 1])) keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
49
+ if (isInvoke(o)) {
50
+ if (!/^[\<\?]/.test(keys[keys.length - 1])) keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
19
51
  }
20
52
  var [name] = keys;
21
53
  if (/^[\<\?]/.test(name) || !name);
22
- else if (c.program?.strap_reg.test(name) || c.program?.value_reg.test(name) || /^(this|arguments)$/.test(name)) name = `<strap>${name}</strap>`;
54
+ else if (!o.isprop && o.text !== name && isConstValue(name)) name = `<strap>${name}</strap>`;
23
55
  else name = `<${label}>${name}</${label}>`;
24
56
  keys[0] = name;
25
- o.text = keys.map(k => /^\</.test(k) || !k ? k : `<express>${k}</express>`).join(".");
57
+ o.text = keys.map(k => /^[\<\?]/.test(k) || !k ? k : `<express>${k}</express>`).join(".");
26
58
  }
27
59
  var setPredef = o => setExpress(o, 'predef');
28
60
  var setOutside = o => setExpress(o, 'outside');
29
61
  if (used) for (var k in envs) {
30
62
  used[k].forEach(k in predefs ? setPredef : setOutside);
31
63
  }
32
- var spaceReg = c.program.space_exp;
64
+ if (c.program) var { space_exp: spaceReg, control_reg } = c.program;
33
65
  var unspaceReg = new RegExp(spaceReg.source.replace(/^\[/, "[^"), spaceReg.flags + 'g');
34
66
  var wraptext = function (t, l) {
35
- t = t.replace(unspaceReg, a => {
67
+ if (unspaceReg) t = t.replace(unspaceReg, a => {
36
68
  a = encode(a);
37
69
  return `<${l}>${a}</${l}>`
38
70
  });
39
71
  return t;
40
72
  }
41
-
73
+ c.colored = true;
42
74
  var setcolor = function (o) {
75
+ if (o.colored) return;
76
+ o.colored = true;
43
77
  var text = o.text;
44
78
  switch (o.type) {
45
79
  case LABEL:
@@ -94,17 +128,16 @@ var codecolor = function (c, encode) {
94
128
  case PROPERTY:
95
129
  var next = o.next;
96
130
  if (next && next.type === SCOPED && next.entry === '(') {
97
- o.text = `<method>${o.text}</method>`;
131
+ setExpress(o, 'method');
98
132
  }
99
- else o.text = `<property>${o.text}</property>`;
133
+ else setExpress(o, 'property');
100
134
 
101
135
  break;
102
136
  case EXPRESS:
103
- setExpress(o, 'express');
137
+ setExpress(o, o.istype || o.isdef || o.next?.needle ? 'predef' : 'express');
104
138
  break;
105
139
  case STRAP:
106
- if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|throw|await|yield|return)$/.test(text))
107
- o.text = `<flow>${o.text}</flow>`;
140
+ if (control_reg?.test(text)) o.text = `<flow>${o.text}</flow>`;
108
141
  else o.text = `<strap>${o.text}</strap>`;
109
142
  break;
110
143
  case STAMP:
@@ -1,6 +1,8 @@
1
1
  <style>
2
2
  :scope {
3
- white-space: pre;
3
+ white-space: pre-wrap;
4
+ line-height: 1.36;
5
+ word-break: break-all;
4
6
  padding: 10px 20px;
5
7
  border-radius: 3px;
6
8
  display: inline-block;
@@ -9,6 +11,7 @@
9
11
  font-family: Consolas, "Courier New", monospace;
10
12
  vertical-align: top;
11
13
  text-decoration-line: none;
14
+ tab-size: 4;
12
15
  }
13
16
 
14
17
  stamp {
@@ -92,10 +95,52 @@
92
95
  return text.replace(/[\<\>\|]/g, a => `&#${a.charCodeAt()};`);
93
96
  };
94
97
  var typescript = new compile$Javascript;
95
- typescript.straps = typescript.straps.concat("interface", "implements", "declare", "module", "readonly", "enum");
96
- typescript.tags[0].push(["{", "}"]);
98
+ typescript.straps = typescript.straps.concat(
99
+ "interface", "implements", "declare", "module", "namespace",
100
+ "readonly", "private", "asserts", "is",
101
+ "enum", "type");
102
+ typescript.tags[0].push("{");
97
103
  var js = new compile$Javascript;
98
- js.tags[0].push(["{", "}"]);
104
+ js.tags[0].push("{");
105
+ var json = new compile$Javascript;
106
+ json.inExpress = true;
107
+ var gl = new compile$Javascript;
108
+ gl.straps = gl.straps.concat(
109
+ "in", "out", "inout", "uniform", "buffer", "shared",
110
+ "highp", "mediump", "lowp",
111
+ "invariant", "const", "varying", "attribute",
112
+ "sampler2D", "texture2D",
113
+ "sampler3D", "texture3D",
114
+ "coherent", "volatile", "restrict", "readonly", "writeonly",
115
+ "flat", "noperspective", "smooth",
116
+ "packed", "shared", "std140", "std340", "row_major", "colum_major",
117
+ "location", "set", "binding", "offset", "index", "xfb_buffer", "xfb_offset", "local_size",
118
+ "void",
119
+ 'require', 'enable', 'disable', 'warn',
120
+ 'struct',
121
+ 'float', 'int',
122
+ 'vec4', 'vec3', 'vec2',
123
+ 'mat4', 'mat3', 'mat2',
124
+ 'bool', 'const', 'precision',
125
+ "step", "smoothstep",
126
+ "mix", "clamp"
127
+ );
128
+ var rust = new compile$Javascript;
129
+ rust.powermap = Object.assign({}, rust.powermap);
130
+ rust.powermap["->"] = 0;
131
+ rust.straps = ["let", 'use', 'mut', 'fn', 'if', 'else', 'loop', 'while', 'for', 'in', 'break', 'true', 'false', 'struct', 'enum', 'impl', 'self', 'match', 'pub', 'mod', 'trait'];
132
+ var struct_reg = /^(while|do|for|with|switch|case|default|if|else|try|catch|finally|loop|import|export)$/;
133
+
134
+ gl.setType = function (o) {
135
+ var { type } = o;
136
+ var queue = o.queue;
137
+ var last = o.prev;
138
+ if (type & (SCOPED | EXPRESS | PROPERTY)) {
139
+ if (last && last === queue[queue.length - 1] && last.type & (EXPRESS | STRAP | PROPERTY)) {
140
+ last.istype = !struct_reg.test(last.text);
141
+ }
142
+ }
143
+ }
99
144
  var codesupports = {
100
145
  javascript(a, blink) {
101
146
  if (blink) var index = a.indexOf(blink);
@@ -115,17 +160,46 @@
115
160
  codecolor(c, encode);
116
161
  return c.toString();
117
162
  },
163
+ json(a) {
164
+ var c = compile$scanner2(a, json);
165
+ codecolor(c, encode);
166
+ return c.toString();
167
+ },
168
+ rs(a) {
169
+ var c = compile$scanner2(a, rust);
170
+ codecolor(c, encode);
171
+ return c.toString();
172
+ },
173
+ glsl(a) {
174
+ var c = compile$scanner2(a, gl);
175
+ codecolor(c, encode);
176
+ return c.toString();
177
+ },
118
178
  html(a) {
119
179
  var code = compile$scanner2(a, 'html');
120
180
  var scoped = code.scoped;
121
- codecolor(code, encode);
122
181
  backEach(scoped.richNodes, n => {
123
182
  if (n.isScript) {
124
- var js = compile$scanner2(compile$common.createString(n));
125
- codecolor(js, encode);
183
+ var js = [];
184
+ compile$common.createString(n).replace(/^(\s*\<\!--)([\s\S]*)(--\!?\>\s*)$|^[\s\S]*$/, (m, p, a, f) => {
185
+ if (!a) {
186
+ js = compile$scanner2(m);
187
+ }
188
+ else {
189
+ js = compile$scanner2(a);
190
+ js.unshift(
191
+ { type: compile$common.COMMENT, text: p },
192
+ );
193
+ js.push(
194
+ { type: compile$common.COMMENT, text: f }
195
+ );
196
+ }
197
+ codecolor(js, encode);
198
+ });
126
199
  n.splice(0, n.length, ...js);
127
200
  }
128
201
  })
202
+ codecolor(code, encode);
129
203
  return code.toString();
130
204
  },
131
205
  css(a) {
@@ -134,11 +208,12 @@
134
208
  return c.toString();
135
209
  }
136
210
  };
211
+ codesupports.gl = codesupports.glsl;
137
212
  codesupports.cmd = codesupports.bat;
138
- codesupports.jsx = codesupports.js = codesupports.javascript;
213
+ codesupports.cjs = codesupports.mjs = codesupports.jsx = codesupports.js = codesupports.javascript;
139
214
  codesupports.tsx = codesupports.ts = codesupports.typescript;
140
- codesupports.xml = codesupports.html;
141
- var { SCOPED, QUOTED, SPACE, EXPRESS } = compile$common;
215
+ codesupports.jsp = codesupports.asp = codesupports.php = codesupports.xml = codesupports.html;
216
+ var { SCOPED, QUOTED, SPACE, STRAP, EXPRESS, PROPERTY } = compile$common;
142
217
  var patchBlink = function (code, index, blink) {
143
218
  for (var cx = 0, dx = code.length; cx < dx; cx++) {
144
219
  var c = code[cx];
@@ -209,7 +284,7 @@
209
284
  var minSpace = 0;
210
285
  for (var c of codes) {
211
286
  var m = /^\s*/.exec(c);
212
- if (m && m[0].length < c.length) {
287
+ if (m && m[0].length < minSpace) {
213
288
  minSpace = m[0].length;
214
289
  }
215
290
  }
@@ -141,19 +141,19 @@
141
141
  }
142
142
  mmap[menu.id] = menu;
143
143
  }
144
- if (menu.id === opened.active) actived = menu, actived_value = historys.length;
144
+ if (menu.id === opened.$active) actived = menu, actived_value = historys.length;
145
145
  }
146
146
  return res;
147
147
  };
148
148
  result.push.apply(result, items.filter(a));
149
149
  result.opened = opened.map(a => mmap[a]).filter(a => !!a);
150
- var active = result.active;
150
+ var active = result.$active;
151
151
  if (!active || result.indexOf(active) < 0) {
152
- actived = mmap[opened.active] || actived;
152
+ actived = mmap[opened.$active] || actived;
153
153
  if (actived) {
154
154
  if (actived_value === historys.length) {
155
155
  setActive(actived, true);
156
- result.active = actived;
156
+ result.$active = actived;
157
157
  };
158
158
  }
159
159
  }
@@ -176,38 +176,38 @@
176
176
  data.setInstance("option-buttons", zimoli.options || [], false);
177
177
  var menu = getChild(zimoli);
178
178
  if (!menu) return;
179
- if (menu !== result.active) {
180
- setActive(result.active, false);
179
+ if (menu !== result.$active) {
180
+ setActive(result.$active, false);
181
181
  setActive(menu, true);
182
- result.active = menu;
182
+ result.$active = menu;
183
183
  }
184
184
  if (menu.id) {
185
185
  var opened = result.opened || [];
186
186
  var oped = opened.map(a => a.id);
187
- oped.active = menu.id;
187
+ oped.$active = menu.id;
188
188
  data.setInstance('menu-opened', oped);
189
189
  }
190
190
  });
191
191
  result.open = function (menu) {
192
192
  if (!menu) {
193
- menu = result.active || result[0];
194
- delete result.active;
193
+ menu = result.$active || result[0];
194
+ delete result.$active;
195
195
  }
196
196
  if (!menu.path) {
197
197
  menu.closed = !menu.closed;
198
198
  return;
199
199
  }
200
- if (menu === result.active) return;
200
+ if (menu === result.$active) return;
201
201
  var opened = result.opened || [];
202
202
  if (!~opened.indexOf(menu) && !getChild(menu).id) {
203
203
  opened.push(menu);
204
204
  }
205
- if (result.active && result.active.id !== menu.id) {
206
- setActive(result.active, false);
205
+ if (result.$active && result.$active.id !== menu.id) {
206
+ setActive(result.$active, false);
207
207
  }
208
208
  setActive(menu, true);
209
209
  result.load(menu);
210
- result.active = menu;
210
+ result.$active = menu;
211
211
  };
212
212
  result.close = function (menu) {
213
213
  if (menu === result[0]) return;
@@ -228,7 +228,7 @@
228
228
  }
229
229
  };
230
230
  result.reload = function () {
231
- result.load(result.active);
231
+ result.load(result.$active);
232
232
  return result;
233
233
  };
234
234
  result.from = result.fetch = function (url) {
@@ -1,3 +1,3 @@
1
1
  return {
2
- url:'http://webst04.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}'
2
+ url:'http://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}'
3
3
  };
@@ -467,7 +467,7 @@ var src2 = function (search) {
467
467
  var savedValue;
468
468
  this.$renders.push(function () {
469
469
  var origin = getter(this);
470
- var temp = shallowClone(origin, 1);
470
+ var temp = shallowClone(origin);
471
471
  if (isHandled(savedValue)) {
472
472
  if (shallowEqual(temp, savedValue, 1)) return;
473
473
  }
@@ -25,9 +25,9 @@ function getChildrenBottom(com) {
25
25
  return t;
26
26
  }
27
27
  }
28
- if (c.target) return c.target;
28
+ if (c.$target) return c.$target;
29
29
  }
30
- return com.target;
30
+ return com.$target;
31
31
  }
32
32
 
33
33
  var getArrayFromTree = Tree.toArray;
@@ -121,13 +121,13 @@ function tree() {
121
121
  }
122
122
  _div.style.zIndex = 1;
123
123
  _div.itemid = com.id;
124
- if (_div._index === changed_index) {
124
+ if (_div.$index === changed_index) {
125
125
  saved_top = _div;
126
126
  setState(true);
127
127
  } else {
128
128
  setState();
129
129
  }
130
- if (_div._index === changed_offset) {
130
+ if (_div.$index === changed_offset) {
131
131
  saved_offset = _div;
132
132
  }
133
133
  com.closed = com.isClosed();
@@ -138,7 +138,7 @@ function tree() {
138
138
  var saved = com.saved;
139
139
  if (com.length) {
140
140
 
141
- if (saved.closed !== closed || _div !== com.target) {
141
+ if (saved.closed !== closed || _div !== com.$target) {
142
142
  saved.closed = closed;
143
143
  if (closed) {
144
144
  addClass(_div, 'closed');
@@ -165,7 +165,7 @@ function tree() {
165
165
  };
166
166
  var getChildrenTop = function (com) {
167
167
  while (com.joined) com = com[0];
168
- return com[0]?.target;
168
+ return com[0]?.$target;
169
169
  }
170
170
  onclick(_div, function (event) {
171
171
  var isClosed = com.isClosed();
@@ -175,24 +175,24 @@ function tree() {
175
175
  if (isClosed === com.isClosed() && com.length) {
176
176
  com.setClosed(!isClosed);
177
177
  }
178
- var index = this._index;
178
+ var index = this.$index;
179
179
  changed_index = index;
180
180
  buildCrack(com);
181
181
  changed_offset = com.crack + index;
182
182
  if (!com.length) {
183
- dom.forEach(d => d.target && d.target.refresh());
183
+ dom.forEach(d => d.$target && d.$target.refresh());
184
184
  return;
185
185
  }
186
186
  var z0 = function () {
187
187
  var z = function (e) {
188
- if (e.target) e.target.style.zIndex = 0;
188
+ if (e.$target) e.$target.style.zIndex = 0;
189
189
  if (e instanceof Array) e.forEach(z);
190
190
  };
191
191
  com.forEach(z);
192
192
  };
193
193
  var z1 = function () {
194
194
  var z = function (e) {
195
- if (e.target) e.target.style.zIndex = 1;
195
+ if (e.$target) e.$target.style.zIndex = 1;
196
196
  if (e instanceof Array) e.forEach(z);
197
197
  };
198
198
  com.forEach(z);
@@ -244,14 +244,14 @@ function tree() {
244
244
  if (index >= coms.length) return;
245
245
  var com = coms[index];
246
246
  if (!com) return;
247
- if (com.target) {
248
- com.target._index = index;
249
- com.target.refresh();
250
- return com.target;
247
+ if (com.$target) {
248
+ com.$target.$index = index;
249
+ com.$target.refresh();
250
+ return com.$target;
251
251
  }
252
252
  var _div = createChild(com, index);
253
- com.target = _div;
254
- _div._index = index;
253
+ com.$target = _div;
254
+ _div.$index = index;
255
255
  _div.refresh();
256
256
  return _div;
257
257
  });
@@ -274,10 +274,10 @@ function tree() {
274
274
  var f = banner.getFirstVisibleElement(stickys.top + 1);
275
275
  if (!f) return;
276
276
  var limitHeight = f.offsetTop - banner.scrollTop;
277
- var c = dom[f._index];
277
+ var c = dom[f.$index];
278
278
  var useLimit = false;
279
279
  if (p) {
280
- var d = dom[p._index];
280
+ var d = dom[p.$index];
281
281
  if (d.tab == c.tab) {
282
282
  var { top, height } = getOffset(p);
283
283
  if (top + height >= limitHeight) {
@@ -296,6 +296,7 @@ function tree() {
296
296
  while (c.parent) {
297
297
  var p = c.parent;
298
298
  if (!p?.joined) {
299
+ if (!c.$target) return;
299
300
  parents.push(c);
300
301
  }
301
302
  c = p;
@@ -303,7 +304,7 @@ function tree() {
303
304
  stickys.forEach(s => s.sticky = false);
304
305
  parents = parents.map(p => {
305
306
  p.sticky = true;
306
- return p.target;
307
+ return p.$target;
307
308
  });
308
309
  parents.reverse();
309
310
  stickys.forEach(s => {
@@ -330,7 +331,7 @@ function tree() {
330
331
  }
331
332
  var refresh = function () {
332
333
  var index = banner.index();
333
- var needremoves = dom.map(d => d.target).filter(d => !!d);
334
+ var needremoves = dom.map(d => d.$target).filter(d => !!d);
334
335
  dom = getArrayFromTree(root, banner.joined);
335
336
  remove(needremoves, false);
336
337
  banner.go(index || 0);
@@ -73,6 +73,7 @@
73
73
  [codearea]>.codetext {
74
74
  overflow: auto;
75
75
  display: block;
76
+ white-space: pre;
76
77
  height: auto;
77
78
  min-height: 100%;
78
79
  border-width: 10px 20px 40px 20px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.10.0",
3
+ "version": "4.10.2",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {