efront 3.31.2 → 3.33.0
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/getIndexFromOrderedArray_test.js +11 -13
- package/coms/{zimoli → basic}/isNode.js +0 -0
- package/coms/basic/removeFromList.js +7 -5
- package/coms/basic/removeFromList_test.js +3 -0
- package/coms/basic/saveToOrderedArray_test.js +25 -0
- package/coms/{zimoli → basic}/search.js +0 -0
- package/coms/basic/serialize.js +4 -4
- package/coms/frame/chat.html +33 -4
- package/coms/frame/chat.js +202 -24
- package/coms/frame/chat.less +255 -13
- package/coms/kugou/loading.less +1 -1
- package/coms/reptile/colored_console.js +205 -29
- package/coms/reptile/colored_console_test.js +57 -0
- package/coms/shapes/file.html +1 -2
- package/coms/zimoli/autofocus.js +2 -2
- package/coms/zimoli/chooseFile.js +1 -1
- package/coms/zimoli/drag.js +2 -1
- package/coms/zimoli/loading.less +1 -1
- package/coms/zimoli/maps.js +0 -1
- package/coms/zimoli/render.js +3 -1
- package/coms/zimoli/resize.js +7 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/frame/chat.less
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
@height: 420px;
|
|
2
2
|
@width: 480px;
|
|
3
|
-
@
|
|
4
|
-
@
|
|
3
|
+
@margintop: -210px;
|
|
4
|
+
@marginleft: -180px;
|
|
5
|
+
@leftwidth: 200px;
|
|
5
6
|
|
|
6
7
|
& {
|
|
7
|
-
|
|
8
|
+
box-sizing: content-box;
|
|
9
|
+
margin: @margintop @marginleft;
|
|
10
|
+
|
|
11
|
+
&:not([resizing], [dragging]) {
|
|
12
|
+
transition: padding .2s, margin .2s;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
top: 50%;
|
|
9
16
|
left: 50%;
|
|
10
17
|
width: @width;
|
|
@@ -18,6 +25,81 @@
|
|
|
18
25
|
max-height: 100%;
|
|
19
26
|
}
|
|
20
27
|
|
|
28
|
+
>list {
|
|
29
|
+
width: @leftwidth;
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
|
|
34
|
+
.id {
|
|
35
|
+
opacity: .6;
|
|
36
|
+
transform: scale(.8);
|
|
37
|
+
transform-origin: left center;
|
|
38
|
+
font-size: 10px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.local(@color) {
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
transform: scale(.6) rotate(-45deg);
|
|
44
|
+
text-align: center;
|
|
45
|
+
padding: 0 6px;
|
|
46
|
+
position: absolute;
|
|
47
|
+
left: -6px;
|
|
48
|
+
top: 4px;
|
|
49
|
+
|
|
50
|
+
&:after,
|
|
51
|
+
&:before {
|
|
52
|
+
display: block;
|
|
53
|
+
content: "";
|
|
54
|
+
border: 8px solid transparent;
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: 50%;
|
|
57
|
+
margin: -8px 0;
|
|
58
|
+
transform: scaleX(.6);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:before {
|
|
62
|
+
left: -8px;
|
|
63
|
+
border-left: 0;
|
|
64
|
+
border-right: 12px solid @color;
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:after {
|
|
69
|
+
right: -8px;
|
|
70
|
+
border-right: 0;
|
|
71
|
+
border-left: 12px solid @color;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
background-color: @color;
|
|
75
|
+
color: #fff;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.local {
|
|
79
|
+
.local(#082);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
>.button {
|
|
83
|
+
text-align: left;
|
|
84
|
+
display: block;
|
|
85
|
+
border-radius: 0;
|
|
86
|
+
width: 100%;
|
|
87
|
+
|
|
88
|
+
&[type=white].hover {
|
|
89
|
+
color: #09c;
|
|
90
|
+
|
|
91
|
+
>.track {
|
|
92
|
+
background: #09c1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&.showList {
|
|
99
|
+
margin: @margintop -380px;
|
|
100
|
+
padding-left: @leftwidth;
|
|
101
|
+
}
|
|
102
|
+
|
|
21
103
|
padding {
|
|
22
104
|
display: block;
|
|
23
105
|
position: relative;
|
|
@@ -29,6 +111,22 @@ padding {
|
|
|
29
111
|
}
|
|
30
112
|
}
|
|
31
113
|
|
|
114
|
+
.user {
|
|
115
|
+
padding: 10px 20px 10px 56px;
|
|
116
|
+
line-height: 20px;
|
|
117
|
+
box-shadow: none;
|
|
118
|
+
|
|
119
|
+
>avatar {
|
|
120
|
+
width: 42px;
|
|
121
|
+
height: 42px;
|
|
122
|
+
background-repeat: no-repeat;
|
|
123
|
+
background-size: cover;
|
|
124
|
+
display: inline-block;
|
|
125
|
+
position: absolute;
|
|
126
|
+
left: 10px;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
32
130
|
msg {
|
|
33
131
|
display: block;
|
|
34
132
|
border-radius: 4px;
|
|
@@ -40,18 +138,18 @@ msg {
|
|
|
40
138
|
position: relative;
|
|
41
139
|
margin: 0 10px;
|
|
42
140
|
float: left;
|
|
141
|
+
user-select: text;
|
|
43
142
|
|
|
44
143
|
&:before {
|
|
45
144
|
content: "";
|
|
46
145
|
display: block;
|
|
47
146
|
position: absolute;
|
|
48
|
-
border:
|
|
147
|
+
border: 8px solid transparent;
|
|
49
148
|
top: 22px;
|
|
50
|
-
margin: -
|
|
149
|
+
margin: -14px;
|
|
51
150
|
}
|
|
52
151
|
|
|
53
152
|
&:not([self]):before {
|
|
54
|
-
display: block;
|
|
55
153
|
left: 0;
|
|
56
154
|
border-right-color: #fff;
|
|
57
155
|
}
|
|
@@ -70,10 +168,77 @@ msg {
|
|
|
70
168
|
}
|
|
71
169
|
}
|
|
72
170
|
|
|
171
|
+
msg[files] {
|
|
172
|
+
|
|
173
|
+
a {
|
|
174
|
+
display: block;
|
|
175
|
+
border: 1px solid transparent;
|
|
176
|
+
border-left: 0;
|
|
177
|
+
border-right: 0;
|
|
178
|
+
margin: 0 -6px;
|
|
179
|
+
background-color: #fff;
|
|
180
|
+
padding: 0 14px 0 10px;
|
|
181
|
+
text-align: left;
|
|
182
|
+
border-radius: 0;
|
|
183
|
+
|
|
184
|
+
&:hover {
|
|
185
|
+
border-color: #c80;
|
|
186
|
+
background-color: #ffe;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
&:active {
|
|
190
|
+
background-color: #ffc;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&:first-child {
|
|
194
|
+
border-top-color: transparent;
|
|
195
|
+
border-radius: 3px 3px 0 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&:last-child {
|
|
199
|
+
border-bottom-color: transparent;
|
|
200
|
+
border-radius: 0 0 3px 3px;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
73
204
|
|
|
74
205
|
>[head] {
|
|
75
206
|
padding: 9px 16px;
|
|
76
207
|
line-height: 24px;
|
|
208
|
+
text-align: center;
|
|
209
|
+
|
|
210
|
+
>span {
|
|
211
|
+
display: inline-block;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&:before {
|
|
215
|
+
display: none;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.id {
|
|
219
|
+
font-size: 10px;
|
|
220
|
+
color: #0009;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.menubtn {
|
|
224
|
+
border-radius: 50%;
|
|
225
|
+
width: 36px;
|
|
226
|
+
height: 36px;
|
|
227
|
+
text-align: center;
|
|
228
|
+
padding: 9px 0;
|
|
229
|
+
margin-right: 6px;
|
|
230
|
+
margin: -6px 6px -6px -6px;
|
|
231
|
+
box-shadow: none;
|
|
232
|
+
float: left;
|
|
233
|
+
|
|
234
|
+
>i {
|
|
235
|
+
margin: 0 auto;
|
|
236
|
+
display: block;
|
|
237
|
+
width: 14px;
|
|
238
|
+
border-top: 3px solid transparent;
|
|
239
|
+
border-bottom: 2px solid;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
77
242
|
}
|
|
78
243
|
|
|
79
244
|
>grid {
|
|
@@ -143,12 +308,41 @@ chat {
|
|
|
143
308
|
box-shadow: none;
|
|
144
309
|
box-shadow: none;
|
|
145
310
|
border-top: none;
|
|
311
|
+
margin-top: -34px;
|
|
312
|
+
}
|
|
146
313
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
314
|
+
>[foot]>.button {
|
|
315
|
+
pointer-events: all;
|
|
316
|
+
bottom: 0;
|
|
317
|
+
margin: 0;
|
|
318
|
+
top: 0;
|
|
319
|
+
padding: 0;
|
|
320
|
+
border-radius: 0;
|
|
321
|
+
min-width: 52px;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.unread {
|
|
325
|
+
position: absolute;
|
|
326
|
+
background: #c00;
|
|
327
|
+
color: #fff;
|
|
328
|
+
border-radius: 8px;
|
|
329
|
+
font-size: 10px;
|
|
330
|
+
padding: 0;
|
|
331
|
+
line-height: 1;
|
|
332
|
+
right: 10px;
|
|
333
|
+
top: 10px;
|
|
334
|
+
border: 2px solid #c00;
|
|
335
|
+
min-width: 16px;
|
|
336
|
+
text-align: center;
|
|
150
337
|
}
|
|
151
338
|
|
|
339
|
+
.file>svg {
|
|
340
|
+
line-height: 1;
|
|
341
|
+
vertical-align: top;
|
|
342
|
+
width: 1em;
|
|
343
|
+
height: 1em;
|
|
344
|
+
margin: 7px 2px 0 0;
|
|
345
|
+
}
|
|
152
346
|
|
|
153
347
|
.max-size() {
|
|
154
348
|
margin-top: 0 !important;
|
|
@@ -156,18 +350,66 @@ chat {
|
|
|
156
350
|
height: 100% !important;
|
|
157
351
|
margin-left: 0 !important;
|
|
158
352
|
left: 0 !important;
|
|
159
|
-
|
|
353
|
+
right: 0;
|
|
354
|
+
width: auto !important;
|
|
160
355
|
border: none;
|
|
161
|
-
.editor-height(
|
|
356
|
+
.editor-height(42px);
|
|
357
|
+
|
|
358
|
+
&.showList {
|
|
359
|
+
>grid:after {
|
|
360
|
+
content: "";
|
|
361
|
+
display: block;
|
|
362
|
+
position: absolute;
|
|
363
|
+
left: 0;
|
|
364
|
+
top: 0;
|
|
365
|
+
bottom: 0;
|
|
366
|
+
right: 0;
|
|
367
|
+
width: 100%;
|
|
368
|
+
height: 100%;
|
|
369
|
+
background: #0002;
|
|
370
|
+
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// margin-left: -@leftwidth !important;
|
|
374
|
+
}
|
|
162
375
|
|
|
163
376
|
[textarea] {
|
|
164
377
|
border-bottom: none;
|
|
165
378
|
outline: none;
|
|
379
|
+
background: #fff;
|
|
166
380
|
|
|
167
381
|
>div {
|
|
168
|
-
|
|
169
|
-
|
|
382
|
+
background-color: #eee;
|
|
383
|
+
background-clip: padding-box;
|
|
384
|
+
border: 4px solid transparent;
|
|
385
|
+
border-right-width: 52px;
|
|
386
|
+
border-left-width: 12px;
|
|
387
|
+
min-height: 32px;
|
|
388
|
+
padding: 6px;
|
|
170
389
|
}
|
|
390
|
+
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
>[foot] {
|
|
394
|
+
padding: 0;
|
|
395
|
+
|
|
396
|
+
>.button {
|
|
397
|
+
height: 42px;
|
|
398
|
+
line-height: 42px;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.file {
|
|
402
|
+
min-width: 40px;
|
|
403
|
+
|
|
404
|
+
>svg {
|
|
405
|
+
margin-top: 14px;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
>span {
|
|
409
|
+
display: none;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
171
413
|
}
|
|
172
414
|
}
|
|
173
415
|
|
package/coms/kugou/loading.less
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
var colored = Object.create(null);
|
|
3
3
|
var lazy = require("../basic/lazy");
|
|
4
4
|
var colors = require("./colors");
|
|
5
|
+
var strings = require("../basic/strings");
|
|
5
6
|
var lastLogLength = 0;
|
|
7
|
+
var needNextLine = false;
|
|
6
8
|
var getColor = function (c) {
|
|
7
9
|
switch (c) {
|
|
8
10
|
case "red":
|
|
@@ -28,14 +30,27 @@ var getColor = function (c) {
|
|
|
28
30
|
}
|
|
29
31
|
return '';
|
|
30
32
|
};
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
var colorReg = /<(\/?)([a-z][\w]*)[^\/\\\>\s]*\>/ig;
|
|
34
|
+
var renderColor = function (obj) {
|
|
35
|
+
var colorpath = [];
|
|
36
|
+
return String(obj).replace(colorReg, function (_, e, c) {
|
|
37
|
+
if (e) {
|
|
38
|
+
colorpath.pop();
|
|
39
|
+
c = colorpath[colorpath.length - 1];
|
|
40
|
+
}
|
|
41
|
+
else colorpath.push(c);
|
|
42
|
+
if (c) var color = getColor(c);
|
|
43
|
+
var res = [];
|
|
44
|
+
if (e) res.push(colors.Reset);
|
|
45
|
+
if (color) res.push(color);
|
|
46
|
+
if (res.length) return res.join('');
|
|
47
|
+
return _;
|
|
36
48
|
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var write = function (hasNewLine, str) {
|
|
37
52
|
process.stdout.cork();
|
|
38
|
-
var hasNextLine = /[\r\n\u2028\u2029]
|
|
53
|
+
var hasNextLine = /[\r\n\u2028\u2029]$/.test(str);
|
|
39
54
|
if (process.stdout.isTTY) {
|
|
40
55
|
if (lastLogLength) {
|
|
41
56
|
var width = process.stdout.columns;
|
|
@@ -48,12 +63,22 @@ var write = function (hasNewLine, str) {
|
|
|
48
63
|
else {
|
|
49
64
|
if (!hasNewLine && !hasNextLine) str = '';
|
|
50
65
|
}
|
|
51
|
-
|
|
66
|
+
if (needNextLine && !/^[\r\n\u2028\u2029]/.test(str)) {
|
|
67
|
+
process.stdout.write("\r\n");
|
|
68
|
+
}
|
|
69
|
+
if (hasNewLine && !hasNextLine) {
|
|
70
|
+
process.stdout.write(str)
|
|
71
|
+
needNextLine = true;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
process.stdout.write("\r" + str);
|
|
75
|
+
needNextLine = false;
|
|
76
|
+
}
|
|
52
77
|
if (hasNextLine) hasNewLine = true;
|
|
53
78
|
if (hasNewLine) {
|
|
54
79
|
lastLogLength = 0;
|
|
55
80
|
} else {
|
|
56
|
-
str = str.replace(/\x1b\[\d+m/g, '').replace(/\b/g, '');
|
|
81
|
+
str = String(str).replace(/\x1b\[\d+m/g, '').replace(/\b/g, '');
|
|
57
82
|
lastLogLength = str.length + str.replace(/[\x20-\xff]/g, "").length;
|
|
58
83
|
}
|
|
59
84
|
process.stdout.uncork();
|
|
@@ -74,44 +99,190 @@ var write = function (hasNewLine, str) {
|
|
|
74
99
|
var logger = function (...args) {
|
|
75
100
|
var label = fgColor + bgColor + info + reset;
|
|
76
101
|
var time_stamp = '';
|
|
77
|
-
var str = [time_stamp, label, ...args].join(" ");
|
|
78
|
-
if (queue.length > 1 && !queue[queue.length - 2] && !/[\r\n\u2028\u2029]/.test(queue[queue.length - 1])) {
|
|
79
|
-
queue.pop();
|
|
80
|
-
queue.pop();
|
|
81
|
-
}
|
|
102
|
+
var str = [time_stamp, label, ...args.map(a => renderColor(a))].join(" ");
|
|
82
103
|
write1(hasNewLine, str);
|
|
83
104
|
};
|
|
84
105
|
colored[log] = logger;
|
|
85
106
|
});
|
|
86
|
-
var queue = [];
|
|
87
|
-
var flush = function () {
|
|
88
|
-
while (queue.length) write(queue.shift(), queue.shift());
|
|
89
|
-
};
|
|
90
|
-
// var write0 = lazy(flush, -60);
|
|
91
107
|
var write1 = function (hasNewLine, str) {
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
drop.cancel();
|
|
109
|
+
str = renderColor(str);
|
|
94
110
|
write(hasNewLine, str);
|
|
95
111
|
};
|
|
96
|
-
|
|
112
|
+
var formatRows = function (arg, rows, deep, entry, leave) {
|
|
113
|
+
if (rows.length === 0) return entry + leave;
|
|
114
|
+
var ci = circleobjs.indexOf(arg);
|
|
115
|
+
if (ci >= 0) {
|
|
116
|
+
entry = `<cyan><引用点 *${ci + 1}></cyan> ` + entry;
|
|
117
|
+
}
|
|
118
|
+
if (deepobjs.length === 0) circleobjs.splice(0, circleobjs.length);
|
|
119
|
+
var space = new Array(deep).join(" ");
|
|
120
|
+
var deepspace = new Array(deep + 1).join(" ");
|
|
121
|
+
var lens = rows.slice(0, 100).map(r => r.replace(colorReg, '').replace(/[\u00ff-\uffff]/g, '00').length);
|
|
122
|
+
var maxLength = Math.max(...lens) + 2;
|
|
123
|
+
var itemcount = (process.stdout.columns - deepspace.length - 10) / maxLength | 0;
|
|
124
|
+
if (rows.length > itemcount) {
|
|
125
|
+
if (itemcount * itemcount > rows.length + process.stdout.columns) itemcount = Math.ceil(Math.sqrt(rows.length + process.stdout.columns));
|
|
126
|
+
if (itemcount > 20) itemcount = 20;
|
|
127
|
+
else if (itemcount > 10) itemcount = 10;
|
|
128
|
+
else if (itemcount > 5) itemcount = 5;
|
|
129
|
+
}
|
|
130
|
+
if (itemcount < 1) itemcount = 1;
|
|
131
|
+
var hasNextLine = false;
|
|
132
|
+
var isArray = arg instanceof Array;
|
|
133
|
+
for (var r of rows) {
|
|
134
|
+
if (/[\r\n\u2028\u2029]/.test(r)) {
|
|
135
|
+
itemcount = 1;
|
|
136
|
+
hasNextLine = true;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (!hasNextLine && deepspace.length + maxLength * rows.length < process.stdout.columns)
|
|
141
|
+
return `${entry} ${rows.join(", ")} ${leave}`;
|
|
142
|
+
var res;
|
|
143
|
+
if (itemcount <= 1) {
|
|
144
|
+
res = rows;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
var maxLength = Array(itemcount).fill(0);
|
|
148
|
+
for (var cy = 0, dy = itemcount; cy < dy; cy++) {
|
|
149
|
+
for (var cx = cy, dx = rows.length - 1; cx < dx; cx += itemcount) {
|
|
150
|
+
if (maxLength[cy] < lens[cx]) maxLength[cy] = lens[cx];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
maxLength = maxLength.map(i => i + 2);
|
|
154
|
+
res = [];
|
|
155
|
+
if (isArray) {
|
|
156
|
+
for (var cx = 0, dx = rows.length; cx < dx; cx += itemcount) {
|
|
157
|
+
res.push(rows.slice(cx, cx + itemcount).map((r, i) => {
|
|
158
|
+
return Array(maxLength[i] - lens[cx + i]).join(" ") + r;
|
|
159
|
+
}).join(', '));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
for (var cx = 0, dx = rows.length; cx < dx; cx += itemcount) {
|
|
164
|
+
res.push([rows[cx], ...rows.slice(cx + 1, cx + itemcount).map((r, i) => {
|
|
165
|
+
return Array(maxLength[i] - lens[cx + i]).join(" ") + r;
|
|
166
|
+
})].join(', '));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return `${entry}\r\n${deepspace + res.join(",\r\n" + deepspace)}\r\n${space}${leave}`
|
|
171
|
+
};
|
|
172
|
+
var deepobjs = [];
|
|
173
|
+
var circleobjs = [];
|
|
174
|
+
var format = function (arg, deep = 0) {
|
|
175
|
+
deep++;
|
|
176
|
+
if (arg === null) return String(arg);
|
|
177
|
+
if (typeof arg === 'string') {
|
|
178
|
+
if (deep > 1) return "<green>" + strings.encode(arg) + "</green>";
|
|
179
|
+
return arg;
|
|
180
|
+
}
|
|
181
|
+
if (typeof arg === 'function') return `<cyan>[${arg.__proto__.constructor.name}${arg.name ? ": " + arg.name : " (匿名)"}]</cyan>`;
|
|
182
|
+
if (/^(number|boolean)$/.test(typeof arg)) return '<yellow>' + arg + "</yellow>";
|
|
183
|
+
if (arg === undefined) return "<gray>undefined</gray>";
|
|
184
|
+
if (typeof arg === "object") {
|
|
185
|
+
if (deepobjs.indexOf(arg) >= 0) {
|
|
186
|
+
var ci = circleobjs.indexOf(arg);
|
|
187
|
+
if (ci < 0) ci = circleobjs.length, circleobjs.push(arg);
|
|
188
|
+
return `<cyan>[循环点 *${ci + 1}]</cyan>`;
|
|
189
|
+
}
|
|
190
|
+
if (arg instanceof Error) {
|
|
191
|
+
if (deep === 1) return String(arg.message);
|
|
192
|
+
return String(arg.stack || arg.message);
|
|
193
|
+
}
|
|
194
|
+
if (arg instanceof Buffer || arg instanceof ArrayBuffer || arg instanceof SharedArrayBuffer) {
|
|
195
|
+
var data = new Uint8Array(arg.buffer || arg, arg.byteOffset || 0, arg.byteLength);
|
|
196
|
+
return `<magenta><${arg.__proto__.constructor.name} ${Array.prototype.slice.call(data, 0, 20).map(a => a < 16 ? "0" + a.toString(16) : a.toString(16)).join(' ')}${arg.byteLength > 20 ? ` ... 其他 ${arg.byteLength - 20} 字节` : ''}></megenta>`;
|
|
197
|
+
}
|
|
198
|
+
else if (isFinite(arg.length)) {
|
|
199
|
+
var entry = "[";
|
|
200
|
+
var leave = "]";
|
|
201
|
+
entry = `${arg.__proto__.constructor.name}(${arg.length})${entry}`;
|
|
202
|
+
if (arg.length === 0) return entry + leave;
|
|
203
|
+
if (deep > 3 && deep + arg.length > 5) return `${entry} ... ${leave}`;
|
|
204
|
+
deepobjs.push(arg);
|
|
205
|
+
var res = Array.prototype.slice.call(arg, 0, 100).map(a => format(a, deep));
|
|
206
|
+
deepobjs.pop();
|
|
207
|
+
if (arg.length > res.length) res.push(`<gray>.. 其他 ${arg.length - res.length} 项</gray>`);
|
|
208
|
+
return formatRows(arg, res, deep, entry, leave);
|
|
209
|
+
}
|
|
210
|
+
if (arg.constructor === Date) {
|
|
211
|
+
return '<purple>' + formatDate.call(arg) + "</purple>";
|
|
212
|
+
}
|
|
213
|
+
if (arg.constructor === RegExp) {
|
|
214
|
+
return `<red2>/${arg.source}/</red2><cyan>${arg.flags}</cyan>`;
|
|
215
|
+
}
|
|
216
|
+
var keys = Object.keys(arg);
|
|
217
|
+
var ks = keys.slice(0, 100);
|
|
218
|
+
if (deep > 3 && deep + keys.length > 5) {
|
|
219
|
+
var kvs = [];
|
|
220
|
+
if (keys.length > 0) kvs.push(`<gray>.. 共 ${keys.length} 个属性</gray>`);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
deepobjs.push(arg);
|
|
224
|
+
var kvs = ks.map(k => `${/[\:'"`\[\{\(\r\n\u2028\u2029]|^\s|\s$/.test(k) ? format(k, deep) : k}: ${format(arg[k], deep)}`);
|
|
225
|
+
deepobjs.pop();
|
|
226
|
+
if (keys.length > ks.length) kvs.push(`<gray>.. 其他 ${keys.length - ks.length} 个属性</gray>`);
|
|
227
|
+
}
|
|
228
|
+
var entry = '{';
|
|
229
|
+
if (arg.constructor && arg.constructor !== Object) entry = arg.constructor.name + entry;
|
|
230
|
+
return formatRows(arg, kvs, deep, entry, '}');
|
|
231
|
+
}
|
|
232
|
+
return String(arg);
|
|
233
|
+
};
|
|
234
|
+
var toLength = function (n, a = -1) {
|
|
235
|
+
n = String(n);
|
|
236
|
+
if (n.length < 2) {
|
|
237
|
+
n = '0' + n;
|
|
238
|
+
}
|
|
239
|
+
if (a === -1 && n.length < 3) {
|
|
240
|
+
n = '0' + n;
|
|
241
|
+
}
|
|
242
|
+
return n;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
var formatDate = function () {
|
|
246
|
+
var year = this.getFullYear();
|
|
247
|
+
var month = this.getMonth() + 1;
|
|
248
|
+
var date = this.getDate();
|
|
249
|
+
var hours = this.getHours();
|
|
250
|
+
var minutes = this.getMinutes();
|
|
251
|
+
var seconds = this.getSeconds();
|
|
252
|
+
var milli = this.getMilliseconds();
|
|
253
|
+
milli = toLength(milli);
|
|
254
|
+
var offset = -this.getTimezoneOffset();
|
|
255
|
+
if (offset >= 0) {
|
|
256
|
+
offset = '+' + toLength(offset / 60 | 0, 0) + toLength(offset % 60, 0);
|
|
257
|
+
} else {
|
|
258
|
+
offset = '-' + toLength(-offset / 60 | 0, 0) + toLength(-offset % 60, 0);
|
|
259
|
+
}
|
|
260
|
+
return `${[year, month, date].map(toLength).join('-')} ${[hours, minutes, seconds].map(toLength).join(':')}.${milli} ${offset}`;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
colored.time = function (date = new Date, str) {
|
|
264
|
+
write1(true, colors.BgGray + colors.FgWhite2 + formatDate.call(date) + str + colors.Reset);
|
|
265
|
+
};
|
|
266
|
+
|
|
97
267
|
colored.type = function (...args) {
|
|
98
|
-
write1(false, args.join(' '));
|
|
268
|
+
write1(false, args.map(a => format(a)).join(' '));
|
|
269
|
+
};
|
|
270
|
+
colored.line = function (...args) {
|
|
271
|
+
write1(true, args.map(a => format(a)).join(' '));
|
|
99
272
|
};
|
|
100
273
|
var _log = console.log;
|
|
101
274
|
colored.log = function () {
|
|
102
|
-
|
|
275
|
+
if (lastLogLength > 0) write1(false, '');
|
|
276
|
+
if (needNextLine) needNextLine = false;
|
|
103
277
|
_log.apply(console, arguments);
|
|
104
278
|
};
|
|
105
279
|
colored.begin = function (c) {
|
|
106
280
|
return write1(false, getColor(c));
|
|
107
281
|
};
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
if (dropid === writeid) write1(false, "");
|
|
282
|
+
var drop = lazy(function () {
|
|
283
|
+
write(false, "");
|
|
111
284
|
}, 160);
|
|
112
|
-
colored.drop =
|
|
113
|
-
drop(++writeid);
|
|
114
|
-
};
|
|
285
|
+
colored.drop = drop;
|
|
115
286
|
colored.end = function () {
|
|
116
287
|
return write1(false, colors.Reset);
|
|
117
288
|
};
|
|
@@ -119,4 +290,9 @@ colored.clear = function (tag) {
|
|
|
119
290
|
write1(false, '');
|
|
120
291
|
if (tag) write1(true, tag);
|
|
121
292
|
};
|
|
293
|
+
colored.format = function (a) {
|
|
294
|
+
a = format(a);
|
|
295
|
+
a = renderColor(a);
|
|
296
|
+
return a;
|
|
297
|
+
};
|
|
122
298
|
module.exports = colored;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var console = require("./colored_console");
|
|
2
|
+
var data = [
|
|
3
|
+
{ a: 1 },
|
|
4
|
+
{ b: [2] },
|
|
5
|
+
{ c: null },
|
|
6
|
+
class c { },
|
|
7
|
+
{ 匿名函数: function () { } },
|
|
8
|
+
{ "arraw function": e => { } },
|
|
9
|
+
{ "function a(){}": function a() { } },
|
|
10
|
+
{ "astar function": function* b() { } },
|
|
11
|
+
{ "async function": async function* d() { } },
|
|
12
|
+
{ "二层对象": { c: 2, "三层对象": { d: 3 } } },
|
|
13
|
+
{
|
|
14
|
+
"多属性节点": {
|
|
15
|
+
a: 1,
|
|
16
|
+
b: 2,
|
|
17
|
+
c: 3,
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"多属性节点": {
|
|
22
|
+
"属性1": 1,
|
|
23
|
+
"属性2": 1,
|
|
24
|
+
"属性3": 1,
|
|
25
|
+
"属性4": 1,
|
|
26
|
+
"属性5": 1,
|
|
27
|
+
"属性6": 1,
|
|
28
|
+
"属性7": 1,
|
|
29
|
+
"属性8": 1,
|
|
30
|
+
"属性10": 1,
|
|
31
|
+
"属性11": 1,
|
|
32
|
+
"属性12": 1,
|
|
33
|
+
"属性13": 1,
|
|
34
|
+
"属性14": 1,
|
|
35
|
+
"属性15": 1,
|
|
36
|
+
"属性16": 1,
|
|
37
|
+
"属性17": 1,
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"多属性节点": function () {
|
|
42
|
+
var a = {};
|
|
43
|
+
for (var cx = 1; cx <= 101; cx++) {
|
|
44
|
+
a["属性" + cx] = cx;
|
|
45
|
+
}
|
|
46
|
+
return a;
|
|
47
|
+
}()
|
|
48
|
+
},
|
|
49
|
+
/Abcdefg/gimuy,
|
|
50
|
+
new Error("错误信息"),
|
|
51
|
+
new Date,
|
|
52
|
+
{ "循环对象": null },
|
|
53
|
+
];
|
|
54
|
+
data[data.length - 1].循环对象 = data[data.length - 1];
|
|
55
|
+
console.log(data);
|
|
56
|
+
console.line(data);
|
|
57
|
+
throw new Error(2);
|
package/coms/shapes/file.html
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<svg width="92" height="92" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
2
|
-
style="fill:
|
|
3
|
-
|
|
2
|
+
style="fill: currentColor" overflow="hidden" viewBox="12 135 92 92">
|
|
4
3
|
<g>
|
|
5
4
|
<path
|
|
6
5
|
d="M32 215 32 147 60 147 60 168 82 168 82 215 32 215ZM66 149.5 78.5 162 66 162 66 149.5ZM66 141 26 141 26 221 88 221 88 163 66 141Z"
|