efront 3.35.0 → 3.35.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.
@@ -3,7 +3,8 @@ function createSeek(express) {
3
3
  express.forEach(function (search) {
4
4
  if (dist) {
5
5
  if (/[\=]/.test(dist)) dist = `(${dist})`;
6
- dist = `typeof ${dist}!=='undefined'&&${dist}!==null?${dist}${search}:''`
6
+ var pd = /[\.\[]/.test(dist) ? `${dist}!==void 0` : `typeof ${dist}!=='undefined'`;
7
+ dist = `${pd}&&${dist}!==null?${dist}${search}:''`
7
8
  } else {
8
9
  dist = search;
9
10
  }
@@ -18,6 +18,7 @@ const {
18
18
  createString,
19
19
  getDeclared,
20
20
  createScoped,
21
+ snapExpressHead,
21
22
  relink,
22
23
  skipAssignment,
23
24
  } = require("./common");
@@ -180,8 +181,13 @@ var isShortMethodEnd = function (o) {
180
181
  };
181
182
 
182
183
  Javascript.prototype.setType = function (o) {
183
- this.fixType(o);
184
184
  var last = o.prev;
185
+ if (o.type === EXPRESS && /^\.[^\.]/.test(o.text) && last.type === STAMP && last.text === "?") {
186
+ last = o.prev = snapExpressHead(last.prev);
187
+ last.type = EXPRESS;
188
+ return false;
189
+ }
190
+ this.fixType(o);
185
191
  var queue = o.queue;
186
192
  if (queue.isObject || queue.isClass) {
187
193
  if (o.type & (VALUE | QUOTED | STRAP)) {
@@ -282,13 +288,32 @@ var collectProperty = function (o, text) {
282
288
  q.defined[text] = o;
283
289
  };
284
290
 
291
+ var replace = function (o, ...args) {
292
+ var queue = o.queue;
293
+ var i = queue.indexOf(o);
294
+ if (i >= 0) queue.splice(i, 1, ...args);
295
+ var prev = o.prev;
296
+ var next = o.next;
297
+ if (!args.length) {
298
+ if (prev) prev.next = next;
299
+ else queue.first = next;
300
+ if (next) next.prev = prev;
301
+ else queue.last = prev;
302
+ }
303
+ else {
304
+ if (prev) prev.next = args[0], args[0].prev = prev;
305
+ else queue.first = args[0];
306
+ if (next) next.prev = args[args.length - 1], args[args.length - 1].next = next;
307
+ else queue.last = args[args.length - 1];
308
+ }
309
+ return args.length ? args[0] : next;
310
+ };
285
311
  var hasComma = function (c) {
286
312
  for (var cc of c) {
287
313
  if (cc.type === STAMP && cc.text === ',') return true;
288
314
  }
289
315
  return false;
290
316
  }
291
-
292
317
  var removeQoute = function (o, c, i) {
293
318
  if (hasComma(c)) return;
294
319
  if (!isFinite(i)) i = o.indexOf(c);
@@ -309,13 +334,21 @@ Javascript.prototype.detour = function detour(o, ie) {
309
334
  this.detour(o.first, ie);
310
335
  break;
311
336
  case EXPRESS:
337
+ var text = o.text.replace(/^\.\.\./, '');
338
+ var hasdot = o.text.length !== text.length;
312
339
  if (avoidMap) {
313
- var m = /^[^\.\[\]]+/.exec(o.text.replace(/^\.\.\./, ''));
340
+ var m = /^[^\.\[\]]+/.exec(o.text);
314
341
  if (m) { avoidMap[m[0]] = true; }
315
342
  }
316
- if (!/^\.\.\.|\.\.\.$/.test(o.text)) {
317
- o.text = o.text.replace(/\.([^\.\[]+)/g, (_, a) => ie === undefined || this.strap_reg.test(a) ? `[${strings.recode(a)}]` : _);
343
+ if (/\?\./.test(text)) {
344
+ text = renderExpress(text);
345
+ if (hasdot) text = "..." + text;
346
+ o = replace(o, ...scan(text));
347
+ continue;
318
348
  }
349
+ text = text.replace(/\.([^\.\[\!\=\:]+)/g, (_, a) => ie === undefined || this.strap_reg.test(a) ? `[${strings.recode(a)}]` : _);
350
+ if (hasdot) text = "..." + text;
351
+ o.text = text;
319
352
  break;
320
353
  case QUOTED:
321
354
  if (o.length) {
@@ -188,7 +188,9 @@ class Program {
188
188
  scope.prev = last;
189
189
  if (scope.type !== COMMENT && scope.type !== SPACE) {
190
190
  if (program.setType(scope) === false) {
191
- last = scope.prev;
191
+ if (queue.last !== last) last = queue.last;
192
+ else if (scope.prev !== last) last = scope.prev;
193
+ while (queue[queue.length - 1] !== last) queue.pop();
192
194
  last.end = scope.end;
193
195
  last.text = text.slice(last.start, last.end);
194
196
  return;
@@ -237,7 +237,7 @@ var snapExpressHead = function (o) {
237
237
  while (o && o.prev) {
238
238
  var p = o.prev;
239
239
  if (p.type & (EXPRESS | VALUE)) {
240
- if (o.type === SCOPED && o.entry === '[' || o.type === EXPRESS && /^\./.test(o.text) || /\.$/.test(p.text) && !p.isdigit) {
240
+ if (o.type === SCOPED && o.entry === '[' || o.type === EXPRESS && /^\??\.[^\.]/.test(o.text) || /\.$/.test(p.text) && !p.isdigit) {
241
241
  o = p;
242
242
  continue;
243
243
  }
@@ -250,7 +250,7 @@ var snapExpressFoot = function (o) {
250
250
  if (!o || !(o.type & (EXPRESS | VALUE))) return;
251
251
  while (o && o.next) {
252
252
  var n = o.next;
253
- if (n.type === SCOPED && o.entry === '[' || /\.$/.test(o.text) && !o.isdigit || n.type === EXPRESS && /^\./.test(n.text)) {
253
+ if (n.type === SCOPED && o.entry === '[' || /\.$/.test(o.text) && !o.isdigit || n.type === EXPRESS && /^\??\.[^\.]/.test(n.text)) {
254
254
  if (n.type & (EXPRESS | SCOPED)) {
255
255
  o = n;
256
256
  continue;
@@ -2,9 +2,16 @@
2
2
 
3
3
  var fs = require("fs").promises;
4
4
  var path = require("path");
5
- var comm_file_reg = /\.([tj]sx?|xht|md)$/i;
5
+ var comm_file_reg = /\.([tj]sx?|xht|md|less)$/i;
6
+ var basepath = path.join(String(__efront), 'coms');
7
+ if (req.id) {
8
+ var compath = path.join(basepath, req.id);
9
+ if (!comm_file_reg.test(req.id) || !/^\.\./.test(path.relative(compath, basepath))) return forbidden("禁止访问");
10
+ return fs.readFile(compath);
11
+ }
12
+
6
13
  var readdir = async function (a) {
7
- var b = path.join(__efront, "coms", a);
14
+ var b = path.join(basepath, a);
8
15
  var names = await fs.readdir(b);
9
16
  names = names.filter(name => {
10
17
  if (/#/.test(name) || !comm_file_reg.test(name)) return false;
package/docs/index.html CHANGED
@@ -39,6 +39,8 @@
39
39
  </script>
40
40
  </head>
41
41
 
42
- <body scroll=no max-render=1440></body>
42
+ <body scroll=no max-render=1440>
43
+ 走过多少路口,听过多少叹息,我认真着你的不知所措..
44
+ </body>
43
45
 
44
46
  </html>
package/docs/main.xht CHANGED
@@ -3,6 +3,7 @@
3
3
  --leftwidth: 260px;
4
4
  display: block;
5
5
  width: auto;
6
+ top: 0;
6
7
  left: 0;
7
8
  right: 0;
8
9
  margin-right: -16px;
@@ -21,16 +22,25 @@
21
22
  vertical-align: top;
22
23
  }
23
24
 
24
- div2 test:before {
25
+ :root>menu f {
26
+ margin-left: 6px;
27
+ }
28
+
29
+ :root>menu f[test]:before {
25
30
  color: #fc0;
26
31
  content: "测";
27
32
  }
28
-
29
- div2 dang:before {
33
+
34
+ :root>menu f[dang]:before {
30
35
  color: #2cf;
31
36
  content: "档";
32
37
  }
33
38
 
39
+ :root>menu f[less]:before {
40
+ color: #2c9;
41
+ content: "样";
42
+ }
43
+
34
44
  menu {
35
45
  width: var(--leftwidth);
36
46
  margin-left: -var(--leftwidth);
@@ -51,6 +61,12 @@
51
61
  position: relative;
52
62
  background: linear-gradient(#f2f4ff, 70%, #e9fff2);
53
63
  }
64
+ :root>menu v{
65
+ display: inline-block;
66
+ font-size: 12px;
67
+ color: #79a;
68
+ margin-left: 12px;
69
+ }
54
70
  </style>
55
71
  <menu #mulu inline -src="m in menus" @active="openMenu(m)">
56
72
  <div2></div2>
@@ -92,10 +108,16 @@
92
108
  }
93
109
  ]);
94
110
  })
111
+ var initVersionInfo = async function () {
112
+ var xhr = await cross("get", "version");
113
+ console.log(xhr)
114
+ var version = xhr.response.split(",");
115
+ menus[0].name += ` <v>${version[0]}</v>`;
116
+ }
95
117
  var initCommandsDocs = async function () {
96
118
  var helps = await init("docs$helps");
97
119
  var m = {
98
- name: "命令详解",
120
+ name: "命令参考",
99
121
  children: [
100
122
  { name: "防御系", a: "f" },
101
123
  { name: "强攻系", a: "q" },
@@ -129,11 +151,13 @@
129
151
  }
130
152
  for (var cc of children) {
131
153
  cc.data = {
132
- mark: !!map[cc.name.replace(/\.js$/i, ".md")],
133
- test: !!map[cc.name.replace(/\.js$/i, "_test.js")]
154
+ mark: !!map[cc.name.replace(/\.[tj]sx?$/i, ".md")],
155
+ test: !!map[cc.name.replace(/\.[tj]sx?$/i, "_test.js")],
156
+ less: !!map[cc.name.replace(/\.[tj]sx?$/i, ".less")]
134
157
  }
135
- if(cc.data.mark)cc.name+="<dang></dang>"
136
- if(cc.data.test)cc.name+="<test></test>"
158
+ if (cc.data.less) cc.name += "<f less></f>"
159
+ if (cc.data.mark) cc.name += "<f dang></f>"
160
+ if (cc.data.test) cc.name += "<f test></f>"
137
161
  }
138
162
  c.children = children;
139
163
  c.closed = true;
@@ -144,6 +168,7 @@
144
168
  var initMenus = async function () {
145
169
  menus[0].children.forEach(c => { c.path = "/mark/" + c.md });
146
170
  zimoli.switch('', scope.content, menus[0].children[0].path);
171
+ await initVersionInfo();
147
172
  await initCommandsDocs();
148
173
  await initComponentDocs();
149
174
  var route = await init("frame$route");
package/docs/mark.xht CHANGED
@@ -143,11 +143,16 @@
143
143
  var target = this;
144
144
  var href = target.getAttribute("href");
145
145
  event.preventDefault();
146
- if (!/^\w+:/.test(href) && /\.md$/i.test(href)) {
147
- href = md.replace(/[^\/]+$/, "") + href;
148
- href = decodeURI(href);
149
- console.log(href)
150
- go('/mark/' + href);
146
+ if (!/^\w+:/.test(href)) {
147
+ if (/\.md$/i.test(href)) {
148
+ href = md.replace(/[^\/]+$/, "") + href;
149
+ href = decodeURI(href);
150
+ console.log(href)
151
+ go('/mark/' + href);
152
+ }
153
+ else {
154
+ window.open('https://github.com/yunxu1019/efront/blob/develop/' + md.replace(/[^\/]+$/, "") + href);
155
+ }
151
156
  }
152
157
  else {
153
158
  window.open(href);
@@ -0,0 +1,3 @@
1
+ <script serverside>
2
+ return __efront.version;
3
+ </script>
package/docs/welcome.jsp CHANGED
@@ -1,4 +1,5 @@
1
1
  <script serverside>
2
+ __efront = String(__efront);
2
3
  var fullpath = path.join(__efront, req.id);
3
4
  if (!/^\.\./.test(path.relative(fullpath, __efront)) || !/\.md$/.test(req.id)) {
4
5
  return forbidden("禁止访问!");
@@ -5,11 +5,13 @@
5
5
  display: block;
6
6
  }
7
7
 
8
- p {
8
+ p4 {
9
9
  line-height: 1.8;
10
+ display: block;
11
+ margin: 20px 0;
10
12
  }
11
13
 
12
- m {
14
+ p4 m{
13
15
  line-height: 1.2;
14
16
  display: inline-block;
15
17
  margin-right: 6px;
@@ -34,46 +36,68 @@
34
36
  color: #29f;
35
37
  }
36
38
 
39
+ b[l] {
40
+ color: #29c;
41
+ }
42
+
37
43
  h2 b {
38
44
  font-size: 14px;
39
45
  display: inline-block;
40
46
  border: 1.2px solid;
47
+ margin-left: 6px;
48
+ padding: 2px 4px;
41
49
  }
42
- markdown{
50
+
51
+ markdown {
43
52
  margin: 0 -20px;
44
53
  }
45
54
  </style>
46
55
  <h2>
47
56
  <span -bind="name"></span>
57
+ <b -if="doc?.less" l>有样式表</b>
48
58
  <b -if="doc?.mark" w>有文档</b>
49
59
  <b -if="doc?.test" t>有测试代码</b>
50
60
  </h2>
51
61
  <container -if="doc?.url" .src="doc.url">
52
62
  </container>
53
- <p envs>
54
- <span -if="com?.args.length">
55
- 环境依赖项:&nbsp; <m -repeat="c in com.args" -bind="c"> </m>
63
+ <p4 envs>
64
+ <span -if="envs?.length">
65
+ 环境依赖项:&nbsp; <m -repeat="c in envs" -bind="c"> </m>
56
66
  </span>
57
67
  <span -else> 无环境依赖项 </span>
58
- </p>
59
- <p imported>
60
- <span -if="com?.required.length">
61
- 导入项:&nbsp;<m -repeat="c in com.required" -bind="c"></m>
68
+ </p4>
69
+ <p4 imported>
70
+ <span -if="required?.length">
71
+ 导入项:&nbsp;<m -repeat="c in required" -bind="c"></m>
62
72
  </span>
63
73
  <span -else>
64
74
  无导入项
65
75
  </span>
66
- </p>
76
+ </p4>
67
77
  <script>
68
- var 分析 = async function (com, props) {
69
- scope.name = com;
70
- await new Promise(ok => load(com, ok));
71
- var loaded = loadedModules[com];
72
- scope.com = loaded;
73
- scope.doc = props;
78
+ var 分析 = lazy(async function (com, props) {
74
79
  if (props.mark) props.url = '/mark/coms/' + com.replace(/\.js$/i, '.md');
80
+ scope.doc = props;
81
+ scope.name = com;
82
+ var xhr = await cross("get", "./components:" + com);
83
+ var code = compile$scanner2(xhr.response);
84
+ code.fix();
85
+ var envs = code.envs;
86
+ if (props.less) envs.cless = true;
87
+ var required = [];
88
+ if (envs.require) code.used.require.forEach(r => {
89
+ var next = r.next;
90
+ if (!next) return;
91
+ if (next.type !== code.SCOPED || next.entry !== '(') return;
92
+ var first = next.first;
93
+ if (!first || first.type !== code.QUOTED) return;
94
+ var req = code.program.createString([first]);
95
+ required.push(req);
96
+ });
97
+ scope.required = required;
98
+ scope.envs = Object.keys(envs);
75
99
  render.refresh();
76
- };
100
+ });
77
101
  var page = document.createElement("component");
78
102
  page.innerHTML = template;
79
103
  var scope = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.35.0",
3
+ "version": "3.35.1",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {