efront 3.36.2 → 3.36.5
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/#loader.js +51 -35
- package/coms/basic/YAML.js +8 -2
- package/coms/basic/YAML_test.js +9 -0
- package/coms/compile/Javascript.js +1 -1
- package/coms/compile/Program.js +6 -1
- package/coms/compile/richcss.js +3 -5
- package/coms/compile/richcss_test.js +8 -1
- package/coms/docs/codetext.xht +284 -0
- package/coms/docs/markdown.js +9 -144
- package/coms/zimoli/AudioContext_test.less +1 -1
- package/coms/zimoli/alert.js +10 -21
- package/coms/zimoli/alert.less +12 -0
- package/coms/zimoli/data_test.js +0 -3
- package/coms/zimoli/getGenerator.js +1 -1
- package/coms/zimoli/render.js +2 -1
- package/coms/zimoli/zimoli.js +2 -1
- package/docs/components.jsp +1 -1
- package/docs/main.xht +9 -3
- package/docs/mark.xht +0 -80
- package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +1 -1
- package/docs//347/273/204/344/273/266.xht +329 -21
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/apps/sciters/main.js +0 -31
- package/coms/zimoli/onhistoryback.js +0 -0
package/coms/basic/#loader.js
CHANGED
|
@@ -244,12 +244,13 @@ var killCircle = function () {
|
|
|
244
244
|
};
|
|
245
245
|
// -->
|
|
246
246
|
var hasOwnProperty = {}.hasOwnProperty;
|
|
247
|
-
var loadModule = function (
|
|
247
|
+
var loadModule = function (url, then, prebuilds = {}) {
|
|
248
|
+
var name = url.replace(/[\*~][\s\S]*$/, '');
|
|
248
249
|
if (/^(?:module|exports|define|require|window|global|undefined)$/.test(name)) return then();
|
|
249
|
-
if ((hasOwnProperty.call(prebuilds,
|
|
250
|
+
if ((hasOwnProperty.call(prebuilds, url)) || hasOwnProperty.call(modules, url) || (!/^on/.test(name) && window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name))
|
|
250
251
|
) return then();
|
|
251
|
-
preLoad(
|
|
252
|
-
var key = keyprefix +
|
|
252
|
+
preLoad(url);
|
|
253
|
+
var key = keyprefix + url;
|
|
253
254
|
if (loadedModules[key] instanceof Function) {
|
|
254
255
|
then();
|
|
255
256
|
return;
|
|
@@ -267,15 +268,15 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
267
268
|
}.bind(null, responseTree[name]));
|
|
268
269
|
};
|
|
269
270
|
if (/\.json([\#\?].*?)?$/i.test(name)) {
|
|
270
|
-
readFile(["JSON",
|
|
271
|
+
readFile(["JSON", url], saveModule);
|
|
271
272
|
} else {
|
|
272
|
-
readFile(
|
|
273
|
+
readFile(url, saveModule);
|
|
273
274
|
};
|
|
274
275
|
}
|
|
275
276
|
else {
|
|
276
277
|
|
|
277
278
|
var saveModule = function (error) {
|
|
278
|
-
var data = responseTree[
|
|
279
|
+
var data = responseTree[url];
|
|
279
280
|
if (typeof data === "function") {
|
|
280
281
|
var mod = data;
|
|
281
282
|
flushTree(loadedModules, key, mod);
|
|
@@ -289,7 +290,8 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
289
290
|
// <!--
|
|
290
291
|
if (!data) undefinedModules[name] = true;
|
|
291
292
|
// -->
|
|
292
|
-
var
|
|
293
|
+
var afterfix = url.slice(name.length);
|
|
294
|
+
var [argNames, body, args, required, strs, isAsync, isYield] = getArgs(data, afterfix);
|
|
293
295
|
if (isProduction) {
|
|
294
296
|
strs = strs.map ? strs.map(toRem) : strs;
|
|
295
297
|
} else {
|
|
@@ -300,7 +302,10 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
300
302
|
mod.argNames = argNames;
|
|
301
303
|
mod.strs = strs;
|
|
302
304
|
var loadingCount = 0;
|
|
303
|
-
if (required)
|
|
305
|
+
if (required) {
|
|
306
|
+
required = required.split(';').filter(a => !!a);
|
|
307
|
+
if (afterfix) required = required.map(r => r + afterfix);
|
|
308
|
+
}
|
|
304
309
|
required = required ? get_relatives(name, required) : [];
|
|
305
310
|
mod.required = required;
|
|
306
311
|
mod.file = name;
|
|
@@ -328,13 +333,15 @@ var loadModule = function (name, then, prebuilds = {}) {
|
|
|
328
333
|
});
|
|
329
334
|
}
|
|
330
335
|
};
|
|
331
|
-
readFile(
|
|
336
|
+
readFile(url, saveModule);
|
|
332
337
|
}
|
|
333
338
|
};
|
|
334
339
|
var toRem = text => pixelDecoder && typeof text === 'string' ? text.replace(/(\:\s*)?\b((?:\d*\.)?\d+)px(\s*\))?/ig, (m, h, d, quote) => (h || "") + (d !== '1' ? h && quote ? renderPixelRatio * d + "pt" : pixelDecoder(d) : renderPixelRatio > 1 ? ".78pt" : 0.78 / devicePixelRatio + "pt") + (quote || "")) : text;
|
|
335
340
|
"use ./#decrypt.js";
|
|
336
|
-
var getArgs = function (text) {
|
|
337
|
-
|
|
341
|
+
var getArgs = function (text, aftfix) {
|
|
342
|
+
if (!aftfix || /^\*/.test(aftfix)) {
|
|
343
|
+
"use ./#decrypt_.js";
|
|
344
|
+
}
|
|
338
345
|
var args, functionBody;
|
|
339
346
|
//依赖项名称部分的长度限制为36*36*18=23328
|
|
340
347
|
var doublecount = parseInt(text.slice(0, 3), 36);
|
|
@@ -365,6 +372,9 @@ var getArgs = function (text) {
|
|
|
365
372
|
var argNames = args.slice(argsstart, argsend);
|
|
366
373
|
var required = args[argsend];
|
|
367
374
|
args = args.slice(0, argsstart);
|
|
375
|
+
if (aftfix) {
|
|
376
|
+
args = args.map(a => a + aftfix);
|
|
377
|
+
}
|
|
368
378
|
} else {
|
|
369
379
|
functionBody = text;
|
|
370
380
|
}
|
|
@@ -422,7 +432,8 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
|
422
432
|
var isModuleInit = false;
|
|
423
433
|
var required = exec.required;
|
|
424
434
|
if (required) required = required.map(a => loadedModules[keyprefix + a]);
|
|
425
|
-
var argsList = originNames.map(function (
|
|
435
|
+
var argsList = originNames.map(function (aName) {
|
|
436
|
+
var argName = aName.replace(/[\*~][\s\S]*$/, '');
|
|
426
437
|
if (hasOwnProperty.call(prebuilds, argName)) {
|
|
427
438
|
return prebuilds[argName];
|
|
428
439
|
}
|
|
@@ -465,11 +476,8 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
|
465
476
|
var prebuilds2 = Object.create(null);
|
|
466
477
|
for (var k in prebuilds) if (hasOwnProperty.call(prebuilds, k)) prebuilds2[k] = prebuilds[k];
|
|
467
478
|
prebuilds = prebuilds2;
|
|
468
|
-
delete prebuilds.popup;
|
|
469
|
-
delete prebuilds.action;
|
|
470
|
-
delete prebuilds.init;
|
|
471
479
|
}
|
|
472
|
-
var promise = init(
|
|
480
|
+
var promise = init(aName, function (res) {
|
|
473
481
|
result = res;
|
|
474
482
|
created = true;
|
|
475
483
|
}, prebuilds);
|
|
@@ -489,19 +497,20 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
|
489
497
|
});
|
|
490
498
|
};
|
|
491
499
|
|
|
492
|
-
var init = function (
|
|
500
|
+
var init = function (url, then, prebuilds) {
|
|
493
501
|
// then = bindthen(then);
|
|
494
|
-
var key = keyprefix +
|
|
502
|
+
var key = keyprefix + url;
|
|
495
503
|
if (prebuilds) {
|
|
496
|
-
if (hasOwnProperty.call(prebuilds,
|
|
497
|
-
if (then) then(prebuilds[
|
|
498
|
-
return prebuilds[
|
|
504
|
+
if (hasOwnProperty.call(prebuilds, url)) {
|
|
505
|
+
if (then) then(prebuilds[url]);
|
|
506
|
+
return prebuilds[url];
|
|
499
507
|
}
|
|
500
508
|
}
|
|
501
|
-
if (hasOwnProperty.call(modules,
|
|
502
|
-
if (then) then(modules[
|
|
503
|
-
return modules[
|
|
509
|
+
if (hasOwnProperty.call(modules, url)) {
|
|
510
|
+
if (then) then(modules[url]);
|
|
511
|
+
return modules[url];
|
|
504
512
|
}
|
|
513
|
+
var name = url.replace(/[\*~][\s\S]*$/, '');
|
|
505
514
|
if (!/^on/.test(name) && window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name)) {
|
|
506
515
|
modules[name] = window[name]
|
|
507
516
|
if (then) then(modules[name]);
|
|
@@ -540,17 +549,17 @@ var init = function (name, then, prebuilds) {
|
|
|
540
549
|
};
|
|
541
550
|
var crack = function (error) {
|
|
542
551
|
if (res.resolved || res.errored) return;
|
|
543
|
-
var ed = errored[
|
|
552
|
+
var ed = errored[url];
|
|
544
553
|
res.errored = true;
|
|
545
554
|
res.error = error;
|
|
546
555
|
res.fire();
|
|
547
|
-
var rest = [
|
|
556
|
+
var rest = [url];
|
|
548
557
|
var track = [];
|
|
549
558
|
var length = 0;
|
|
550
559
|
var deep = 0;
|
|
551
560
|
// <!--
|
|
552
561
|
var map = Object.create(null);
|
|
553
|
-
map[
|
|
562
|
+
map[url] = true;
|
|
554
563
|
do {
|
|
555
564
|
deep++;
|
|
556
565
|
var rest2 = Object.create(null);
|
|
@@ -573,11 +582,11 @@ var init = function (name, then, prebuilds) {
|
|
|
573
582
|
track = track.map(([d, a, e]) => ` ${new Array(d + 1).join("•")} ${new Array(2 + length - a.length - d).join("-")} ${a} 溃于: ${e.reverse().join(", ")}`)
|
|
574
583
|
// -->
|
|
575
584
|
var report = window.performance || !window.alert ? console.error : window.alert;
|
|
576
|
-
report(`加载 ${
|
|
585
|
+
report(`加载 ${url} 失败,${ed && ed.length ? `${ed.join(', ')} 等 ${ed.length} 个模块` : "没有其他模块"}受到影响。\r\n${track.join("\r\n")}`);
|
|
577
586
|
};
|
|
578
|
-
loadModule(
|
|
579
|
-
if (hasOwnProperty.call(modules,
|
|
580
|
-
then(modules[
|
|
587
|
+
loadModule(url, function (error) {
|
|
588
|
+
if (hasOwnProperty.call(modules, url)) {
|
|
589
|
+
then(modules[url]);
|
|
581
590
|
return;
|
|
582
591
|
}
|
|
583
592
|
if (error) return crack(error);
|
|
@@ -587,7 +596,7 @@ var init = function (name, then, prebuilds) {
|
|
|
587
596
|
|
|
588
597
|
if (!args || !args.length) {
|
|
589
598
|
var created = module.call(window);
|
|
590
|
-
then(module.created = modules[
|
|
599
|
+
then(module.created = modules[url] = created);
|
|
591
600
|
return;
|
|
592
601
|
}
|
|
593
602
|
var filteredArgs = prebuilds ? args.filter(a => !hasOwnProperty.call(prebuilds, a)) : args;
|
|
@@ -611,12 +620,12 @@ var init = function (name, then, prebuilds) {
|
|
|
611
620
|
if (saveAsModule) {
|
|
612
621
|
penddings[key] = created;
|
|
613
622
|
created.then(function (res) {
|
|
614
|
-
then(modules[
|
|
623
|
+
then(modules[url] = res);
|
|
615
624
|
});
|
|
616
625
|
return;
|
|
617
626
|
}
|
|
618
627
|
} else {
|
|
619
|
-
if (saveAsModule) module.created = modules[
|
|
628
|
+
if (saveAsModule) module.created = modules[url] = created;
|
|
620
629
|
}
|
|
621
630
|
then(created);
|
|
622
631
|
}, prebuilds);
|
|
@@ -817,8 +826,15 @@ var modules = {
|
|
|
817
826
|
load: loadModule,
|
|
818
827
|
devicePixelRatio,
|
|
819
828
|
renderPixelRatio,
|
|
829
|
+
createFunction,
|
|
820
830
|
efrontsign: "",
|
|
821
831
|
};
|
|
832
|
+
modules["set request"] = function (req) {
|
|
833
|
+
request = req;
|
|
834
|
+
};
|
|
835
|
+
modules["get request"] = function () {
|
|
836
|
+
return request;
|
|
837
|
+
};
|
|
822
838
|
modules.debug = function () {
|
|
823
839
|
document.addEventListener("blur", e => e.stopPropagation(), true);
|
|
824
840
|
};
|
package/coms/basic/YAML.js
CHANGED
|
@@ -13,8 +13,14 @@ var stringify = function (data) {
|
|
|
13
13
|
var save = function (data) {
|
|
14
14
|
var v = String(data);
|
|
15
15
|
if (kesize.length) {
|
|
16
|
-
var
|
|
17
|
-
|
|
16
|
+
var isrow = /^\s*\-/.test(result[result.length - 2]);
|
|
17
|
+
if (isrow) {
|
|
18
|
+
var ksize = kesize[kesize.length - 1] - result[result.length - 1].length + 1;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
var ksize = kesize[kesize.length - 1] - result[result.length - 1].length + (kesize.length << 1);
|
|
22
|
+
}
|
|
23
|
+
v = new Array(ksize + 3).join(" ") + v;
|
|
18
24
|
}
|
|
19
25
|
result.push(v);
|
|
20
26
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var data = [
|
|
2
|
+
{ a: 1, b: 2 },
|
|
3
|
+
{ abcd: 2, c: 3 },
|
|
4
|
+
{ abcdefg: 3, d: 4 },
|
|
5
|
+
{ abcdefgh: 3, e: 5, g: { h: 1, k: 2 } },
|
|
6
|
+
{ abcdefgh: 3, e: 5, g: [{ a: 1, b: 2 }] },
|
|
7
|
+
{ abcdefgh: 3, e: 5, g: [{ a: 1, b: [{ c: 3, defg: 3 }] }] },
|
|
8
|
+
]
|
|
9
|
+
console.log(YAML.stringify(data));
|
|
@@ -183,7 +183,7 @@ var isShortMethodEnd = function (o) {
|
|
|
183
183
|
|
|
184
184
|
Javascript.prototype.setType = function (o) {
|
|
185
185
|
var last = o.prev;
|
|
186
|
-
if (o.type === EXPRESS && /^\.[^\.]/.test(o.text) && last.type === STAMP && last.text === "?") {
|
|
186
|
+
if (o.type === EXPRESS && /^\.[^\.]/.test(o.text) && last && last.type === STAMP && last.text === "?") {
|
|
187
187
|
last = o.prev = snapExpressHead(last.prev);
|
|
188
188
|
last.type = EXPRESS;
|
|
189
189
|
return false;
|
package/coms/compile/Program.js
CHANGED
|
@@ -194,7 +194,8 @@ class Program {
|
|
|
194
194
|
Object.defineProperty(scope, 'queue', { value: queue, enumerable: false });
|
|
195
195
|
scope.prev = last;
|
|
196
196
|
if (scope.type !== COMMENT && scope.type !== SPACE) {
|
|
197
|
-
|
|
197
|
+
var keeplast = program.setType(scope) === false;
|
|
198
|
+
if (keeplast) {
|
|
198
199
|
if (queue.last !== last) last = queue.last;
|
|
199
200
|
else if (scope.prev !== last) last = scope.prev;
|
|
200
201
|
while (queue[queue.length - 1] !== last) queue.pop();
|
|
@@ -202,6 +203,10 @@ class Program {
|
|
|
202
203
|
last.text = text.slice(last.start, last.end);
|
|
203
204
|
return;
|
|
204
205
|
}
|
|
206
|
+
if (queue.last !== last && queue.last !== o) {
|
|
207
|
+
last = queue.last, scope.prev = last;
|
|
208
|
+
if (last) last.text = text.slice(last.start, last.end);
|
|
209
|
+
}
|
|
205
210
|
if (last) last.next = scope;
|
|
206
211
|
queue.last = scope;
|
|
207
212
|
for (var cx = queue.length - 1; cx >= 0; cx--) {
|
package/coms/compile/richcss.js
CHANGED
|
@@ -26,13 +26,11 @@ Richcss.prototype.setType = function (o) {
|
|
|
26
26
|
}
|
|
27
27
|
if (pps.length > 1) {
|
|
28
28
|
var i = q.lastIndexOf(p = pps.pop());
|
|
29
|
-
q.splice(i + 1, q.length
|
|
30
|
-
p.next = o;
|
|
29
|
+
q.splice(i + 1, q.length);
|
|
31
30
|
p.type = PROPERTY;
|
|
32
31
|
p.end = pps[0].end;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return false;
|
|
32
|
+
q.last = p;
|
|
33
|
+
return;
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
if (!q.entry && o.type !== SCOPED) {
|
|
@@ -4,4 +4,11 @@ var test = function (data, expect) {
|
|
|
4
4
|
test(`:scope{--a:1}a{opacity:--a}`, `a{opacity:1;}`);
|
|
5
5
|
test(`:scope{--b:--a;--a:1;}a{opacity:--b}`, `a{opacity:1;}`);
|
|
6
6
|
test(`@a(@p,@b){@p{opacity:@b}}@a(a,1);`, `a{opacity:1;}`);
|
|
7
|
-
test(`@a(a,1);@a(@p,@b){@p{opacity:@b}}`, `a{opacity:1;}`);
|
|
7
|
+
test(`@a(a,1);@a(@p,@b){@p{opacity:@b}}`, `a{opacity:1;}`);
|
|
8
|
+
test(`a{ b{a:1}}`,`a b{a:1;}`);
|
|
9
|
+
test(`a{ >b{a:1}}`,`a>b{a:1;}`);
|
|
10
|
+
test(`a{ &>b{a:1}}`,`a>b{a:1;}`);
|
|
11
|
+
test(`a{ &b{a:1}}`,`ab{a:1;}`);
|
|
12
|
+
test(`a{ &.b{a:1}}`,`a.b{a:1;}`);
|
|
13
|
+
test(`a{ &[b]{a:1}}`,`a[b]{a:1;}`);
|
|
14
|
+
test(`a{ &[b]:nth-child(1){a:1}}`,`a[b]:nth-child(1){a:1;}`);
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
:scope {
|
|
3
|
+
padding: 10px 20px;
|
|
4
|
+
border-radius: 3px;
|
|
5
|
+
display: inline-block;
|
|
6
|
+
background: #333;
|
|
7
|
+
color: #d4d4d4;
|
|
8
|
+
vertical-align: top;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
strap,
|
|
12
|
+
value {
|
|
13
|
+
color: #569cd6;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
regexp {
|
|
17
|
+
color: #d16969;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
text {
|
|
21
|
+
color: #ce9178;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
flow {
|
|
25
|
+
color: #c586c0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
digit {
|
|
29
|
+
color: #b5cea8;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
label {
|
|
33
|
+
color: #569cd6;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@deep(@num, @color) {
|
|
37
|
+
deep@num {
|
|
38
|
+
color: @color;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@deep(0, #ffd700);
|
|
43
|
+
@deep(1, #da70d6);
|
|
44
|
+
@deep(2, #179fff);
|
|
45
|
+
@deep(3, #ffd700);
|
|
46
|
+
@deep(4, #da70d6);
|
|
47
|
+
@deep(5, #179fff);
|
|
48
|
+
@deep(6, #ffd700);
|
|
49
|
+
@deep(7, #da70d6);
|
|
50
|
+
@deep(8, #179fff);
|
|
51
|
+
@deep(9, #ffd700);
|
|
52
|
+
@deep(10, #da70d6);
|
|
53
|
+
@deep(11, #179fff);
|
|
54
|
+
@deep(12, #ffd700);
|
|
55
|
+
@deep(13, #da70d6);
|
|
56
|
+
@deep(14, #179fff);
|
|
57
|
+
@deep(15, #ffd700);
|
|
58
|
+
@deep(16, #da70d6);
|
|
59
|
+
@deep(17, #179fff);
|
|
60
|
+
|
|
61
|
+
express,
|
|
62
|
+
property {
|
|
63
|
+
color: #9cdcfe;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
invoke,
|
|
67
|
+
method {
|
|
68
|
+
color: #dcdcaa;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
predef {
|
|
72
|
+
color: #4ec9b0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
outside {
|
|
76
|
+
color: #4fc1ff;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
comment {
|
|
80
|
+
color: #6a9955;
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
83
|
+
<script>
|
|
84
|
+
var encode = function (text) {
|
|
85
|
+
return text.replace(/[\<\>\|]/g, a => `&#${a.charCodeAt()};`)
|
|
86
|
+
};
|
|
87
|
+
var codecolor = function (c, blink) {
|
|
88
|
+
var envs = c.envs;
|
|
89
|
+
var predefs = Object.create(null);
|
|
90
|
+
predefs.module = true;
|
|
91
|
+
predefs.exports = true;
|
|
92
|
+
predefs["module.exports"] = true;
|
|
93
|
+
predefs.Promise = true;
|
|
94
|
+
[Boolean, Number, String, Function, Object, Array, Date, RegExp, Error].forEach(p => predefs[p.name] = true);
|
|
95
|
+
var { STRAP, SCOPED, QUOTED, LABEL, COMMENT, STAMP, VALUE, EXPRESS, PROPERTY, PIECE } = c;
|
|
96
|
+
var deep = 0;
|
|
97
|
+
var setcolor = function (o) {
|
|
98
|
+
var text = o.text;
|
|
99
|
+
if (o.blink >= 0) o.text = o.text.slice(0, o.blink) + blink + o.text.slice(o.blink);
|
|
100
|
+
switch (o.type) {
|
|
101
|
+
case LABEL:
|
|
102
|
+
o.text = `<label>${o.text}</label>`;
|
|
103
|
+
break;
|
|
104
|
+
case QUOTED:
|
|
105
|
+
case PIECE:
|
|
106
|
+
if (!o.length) {
|
|
107
|
+
if (/^\//.test(o.text)) {
|
|
108
|
+
o.text = `<regexp>${encode(o.text)}</regexp>`;
|
|
109
|
+
}
|
|
110
|
+
else o.text = `<text>${encode(o.text)}</text>`;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
o.forEach(setcolor);
|
|
114
|
+
o.entry = "<text>" + o.entry;
|
|
115
|
+
o.leave = o.leave + "</text>";
|
|
116
|
+
break;
|
|
117
|
+
case SCOPED:
|
|
118
|
+
deep++;
|
|
119
|
+
o.forEach(setcolor);
|
|
120
|
+
deep--;
|
|
121
|
+
o.entry = `<deep${deep}>${o.entry}</deep${deep}>`;
|
|
122
|
+
o.leave = `<deep${deep}>${o.leave}</deep${deep}>`;
|
|
123
|
+
break;
|
|
124
|
+
case VALUE:
|
|
125
|
+
if (o.isdigit) o.text = `<digit>${o.text}</digit>`;
|
|
126
|
+
else o.text = `<value>${o.text}</value>`;
|
|
127
|
+
break;
|
|
128
|
+
case PROPERTY:
|
|
129
|
+
var next = o.next;
|
|
130
|
+
if (next && next.type === c.SCOPED && next.entry === '(') {
|
|
131
|
+
o.text = `<method>${o.text}</method>`;
|
|
132
|
+
}
|
|
133
|
+
else o.text = `<property>${o.text}</property>`;
|
|
134
|
+
|
|
135
|
+
break;
|
|
136
|
+
case EXPRESS:
|
|
137
|
+
var keys = o.text.split(".");
|
|
138
|
+
var next = o.next;
|
|
139
|
+
if (next && next.type === c.SCOPED && next.entry === '(') {
|
|
140
|
+
keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
|
|
141
|
+
}
|
|
142
|
+
var [name0] = text.split(".");
|
|
143
|
+
var [name] = keys;
|
|
144
|
+
if (/^</.test(name0));
|
|
145
|
+
else if (/^(arguments|this|super|Infinity|NaN)$/.test(name0)) name = `<strap>${name}</strap>`;
|
|
146
|
+
else if (name0 in envs) name = name0 in predefs ? `<predef>${name}</predef>` : `<outside>${name}</outside>`;
|
|
147
|
+
keys[0] = name;
|
|
148
|
+
o.text = keys.map(k => /^\</.test(k) || !k ? k : `<express>${k}</express>`).join(".");
|
|
149
|
+
break;
|
|
150
|
+
case STRAP:
|
|
151
|
+
if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|await|yield|return)/.test(text))
|
|
152
|
+
o.text = `<flow>${o.text}</flow>`;
|
|
153
|
+
else o.text = `<strap>${o.text}</strap>`;
|
|
154
|
+
break;
|
|
155
|
+
case STAMP:
|
|
156
|
+
if (/^(=>)$/.test(o.text) || o.text === "*" && o.prev && o.prev.type === c.STRAP) o.text = `<strap>${encode(o.text)}</strap>`;
|
|
157
|
+
else if (!/^[<\/>]+$/.test(o.text));
|
|
158
|
+
else o.text = `<stamp>${encode(o.text)}</stamp>`;
|
|
159
|
+
break;
|
|
160
|
+
case COMMENT:
|
|
161
|
+
o.text = `<comment>${encode(o.text)}</comment>`;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
c.forEach(setcolor);
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
var typescript = new compile$Javascript;
|
|
169
|
+
typescript.straps = typescript.straps.concat("interface", "implements", "declare", "module", "readonly", "enum");
|
|
170
|
+
var codesupports = {
|
|
171
|
+
javascript(a, blink) {
|
|
172
|
+
if (blink) var index = a.indexOf(blink);
|
|
173
|
+
if (index >= 0) a = a.slice(0, index) + a.slice(index + 1);
|
|
174
|
+
var c = compile$scanner2(a);
|
|
175
|
+
if (index >= 0) {
|
|
176
|
+
var patched = patchBlink(c, index, blink);
|
|
177
|
+
}
|
|
178
|
+
codecolor(c, blink);
|
|
179
|
+
a = c.toString();
|
|
180
|
+
if (index >= 0 && !patched) a = blink + a;
|
|
181
|
+
return a;
|
|
182
|
+
},
|
|
183
|
+
typescript(a) {
|
|
184
|
+
var c = compile$scanner2(a, typescript);
|
|
185
|
+
codecolor(c);
|
|
186
|
+
return c.toString();
|
|
187
|
+
},
|
|
188
|
+
html(a) {
|
|
189
|
+
var code = compile$scanner2(a, 'html');
|
|
190
|
+
var scoped = code.scoped;
|
|
191
|
+
codecolor(code);
|
|
192
|
+
backEach(scoped.richNodes, n => {
|
|
193
|
+
if (n.isScript) {
|
|
194
|
+
var js = compile$scanner2(n.innerText);
|
|
195
|
+
codecolor(js);
|
|
196
|
+
code.splice(n.innerStart, n.innerEnd - n.innerStart, { text: js.toString() });
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
return code.toString();
|
|
200
|
+
},
|
|
201
|
+
css(a) {
|
|
202
|
+
var c = compile$scanner2(a);
|
|
203
|
+
codecolor(c);
|
|
204
|
+
return c.toString();
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
codesupports.cmd = codesupports.bat;
|
|
208
|
+
codesupports.jsx = codesupports.js = codesupports.javascript;
|
|
209
|
+
codesupports.tsx = codesupports.ts = codesupports.typescript;
|
|
210
|
+
codesupports.xml = codesupports.html;
|
|
211
|
+
var { SCOPED, QUOTED } = compile$common;
|
|
212
|
+
var patchBlink = function (code, index, blink) {
|
|
213
|
+
for (var cx = 0, dx = code.length; cx < dx; cx++) {
|
|
214
|
+
var c = code[cx];
|
|
215
|
+
var haschildren = c => c.type === SCOPED || c.type === QUOTED && c.length;
|
|
216
|
+
if (c.start === index) {
|
|
217
|
+
if (haschildren(c)) {
|
|
218
|
+
c.entry = blink + c.entry;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
c.blink = 0;
|
|
222
|
+
}
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
else if (c.start < index && c.end > index) {
|
|
226
|
+
if (haschildren(c)) {
|
|
227
|
+
return patchBlink(c, index, blink);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
c.blink = index - c.start;
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else if (c.end === index) {
|
|
235
|
+
if (haschildren(c)) {
|
|
236
|
+
c.leave += blink;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
c.blink = c.text.length;
|
|
240
|
+
}
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
else if (c.start > index) {
|
|
244
|
+
if (cx === 0) {
|
|
245
|
+
if (code.entry) return code.entry += blink, true;
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
var p = code[cx - 1];
|
|
250
|
+
if (haschildren(p)) {
|
|
251
|
+
p.leave += blink;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
p.blink = p.text.length;
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (code.leave) {
|
|
261
|
+
code.leave = blink + code.leave;
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
265
|
+
};
|
|
266
|
+
function codetext(type, text, blink) {
|
|
267
|
+
type = type.toLowerCase();
|
|
268
|
+
if (type in codesupports) {
|
|
269
|
+
text = codesupports[type](text, blink);
|
|
270
|
+
}
|
|
271
|
+
else text = encode(text);
|
|
272
|
+
var codes = text.split(/\r\n|\r|\n/);
|
|
273
|
+
var minSpace = 0;
|
|
274
|
+
for (var c of codes) {
|
|
275
|
+
var m = /^\s*/.exec(c);
|
|
276
|
+
if (m && m[0].length < c.length) {
|
|
277
|
+
minSpace = m[0].length;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (minSpace > 0) codes = codes.map(c => /^\s+/.test(c) ? c.slice(minSpace) : c);
|
|
281
|
+
return `<code type=${type}>${codes.join("<br/>").replace(/\t/g, Array(5).join(' ')).replace(/\s/g, ' ')}</code> `;
|
|
282
|
+
}
|
|
283
|
+
codetext.encode = encode;
|
|
284
|
+
</script>
|