efront 4.11.2 → 4.11.4
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/assert.js +5 -3
- package/coms/compile/Html_test.js +1 -0
- package/coms/compile/Javascript.js +5 -1
- package/coms/compile/Javascript_test.js +14 -2
- package/coms/compile/Program.js +6 -3
- package/coms/compile/common.js +1 -1
- package/coms/docs/markdown.js +5 -3
- package/coms/frame/route.js +15 -15
- package/coms/zimoli/render.js +45 -61
- package/coms/zimoli/view.less +0 -1
- package/coms//350/214/250/350/217/260/tab.js +34 -0
- package/coms//350/214/250/350/217/260//344/270/212/350/211/262.xht +99 -0
- package/coms//350/214/250/350/217/260//345/205/211/346/240/207.js +1 -0
- package/coms//350/214/250/350/217/260//346/211/253/346/217/217.js +12 -0
- package/coms/{docs/codecolor.js → /350/214/250/350/217/260//346/240/207/347/255/276/345/214/226.js} +2 -1
- package/coms//350/214/250/350/217/260//346/270/262/346/237/223.js +45 -0
- package/coms//350/214/250/350/217/260//347/274/226/350/276/221/346/241/206.xht +132 -0
- package/coms//350/214/250/350/217/260//350/257/255/350/250/200.js +210 -0
- package/coms//350/214/250/350/217/260//350/277/275/345/212/240/345/205/211/346/240/207.js +62 -0
- package/docs//347/273/204/344/273/266.xht +8 -162
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/coms/docs/codetext.xht +0 -386
package/coms/basic/assert.js
CHANGED
|
@@ -34,7 +34,7 @@ var gray = format('<gray>;</gray>').split(';');
|
|
|
34
34
|
var green = format('<green>;</green>').split(';');
|
|
35
35
|
var crack = format('<red2>;</red2>').split(';');
|
|
36
36
|
var dump = function (a, msg) {
|
|
37
|
-
if (a
|
|
37
|
+
if (isObject(a)) console.error(i18n`属性错误`), clog(msg ? msg + " " : " {\r\n", Object.keys(a).map(k => ` ${k}${gray.join(':')}\r\n ${a[k]}`).join('\r\n') + "\r\n }");
|
|
38
38
|
else if (msg) clog(msg + ":", a);
|
|
39
39
|
else clog(a);
|
|
40
40
|
};
|
|
@@ -66,12 +66,14 @@ var assert = function (result, expect, log = dump) {
|
|
|
66
66
|
mark.setTag2(color2[1], color2[0]);
|
|
67
67
|
var [r, e] = mark.pair(result, expect);
|
|
68
68
|
var s = r;
|
|
69
|
+
if (typeof s === 'object') console.log(typeof s, s);
|
|
70
|
+
|
|
69
71
|
r = colorString(r, color1, e, color2);
|
|
70
72
|
e = colorString(e, color2, s, color1);
|
|
71
73
|
errors = `${color3[0]}结果 ${color3[1]}${r}\r\n ${color3[0]}应为 ${color3[1]}${e}\r\n`;
|
|
72
74
|
};
|
|
73
75
|
return function (error) {
|
|
74
|
-
if (error
|
|
76
|
+
if (isObject(error)) {
|
|
75
77
|
Object.keys(error).forEach(y => {
|
|
76
78
|
var e = y;
|
|
77
79
|
errors[`${gray.join('[')}${green.join(k)}${gray.join("]->")}` + e] = error[y];
|
|
@@ -101,7 +103,7 @@ var assert = function (result, expect, log = dump) {
|
|
|
101
103
|
}
|
|
102
104
|
} else if (expect instanceof Function) {
|
|
103
105
|
res = expect(result, (...args) => (b) => assert(result.apply(null, args), b, collect(b, args)), collect(`()`)) !== false;
|
|
104
|
-
} else if (expect
|
|
106
|
+
} else if (isObject(expect) && isObject(result)) {
|
|
105
107
|
var res = true;
|
|
106
108
|
for (var k in expect) {
|
|
107
109
|
res = res && assert(result[k], expect[k], collect(k));
|
|
@@ -35,6 +35,7 @@ test('${i18n`加载中..`}<div class="loader"></div>');
|
|
|
35
35
|
test('${a +typeof i18n`加载中..`}<div class="loader"></div>', '${a + typeof i18n`加载中..`}<div class="loader"></div>');
|
|
36
36
|
test('${a > 1}');
|
|
37
37
|
test('a>1', 'a > 1');
|
|
38
|
+
test(`<meta charset="utf-8" />`);
|
|
38
39
|
test('a><a></a>', 'a > <a></a>');
|
|
39
40
|
test('X', 'X');
|
|
40
41
|
test('<input -class="{actived:actived===f}"/>', 'scoped.envs.actived', true);
|
|
@@ -434,7 +434,11 @@ Javascript.prototype.setType = function (o) {
|
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
else if (o.type === STAMP) {
|
|
437
|
-
|
|
437
|
+
if (!/^[,;:=\|&]$/.test(o.text)) {
|
|
438
|
+
if (!last || last.type === STAMP && /^[,;]$/.test(last.text) || last.isprop || queue.isClass && isShortMethodEnd(last)) {
|
|
439
|
+
o.isprop = true;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
438
442
|
}
|
|
439
443
|
else if (o.type === PROPERTY) {
|
|
440
444
|
o.isprop = true;
|
|
@@ -6,6 +6,7 @@ var testFix = function (a, e) {
|
|
|
6
6
|
assert(c.toString(), e);
|
|
7
7
|
}
|
|
8
8
|
js.debug = true;
|
|
9
|
+
assert(scanner2("/a/g", js)[0].type, common.QUOTED);
|
|
9
10
|
testFix(`import a from "a";console.log(a)`, 'var a = require("a"); console.log(a.default)');
|
|
10
11
|
testFix(`import {a} from "a";console.log(a)`, 'var a1 = require("a"); console.log(a1.a)');
|
|
11
12
|
testFix(`import a,{a as b} from "a";console.log(a,b)`, 'var a = require("a"); console.log(a.default, a.a)');
|
|
@@ -120,5 +121,16 @@ var testPress = function (text, expect) {
|
|
|
120
121
|
};
|
|
121
122
|
testPress(`if(){}\r\nelse {}`, `if(){}else{}`)
|
|
122
123
|
testPress(`if(a)a={}\r\nelse{}`, `if(a)a={};else{}`)
|
|
123
|
-
testPress(`if()a=function(){}\r\nelse {}
|
|
124
|
-
testPress(`if()function a(){}\r\nelse {}
|
|
124
|
+
testPress(`if()a=function(){}\r\nelse {}`, `if()a=function(){};else{}`)
|
|
125
|
+
testPress(`if()function a(){}\r\nelse {}`, `if()function a(){}else{}`)
|
|
126
|
+
|
|
127
|
+
var testStar = function (text, envs) {
|
|
128
|
+
var code = scanner2(text);
|
|
129
|
+
return assert(code.envs, envs);
|
|
130
|
+
};
|
|
131
|
+
testStar(`var a=class {a=1\r\nasync * a(){
|
|
132
|
+
var names=[];
|
|
133
|
+
for(var n of names) {
|
|
134
|
+
yield n;
|
|
135
|
+
}
|
|
136
|
+
}}`, {});
|
package/coms/compile/Program.js
CHANGED
|
@@ -197,7 +197,7 @@ class Program {
|
|
|
197
197
|
index = reg.lastIndex;
|
|
198
198
|
var match = reg.exec(m);
|
|
199
199
|
} while (match);
|
|
200
|
-
colstart = start + index;
|
|
200
|
+
colstart = start + index - 1;
|
|
201
201
|
};
|
|
202
202
|
var queue_push = (scope) => {
|
|
203
203
|
if (scope.type & (SPACE | COMMENT | PIECE | QUOTED)) {
|
|
@@ -459,8 +459,11 @@ class Program {
|
|
|
459
459
|
queue.last = last.prev;
|
|
460
460
|
}
|
|
461
461
|
else {
|
|
462
|
-
var m = queue.leave;
|
|
463
|
-
index = queue.end
|
|
462
|
+
var m = queue.leave || queue.tag_leave;
|
|
463
|
+
index = queue.end
|
|
464
|
+
if (m) {
|
|
465
|
+
index - m.length;
|
|
466
|
+
}
|
|
464
467
|
}
|
|
465
468
|
delete queue.start;
|
|
466
469
|
delete queue.end;
|
package/coms/compile/common.js
CHANGED
|
@@ -1326,7 +1326,7 @@ var createString = function (parsed) {
|
|
|
1326
1326
|
}
|
|
1327
1327
|
else {
|
|
1328
1328
|
if (a.type === PIECE && !a.text) continue;
|
|
1329
|
-
if (!needvalue && !/\s$/.test(result[result.length - 1]) && a.type !== ELEMENT && (a.type
|
|
1329
|
+
if (!needvalue && !/\s$/.test(result[result.length - 1]) && a.type !== ELEMENT && (a.type & ~(PIECE | SPACE) || !/^[\=\s]/.test(a.text))) result.push(" ");
|
|
1330
1330
|
run(a);
|
|
1331
1331
|
needvalue = a.type === PIECE && /[\=]$/.test(a.text);
|
|
1332
1332
|
}
|
package/coms/docs/markdown.js
CHANGED
|
@@ -107,13 +107,15 @@ function markdown(text) {
|
|
|
107
107
|
if (m & 2) c = `<b>${c}</b>`;
|
|
108
108
|
return c;
|
|
109
109
|
}
|
|
110
|
-
_ = codetext.encode(_.trim()).slice(1, -1);
|
|
111
110
|
if (/[\*#\.]\s/.test(text.slice(i - 1, i + 1))) _ = " " + _;
|
|
112
|
-
if (q.length === 1)
|
|
111
|
+
if (q.length === 1) {
|
|
112
|
+
_ = 茨菰$渲染.encode(_.trim()).slice(1, -1);
|
|
113
|
+
return `${s1}<m>${_}</m>${s2}`;
|
|
114
|
+
}
|
|
113
115
|
var t = /^\S+/.exec(c);
|
|
114
116
|
if (t) t = t[0]; c = c.slice(t.length).replace(/^(\r\n|\r|\n)|\s+$/g, '');
|
|
115
117
|
try {
|
|
116
|
-
return s1 +
|
|
118
|
+
return s1 + 茨菰$上色(t, c) + s2;
|
|
117
119
|
} catch (e) {
|
|
118
120
|
console.error(e);
|
|
119
121
|
return c;
|
package/coms/frame/route.js
CHANGED
|
@@ -141,19 +141,19 @@
|
|
|
141
141
|
}
|
|
142
142
|
mmap[menu.id] = menu;
|
|
143
143
|
}
|
|
144
|
-
if (menu.id === opened
|
|
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
|
|
150
|
+
var active = result.active;
|
|
151
151
|
if (!active || result.indexOf(active) < 0) {
|
|
152
|
-
actived = mmap[opened
|
|
152
|
+
actived = mmap[opened.active] || actived;
|
|
153
153
|
if (actived) {
|
|
154
154
|
if (actived_value === historys.length) {
|
|
155
155
|
setActive(actived, true);
|
|
156
|
-
result
|
|
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
|
|
180
|
-
setActive(result
|
|
179
|
+
if (menu !== result.active) {
|
|
180
|
+
setActive(result.active, false);
|
|
181
181
|
setActive(menu, true);
|
|
182
|
-
result
|
|
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
|
|
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
|
|
194
|
-
delete result
|
|
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
|
|
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
|
|
206
|
-
setActive(result
|
|
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
|
|
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
|
|
231
|
+
result.load(result.active);
|
|
232
232
|
return result;
|
|
233
233
|
};
|
|
234
234
|
result.from = result.fetch = function (url) {
|
package/coms/zimoli/render.js
CHANGED
|
@@ -109,13 +109,19 @@ function rebuild(element) {
|
|
|
109
109
|
}
|
|
110
110
|
var variableReg = /([^\:\,\+\=\-\!%\^\|\/\&\*\!\;\?\>\<~\{\}\s\[\]\(\)]|\?\s*\.(?=[^\d])|\s*\.\s*)+/g;
|
|
111
111
|
var variableOnlyReg = new RegExp(`^${variableReg.source}$`);
|
|
112
|
+
var getScopeList = function (element) {
|
|
113
|
+
return element.$parentScopes.concat([element.$scope]);
|
|
114
|
+
};
|
|
112
115
|
var createGetter = function (target, search, isprop = true) {
|
|
113
116
|
if (!search) return function () { };
|
|
114
117
|
if (/^\{/.test(search)) search = `(${search})`;
|
|
115
118
|
search = renderExpress(search);
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
else
|
|
119
|
+
var scopes = getScopeList(target);
|
|
120
|
+
if (isprop) var getter = $$eval.bind(target, search, scopes);
|
|
121
|
+
else if (variableOnlyReg.test(search)) getter = $$eval.bind(target, search + "(event)", scopes);
|
|
122
|
+
else getter = $$eval.bind(target, search, scopes);
|
|
123
|
+
getter.scopes = scopes;
|
|
124
|
+
return getter;
|
|
119
125
|
};
|
|
120
126
|
var createComment = function (renders, type, expression) {
|
|
121
127
|
var comment = document.createComment(`${type} ${expression}`);
|
|
@@ -389,10 +395,11 @@ var parseIfWithRepeat = function (ifExpression, repeatExpression) {
|
|
|
389
395
|
};
|
|
390
396
|
};
|
|
391
397
|
|
|
392
|
-
var mountElementIds = function (element) {
|
|
398
|
+
var mountElementIds = function (element, ids) {
|
|
393
399
|
var scope = element.$scope;
|
|
394
|
-
|
|
395
|
-
|
|
400
|
+
if (!scope) return;
|
|
401
|
+
for (var id of ids) {
|
|
402
|
+
if (isHandled(scope[id]) && scope[id] !== element) throw new Error(i18n`同一个id不能使用两次:` + id);
|
|
396
403
|
scope[id] = element;
|
|
397
404
|
}
|
|
398
405
|
}
|
|
@@ -447,28 +454,6 @@ var structures = {
|
|
|
447
454
|
};
|
|
448
455
|
structures["else-if"] = structures.elseif = structures.else;
|
|
449
456
|
structures["for-each"] = structures.foreach = structures.for = structures.each = structures.repeat;
|
|
450
|
-
var createBinder = function (binder) {
|
|
451
|
-
return function (search) {
|
|
452
|
-
var getter = createGetter(this, `(${search})`);
|
|
453
|
-
var oldValue;
|
|
454
|
-
this.$renders.push(function () {
|
|
455
|
-
var value = getter(this);
|
|
456
|
-
if (shallowEqual(value, oldValue)) return;
|
|
457
|
-
var oldv = oldValue;
|
|
458
|
-
oldValue = value;
|
|
459
|
-
if (isNode(value) || isArray(value)) {
|
|
460
|
-
if (value !== this.firstChild) {
|
|
461
|
-
remove(this.childNodes);
|
|
462
|
-
appendChild(this, value);
|
|
463
|
-
}
|
|
464
|
-
} else {
|
|
465
|
-
if (isEmpty(value)) value = '';
|
|
466
|
-
if (binder(this) !== value) binder(this, value, oldv);
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
457
|
var createMapper = function (write, mapper) {
|
|
473
458
|
return function (search) {
|
|
474
459
|
var getter = isArray(search) ? search.map(s => createGetter(this, s)) : createGetter(this, search);
|
|
@@ -596,7 +581,7 @@ var directives = {
|
|
|
596
581
|
var change = getstr || "'value' in this?this.value:this.innerHTML";
|
|
597
582
|
}
|
|
598
583
|
setter2 = null;
|
|
599
|
-
var changeme = $$eval.bind(this, search + "=" + change,
|
|
584
|
+
var changeme = $$eval.bind(this, search + "=" + change, getScopeList(this));
|
|
600
585
|
var onchange = function () {
|
|
601
586
|
changeme(this);
|
|
602
587
|
var value = getter(this);
|
|
@@ -687,12 +672,9 @@ var createEmiter = function (on) {
|
|
|
687
672
|
}
|
|
688
673
|
var res;
|
|
689
674
|
if (scope) {
|
|
690
|
-
|
|
691
|
-
this.$parentScopes.push(temp);
|
|
692
|
-
this.$scope = scope;
|
|
675
|
+
getter.scopes.push(scope);
|
|
693
676
|
res = getter(this, e);
|
|
694
|
-
|
|
695
|
-
this.$scope = temp;
|
|
677
|
+
getter.scopes.pop();
|
|
696
678
|
}
|
|
697
679
|
else {
|
|
698
680
|
res = getter(this, e);
|
|
@@ -750,6 +732,8 @@ function renderRest(element, struct, replacer = element) {
|
|
|
750
732
|
}
|
|
751
733
|
if (binds.src) directives.src.call(element, binds.src);
|
|
752
734
|
if (renders && renders.length) element.$renders.push.apply(element.$renders, renders);
|
|
735
|
+
if (!isElement(replacer)) replacer = element;
|
|
736
|
+
struct.ons.forEach(([on, key, value]) => on.call(element, replacer, key, value));
|
|
753
737
|
}
|
|
754
738
|
|
|
755
739
|
function renderElement(element, scope = element.$scope, parentScopes = element.$parentScopes, once) {
|
|
@@ -774,10 +758,12 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
774
758
|
}
|
|
775
759
|
element.$parentScopes = parentScopes || [];
|
|
776
760
|
var s = createStructure(element);
|
|
761
|
+
element.$struct = s;
|
|
762
|
+
mountElementIds(element, s.ids);
|
|
777
763
|
if (isEmpty(s.once)) s.once = once;
|
|
778
764
|
element.$eval = $eval;
|
|
779
765
|
}
|
|
780
|
-
|
|
766
|
+
element.$scope = scope;
|
|
781
767
|
if (element.$renderid <= -1) element = renderStructure(element);
|
|
782
768
|
if (!element) return;
|
|
783
769
|
if (!element || element.$renderid < 0 || element.nodeType !== 1) {
|
|
@@ -791,8 +777,9 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
791
777
|
if (parentNode) {
|
|
792
778
|
if (parentNode.$renderid > 1 || isMounted(parentNode)) element.$renderid = 2;
|
|
793
779
|
}
|
|
780
|
+
var $struct = element.$struct;
|
|
794
781
|
element.$renders = element.$renders || element.renders ? [].concat(element.$renders || [], element.renders || []) : [];
|
|
795
|
-
var { copys, binds, once } =
|
|
782
|
+
var { copys, binds, once } = $struct;
|
|
796
783
|
if (once) element.$renderid = 9;
|
|
797
784
|
if (binds.src) {
|
|
798
785
|
element.$src = parseRepeat(binds.src);
|
|
@@ -802,16 +789,20 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
802
789
|
var constructor = getFromScopes(tagName, scope, parentScopes);
|
|
803
790
|
if (isFunction(constructor)) {
|
|
804
791
|
var replacer = constructor.call(scope, element, scope, parentScopes);
|
|
805
|
-
if (
|
|
806
|
-
|
|
807
|
-
|
|
792
|
+
if (element === replacer) {
|
|
793
|
+
var struct1 = createStructure(element, false);
|
|
794
|
+
renderRest(element, struct1);
|
|
795
|
+
element.$scope = scope;
|
|
796
|
+
}
|
|
797
|
+
else if (isNode(replacer)) {
|
|
808
798
|
if (isElement(replacer) && !replacer.$renderid) {
|
|
799
|
+
if (!replacer.$scope) replacer.$scope = scope;
|
|
800
|
+
if (!replacer.$parentScopes) replacer.$parentScopes = parentScopes;
|
|
809
801
|
createStructure(replacer);
|
|
810
|
-
replacer.$struct = mergeStruct(element.$struct, replacer.$struct);
|
|
811
802
|
if (replacer.children && replacer.children.length) renderElement(replacer.children, replacer.$scope, replacer.$parentScopes, once);
|
|
812
803
|
renderRest(replacer, replacer.$struct);
|
|
813
|
-
replacer.$struct.ons.forEach(([on, key, value]) => on.call(replacer, replacer, key, value));
|
|
814
804
|
}
|
|
805
|
+
|
|
815
806
|
copyAttribute(replacer, copys);
|
|
816
807
|
if (nextSibling) appendChild.before(nextSibling, replacer);
|
|
817
808
|
else if (parentNode) appendChild(parentNode, replacer);
|
|
@@ -827,7 +818,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
827
818
|
if (element.children && element.children.length) renderElement(element.children, scope, parentScopes, once);
|
|
828
819
|
}
|
|
829
820
|
if (!isFirstRender) return element;
|
|
830
|
-
renderRest(element,
|
|
821
|
+
renderRest(element, $struct, replacer);
|
|
831
822
|
if (isNode(replacer) && replacer !== element) {
|
|
832
823
|
if (!replacer.$renders) replacer.$renders = [];
|
|
833
824
|
replacer.$renders.push.apply(replacer.$renders, element.$renders);
|
|
@@ -836,9 +827,6 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
836
827
|
}
|
|
837
828
|
element = replacer;
|
|
838
829
|
}
|
|
839
|
-
else {
|
|
840
|
-
element.$struct.ons.forEach(([on, key, value]) => on.call(element, element, key, value));
|
|
841
|
-
}
|
|
842
830
|
if (element.$renders.length) {
|
|
843
831
|
if (element.$renderid !== 9) {
|
|
844
832
|
onmounted(element, addRenderElement);
|
|
@@ -857,26 +845,22 @@ var createEval = function (deep) {
|
|
|
857
845
|
while (deep-- > 0) {
|
|
858
846
|
context[deep] = `with($parentScopes[${deep}])`;
|
|
859
847
|
}
|
|
860
|
-
return new Function("$parentScopes", "
|
|
848
|
+
return new Function("$parentScopes", "code", "event", `${context.join('')}return eval(code)`);
|
|
861
849
|
};
|
|
862
850
|
var evalcontexts = [createEval(0)];
|
|
863
851
|
|
|
864
|
-
function $$eval(search,
|
|
865
|
-
var
|
|
866
|
-
if (needpop) {
|
|
867
|
-
this.$parentScopes.push(this.$scope);
|
|
868
|
-
this.$scope = scope;
|
|
869
|
-
}
|
|
870
|
-
var length = this.$parentScopes ? this.$parentScopes.length : 0;
|
|
852
|
+
function $$eval(search, scopes, target = this, event) {
|
|
853
|
+
var length = scopes.length;
|
|
871
854
|
if (!evalcontexts[length]) evalcontexts[length] = createEval(length);
|
|
872
855
|
var eval2 = evalcontexts[length];
|
|
873
|
-
var res = eval2.call(target,
|
|
874
|
-
if (needpop) this.$scope = this.$parentScopes.pop();
|
|
856
|
+
var res = eval2.call(target, scopes, search, event);
|
|
875
857
|
return res;
|
|
876
858
|
}
|
|
877
859
|
|
|
878
860
|
function $eval(search, scope, event) {
|
|
879
|
-
|
|
861
|
+
var scopes = getScopeList(this);
|
|
862
|
+
if (isHandled(scope) && scope !== this.$scope) scopes.push(scope);
|
|
863
|
+
return $$eval.call(this, search, scopes, this, event);
|
|
880
864
|
}
|
|
881
865
|
|
|
882
866
|
var merge = function (dst, src) {
|
|
@@ -938,9 +922,9 @@ var pushid = function (ids, name) {
|
|
|
938
922
|
if (name1 !== name) ids.push(name1);
|
|
939
923
|
};
|
|
940
924
|
|
|
941
|
-
function createStructure(element) {
|
|
925
|
+
function createStructure(element, useExists) {
|
|
942
926
|
if (isArrayLike(element)) return Array.prototype.map.call(element, createStructure);
|
|
943
|
-
if (element.$struct) return element.$struct;
|
|
927
|
+
if (useExists !== false && element.$struct) return element.$struct;
|
|
944
928
|
if (element.nodeType !== 1) return;
|
|
945
929
|
// 处理结构流
|
|
946
930
|
var attributes = element.attributes;
|
|
@@ -1009,7 +993,7 @@ function createStructure(element) {
|
|
|
1009
993
|
// ng-html,ng-src,ng-text,ng-model,ng-style,ng-class,...
|
|
1010
994
|
var key = name.replace(/^(ng|v|[^\_\:\.]*?)\-|^[\:\_\.]|^v\-bind\:/i, "").toLowerCase();
|
|
1011
995
|
if (directives.hasOwnProperty(key) || /^([\_\:\.]|v\-bind\:)/.test(name)) {
|
|
1012
|
-
binds[key] = value;
|
|
996
|
+
if (value) binds[key] = value;
|
|
1013
997
|
element.removeAttribute(name);
|
|
1014
998
|
}
|
|
1015
999
|
// ng-click on-click v-click @click @mousedown ...
|
|
@@ -1017,11 +1001,11 @@ function createStructure(element) {
|
|
|
1017
1001
|
var match = emiter_reg.exec(name);
|
|
1018
1002
|
var ngon = (match[1] || match[0]).toLowerCase() === 'once' ? 'once' : 'on';
|
|
1019
1003
|
element.removeAttribute(name);
|
|
1020
|
-
ons.push([emiters[ngon], name.replace(emiter_reg, ''), value]);
|
|
1004
|
+
if (value) ons.push([emiters[ngon], name.replace(emiter_reg, ''), value]);
|
|
1021
1005
|
}
|
|
1022
1006
|
// placeholder_ href_ checked_ ...
|
|
1023
1007
|
else if (/[_@\:\.]$/.test(name)) {
|
|
1024
|
-
attr1[name.replace(/[_@\:\.]$/, "")] = value;
|
|
1008
|
+
if (value) attr1[name.replace(/[_@\:\.]$/, "")] = value;
|
|
1025
1009
|
element.removeAttribute(name);
|
|
1026
1010
|
}
|
|
1027
1011
|
// title alt name type placeholder href checked ...
|
package/coms/zimoli/view.less
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var ensp = s => Array(s + 1).join("\u2002"/*&ensp*/);
|
|
2
|
+
var getEnspBefore = function (node) {
|
|
3
|
+
if (!node) return 0;
|
|
4
|
+
while (node && (node.nodeType !== 1 || !/^br$/i.test(node.tagName))) {
|
|
5
|
+
node = node.previousSibling;
|
|
6
|
+
}
|
|
7
|
+
if (node) {
|
|
8
|
+
var next = node.nextSibling;
|
|
9
|
+
if (next) {
|
|
10
|
+
next = /^[\u2002\u0020\u00a0]+/.exec(next.nodeValue);
|
|
11
|
+
if (next) return next[0].length;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
return function (forcetab) {
|
|
16
|
+
var selection = document.getSelection();
|
|
17
|
+
var { anchorNode, anchorOffset } = selection;
|
|
18
|
+
if (anchorNode.nodeType === 1) {
|
|
19
|
+
var child = anchorNode.childNodes[anchorOffset];
|
|
20
|
+
var spaceSize = 4;
|
|
21
|
+
if (child.nodeType === 1) spaceSize = getEnspBefore(child?.previousSibling?.previousSibling || anchorNode);
|
|
22
|
+
if (!spaceSize && forcetab !== false) spaceSize = 4;
|
|
23
|
+
if (!spaceSize) return;
|
|
24
|
+
var space = document.createTextNode(ensp(spaceSize));
|
|
25
|
+
anchorNode.insertBefore(space, child);
|
|
26
|
+
selection.setBaseAndExtent(space, spaceSize, space, spaceSize);
|
|
27
|
+
}
|
|
28
|
+
else if (anchorNode.nodeType === 3) {
|
|
29
|
+
if (forcetab === 0) return;
|
|
30
|
+
anchorNode.nodeValue = anchorNode.nodeValue.slice(0, anchorOffset) + ensp(4) + anchorNode.nodeValue.slice(anchorOffset);
|
|
31
|
+
anchorOffset += 4;
|
|
32
|
+
selection.setBaseAndExtent(anchorNode, anchorOffset, anchorNode, anchorOffset);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
:scope {
|
|
3
|
+
white-space: pre-wrap;
|
|
4
|
+
line-height: 1.36;
|
|
5
|
+
word-break: break-all;
|
|
6
|
+
padding: 10px 20px;
|
|
7
|
+
border-radius: 3px;
|
|
8
|
+
display: inline-block;
|
|
9
|
+
background: #2c2c2c;
|
|
10
|
+
color: #d4d4d4;
|
|
11
|
+
font-family: Consolas, "Courier New", monospace;
|
|
12
|
+
vertical-align: top;
|
|
13
|
+
text-decoration-line: none;
|
|
14
|
+
tab-size: 4;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
stamp {
|
|
18
|
+
color: #808080;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
strap,
|
|
22
|
+
value {
|
|
23
|
+
color: #569cd6;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
regexp {
|
|
27
|
+
color: #d16969;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
text {
|
|
31
|
+
color: #ce9178;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
flow {
|
|
35
|
+
color: #c586c0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
digit {
|
|
39
|
+
color: #b5cea8;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
label {
|
|
43
|
+
color: #569cd6;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
selector {
|
|
47
|
+
color: #d7ba7d;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@deep(@num, @color) {
|
|
51
|
+
deep@num {
|
|
52
|
+
color: @color;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@deep(0, #ffd700);
|
|
57
|
+
@deep(1, #da70d6);
|
|
58
|
+
@deep(2, #179fff);
|
|
59
|
+
@deep(3, #ffd700);
|
|
60
|
+
@deep(4, #da70d6);
|
|
61
|
+
@deep(5, #179fff);
|
|
62
|
+
@deep(6, #ffd700);
|
|
63
|
+
@deep(7, #da70d6);
|
|
64
|
+
@deep(8, #179fff);
|
|
65
|
+
@deep(9, #ffd700);
|
|
66
|
+
@deep(10, #da70d6);
|
|
67
|
+
@deep(11, #179fff);
|
|
68
|
+
@deep(12, #ffd700);
|
|
69
|
+
@deep(13, #da70d6);
|
|
70
|
+
@deep(14, #179fff);
|
|
71
|
+
@deep(15, #ffd700);
|
|
72
|
+
@deep(16, #da70d6);
|
|
73
|
+
@deep(17, #179fff);
|
|
74
|
+
|
|
75
|
+
express,
|
|
76
|
+
property {
|
|
77
|
+
color: #9cdcfe;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
invoke,
|
|
81
|
+
method {
|
|
82
|
+
color: #dcdcaa;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
predef {
|
|
86
|
+
color: #4ec9b0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
outside {
|
|
90
|
+
color: #4fc1ff;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
comment {
|
|
94
|
+
color: #6a9955;
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
97
|
+
<script>
|
|
98
|
+
茨菰$渲染;
|
|
99
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
return "\u0080";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var { STAMP, PIECE, SPACE } = compile$common;
|
|
2
|
+
return function (a, type) {
|
|
3
|
+
if (光标) var index = a.indexOf(光标);
|
|
4
|
+
if (index >= 0) a = a.slice(0, index) + a.slice(index + 1);
|
|
5
|
+
var c = compile$scanner2(a, type);
|
|
6
|
+
if (index >= 0) {
|
|
7
|
+
c.scoped;
|
|
8
|
+
var patched = 追加光标(c, index, 光标);
|
|
9
|
+
if (!patched) c.push({ type: SPACE, text: 光标 });
|
|
10
|
+
}
|
|
11
|
+
return c;
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
var { SCOPED, QUOTED, SPACE, STAMP, STRAP, EXPRESS, PROPERTY } = compile$common;
|
|
3
|
+
var encode = function (text) {
|
|
4
|
+
return text.replace(/[\<\>\|]/g, a => `&#${a.charCodeAt()};`);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
var rows = function (type, text) {
|
|
8
|
+
if (typeof text !== 'string') {
|
|
9
|
+
console.log(text)
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
type = type.toLowerCase();
|
|
13
|
+
if (type in 语言) {
|
|
14
|
+
var c = 语言[type](text);
|
|
15
|
+
标签化(c, encode);
|
|
16
|
+
text = c.toString();
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
else text = encode(text);
|
|
20
|
+
|
|
21
|
+
var codes = text.split(/\r\n|\r|\n/);
|
|
22
|
+
var minSpace = Infinity;
|
|
23
|
+
for (var c of codes) {
|
|
24
|
+
var m = /^\s+/.exec(c);
|
|
25
|
+
if (!m) {
|
|
26
|
+
minSpace = 0;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
if (m[0].length < minSpace) {
|
|
30
|
+
minSpace = m[0].length;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (minSpace > 0 && minSpace < Infinity) codes = codes.map(c => /^\s+/.test(c) ? c.slice(minSpace) : c);
|
|
34
|
+
return codes;
|
|
35
|
+
}
|
|
36
|
+
function 茨菰(type, text) {
|
|
37
|
+
return `<code type=${type}>${rows(type, text).join("<br/>")}</code>`;
|
|
38
|
+
}
|
|
39
|
+
茨菰.text = function (type, text) {
|
|
40
|
+
return `${rows(type, text).join("<br/>")}`;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
茨菰.rows = rows;
|
|
44
|
+
茨菰.encode = encode;
|
|
45
|
+
return 茨菰;
|