efront 4.11.0 → 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.
- package/coms/basic/getName.js +4 -4
- package/coms/compile/Html.js +2 -1
- package/coms/compile/Html_test.js +6 -3
- package/coms/compile/Program.js +10 -3
- package/coms/compile//347/264/240/351/246/250.js +14 -10
- package/coms/compile//347/264/240/351/246/250_test.js +7 -3
- package/coms/docs/codecolor.js +9 -8
- package/coms/docs/codetext.xht +91 -10
- package/coms/zimoli/getGenerator.js +32 -12
- package/coms/zimoli/render.js +2 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/basic/getName.js
CHANGED
|
@@ -9,11 +9,11 @@ function getName(o) {
|
|
|
9
9
|
if (!isEmpty(name)) return String(name);
|
|
10
10
|
}
|
|
11
11
|
for (var k of keys) {
|
|
12
|
-
|
|
13
|
-
if (!isEmpty(o
|
|
14
|
-
if (isString(
|
|
12
|
+
var v = o[k];
|
|
13
|
+
if (!isEmpty(v) && hasOwnProperty.call(o, k)) return String(v);
|
|
14
|
+
if (isString(v)) name = v;
|
|
15
15
|
}
|
|
16
|
-
if (hasOwnProperty.call(o, 'valueOf')) name = o.valueOf();
|
|
16
|
+
if (!name && hasOwnProperty.call(o, 'valueOf')) name = o.valueOf();
|
|
17
17
|
if (isString(name)) return name;
|
|
18
18
|
return String(o);
|
|
19
19
|
}
|
package/coms/compile/Html.js
CHANGED
|
@@ -88,7 +88,7 @@ var replaceISO8859 = function (data) {
|
|
|
88
88
|
return String(data).replace(/<\!--([\s\S]*)--\>$/g, '$1').replace(/&\w+;/g, a => iso8859[a] || a).replace(/&#(\d+);/g, (_, a) => String.fromCodePoint(a))
|
|
89
89
|
};
|
|
90
90
|
var parseExpress = function (data, mayberepeat) {
|
|
91
|
-
data = replaceISO8859(data);
|
|
91
|
+
data = "=" + replaceISO8859(data);
|
|
92
92
|
if (mayberepeat && /\s+(in|of)\s+/.test(data)) {
|
|
93
93
|
data = data.split(/\s+(in|of)\s+/).pop();
|
|
94
94
|
}
|
|
@@ -132,6 +132,7 @@ Html.prototype.createScoped = function (code) {
|
|
|
132
132
|
else if (c.tagName === 'STYLE') {
|
|
133
133
|
styleNodes.push(c);
|
|
134
134
|
tempNodes.push(c);
|
|
135
|
+
c.isStyle = true;
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -7,6 +7,7 @@ var test = function (source, pick, value) {
|
|
|
7
7
|
if (arguments.length === 2) source = pick;
|
|
8
8
|
assert(h.createString(b), source);
|
|
9
9
|
if (arguments.length === 3) {
|
|
10
|
+
b.scoped = h.createScoped(b);
|
|
10
11
|
assert(seek(b, pick), value);
|
|
11
12
|
}
|
|
12
13
|
};
|
|
@@ -31,7 +32,9 @@ test('<div>$\\{${`<div></div>`}</div>');
|
|
|
31
32
|
test('<div>$\\{${typeof `<div></div>`}</div>');
|
|
32
33
|
test('<div>$\\{${\\a+typeof`<div></div>`}</div>', '<div>$\\{${\\a + typeof `<div></div>`}</div>');
|
|
33
34
|
test('${i18n`加载中..`}<div class="loader"></div>');
|
|
34
|
-
test('${a +typeof i18n`加载中..`}<div class="loader"></div>','${a + typeof i18n`加载中..`}<div class="loader"></div>');
|
|
35
|
+
test('${a +typeof i18n`加载中..`}<div class="loader"></div>', '${a + typeof i18n`加载中..`}<div class="loader"></div>');
|
|
35
36
|
test('${a > 1}');
|
|
36
|
-
test('a>1','a > 1');
|
|
37
|
-
test('a><a></a>','a > <a></a>');
|
|
37
|
+
test('a>1', 'a > 1');
|
|
38
|
+
test('a><a></a>', 'a > <a></a>');
|
|
39
|
+
test('X', 'X');
|
|
40
|
+
test('<input -class="{actived:actived===f}"/>', 'scoped.envs.actived', true);
|
package/coms/compile/Program.js
CHANGED
|
@@ -13,6 +13,7 @@ const {
|
|
|
13
13
|
/*2048 */ELEMENT,
|
|
14
14
|
createString,
|
|
15
15
|
number_reg,
|
|
16
|
+
digit_reg,
|
|
16
17
|
} = require("./common");
|
|
17
18
|
var combine = require("../basic/combine");
|
|
18
19
|
var sortRegster = require("../basic/sortRegister");
|
|
@@ -105,6 +106,7 @@ class Program {
|
|
|
105
106
|
stamps = "/=+;|:?<>-!~%^&*,".split("")
|
|
106
107
|
value_reg = /^(false|true|null)$/
|
|
107
108
|
number_reg = number_reg;
|
|
109
|
+
digit_reg = digit_reg;
|
|
108
110
|
Code = Array;
|
|
109
111
|
powermap = powermap;
|
|
110
112
|
transive_reg = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|default|instanceof|throw|extends|import|from)$/;
|
|
@@ -183,6 +185,7 @@ class Program {
|
|
|
183
185
|
var funcstrap_reg = this.funcstrap_reg;
|
|
184
186
|
var entry_reg = this.entry_reg;
|
|
185
187
|
var type_reg = this.type_reg;
|
|
188
|
+
var digit_reg = this.digit_reg;
|
|
186
189
|
var comment_entry = this.comment_entry;
|
|
187
190
|
var rowsOf = m => m.replace(/[^\r\n\u2028\u2029]+/g, ';').replace(/\r\n|\r|\n|\u2028|\u2029/g, ' ').replace(/;/g, '').length;
|
|
188
191
|
var setRows = m => {
|
|
@@ -479,7 +482,7 @@ class Program {
|
|
|
479
482
|
save(space_reg.test(m) ? SPACE : PIECE);
|
|
480
483
|
}
|
|
481
484
|
}
|
|
482
|
-
m = match[0];
|
|
485
|
+
m = match?.[0];
|
|
483
486
|
}
|
|
484
487
|
loop: while (index < text.length) {
|
|
485
488
|
|
|
@@ -492,6 +495,7 @@ class Program {
|
|
|
492
495
|
var match = reg.exec(text);
|
|
493
496
|
if (!match) {
|
|
494
497
|
index = text.length;
|
|
498
|
+
if (queue === origin) push_piece(index);
|
|
495
499
|
break loop;
|
|
496
500
|
}
|
|
497
501
|
var m = match[0];
|
|
@@ -763,7 +767,7 @@ class Program {
|
|
|
763
767
|
}
|
|
764
768
|
continue;
|
|
765
769
|
}
|
|
766
|
-
var isdigit =
|
|
770
|
+
var isdigit = digit_reg.exec(m);
|
|
767
771
|
if (isdigit) {
|
|
768
772
|
var m1 = isdigit[0];
|
|
769
773
|
if (m1.length < m.length) {
|
|
@@ -1003,7 +1007,10 @@ class Program {
|
|
|
1003
1007
|
var powers_entries = this.createRegExp(this.tags.map(t => t[0]).concat(powers), true).source;
|
|
1004
1008
|
var entries_reg = new RegExp(`^(${powers_entries}|${quotes_entries}|${scopes})$`, this.nocase ? 'iu' : '');
|
|
1005
1009
|
stamps = this.compile(this.stamps.filter(s => !entries_reg.test(s)).join(''));
|
|
1006
|
-
|
|
1010
|
+
var number_reg = this.number_reg;
|
|
1011
|
+
var numbers = number_reg.source.replace(/^\^|\$$/g, "");
|
|
1012
|
+
this.digit_reg = new RegExp(/^[+\-]?/.source + numbers, number_reg.flags);
|
|
1013
|
+
this.entry_reg = new RegExp([`[${spaces}]+|${quotes_entries}|[${scopes}]|${numbers}[^${tokens}]*|${express}|${powers_entries}|[${stamps}]`], "gi" + flagUnicode);
|
|
1007
1014
|
}
|
|
1008
1015
|
}
|
|
1009
1016
|
module.exports = Program;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var { STAMP, PROPERTY, SCOPED, VALUE, EXPRESS, QUOTED, SPACE, COMMENT, createString: _createString, splice } = require("./common");
|
|
1
|
+
var { STAMP, PROPERTY, SCOPED, VALUE, STRAP, EXPRESS, QUOTED, SPACE, COMMENT, createString: _createString, splice } = require("./common");
|
|
2
2
|
var createString = function (a) {
|
|
3
3
|
a.autospace = false;
|
|
4
4
|
return _createString(a);
|
|
@@ -274,25 +274,28 @@ macros.each = function (list, body) {
|
|
|
274
274
|
};
|
|
275
275
|
|
|
276
276
|
|
|
277
|
+
var presets = /^@(media|keyframes|layer|import|namespace|page|property|suppports|font-face|document|counter-style|charset|color-profile|container|font-feature-values|font-palette-values|scope|starting-style)(\s|\(|$)/i;
|
|
277
278
|
class 素心 extends Program {
|
|
278
|
-
straps = ["and"];
|
|
279
|
+
straps = ["and", ...presets.source.replace(/^[\s\S]*?\(([\s\S]*?)\)[\s\S]*$/, '$1').split('|').map(a => "@" + a)];
|
|
279
280
|
stamps = `;:,>+~&!/`.split("");
|
|
280
281
|
quotes = rarg.quotes;
|
|
281
282
|
keepspace = true;
|
|
283
|
+
control_reg = presets;
|
|
282
284
|
scopes = [["{", "}"], ["(", ")"]]
|
|
283
285
|
}
|
|
284
286
|
|
|
285
|
-
var presets = /^@(media|keyframes|layer|import|namespace|page|property|suppports|font-face|document|counter-style|charset|color-profile|container|font-feature-values|font-palette-values)(\s|\(|$)/i;
|
|
286
287
|
|
|
287
288
|
素心.prototype.setType = function (o) {
|
|
288
289
|
var p = o.prev;
|
|
289
290
|
if (o.type !== SCOPED) {
|
|
290
291
|
if (!p || p.type === STAMP && p.text === ";" || p.type === SCOPED && p.entry === '{') {
|
|
291
|
-
o.type = PROPERTY;
|
|
292
|
+
if (o.type === EXPRESS) o.type = PROPERTY;
|
|
293
|
+
o.isprop = true;
|
|
292
294
|
return;
|
|
293
295
|
}
|
|
294
|
-
if (p.
|
|
295
|
-
o.type = PROPERTY;
|
|
296
|
+
if (p.isprop && o.type & ~(STAMP | SCOPED)) {
|
|
297
|
+
if (o.type === EXPRESS) o.type = PROPERTY;
|
|
298
|
+
o.isprop = true;
|
|
296
299
|
return;
|
|
297
300
|
}
|
|
298
301
|
}
|
|
@@ -303,7 +306,7 @@ var presets = /^@(media|keyframes|layer|import|namespace|page|property|suppports
|
|
|
303
306
|
}
|
|
304
307
|
while (p && (p.type !== SCOPED || p.entry !== "{") && (p.type !== STAMP || p.text !== ';')) {
|
|
305
308
|
p.isprop = true;
|
|
306
|
-
if (p.type
|
|
309
|
+
if (p.type === EXPRESS) p.type = PROPERTY;
|
|
307
310
|
p = p.prev;
|
|
308
311
|
}
|
|
309
312
|
}
|
|
@@ -334,13 +337,13 @@ var presets = /^@(media|keyframes|layer|import|namespace|page|property|suppports
|
|
|
334
337
|
for (var cx = 0, dx = code.length; cx < dx; cx++) {
|
|
335
338
|
var o = code[cx];
|
|
336
339
|
if (o && (o.type & (SPACE | COMMENT) || o.type === STAMP && o.text === ';')) continue;
|
|
337
|
-
if (o.
|
|
340
|
+
if (!o.isprop) {
|
|
338
341
|
console.log(createString([o]), o.type, createString(code))
|
|
339
342
|
throw new Error(i18n`结构异常`);
|
|
340
343
|
}
|
|
341
344
|
var p = [], v = [];
|
|
342
345
|
while (o && (o.type !== SCOPED || o.entry !== "{")) {
|
|
343
|
-
if (o.type === STAMP) break;
|
|
346
|
+
if (o.type === STAMP && !o.isprop) break;
|
|
344
347
|
p.push(o);
|
|
345
348
|
o = code[++cx];
|
|
346
349
|
}
|
|
@@ -609,4 +612,5 @@ function 素馨(text, scopeName, compress) {
|
|
|
609
612
|
}
|
|
610
613
|
return a;
|
|
611
614
|
}).filter(a => !!a).join(compress ? "" : "\r\n") + getquried();
|
|
612
|
-
}
|
|
615
|
+
}
|
|
616
|
+
素馨.素心 = 素心;
|
|
@@ -70,7 +70,11 @@ assert(素馨(`a>:root{&:not(a):not(b){c:d}}`, '.abc-'), `a>.abc-:not(a):not(b){
|
|
|
70
70
|
assert(素馨(`.a (){ &:after{abc:1}} .b{.a();}`, '.abc-'), `.abc- .b:after{abc:1;}`);
|
|
71
71
|
assert(素馨(`@a:1px;@margin-x:@a+10px; a{m:-@margin-x}`), `a{m:-11px;}`);
|
|
72
72
|
assert(素馨(`a{@a:1px;@margin-x:@a+10px;m:-@margin-x}`), `a{m:-11px;}`);
|
|
73
|
-
assert(素馨(`@media screen{&.a{b:1}}`,'a'), `@media screen{a.a{b:1;}}`);
|
|
74
|
-
assert(素馨(`@media screen and(max-width:100px){&.a{b:1}}`,'a'), `@media screen and (max-width:100px){a.a{b:1;}}`);
|
|
73
|
+
assert(素馨(`@media screen{&.a{b:1}}`, 'a'), `@media screen{a.a{b:1;}}`);
|
|
74
|
+
assert(素馨(`@media screen and(max-width:100px){&.a{b:1}}`, 'a'), `@media screen and (max-width:100px){a.a{b:1;}}`);
|
|
75
75
|
assert(素馨(`b{:not([resizing], [dragging]) {transition: padding .2s, margin .2s;}}`), `b :not([resizing], [dragging]){transition:padding .2s, margin .2s;}`);
|
|
76
|
-
assert(素馨(`@a(@b){a@b{@w:@b/2;c:@w;}} @a(1); @a(2); @a(3)`)
|
|
76
|
+
assert(素馨(`@a(@b){a@b{@w:@b/2;c:@w;}} @a(1); @a(2); @a(3)`), `a1{c:0.5;}\r\na2{c:1;}\r\na3{c:1.5;}`);
|
|
77
|
+
assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[0].text, '-0.2em');
|
|
78
|
+
assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[0].isdigit, true);
|
|
79
|
+
assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[2].text, ".3em");
|
|
80
|
+
assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[2].isdigit, true);
|
package/coms/docs/codecolor.js
CHANGED
|
@@ -13,6 +13,7 @@ var codecolor = function (c, encode) {
|
|
|
13
13
|
var scoped = c.scoped;
|
|
14
14
|
var setdefs = function (scoped) {
|
|
15
15
|
var { used } = scoped;
|
|
16
|
+
if (!isObject(used) || isArray(used)) return;
|
|
16
17
|
for (var k in used) {
|
|
17
18
|
var isdef = false;
|
|
18
19
|
for (var o of used[k]) {
|
|
@@ -29,12 +30,12 @@ var codecolor = function (c, encode) {
|
|
|
29
30
|
}
|
|
30
31
|
scoped.forEach(setdefs);
|
|
31
32
|
};
|
|
32
|
-
setdefs(scoped);
|
|
33
|
+
if (scoped) setdefs(scoped);
|
|
33
34
|
var isConstValue = () => false;
|
|
34
35
|
if (c.program) {
|
|
35
36
|
var { strap_reg, value_reg } = c.program;
|
|
36
37
|
isConstValue = a => strap_reg.test(a) || value_reg.test(a);
|
|
37
|
-
}
|
|
38
|
+
}
|
|
38
39
|
var isInvoke = function (o) {
|
|
39
40
|
var o = o.next;
|
|
40
41
|
if (o?.type === EXPRESS && needhead_reg.test(o.text)) o = o.next;
|
|
@@ -42,9 +43,9 @@ var codecolor = function (c, encode) {
|
|
|
42
43
|
if (o?.type === STAMP && o.needle) o = o.next;
|
|
43
44
|
if (o?.type === SCOPED && o.entry === "(") return true;
|
|
44
45
|
return false;
|
|
45
|
-
}
|
|
46
|
+
};
|
|
46
47
|
var setExpress = function (o, label) {
|
|
47
|
-
if (!o.text) return;
|
|
48
|
+
if (!o.text || /^</.test(o.text)) return;
|
|
48
49
|
var keys = o.text.split(".");
|
|
49
50
|
if (isInvoke(o)) {
|
|
50
51
|
if (!/^[\<\?]/.test(keys[keys.length - 1])) keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
|
|
@@ -55,21 +56,21 @@ var codecolor = function (c, encode) {
|
|
|
55
56
|
else name = `<${label}>${name}</${label}>`;
|
|
56
57
|
keys[0] = name;
|
|
57
58
|
o.text = keys.map(k => /^[\<\?]/.test(k) || !k ? k : `<express>${k}</express>`).join(".");
|
|
58
|
-
}
|
|
59
|
+
};
|
|
59
60
|
var setPredef = o => setExpress(o, 'predef');
|
|
60
61
|
var setOutside = o => setExpress(o, 'outside');
|
|
61
62
|
if (used) for (var k in envs) {
|
|
62
63
|
used[k].forEach(k in predefs ? setPredef : setOutside);
|
|
63
64
|
}
|
|
64
65
|
if (c.program) var { space_exp: spaceReg, control_reg } = c.program;
|
|
65
|
-
var unspaceReg = new RegExp(spaceReg.source.replace(/^\[/, "[^"), spaceReg.flags + 'g');
|
|
66
|
+
if (spaceReg) var unspaceReg = new RegExp(spaceReg.source.replace(/^\[/, "[^"), spaceReg.flags + 'g');
|
|
66
67
|
var wraptext = function (t, l) {
|
|
67
68
|
if (unspaceReg) t = t.replace(unspaceReg, a => {
|
|
68
69
|
a = encode(a);
|
|
69
70
|
return `<${l}>${a}</${l}>`
|
|
70
71
|
});
|
|
71
72
|
return t;
|
|
72
|
-
}
|
|
73
|
+
};
|
|
73
74
|
c.colored = true;
|
|
74
75
|
var setcolor = function (o) {
|
|
75
76
|
if (o.colored) return;
|
|
@@ -151,5 +152,5 @@ var codecolor = function (c, encode) {
|
|
|
151
152
|
}
|
|
152
153
|
};
|
|
153
154
|
c.forEach(setcolor);
|
|
154
|
-
|
|
155
|
+
return c;
|
|
155
156
|
}
|
package/coms/docs/codetext.xht
CHANGED
|
@@ -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
|
|
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
|
-
|
|
265
|
+
c = compile$scanner2(m, s);
|
|
187
266
|
}
|
|
188
267
|
else {
|
|
189
|
-
|
|
190
|
-
|
|
268
|
+
c = compile$scanner2(a, s);
|
|
269
|
+
c.unshift(
|
|
191
270
|
{ type: compile$common.COMMENT, text: p },
|
|
192
271
|
);
|
|
193
|
-
|
|
272
|
+
c.push(
|
|
194
273
|
{ type: compile$common.COMMENT, text: f }
|
|
195
274
|
);
|
|
196
275
|
}
|
|
197
|
-
|
|
276
|
+
if (n.isStyle) setless(c);
|
|
277
|
+
codecolor(c, encode);
|
|
198
278
|
});
|
|
199
|
-
n.splice(0, n.length, ...
|
|
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];
|
|
@@ -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 =
|
|
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
|
};
|
package/coms/zimoli/render.js
CHANGED
|
@@ -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,
|
|
562
|
+
var getter = createGetter(this, search);
|
|
562
563
|
var generatedClassNames = {};
|
|
563
564
|
var oldValue;
|
|
564
565
|
this.$renders.push(function () {
|