efront 4.9.4 → 4.10.1

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.
Files changed (42) hide show
  1. package/coms/basic/Item.js +6 -1
  2. package/coms/basic/Tree.js +15 -1
  3. package/coms/basic/shallowClone.js +6 -2
  4. package/coms/basic_/JSON.js +1 -5
  5. package/coms/basic_/JSON_test.js +7 -1
  6. package/coms/compile/Html_test.js +12 -1
  7. package/coms/compile/Javascript.js +94 -58
  8. package/coms/compile/Javascript_test.js +70 -2
  9. package/coms/compile/Program.js +187 -53
  10. package/coms/compile/audit.js +1 -1
  11. package/coms/compile/autoenum.js +1 -1
  12. package/coms/compile/cloneNode.js +2 -0
  13. package/coms/compile/common.js +74 -43
  14. package/coms/compile/downLevel.js +6 -6
  15. package/coms/compile/downLevel_test.js +5 -1
  16. package/coms/compile/formatcode.js +1 -1
  17. package/coms/compile/powermap.js +1 -1
  18. package/coms/compile/unstruct.js +2 -2
  19. package/coms/docs/codecolor.js +47 -17
  20. package/coms/docs/codetext.xht +83 -12
  21. package/coms/frame/route.js +15 -15
  22. package/coms/zimoli/XMLHttpRequest.js +2 -5
  23. package/coms/zimoli/alert.js +2 -2
  24. package/coms/zimoli/confirm.js +1 -1
  25. package/coms/zimoli/createEvent.js +6 -7
  26. package/coms/zimoli/dispatch.js +8 -4
  27. package/coms/zimoli/getScreenPosition.js +6 -6
  28. package/coms/zimoli/grid.js +14 -10
  29. package/coms/zimoli/list.js +13 -1
  30. package/coms/zimoli/on.js +2 -1
  31. package/coms/zimoli/picture.js +1 -1
  32. package/coms/zimoli/render.js +1 -1
  33. package/coms/zimoli/slider.js +4 -0
  34. package/coms/zimoli/tree.js +133 -43
  35. package/coms/zimoli/tree.less +2 -1
  36. package/coms/zimoli/vbox.js +5 -5
  37. package/coms/zimoli/vbox.less +3 -1
  38. package/coms/zimoli/zimoli.js +1 -1
  39. package/data/packexe-setup.sfx +0 -0
  40. package/docs//347/273/204/344/273/266.xht +4 -4
  41. package/package.json +1 -1
  42. package/public/efront.js +1 -1
@@ -1,5 +1,8 @@
1
1
  <style>
2
2
  :scope {
3
+ white-space: pre-wrap;
4
+ line-height: 1.36;
5
+ word-break: break-all;
3
6
  padding: 10px 20px;
4
7
  border-radius: 3px;
5
8
  display: inline-block;
@@ -88,13 +91,51 @@
88
91
  </style>
89
92
  <script>
90
93
  var encode = function (text) {
91
- return text.replace(/[\<\>\|]/g, a => `&#${a.charCodeAt()};`)
94
+ return text.replace(/[\<\>\|]/g, a => `&#${a.charCodeAt()};`);
92
95
  };
93
96
  var typescript = new compile$Javascript;
94
- typescript.straps = typescript.straps.concat("interface", "implements", "declare", "module", "readonly", "enum");
95
- typescript.tags[0].push(["{", "}"]);
97
+ typescript.straps = typescript.straps.concat(
98
+ "interface", "implements", "declare", "module", "namespace",
99
+ "readonly", "private", "asserts", "is",
100
+ "enum", "type");
101
+ typescript.tags[0].push("{");
96
102
  var js = new compile$Javascript;
97
- js.tags[0].push(["{", "}"]);
103
+ js.tags[0].push("{");
104
+ var json = new compile$Javascript;
105
+ json.inExpress = true;
106
+ var gl = new compile$Javascript;
107
+ gl.straps = gl.straps.concat(
108
+ "in", "out", "inout", "uniform", "buffer", "shared",
109
+ "highp", "mediump", "lowp",
110
+ "invariant", "const", "varying", "attribute",
111
+ "sampler2D", "texture2D",
112
+ "sampler3D", "texture3D",
113
+ "coherent", "volatile", "restrict", "readonly", "writeonly",
114
+ "flat", "noperspective", "smooth",
115
+ "packed", "shared", "std140", "std340", "row_major", "colum_major",
116
+ "location", "set", "binding", "offset", "index", "xfb_buffer", "xfb_offset", "local_size",
117
+ "void",
118
+ 'require', 'enable', 'disable', 'warn',
119
+ 'struct',
120
+ 'float', 'int',
121
+ 'vec4', 'vec3', 'vec2',
122
+ 'mat4', 'mat3', 'mat2',
123
+ 'bool', 'const', 'precision',
124
+ "step", "smoothstep",
125
+ "mix", "clamp"
126
+ );
127
+ var struct_reg = /^(while|do|for|with|switch|case|default|if|else|try|catch|finally)$/;
128
+
129
+ gl.setType = function (o) {
130
+ var { type } = o;
131
+ var queue = o.queue;
132
+ var last = o.prev;
133
+ if (type & (SCOPED | EXPRESS | PROPERTY)) {
134
+ if (last && last === queue[queue.length - 1] && last.type & (EXPRESS | STRAP | PROPERTY)) {
135
+ last.istype = !struct_reg.test(last.text);
136
+ }
137
+ }
138
+ }
98
139
  var codesupports = {
99
140
  javascript(a, blink) {
100
141
  if (blink) var index = a.indexOf(blink);
@@ -114,17 +155,41 @@
114
155
  codecolor(c, encode);
115
156
  return c.toString();
116
157
  },
158
+ json(a) {
159
+ var c = compile$scanner2(a, json);
160
+ codecolor(c, encode);
161
+ return c.toString();
162
+ },
163
+ glsl(a) {
164
+ var c = compile$scanner2(a, gl);
165
+ codecolor(c, encode);
166
+ return c.toString();
167
+ },
117
168
  html(a) {
118
169
  var code = compile$scanner2(a, 'html');
119
170
  var scoped = code.scoped;
120
- codecolor(code, encode);
121
171
  backEach(scoped.richNodes, n => {
122
172
  if (n.isScript) {
123
- var js = compile$scanner2(compile$common.createString(n));
124
- codecolor(js, encode);
173
+ var js = [];
174
+ compile$common.createString(n).replace(/^(\s*\<\!--)([\s\S]*)(--\!?\>\s*)$|^[\s\S]*$/, (m, p, a, f) => {
175
+ if (!a) {
176
+ js = compile$scanner2(m);
177
+ }
178
+ else {
179
+ js = compile$scanner2(a);
180
+ js.unshift(
181
+ { type: compile$common.COMMENT, text: p },
182
+ );
183
+ js.push(
184
+ { type: compile$common.COMMENT, text: f }
185
+ );
186
+ }
187
+ codecolor(js, encode);
188
+ });
125
189
  n.splice(0, n.length, ...js);
126
190
  }
127
191
  })
192
+ codecolor(code, encode);
128
193
  return code.toString();
129
194
  },
130
195
  css(a) {
@@ -133,11 +198,12 @@
133
198
  return c.toString();
134
199
  }
135
200
  };
201
+ codesupports.gl = codesupports.glsl;
136
202
  codesupports.cmd = codesupports.bat;
137
203
  codesupports.jsx = codesupports.js = codesupports.javascript;
138
204
  codesupports.tsx = codesupports.ts = codesupports.typescript;
139
- codesupports.xml = codesupports.html;
140
- var { SCOPED, QUOTED, SPACE, EXPRESS } = compile$common;
205
+ codesupports.jsp = codesupports.asp = codesupports.php = codesupports.xml = codesupports.html;
206
+ var { SCOPED, QUOTED, SPACE, STRAP, EXPRESS, PROPERTY } = compile$common;
141
207
  var patchBlink = function (code, index, blink) {
142
208
  for (var cx = 0, dx = code.length; cx < dx; cx++) {
143
209
  var c = code[cx];
@@ -198,7 +264,7 @@
198
264
  if (c) return c.text += blink, true;
199
265
  return false;
200
266
  };
201
- function codetext(type, text, blink) {
267
+ var rows = function (type, text, blink) {
202
268
  type = type.toLowerCase();
203
269
  if (type in codesupports) {
204
270
  text = codesupports[type](text, blink);
@@ -208,12 +274,17 @@
208
274
  var minSpace = 0;
209
275
  for (var c of codes) {
210
276
  var m = /^\s*/.exec(c);
211
- if (m && m[0].length < c.length) {
277
+ if (m && m[0].length < minSpace) {
212
278
  minSpace = m[0].length;
213
279
  }
214
280
  }
215
281
  if (minSpace > 0) codes = codes.map(c => /^\s+/.test(c) ? c.slice(minSpace) : c);
216
- return `<code type=${type}>${codes.join("<br/>").replace(/\t/g, Array(5).join('&ensp;')).replace(/\s/g, '&ensp;')}</code>`;
282
+ return codes;
283
+ }
284
+ function codetext(type, text, blink) {
285
+ var ws = rows(type, text, blink);
286
+ return `<code type=${type}>${ws.join("<br/>")}</code>`;
217
287
  }
288
+ codetext.rows = rows;
218
289
  codetext.encode = encode;
219
290
  </script>
@@ -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) {
@@ -14,14 +14,11 @@ return class XMLHttpRequest {
14
14
  this.url = url;
15
15
  }
16
16
  send(data) {
17
- var u = new URL(this.url);
18
- if (!u.host) u.host = location.host || 'localhost'
19
- this.fetch(this.url, { method: this.method }).then(d => {
20
-
17
+ this.fetch(this.url, { method: this.method, headers: { referer: document.location.href.replace(/^#[\s\S]*$/g, '') } }).then(async d => {
21
18
  this.fetched = d;
22
19
  this.readyState = 4;
23
20
  this.status = d.status;
24
- this.responseText = d.text();
21
+ this.responseText = await d.text();
25
22
  if (this.onreadystatechange) this.onreadystatechange({ target: this });
26
23
  if (this.onload) this.onload({ target: this });
27
24
  }, e => {
@@ -71,8 +71,8 @@ function alert() {
71
71
  } else {
72
72
  elem = _text(elem, styles.log, [text]);
73
73
  }
74
- if (!container.parentNode) popup(container);
75
- if (!elem.parentNode) appendChild(container, elem);
74
+ if (!isMounted(container)) popup(container);
75
+ if (!isMounted(elem)) appendChild(container, elem);
76
76
  waitclose(autoclose, 400);
77
77
  return elem;
78
78
  };
@@ -141,7 +141,7 @@ function confirm() {
141
141
  element.tabIndex = -1;
142
142
 
143
143
  Promise.resolve().then(function () {
144
- if (element.parentNode) return;
144
+ if (isMounted(element)) return;
145
145
  element.mask = true;
146
146
  popup(element, target || [.5, .5], target ? 'rhomb' : true);
147
147
  element.focus();
@@ -2,16 +2,15 @@
2
2
  * 创建自定义事件
3
3
  */
4
4
  if ("createEvent" in document) var createEvent = function createEvent(eventName, canBubble = false, cancelable = true) {
5
- var event = document.createEvent("Event");
5
+ var event = document.createEvent(/Events?$/.test(eventName) ? eventName : "Event");
6
6
  event.initEvent(eventName, canBubble, cancelable);
7
7
  return event;
8
8
  }
9
- else if ("createEventObject" in document) var createEvent = function createEventObject(eventName) {
10
- var event = document.createEventObject();
9
+ else var createEvent = function createEventObject(eventName) {
10
+ if ("createEventObject" in document) var event = document.createEventObject();
11
+ else if (window.Event) event = new Event(eventName);
12
+ else event = {};
11
13
  event.type = eventName;
12
- return event;
13
- }
14
- else var Event = window.Event, createEvent = function (eventName) {
15
- var event = new Event(eventName);
14
+ if (!event.initMouseEvent) event.initMouseEvent = function () { };
16
15
  return event;
17
16
  }
@@ -1,11 +1,15 @@
1
- var dispatch = "dispatchEvent" in document ? function dispatchEvent(target, event) {
2
- return target.dispatchEvent(event);
1
+ var dispatch = "dispatchEvent" in document ? function dispatchEvent2(target, event) {
2
+ try {
3
+ return target.dispatchEvent(event);
4
+ } catch (e) {
5
+ return -1;
6
+ }
3
7
  } : function (target, event) {
4
8
  var fire = "on" + event.type;
5
9
  try {
6
10
  return target.fireEvent(fire, event);
7
11
  } catch (e) {
8
- return target[fire] && target[fire](event);
12
+ return -1;
9
13
  }
10
14
  };
11
15
  var isWorseEnv = /MSIE\s([2-9]|10)|Presto/.test(navigator.userAgent);
@@ -16,7 +20,7 @@ function dispatch2(t, e) {
16
20
  var on = 'on' + e.type;
17
21
  var f = t[on];
18
22
  var res = dispatch(t, e);
19
- if (f && (t.nodeType !== 1 || t.constructor === window.HTMLUnknownElement || isWorseEnv && !(on in t.constructor.prototype))) {
23
+ if (f && (res === -1 || t.nodeType && t.nodeType !== 1 || t.constructor === window.HTMLUnknownElement || isWorseEnv && !(on in t.constructor.prototype))) {
20
24
  return f.call(t, e) !== false;
21
25
  }
22
26
  return res;
@@ -1,4 +1,4 @@
1
- function getScreenPosition(target) {
1
+ function getScreenPosition(target, bounding = true) {
2
2
  if (!target) {
3
3
  target = {
4
4
  offsetTop: 0,
@@ -12,7 +12,7 @@ function getScreenPosition(target) {
12
12
  top = target.offsetTop,
13
13
  width = target.offsetWidth,
14
14
  height = target.offsetHeight;
15
- while (target.offsetParent) {
15
+ if (bounding) while (target.offsetParent) {
16
16
  target = target.offsetParent;
17
17
  left += target.offsetLeft - target.scrollLeft + target.clientLeft;
18
18
  top += target.offsetTop - target.scrollTop + target.clientTop;
@@ -30,10 +30,10 @@ function getScreenPosition(target) {
30
30
  }
31
31
  var rect = target.getBoundingClientRect();
32
32
  var { left, top, width, height, right, bottom } = rect;
33
- rect = { left, top, width, height, right, bottom };
34
- if (rect.width === undefined) {
35
- rect.width = rect.right - rect.left;
36
- rect.height = rect.bottom - rect.top;
33
+ if (width === undefined) {
34
+ width = right - left;
35
+ height = bottom - top;
37
36
  }
37
+ rect = { left, top, width, height, right, bottom };
38
38
  return rect;
39
39
  }
@@ -485,28 +485,27 @@ var grid_prototype = {
485
485
  if (rest_height < 1) {
486
486
  return (height - rest_height) / (grid_height - bounds_bottom - bounds_top) * 100 + "%";
487
487
  }
488
- var rest_offset = fromOffset(rest_height / (bounds_top + bounds_bottom) * (parseFloat(grid_padding_top) + parseFloat(grid_padding_bottom)));
488
+ var rest_offset = rest_height / (bounds_top + bounds_bottom) * (grid_padding_top + grid_padding_bottom);
489
489
  if (rest_height < height) {
490
- return `calc(${(height - rest_height) / (grid_height - bounds_bottom - bounds_top) * 100}% + ${rest_offset})`;
490
+ return `calc(${(height - rest_height) / (grid_height - bounds_bottom - bounds_top) * 100}% + ${fromOffset(rest_offset)})`;
491
491
  }
492
- return rest_offset;
492
+ return height / rest_height * rest_offset;
493
493
  }
494
494
  var setRelativeDiv = function (_div, width, height, left, top) {
495
495
  var [bounds_top, bounds_right, bounds_bottom, bounds_left] = bounds;
496
- var computed = getComputedStyle(grid);
497
496
  css(_div, {
498
- width: getDivSize(left, width, bounds_left, bounds_right, grid.width, computed.paddingLeft, computed.paddingRight),
499
- height: getDivSize(top, height, bounds_top, bounds_bottom, grid.height, computed.paddingTop, computed.paddingBottom)
497
+ width: getDivSize(left, width, bounds_left, bounds_right, grid.width, grid_left, grid_right),
498
+ height: getDivSize(top, height, bounds_top, bounds_bottom, grid.height, grid_top, grid_bottom)
500
499
  });
501
500
  if (top <= 0) {
502
- css(_div, { marginTop: fromOffset(- parseFloat(computed.paddingTop)) });
501
+ css(_div, { marginTop: fromOffset(- grid_top) });
503
502
  } else if (top + height >= grid.height) {
504
- css(_div, { marginBottom: fromOffset(-parseFloat(computed.paddingBottom)) });
503
+ css(_div, { marginBottom: fromOffset(-grid_bottom) });
505
504
  }
506
505
  if (left <= 0) {
507
- css(_div, { marginLeft: fromOffset(-parseFloat(computed.paddingLeft)) });
506
+ css(_div, { marginLeft: fromOffset(-grid_left) });
508
507
  } else if (left + width >= grid.width) {
509
- css(_div, { marginRight: fromOffset(-parseFloat(computed.paddingRight)) });
508
+ css(_div, { marginRight: fromOffset(-grid_right) });
510
509
  }
511
510
  }
512
511
  var append = function (point, index, points) {
@@ -607,6 +606,11 @@ var grid_prototype = {
607
606
  }
608
607
  }
609
608
  };
609
+ var computed = getComputedStyle(grid);
610
+ var grid_top = parseFloat(computed.paddingTop);
611
+ var grid_bottom = parseFloat(computed.paddingBottom);
612
+ var grid_left = parseFloat(computed.paddingLeft);
613
+ var grid_right = parseFloat(computed.paddingRight);
610
614
  append(this.breakpoints);
611
615
  var reshapecount = 0;
612
616
  var store = function (point) {
@@ -72,6 +72,18 @@ function ylist(container, generator, $Y) {
72
72
  }
73
73
  return null;
74
74
  };
75
+ var getRelativeElement = function (element, delta) {
76
+ delta = +delta;
77
+ if (!delta || !isFinite(element.index)) return;
78
+ var target = element.index + delta;
79
+ if (!target) return;
80
+ if (delta < 0) var key = "previousElementSibling";
81
+ else key = "nextElementSibling";
82
+ while (element) {
83
+ if (element.index === target) return element;
84
+ element = element[key];
85
+ }
86
+ }
75
87
  var hasCover = function (child) {
76
88
  var scrollTop = list.scrollTop;
77
89
  if (child.offsetTop + child.offsetHeight < scrollTop || child.offsetTop >= scrollTop + list.clientHeight) return false;
@@ -581,6 +593,7 @@ function ylist(container, generator, $Y) {
581
593
  else if (emit) list.setFocus(e, true), dispatch(list, 'focused');
582
594
  else list.setFocus(e);
583
595
  };
596
+ list.getRelativeElement = getRelativeElement;
584
597
  return list;
585
598
  }
586
599
  var allArgumentsNames = arguments[arguments.length - 1];
@@ -667,6 +680,5 @@ function list() {
667
680
  if (src && old) children = Array.prototype.filter.call(children, c => src[c.index] !== old[c.index]);
668
681
  remove(children);
669
682
  };
670
-
671
683
  return list;
672
684
  }
package/coms/zimoli/on.js CHANGED
@@ -416,7 +416,7 @@ var on = document.efronton = function (k) {
416
416
  var invoke = function (event, type, pointerType) {
417
417
  var target = event.target;
418
418
  var touch = event.changedTouches ? event.changedTouches[0] : event;
419
- var clickEvent = document.createEvent("MouseEvents");
419
+ var clickEvent = createEvent("MouseEvents");
420
420
  clickEvent.touchend = true;
421
421
  clickEvent.pointerType = pointerType
422
422
  clickEvent.initMouseEvent(type, true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
@@ -426,6 +426,7 @@ var invoke = function (event, type, pointerType) {
426
426
  (function () {
427
427
  var pointeractive = null;
428
428
  if ("onpointerdown" in document) return;
429
+ document.onpointerdown = null;
429
430
  var getPointerType = function (event) {
430
431
  return event.type.replace(/(start|move|end|cancel|down|up|leave|out|over|enter)$/i, '');
431
432
  };
@@ -163,7 +163,7 @@ function picture(url, to = 0, key) {
163
163
  var urls = [].concat(url);
164
164
  var p = slider(gen, false);
165
165
  }
166
- p.go(to);
166
+ if (isFinite(to)) p.go(to);
167
167
  p.getScale = function () {
168
168
  if (p.current) return p.current.getScale();
169
169
  return 1;
@@ -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
  }
@@ -68,6 +68,8 @@ function slider() {
68
68
  direction,
69
69
  _speed = speed(1);
70
70
  var reshape = function (index, ising, emit) {
71
+ if (!isFinite(index)) return;
72
+ index = +index;
71
73
  outter.index = current_index = index;
72
74
  var width = outter.clientWidth || +innerWidth;
73
75
  var indexLeft = floor(index);
@@ -272,6 +274,8 @@ function slider() {
272
274
  })
273
275
 
274
276
  outter.go = lazy(function (index, cache) {
277
+ if (!isFinite(index)) return;
278
+ index = +index;
275
279
  if (outter.index === index && cache !== false) return;
276
280
  negative_index = -index;
277
281
  var _removingMain = _imageMain;