efront 4.10.2 → 4.11.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.
@@ -43,6 +43,10 @@
43
43
  color: #569cd6;
44
44
  }
45
45
 
46
+ selector {
47
+ color: #d7ba7d;
48
+ }
49
+
46
50
  @deep(@num, @color) {
47
51
  deep@num {
48
52
  color: @color;
@@ -141,6 +145,74 @@
141
145
  }
142
146
  }
143
147
  }
148
+ var 素心 = new compile$素馨.素心;
149
+ 素心.scopes.push(['[', ']']);
150
+ 素心.straps.push('important',
151
+ 'after', 'backdrop', 'before',
152
+ 'cue', 'cue-range',
153
+ 'file-selector-button', 'first-letter', 'last-letter', 'first-line',
154
+ 'grammer-error', 'highlight', 'marker', 'part',
155
+ 'placeholder', 'selection', 'slotted', 'spelling-error', 'target-text',
156
+ 'view-transition', 'view-transition-group', 'view-transition-image-pair', 'view-transition-new', 'view-transition-old',
157
+ 'active', 'any-link', 'autofill',
158
+ 'blank',
159
+ 'checked', 'current',
160
+ 'dir', 'default', 'defined', 'disabled',
161
+ 'empty', 'enabled',
162
+ 'first', 'first-child', 'first-of-type', 'future', 'focus', 'focus-visible', 'focus-within', 'fullscreen',
163
+ 'has', 'host', 'host-context', 'hover',
164
+ 'indeterminate', 'in-range', 'invalid', 'is',
165
+ 'lang', 'last-child', 'last-of-type', 'left', 'link', 'local-link',
166
+ 'modal',
167
+ 'not', 'nth-child', 'nth-col', 'nth-last-child', 'nth-last-col', 'nth-last-of-type', 'nth-of-type',
168
+ "only-child", 'only-of-type', 'optional', 'out-of-range',
169
+ 'past', 'picture-in-picture', 'placeholder-shown', 'paused', 'playing',
170
+ 'read-only', 'read-write', 'required', 'right', 'root',
171
+ 'scope', 'state',
172
+ 'target', 'target-within',
173
+ 'user-invalid',
174
+ 'valid', 'visited',
175
+ 'where'
176
+ );
177
+ 素心.stamps.push("=");
178
+ var setless = function (c) {
179
+ var set = function (o) {
180
+ if (o.type === PROPERTY) {
181
+ var q = o.queue;
182
+ if (q.type === SCOPED && q.entry !== "{") return;
183
+ var next = o.next;
184
+ if (next && (next.type !== STAMP || !/^[\:\=]$/.test(next.text))) {
185
+ o.text = `<selector>${o.text}</selector>`;
186
+ return;
187
+ }
188
+ if (next && (next.type === STAMP && next.text === ':')) {
189
+ while (next && next.type !== SCOPED) {
190
+ if (next.type === STAMP && next.text === ';') return;
191
+ next = next.next;
192
+ }
193
+ if (next) o.text = `<selector>${o.text}</selector>`;
194
+ }
195
+ return;
196
+ }
197
+ if (o.type === EXPRESS) {
198
+ var next = o.next;
199
+ if (next?.type === SCOPED) return;
200
+ if (!o.length) o.type = QUOTED;
201
+ return;
202
+ }
203
+ if (o.type === STRAP) {
204
+ if (!o.isprop) return o.type = EXPRESS;
205
+ var p = o.prev;
206
+ if (!/^@/.test(o.text) && (!p || p.type !== STAMP || !/\:$/.test(p.text))) o.type = PROPERTY;
207
+ return;
208
+ }
209
+
210
+ if (o.type === SCOPED && o.length) {
211
+ o.forEach(set);
212
+ }
213
+ };
214
+ c.forEach(set);
215
+ };
144
216
  var codesupports = {
145
217
  javascript(a, blink) {
146
218
  if (blink) var index = a.indexOf(blink);
@@ -165,6 +237,12 @@
165
237
  codecolor(c, encode);
166
238
  return c.toString();
167
239
  },
240
+ less(a) {
241
+ var c = compile$scanner2(a, 素心);
242
+ setless(c);
243
+ codecolor(c, encode);
244
+ return c.toString();
245
+ },
168
246
  rs(a) {
169
247
  var c = compile$scanner2(a, rust);
170
248
  codecolor(c, encode);
@@ -179,24 +257,26 @@
179
257
  var code = compile$scanner2(a, 'html');
180
258
  var scoped = code.scoped;
181
259
  backEach(scoped.richNodes, n => {
182
- if (n.isScript) {
183
- var js = [];
260
+ if (n.isScript || n.isStyle) {
261
+ var s = n.isScript ? js : 素心;
262
+ var c = [];
184
263
  compile$common.createString(n).replace(/^(\s*\<\!--)([\s\S]*)(--\!?\>\s*)$|^[\s\S]*$/, (m, p, a, f) => {
185
264
  if (!a) {
186
- js = compile$scanner2(m);
265
+ c = compile$scanner2(m, s);
187
266
  }
188
267
  else {
189
- js = compile$scanner2(a);
190
- js.unshift(
268
+ c = compile$scanner2(a, s);
269
+ c.unshift(
191
270
  { type: compile$common.COMMENT, text: p },
192
271
  );
193
- js.push(
272
+ c.push(
194
273
  { type: compile$common.COMMENT, text: f }
195
274
  );
196
275
  }
197
- codecolor(js, encode);
276
+ if (n.isStyle) setless(c);
277
+ codecolor(c, encode);
198
278
  });
199
- n.splice(0, n.length, ...js);
279
+ n.splice(0, n.length, ...c);
200
280
  }
201
281
  })
202
282
  codecolor(code, encode);
@@ -210,10 +290,11 @@
210
290
  };
211
291
  codesupports.gl = codesupports.glsl;
212
292
  codesupports.cmd = codesupports.bat;
293
+ codesupports.css = codesupports.less;
213
294
  codesupports.cjs = codesupports.mjs = codesupports.jsx = codesupports.js = codesupports.javascript;
214
295
  codesupports.tsx = codesupports.ts = codesupports.typescript;
215
- codesupports.jsp = codesupports.asp = codesupports.php = codesupports.xml = codesupports.html;
216
- var { SCOPED, QUOTED, SPACE, STRAP, EXPRESS, PROPERTY } = compile$common;
296
+ codesupports.xht = codesupports.jsp = codesupports.asp = codesupports.php = codesupports.xml = codesupports.html;
297
+ var { SCOPED, QUOTED, SPACE, STAMP, STRAP, EXPRESS, PROPERTY } = compile$common;
217
298
  var patchBlink = function (code, index, blink) {
218
299
  for (var cx = 0, dx = code.length; cx < dx; cx++) {
219
300
  var c = code[cx];
@@ -281,14 +362,18 @@
281
362
  }
282
363
  else text = encode(text);
283
364
  var codes = text.split(/\r\n|\r|\n/);
284
- var minSpace = 0;
365
+ var minSpace = Infinity;
285
366
  for (var c of codes) {
286
- var m = /^\s*/.exec(c);
287
- if (m && m[0].length < minSpace) {
367
+ var m = /^\s+/.exec(c);
368
+ if (!m) {
369
+ minSpace = 0;
370
+ break;
371
+ }
372
+ if (m[0].length < minSpace) {
288
373
  minSpace = m[0].length;
289
374
  }
290
375
  }
291
- if (minSpace > 0) codes = codes.map(c => /^\s+/.test(c) ? c.slice(minSpace) : c);
376
+ if (minSpace > 0 && minSpace < Infinity) codes = codes.map(c => /^\s+/.test(c) ? c.slice(minSpace) : c);
292
377
  return codes;
293
378
  }
294
379
  function codetext(type, text, blink) {
@@ -11,6 +11,18 @@ var cloneChildNodes = function (template) {
11
11
  }
12
12
  return cNodes;
13
13
  }
14
+ var merge = function (dst, src) {
15
+ if (!src) return dst;
16
+ if (!dst) return src;
17
+ if (dst instanceof Array) {
18
+ return dst.concat(src);
19
+ }
20
+ if (isObject(dst)) return Object.assign(dst, src);
21
+ return src;
22
+ };
23
+ var mergeStruct = function (struct1, struct2) {
24
+ for (var k in struct2) struct1[k] = merge(struct1[k], struct2[k]);
25
+ }
14
26
  /**
15
27
  * @param {Element} container
16
28
  * @param {Element|string} tagName;
@@ -22,6 +34,7 @@ var getGenerator = function (container, tagName = 'item') {
22
34
  container.$generatorScopes = scopes;
23
35
  if (container.$generator) return container.$generator;
24
36
  var template = document.createElement(container.tagName);
37
+ var tagTemplate = isElement(tagName);
25
38
  var templates = [];
26
39
  var hasAfter = false;
27
40
  for (let a of container.childNodes) {
@@ -42,8 +55,22 @@ var getGenerator = function (container, tagName = 'item') {
42
55
  var paddingCount = [].indexOf.call(container.childNodes, c);
43
56
  container.paddingCount = paddingCount;
44
57
  }
58
+ if (tagTemplate) {
59
+ if (!templates.length) {
60
+ templates = [tagName];
61
+ tagTemplate = false;
62
+ }
63
+ }
64
+
45
65
  appendChild(template, templates);
46
66
  render.struct(templates);
67
+ if (tagTemplate) {
68
+ render.struct(tagName);
69
+ var template0 = templates[0];
70
+ mergeStruct(tagName.$struct, template0.$struct);
71
+ template0.$struct = tagName.$struct;
72
+ template0.$renderid = tagName.$renderid;
73
+ }
47
74
  if (templates.length) container.$template = template;
48
75
  /**
49
76
  * @param {number} index;
@@ -56,28 +83,19 @@ var getGenerator = function (container, tagName = 'item') {
56
83
  com = container.src[index];
57
84
  }
58
85
  if (com === undefined) return;
59
- var needSetAttr = isElement(tagName);
60
86
  if (isNode(element));
61
87
  else if (!template.childNodes.length) {
62
- element = needSetAttr ? tagName.cloneNode(true) : document.createElement(tagName);
63
- needSetAttr = false;
88
+ element = document.createElement(tagName);
64
89
  }
65
90
  else {
66
91
  var childNodes = cloneChildNodes(template);
67
92
  element = childNodes[0];
68
93
  if (childNodes.length > 1) element.with = Array.prototype.slice.call(childNodes, 1);
69
94
  }
70
- if (needSetAttr) {
71
- for (var a of tagName.attributes) {
72
- element.setAttribute(a.name, a.value);
73
- }
74
- }
75
95
  var scopes = container.$generatorScopes;
76
96
  var parsedSrc = container.$src;
77
97
  if (parsedSrc) {
78
98
  var newScope = parsedSrc.createScope(com, index, index);
79
- var newItem = render(element, newScope, scopes, false);
80
- if (element.with) newItem.with = render(element.with, newScope, scopes, false);
81
99
  } else {
82
100
  var newScope = container.src[index];
83
101
  if (!isObject(newScope)) newScope = {
@@ -97,9 +115,11 @@ var getGenerator = function (container, tagName = 'item') {
97
115
  return this.$item;
98
116
  }
99
117
  }
100
- var newItem = render(element, newScope, scopes, false);
101
- if (element.with) newItem.with = render(element.with, newScope, scopes, false);
102
118
  }
119
+ element.$scope = newScope;
120
+ element.$parentScopes = scopes;
121
+ var newItem = render(element, newScope, scopes, false);
122
+ if (element.with) newItem.with = render(element.with, newScope, scopes, false);
103
123
  return newItem;
104
124
  };
105
125
  };
@@ -111,6 +111,7 @@ var variableReg = /([^\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<~\{\}\s\[\]\(\)]|\?\s*\.(
111
111
  var variableOnlyReg = new RegExp(`^${variableReg.source}$`);
112
112
  var createGetter = function (target, search, isprop = true) {
113
113
  if (!search) return function () { };
114
+ if (/^\{/.test(search)) search = `(${search})`;
114
115
  search = renderExpress(search);
115
116
  if (isprop) return $$eval.bind(target, search, null);
116
117
  if (variableOnlyReg.test(search)) return $$eval.bind(target, search + "(event)", null);
@@ -558,7 +559,7 @@ var directives = {
558
559
  },
559
560
 
560
561
  "class"(search) {
561
- var getter = createGetter(this, `(${search})`);
562
+ var getter = createGetter(this, search);
562
563
  var generatedClassNames = {};
563
564
  var oldValue;
564
565
  this.$renders.push(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.10.2",
3
+ "version": "4.11.1",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {