llonebot-dist 7.0.1 → 7.1.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/llonebot.js +2336 -10459
- package/llonebot.js.map +1 -1
- package/node_modules/cosmokit/LICENSE +21 -0
- package/node_modules/cosmokit/README.md +24 -0
- package/node_modules/cosmokit/lib/index.cjs +463 -0
- package/node_modules/cosmokit/lib/index.cjs.map +6 -0
- package/node_modules/cosmokit/lib/index.d.ts +142 -0
- package/node_modules/cosmokit/lib/index.mjs +403 -0
- package/node_modules/cosmokit/lib/index.mjs.map +6 -0
- package/node_modules/cosmokit/package.json +56 -0
- package/node_modules/cosmokit/src/array.ts +35 -0
- package/node_modules/cosmokit/src/index.ts +5 -0
- package/node_modules/cosmokit/src/misc.ts +57 -0
- package/node_modules/cosmokit/src/string.ts +101 -0
- package/node_modules/cosmokit/src/time.ts +91 -0
- package/node_modules/cosmokit/src/types.ts +129 -0
- package/node_modules/has-flag/index.d.ts +39 -0
- package/node_modules/has-flag/index.js +8 -0
- package/node_modules/has-flag/license +9 -0
- package/node_modules/has-flag/package.json +46 -0
- package/node_modules/has-flag/readme.md +89 -0
- package/node_modules/object-inspect/CHANGELOG.md +424 -0
- package/node_modules/object-inspect/LICENSE +21 -0
- package/node_modules/object-inspect/example/all.js +23 -0
- package/node_modules/object-inspect/example/circular.js +6 -0
- package/node_modules/object-inspect/example/fn.js +5 -0
- package/node_modules/object-inspect/example/inspect.js +10 -0
- package/node_modules/object-inspect/index.js +544 -0
- package/node_modules/object-inspect/package-support.json +20 -0
- package/node_modules/object-inspect/package.json +105 -0
- package/node_modules/object-inspect/readme.markdown +84 -0
- package/node_modules/object-inspect/test/bigint.js +58 -0
- package/node_modules/object-inspect/test/browser/dom.js +15 -0
- package/node_modules/object-inspect/test/circular.js +16 -0
- package/node_modules/object-inspect/test/deep.js +12 -0
- package/node_modules/object-inspect/test/element.js +53 -0
- package/node_modules/object-inspect/test/err.js +48 -0
- package/node_modules/object-inspect/test/fakes.js +29 -0
- package/node_modules/object-inspect/test/fn.js +76 -0
- package/node_modules/object-inspect/test/global.js +17 -0
- package/node_modules/object-inspect/test/has.js +15 -0
- package/node_modules/object-inspect/test/holes.js +15 -0
- package/node_modules/object-inspect/test/indent-option.js +271 -0
- package/node_modules/object-inspect/test/inspect.js +139 -0
- package/node_modules/object-inspect/test/lowbyte.js +12 -0
- package/node_modules/object-inspect/test/number.js +58 -0
- package/node_modules/object-inspect/test/quoteStyle.js +26 -0
- package/node_modules/object-inspect/test/toStringTag.js +40 -0
- package/node_modules/object-inspect/test/undef.js +12 -0
- package/node_modules/object-inspect/test/values.js +261 -0
- package/node_modules/object-inspect/test-core-js.js +26 -0
- package/node_modules/object-inspect/util.inspect.js +1 -0
- package/node_modules/reggol/LICENSE +21 -0
- package/node_modules/reggol/README.md +8 -0
- package/node_modules/reggol/index.d.ts +79 -0
- package/node_modules/reggol/lib/browser.mjs +299 -0
- package/node_modules/reggol/lib/node.js +31 -0
- package/node_modules/reggol/lib/shared.js +258 -0
- package/node_modules/reggol/lib/shared.mjs +266 -0
- package/node_modules/reggol/node_modules/supports-color/browser.js +24 -0
- package/node_modules/reggol/node_modules/supports-color/index.js +152 -0
- package/node_modules/reggol/node_modules/supports-color/license +9 -0
- package/node_modules/reggol/node_modules/supports-color/package.json +58 -0
- package/node_modules/reggol/node_modules/supports-color/readme.md +77 -0
- package/node_modules/reggol/package.json +65 -0
- package/node_modules/reggol/src/browser.ts +8 -0
- package/node_modules/reggol/src/index.ts +3 -0
- package/node_modules/reggol/src/node.ts +8 -0
- package/node_modules/reggol/src/shared.ts +249 -0
- package/node_modules/supports-color/browser.d.ts +1 -0
- package/node_modules/supports-color/browser.js +35 -0
- package/node_modules/supports-color/index.d.ts +55 -0
- package/node_modules/supports-color/index.js +202 -0
- package/node_modules/supports-color/license +9 -0
- package/node_modules/supports-color/package.json +64 -0
- package/node_modules/supports-color/readme.md +75 -0
- package/package.json +1 -1
- package//344/275/277/347/224/250/350/257/264/346/230/216.txt +2 -2
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +23 -0
- package/webui/assets/index-DH65Wt1j.css +0 -1
- package/webui/assets/index-fRyBxWld.js +0 -273
- package/webui/index.html +0 -13
- package/webui/logo.jpg +0 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var inspect = require('../');
|
|
4
|
+
var test = require('tape');
|
|
5
|
+
var mockProperty = require('mock-property');
|
|
6
|
+
var hasSymbols = require('has-symbols/shams')();
|
|
7
|
+
var hasToStringTag = require('has-tostringtag/shams')();
|
|
8
|
+
var forEach = require('for-each');
|
|
9
|
+
var semver = require('semver');
|
|
10
|
+
|
|
11
|
+
test('values', function (t) {
|
|
12
|
+
t.plan(1);
|
|
13
|
+
var obj = [{}, [], { 'a-b': 5 }];
|
|
14
|
+
t.equal(inspect(obj), '[ {}, [], { \'a-b\': 5 } ]');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('arrays with properties', function (t) {
|
|
18
|
+
t.plan(1);
|
|
19
|
+
var arr = [3];
|
|
20
|
+
arr.foo = 'bar';
|
|
21
|
+
var obj = [1, 2, arr];
|
|
22
|
+
obj.baz = 'quux';
|
|
23
|
+
obj.index = -1;
|
|
24
|
+
t.equal(inspect(obj), '[ 1, 2, [ 3, foo: \'bar\' ], baz: \'quux\', index: -1 ]');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('has', function (t) {
|
|
28
|
+
t.plan(1);
|
|
29
|
+
t.teardown(mockProperty(Object.prototype, 'hasOwnProperty', { 'delete': true }));
|
|
30
|
+
|
|
31
|
+
t.equal(inspect({ a: 1, b: 2 }), '{ a: 1, b: 2 }');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('indexOf seen', function (t) {
|
|
35
|
+
t.plan(1);
|
|
36
|
+
var xs = [1, 2, 3, {}];
|
|
37
|
+
xs.push(xs);
|
|
38
|
+
|
|
39
|
+
var seen = [];
|
|
40
|
+
seen.indexOf = undefined;
|
|
41
|
+
|
|
42
|
+
t.equal(
|
|
43
|
+
inspect(xs, {}, 0, seen),
|
|
44
|
+
'[ 1, 2, 3, {}, [Circular] ]'
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('seen seen', function (t) {
|
|
49
|
+
t.plan(1);
|
|
50
|
+
var xs = [1, 2, 3];
|
|
51
|
+
|
|
52
|
+
var seen = [xs];
|
|
53
|
+
seen.indexOf = undefined;
|
|
54
|
+
|
|
55
|
+
t.equal(
|
|
56
|
+
inspect(xs, {}, 0, seen),
|
|
57
|
+
'[Circular]'
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('seen seen seen', function (t) {
|
|
62
|
+
t.plan(1);
|
|
63
|
+
var xs = [1, 2, 3];
|
|
64
|
+
|
|
65
|
+
var seen = [5, xs];
|
|
66
|
+
seen.indexOf = undefined;
|
|
67
|
+
|
|
68
|
+
t.equal(
|
|
69
|
+
inspect(xs, {}, 0, seen),
|
|
70
|
+
'[Circular]'
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('symbols', { skip: !hasSymbols }, function (t) {
|
|
75
|
+
var sym = Symbol('foo');
|
|
76
|
+
t.equal(inspect(sym), 'Symbol(foo)', 'Symbol("foo") should be "Symbol(foo)"');
|
|
77
|
+
if (typeof sym === 'symbol') {
|
|
78
|
+
// Symbol shams are incapable of differentiating boxed from unboxed symbols
|
|
79
|
+
t.equal(inspect(Object(sym)), 'Object(Symbol(foo))', 'Object(Symbol("foo")) should be "Object(Symbol(foo))"');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
t.test('toStringTag', { skip: !hasToStringTag }, function (st) {
|
|
83
|
+
st.plan(1);
|
|
84
|
+
|
|
85
|
+
var faker = {};
|
|
86
|
+
faker[Symbol.toStringTag] = 'Symbol';
|
|
87
|
+
st.equal(
|
|
88
|
+
inspect(faker),
|
|
89
|
+
'{ [Symbol(Symbol.toStringTag)]: \'Symbol\' }',
|
|
90
|
+
'object lying about being a Symbol inspects as an object'
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
t.end();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('Map', { skip: typeof Map !== 'function' }, function (t) {
|
|
98
|
+
var map = new Map();
|
|
99
|
+
map.set({ a: 1 }, ['b']);
|
|
100
|
+
map.set(3, NaN);
|
|
101
|
+
var expectedString = 'Map (2) {' + inspect({ a: 1 }) + ' => ' + inspect(['b']) + ', 3 => NaN}';
|
|
102
|
+
t.equal(inspect(map), expectedString, 'new Map([[{ a: 1 }, ["b"]], [3, NaN]]) should show size and contents');
|
|
103
|
+
t.equal(inspect(new Map()), 'Map (0) {}', 'empty Map should show as empty');
|
|
104
|
+
|
|
105
|
+
var nestedMap = new Map();
|
|
106
|
+
nestedMap.set(nestedMap, map);
|
|
107
|
+
t.equal(inspect(nestedMap), 'Map (1) {[Circular] => ' + expectedString + '}', 'Map containing a Map should work');
|
|
108
|
+
|
|
109
|
+
t.end();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('WeakMap', { skip: typeof WeakMap !== 'function' }, function (t) {
|
|
113
|
+
var map = new WeakMap();
|
|
114
|
+
map.set({ a: 1 }, ['b']);
|
|
115
|
+
var expectedString = 'WeakMap { ? }';
|
|
116
|
+
t.equal(inspect(map), expectedString, 'new WeakMap([[{ a: 1 }, ["b"]]]) should not show size or contents');
|
|
117
|
+
t.equal(inspect(new WeakMap()), 'WeakMap { ? }', 'empty WeakMap should not show as empty');
|
|
118
|
+
|
|
119
|
+
t.end();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('Set', { skip: typeof Set !== 'function' }, function (t) {
|
|
123
|
+
var set = new Set();
|
|
124
|
+
set.add({ a: 1 });
|
|
125
|
+
set.add(['b']);
|
|
126
|
+
var expectedString = 'Set (2) {' + inspect({ a: 1 }) + ', ' + inspect(['b']) + '}';
|
|
127
|
+
t.equal(inspect(set), expectedString, 'new Set([{ a: 1 }, ["b"]]) should show size and contents');
|
|
128
|
+
t.equal(inspect(new Set()), 'Set (0) {}', 'empty Set should show as empty');
|
|
129
|
+
|
|
130
|
+
var nestedSet = new Set();
|
|
131
|
+
nestedSet.add(set);
|
|
132
|
+
nestedSet.add(nestedSet);
|
|
133
|
+
t.equal(inspect(nestedSet), 'Set (2) {' + expectedString + ', [Circular]}', 'Set containing a Set should work');
|
|
134
|
+
|
|
135
|
+
t.end();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('WeakSet', { skip: typeof WeakSet !== 'function' }, function (t) {
|
|
139
|
+
var map = new WeakSet();
|
|
140
|
+
map.add({ a: 1 });
|
|
141
|
+
var expectedString = 'WeakSet { ? }';
|
|
142
|
+
t.equal(inspect(map), expectedString, 'new WeakSet([{ a: 1 }]) should not show size or contents');
|
|
143
|
+
t.equal(inspect(new WeakSet()), 'WeakSet { ? }', 'empty WeakSet should not show as empty');
|
|
144
|
+
|
|
145
|
+
t.end();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('WeakRef', { skip: typeof WeakRef !== 'function' }, function (t) {
|
|
149
|
+
var ref = new WeakRef({ a: 1 });
|
|
150
|
+
var expectedString = 'WeakRef { ? }';
|
|
151
|
+
t.equal(inspect(ref), expectedString, 'new WeakRef({ a: 1 }) should not show contents');
|
|
152
|
+
|
|
153
|
+
t.end();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('FinalizationRegistry', { skip: typeof FinalizationRegistry !== 'function' }, function (t) {
|
|
157
|
+
var registry = new FinalizationRegistry(function () {});
|
|
158
|
+
var expectedString = 'FinalizationRegistry [FinalizationRegistry] {}';
|
|
159
|
+
t.equal(inspect(registry), expectedString, 'new FinalizationRegistry(function () {}) should work normallys');
|
|
160
|
+
|
|
161
|
+
t.end();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('Strings', function (t) {
|
|
165
|
+
var str = 'abc';
|
|
166
|
+
|
|
167
|
+
t.equal(inspect(str), "'" + str + "'", 'primitive string shows as such');
|
|
168
|
+
t.equal(inspect(str, { quoteStyle: 'single' }), "'" + str + "'", 'primitive string shows as such, single quoted');
|
|
169
|
+
t.equal(inspect(str, { quoteStyle: 'double' }), '"' + str + '"', 'primitive string shows as such, double quoted');
|
|
170
|
+
t.equal(inspect(Object(str)), 'Object(' + inspect(str) + ')', 'String object shows as such');
|
|
171
|
+
t.equal(inspect(Object(str), { quoteStyle: 'single' }), 'Object(' + inspect(str, { quoteStyle: 'single' }) + ')', 'String object shows as such, single quoted');
|
|
172
|
+
t.equal(inspect(Object(str), { quoteStyle: 'double' }), 'Object(' + inspect(str, { quoteStyle: 'double' }) + ')', 'String object shows as such, double quoted');
|
|
173
|
+
|
|
174
|
+
t.end();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('Numbers', function (t) {
|
|
178
|
+
var num = 42;
|
|
179
|
+
|
|
180
|
+
t.equal(inspect(num), String(num), 'primitive number shows as such');
|
|
181
|
+
t.equal(inspect(Object(num)), 'Object(' + inspect(num) + ')', 'Number object shows as such');
|
|
182
|
+
|
|
183
|
+
t.end();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('Booleans', function (t) {
|
|
187
|
+
t.equal(inspect(true), String(true), 'primitive true shows as such');
|
|
188
|
+
t.equal(inspect(Object(true)), 'Object(' + inspect(true) + ')', 'Boolean object true shows as such');
|
|
189
|
+
|
|
190
|
+
t.equal(inspect(false), String(false), 'primitive false shows as such');
|
|
191
|
+
t.equal(inspect(Object(false)), 'Object(' + inspect(false) + ')', 'Boolean false object shows as such');
|
|
192
|
+
|
|
193
|
+
t.end();
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('Date', function (t) {
|
|
197
|
+
var now = new Date();
|
|
198
|
+
t.equal(inspect(now), String(now), 'Date shows properly');
|
|
199
|
+
t.equal(inspect(new Date(NaN)), 'Invalid Date', 'Invalid Date shows properly');
|
|
200
|
+
|
|
201
|
+
t.end();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('RegExps', function (t) {
|
|
205
|
+
t.equal(inspect(/a/g), '/a/g', 'regex shows properly');
|
|
206
|
+
t.equal(inspect(new RegExp('abc', 'i')), '/abc/i', 'new RegExp shows properly');
|
|
207
|
+
|
|
208
|
+
var match = 'abc abc'.match(/[ab]+/);
|
|
209
|
+
delete match.groups; // for node < 10
|
|
210
|
+
t.equal(inspect(match), '[ \'ab\', index: 0, input: \'abc abc\' ]', 'RegExp match object shows properly');
|
|
211
|
+
|
|
212
|
+
t.end();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
test('Proxies', { skip: typeof Proxy !== 'function' || !hasToStringTag }, function (t) {
|
|
216
|
+
var target = { proxy: true };
|
|
217
|
+
var fake = new Proxy(target, { has: function () { return false; } });
|
|
218
|
+
|
|
219
|
+
// needed to work around a weird difference in node v6.0 - v6.4 where non-present properties are not logged
|
|
220
|
+
var isNode60 = semver.satisfies(process.version, '6.0 - 6.4');
|
|
221
|
+
|
|
222
|
+
forEach([
|
|
223
|
+
'Boolean',
|
|
224
|
+
'Number',
|
|
225
|
+
'String',
|
|
226
|
+
'Symbol',
|
|
227
|
+
'Date'
|
|
228
|
+
], function (tag) {
|
|
229
|
+
target[Symbol.toStringTag] = tag;
|
|
230
|
+
|
|
231
|
+
t.equal(
|
|
232
|
+
inspect(fake),
|
|
233
|
+
'{ ' + (isNode60 ? '' : 'proxy: true, ') + '[Symbol(Symbol.toStringTag)]: \'' + tag + '\' }',
|
|
234
|
+
'Proxy for + ' + tag + ' shows as the target, which has no slots'
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
t.end();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test('fakers', { skip: !hasToStringTag }, function (t) {
|
|
242
|
+
var target = { proxy: false };
|
|
243
|
+
|
|
244
|
+
forEach([
|
|
245
|
+
'Boolean',
|
|
246
|
+
'Number',
|
|
247
|
+
'String',
|
|
248
|
+
'Symbol',
|
|
249
|
+
'Date'
|
|
250
|
+
], function (tag) {
|
|
251
|
+
target[Symbol.toStringTag] = tag;
|
|
252
|
+
|
|
253
|
+
t.equal(
|
|
254
|
+
inspect(target),
|
|
255
|
+
'{ proxy: false, [Symbol(Symbol.toStringTag)]: \'' + tag + '\' }',
|
|
256
|
+
'Object pretending to be ' + tag + ' does not trick us'
|
|
257
|
+
);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
t.end();
|
|
261
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('core-js');
|
|
4
|
+
|
|
5
|
+
var inspect = require('./');
|
|
6
|
+
var test = require('tape');
|
|
7
|
+
|
|
8
|
+
test('Maps', function (t) {
|
|
9
|
+
t.equal(inspect(new Map([[1, 2]])), 'Map (1) {1 => 2}');
|
|
10
|
+
t.end();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('WeakMaps', function (t) {
|
|
14
|
+
t.equal(inspect(new WeakMap([[{}, 2]])), 'WeakMap { ? }');
|
|
15
|
+
t.end();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('Sets', function (t) {
|
|
19
|
+
t.equal(inspect(new Set([[1, 2]])), 'Set (1) {[ 1, 2 ]}');
|
|
20
|
+
t.end();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('WeakSets', function (t) {
|
|
24
|
+
t.equal(inspect(new WeakSet([[1, 2]])), 'WeakSet { ? }');
|
|
25
|
+
t.end();
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('util').inspect;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Shigma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# reggol
|
|
2
|
+
|
|
3
|
+
[](https://codecov.io/gh/shigma/reggol)
|
|
4
|
+
[](https://www.npmjs.com/package/reggol)
|
|
5
|
+
[](https://www.npmjs.com/package/reggol)
|
|
6
|
+
[](https://github.com/shigma/reggol/blob/master/LICENSE)
|
|
7
|
+
|
|
8
|
+
Logger for professionals.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
declare namespace Logger {
|
|
2
|
+
export interface LevelConfig {
|
|
3
|
+
base: number
|
|
4
|
+
[K: string]: Level
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type Level = number | LevelConfig
|
|
8
|
+
export type Function = (format: any, ...param: any[]) => void
|
|
9
|
+
export type Type = 'success' | 'error' | 'info' | 'warn' | 'debug'
|
|
10
|
+
export type Formatter = (this: Logger, value: any) => string
|
|
11
|
+
|
|
12
|
+
export interface LabelStyle {
|
|
13
|
+
width?: number
|
|
14
|
+
margin?: number
|
|
15
|
+
align?: 'left' | 'right'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Record {
|
|
19
|
+
id: number
|
|
20
|
+
meta: Meta
|
|
21
|
+
name: string
|
|
22
|
+
type: Type
|
|
23
|
+
level: number
|
|
24
|
+
content: string
|
|
25
|
+
timestamp: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Meta {}
|
|
29
|
+
|
|
30
|
+
export interface Target {
|
|
31
|
+
/**
|
|
32
|
+
* - 0: no color support
|
|
33
|
+
* - 1: 16 color support
|
|
34
|
+
* - 2: 256 color support
|
|
35
|
+
* - 3: truecolor support
|
|
36
|
+
*/
|
|
37
|
+
colors?: number
|
|
38
|
+
showDiff?: boolean
|
|
39
|
+
showTime?: string
|
|
40
|
+
label?: LabelStyle
|
|
41
|
+
record?(record: Record): void
|
|
42
|
+
print?(text: string): void
|
|
43
|
+
levels?: LevelConfig
|
|
44
|
+
timestamp?: number
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare interface Logger extends Record<Logger.Type, Logger.Function> {}
|
|
49
|
+
|
|
50
|
+
declare class Logger {
|
|
51
|
+
// log levels
|
|
52
|
+
static readonly SILENT = 0
|
|
53
|
+
static readonly SUCCESS = 1
|
|
54
|
+
static readonly ERROR = 1
|
|
55
|
+
static readonly INFO = 2
|
|
56
|
+
static readonly WARN = 2
|
|
57
|
+
static readonly DEBUG = 3
|
|
58
|
+
|
|
59
|
+
// global config
|
|
60
|
+
static colors: number[]
|
|
61
|
+
static instances: Record<string, Logger>
|
|
62
|
+
static targets: Logger.Target[]
|
|
63
|
+
static levels: Logger.LevelConfig
|
|
64
|
+
static formatters: Record<string, Logger.Formatter>
|
|
65
|
+
|
|
66
|
+
static color(code: number, value: any, decoration?: string): string
|
|
67
|
+
static code(name: string, target: Logger.Target): number
|
|
68
|
+
|
|
69
|
+
public name: string
|
|
70
|
+
public level: number
|
|
71
|
+
|
|
72
|
+
private code: number
|
|
73
|
+
|
|
74
|
+
constructor(name: string, meta?: any)
|
|
75
|
+
|
|
76
|
+
extend(namespace: string): Logger
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export = Logger
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
// src/shared.ts
|
|
29
|
+
import { stdout } from "supports-color";
|
|
30
|
+
import { Time } from "cosmokit";
|
|
31
|
+
var require_shared = __commonJS({
|
|
32
|
+
"src/shared.ts"(exports, module) {
|
|
33
|
+
"use strict";
|
|
34
|
+
var c16 = [6, 2, 3, 4, 5, 1];
|
|
35
|
+
var c256 = [
|
|
36
|
+
20,
|
|
37
|
+
21,
|
|
38
|
+
26,
|
|
39
|
+
27,
|
|
40
|
+
32,
|
|
41
|
+
33,
|
|
42
|
+
38,
|
|
43
|
+
39,
|
|
44
|
+
40,
|
|
45
|
+
41,
|
|
46
|
+
42,
|
|
47
|
+
43,
|
|
48
|
+
44,
|
|
49
|
+
45,
|
|
50
|
+
56,
|
|
51
|
+
57,
|
|
52
|
+
62,
|
|
53
|
+
63,
|
|
54
|
+
68,
|
|
55
|
+
69,
|
|
56
|
+
74,
|
|
57
|
+
75,
|
|
58
|
+
76,
|
|
59
|
+
77,
|
|
60
|
+
78,
|
|
61
|
+
79,
|
|
62
|
+
80,
|
|
63
|
+
81,
|
|
64
|
+
92,
|
|
65
|
+
93,
|
|
66
|
+
98,
|
|
67
|
+
99,
|
|
68
|
+
112,
|
|
69
|
+
113,
|
|
70
|
+
129,
|
|
71
|
+
134,
|
|
72
|
+
135,
|
|
73
|
+
148,
|
|
74
|
+
149,
|
|
75
|
+
160,
|
|
76
|
+
161,
|
|
77
|
+
162,
|
|
78
|
+
163,
|
|
79
|
+
164,
|
|
80
|
+
165,
|
|
81
|
+
166,
|
|
82
|
+
167,
|
|
83
|
+
168,
|
|
84
|
+
169,
|
|
85
|
+
170,
|
|
86
|
+
171,
|
|
87
|
+
172,
|
|
88
|
+
173,
|
|
89
|
+
178,
|
|
90
|
+
179,
|
|
91
|
+
184,
|
|
92
|
+
185,
|
|
93
|
+
196,
|
|
94
|
+
197,
|
|
95
|
+
198,
|
|
96
|
+
199,
|
|
97
|
+
200,
|
|
98
|
+
201,
|
|
99
|
+
202,
|
|
100
|
+
203,
|
|
101
|
+
204,
|
|
102
|
+
205,
|
|
103
|
+
206,
|
|
104
|
+
207,
|
|
105
|
+
208,
|
|
106
|
+
209,
|
|
107
|
+
214,
|
|
108
|
+
215,
|
|
109
|
+
220,
|
|
110
|
+
221
|
|
111
|
+
];
|
|
112
|
+
function isAggregateError(error) {
|
|
113
|
+
return error instanceof Error && Array.isArray(error["errors"]);
|
|
114
|
+
}
|
|
115
|
+
__name(isAggregateError, "isAggregateError");
|
|
116
|
+
var Logger = class _Logger {
|
|
117
|
+
constructor(name, meta) {
|
|
118
|
+
this.name = name;
|
|
119
|
+
this.meta = meta;
|
|
120
|
+
this.createMethod("success", _Logger.SUCCESS);
|
|
121
|
+
this.createMethod("error", _Logger.ERROR);
|
|
122
|
+
this.createMethod("info", _Logger.INFO);
|
|
123
|
+
this.createMethod("warn", _Logger.WARN);
|
|
124
|
+
this.createMethod("debug", _Logger.DEBUG);
|
|
125
|
+
}
|
|
126
|
+
static {
|
|
127
|
+
__name(this, "Logger");
|
|
128
|
+
}
|
|
129
|
+
// log levels
|
|
130
|
+
static SILENT = 0;
|
|
131
|
+
static SUCCESS = 1;
|
|
132
|
+
static ERROR = 1;
|
|
133
|
+
static INFO = 2;
|
|
134
|
+
static WARN = 2;
|
|
135
|
+
static DEBUG = 3;
|
|
136
|
+
// global config
|
|
137
|
+
static id = 0;
|
|
138
|
+
static targets = [{
|
|
139
|
+
colors: stdout && stdout.level,
|
|
140
|
+
print(text) {
|
|
141
|
+
console.log(text);
|
|
142
|
+
}
|
|
143
|
+
}];
|
|
144
|
+
// global registry
|
|
145
|
+
static formatters = /* @__PURE__ */ Object.create(null);
|
|
146
|
+
static format(name, formatter) {
|
|
147
|
+
this.formatters[name] = formatter;
|
|
148
|
+
}
|
|
149
|
+
static levels = {
|
|
150
|
+
base: 2
|
|
151
|
+
};
|
|
152
|
+
static color(target, code, value, decoration = "") {
|
|
153
|
+
if (!target.colors) return "" + value;
|
|
154
|
+
return `\x1B[3${code < 8 ? code : "8;5;" + code}${target.colors >= 2 ? decoration : ""}m${value}\x1B[0m`;
|
|
155
|
+
}
|
|
156
|
+
static code(name, target) {
|
|
157
|
+
let hash = 0;
|
|
158
|
+
for (let i = 0; i < name.length; i++) {
|
|
159
|
+
hash = (hash << 3) - hash + name.charCodeAt(i) + 13;
|
|
160
|
+
hash |= 0;
|
|
161
|
+
}
|
|
162
|
+
const colors = !target.colors ? [] : target.colors >= 2 ? c256 : c16;
|
|
163
|
+
return colors[Math.abs(hash) % colors.length];
|
|
164
|
+
}
|
|
165
|
+
static render(target, record) {
|
|
166
|
+
const prefix = `[${record.type[0].toUpperCase()}]`;
|
|
167
|
+
const space = " ".repeat(target.label?.margin ?? 1);
|
|
168
|
+
let indent = 3 + space.length, output = "";
|
|
169
|
+
if (target.showTime) {
|
|
170
|
+
indent += target.showTime.length + space.length;
|
|
171
|
+
output += _Logger.color(target, 8, Time.template(target.showTime)) + space;
|
|
172
|
+
}
|
|
173
|
+
const code = _Logger.code(record.name, target);
|
|
174
|
+
const label = _Logger.color(target, code, record.name, ";1");
|
|
175
|
+
const padLength = (target.label?.width ?? 0) + label.length - record.name.length;
|
|
176
|
+
if (target.label?.align === "right") {
|
|
177
|
+
output += label.padStart(padLength) + space + prefix + space;
|
|
178
|
+
indent += (target.label.width ?? 0) + space.length;
|
|
179
|
+
} else {
|
|
180
|
+
output += prefix + space + label.padEnd(padLength) + space;
|
|
181
|
+
}
|
|
182
|
+
output += record.content.replace(/\n/g, "\n" + " ".repeat(indent));
|
|
183
|
+
if (target.showDiff && target.timestamp) {
|
|
184
|
+
const diff = record.timestamp - target.timestamp;
|
|
185
|
+
output += _Logger.color(target, code, " +" + Time.format(diff));
|
|
186
|
+
}
|
|
187
|
+
return output;
|
|
188
|
+
}
|
|
189
|
+
extend = /* @__PURE__ */ __name((namespace) => {
|
|
190
|
+
return new _Logger(`${this.name}:${namespace}`, this.meta);
|
|
191
|
+
}, "extend");
|
|
192
|
+
warning = /* @__PURE__ */ __name((format, ...args) => {
|
|
193
|
+
this.warn(format, ...args);
|
|
194
|
+
}, "warning");
|
|
195
|
+
createMethod(type, level) {
|
|
196
|
+
this[type] = (...args) => {
|
|
197
|
+
if (args.length === 1 && args[0] instanceof Error) {
|
|
198
|
+
if (args[0].cause) {
|
|
199
|
+
this[type](args[0].cause);
|
|
200
|
+
} else if (isAggregateError(args[0])) {
|
|
201
|
+
args[0].errors.forEach((error) => this[type](error));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const id = ++_Logger.id;
|
|
206
|
+
const timestamp = Date.now();
|
|
207
|
+
for (const target of _Logger.targets) {
|
|
208
|
+
if (this.getLevel(target) < level) continue;
|
|
209
|
+
const content = this.format(target, ...args);
|
|
210
|
+
const record = { id, type, level, name: this.name, meta: this.meta, content, timestamp };
|
|
211
|
+
if (target.record) {
|
|
212
|
+
target.record(record);
|
|
213
|
+
} else {
|
|
214
|
+
const { print = console.log } = target;
|
|
215
|
+
print(_Logger.render(target, record));
|
|
216
|
+
}
|
|
217
|
+
target.timestamp = timestamp;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
format(target, ...args) {
|
|
222
|
+
if (args[0] instanceof Error) {
|
|
223
|
+
args[0] = args[0].stack || args[0].message;
|
|
224
|
+
args.unshift("%s");
|
|
225
|
+
} else if (typeof args[0] !== "string") {
|
|
226
|
+
args.unshift("%o");
|
|
227
|
+
}
|
|
228
|
+
let format = args.shift();
|
|
229
|
+
format = format.replace(/%([a-zA-Z%])/g, (match, char) => {
|
|
230
|
+
if (match === "%%") return "%";
|
|
231
|
+
const formatter = _Logger.formatters[char];
|
|
232
|
+
if (typeof formatter === "function") {
|
|
233
|
+
const value = args.shift();
|
|
234
|
+
return formatter(value, target, this);
|
|
235
|
+
}
|
|
236
|
+
return match;
|
|
237
|
+
});
|
|
238
|
+
for (let arg of args) {
|
|
239
|
+
if (typeof arg === "object" && arg) {
|
|
240
|
+
arg = _Logger.formatters["o"](arg, target, this);
|
|
241
|
+
}
|
|
242
|
+
format += " " + arg;
|
|
243
|
+
}
|
|
244
|
+
const { maxLength = 10240 } = target;
|
|
245
|
+
return format.split(/\r?\n/g).map((line) => {
|
|
246
|
+
return line.slice(0, maxLength) + (line.length > maxLength ? "..." : "");
|
|
247
|
+
}).join("\n");
|
|
248
|
+
}
|
|
249
|
+
getLevel(target) {
|
|
250
|
+
const paths = this.name.split(":");
|
|
251
|
+
let config = target?.levels || _Logger.levels;
|
|
252
|
+
do {
|
|
253
|
+
config = config[paths.shift()] ?? config["base"];
|
|
254
|
+
} while (paths.length && typeof config === "object");
|
|
255
|
+
return config;
|
|
256
|
+
}
|
|
257
|
+
get level() {
|
|
258
|
+
return this.getLevel();
|
|
259
|
+
}
|
|
260
|
+
set level(value) {
|
|
261
|
+
const paths = this.name.split(":");
|
|
262
|
+
let config = _Logger.levels;
|
|
263
|
+
while (paths.length > 1) {
|
|
264
|
+
const name = paths.shift();
|
|
265
|
+
const value2 = config[name];
|
|
266
|
+
if (typeof value2 === "object") {
|
|
267
|
+
config = value2;
|
|
268
|
+
} else {
|
|
269
|
+
config = config[name] = { base: value2 ?? config.base };
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
config[paths[0]] = value;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
Logger.format("s", (value) => value);
|
|
276
|
+
Logger.format("d", (value) => +value);
|
|
277
|
+
Logger.format("j", (value) => JSON.stringify(value));
|
|
278
|
+
Logger.format("c", (value, target, logger) => {
|
|
279
|
+
return Logger.color(target, Logger.code(logger.name, target), value);
|
|
280
|
+
});
|
|
281
|
+
Logger.format("C", (value, target) => {
|
|
282
|
+
return Logger.color(target, 15, value, ";1");
|
|
283
|
+
});
|
|
284
|
+
module.exports = Logger;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// src/browser.ts
|
|
289
|
+
import inspect from "object-inspect";
|
|
290
|
+
var require_browser = __commonJS({
|
|
291
|
+
"src/browser.ts"(exports, module) {
|
|
292
|
+
var import_shared = __toESM(require_shared());
|
|
293
|
+
import_shared.default.format("o", (value, target) => {
|
|
294
|
+
return inspect(value, { depth: Infinity }).replace(/\s*\n\s*/g, " ");
|
|
295
|
+
});
|
|
296
|
+
module.exports = import_shared.default;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
export default require_browser();
|