llonebot-dist 7.11.3 → 7.12.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.
Files changed (43) hide show
  1. package/llbot.js +25478 -22920
  2. package/llbot.js.map +1 -1
  3. package/node_modules/file-type/package.json +2 -1
  4. package/node_modules/file-type/source/index.js +7 -2
  5. package/node_modules/reggol/lib/browser.d.ts +1 -0
  6. package/node_modules/reggol/lib/browser.js +255 -0
  7. package/node_modules/reggol/lib/node.d.ts +1 -0
  8. package/node_modules/reggol/lib/node.js +251 -27
  9. package/node_modules/reggol/lib/shared.d.ts +78 -0
  10. package/node_modules/reggol/package.json +10 -14
  11. package/node_modules/supports-color/browser.d.ts +1 -0
  12. package/node_modules/supports-color/browser.js +25 -14
  13. package/node_modules/supports-color/index.d.ts +55 -0
  14. package/node_modules/supports-color/index.js +88 -38
  15. package/node_modules/supports-color/package.json +21 -15
  16. package/node_modules/supports-color/readme.md +20 -22
  17. package/package.json +1 -1
  18. package/webui/assets/index-As4y32b7.js +37 -0
  19. package/webui/assets/index-CW4srXaj.css +2 -0
  20. package/webui/index.html +2 -2
  21. package//346/233/264/346/226/260/346/227/245/345/277/227.txt +19 -0
  22. package/default_config.json +0 -85
  23. package/node_modules/@minatojs/sql.js/LICENSE +0 -44
  24. package/node_modules/@minatojs/sql.js/README.md +0 -357
  25. package/node_modules/@minatojs/sql.js/dist/sql-wasm.d.ts +0 -316
  26. package/node_modules/@minatojs/sql.js/dist/sql-wasm.js +0 -225
  27. package/node_modules/@minatojs/sql.js/dist/sql-wasm.wasm +0 -0
  28. package/node_modules/@minatojs/sql.js/package.json +0 -58
  29. package/node_modules/has-flag/index.d.ts +0 -39
  30. package/node_modules/has-flag/index.js +0 -8
  31. package/node_modules/has-flag/license +0 -9
  32. package/node_modules/has-flag/package.json +0 -46
  33. package/node_modules/has-flag/readme.md +0 -89
  34. package/node_modules/reggol/index.d.ts +0 -79
  35. package/node_modules/reggol/lib/browser.mjs +0 -299
  36. package/node_modules/reggol/lib/shared.js +0 -258
  37. package/node_modules/reggol/lib/shared.mjs +0 -266
  38. package/node_modules/reggol/src/browser.ts +0 -8
  39. package/node_modules/reggol/src/index.ts +0 -3
  40. package/node_modules/reggol/src/node.ts +0 -8
  41. package/node_modules/reggol/src/shared.ts +0 -249
  42. package/webui/assets/index-DEXb-chN.js +0 -37
  43. package/webui/assets/index-DsGxgscs.css +0 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-type",
3
- "version": "22.0.0",
3
+ "version": "22.0.1",
4
4
  "description": "Detect the file type of a file, stream, or data",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",
@@ -241,6 +241,7 @@
241
241
  "@types/node": "^25.5.0",
242
242
  "ava": "^7.0.0",
243
243
  "commonmark": "^0.31.2",
244
+ "esbuild": "^0.28.0",
244
245
  "get-stream": "^9.0.1",
245
246
  "tsd": "^0.33.0",
246
247
  "xo": "^2.0.2"
@@ -62,6 +62,11 @@ function getKnownFileSizeOrMaximum(fileSize) {
62
62
  return Math.max(0, fileSize);
63
63
  }
64
64
 
65
+ // Keep the specifier non-literal at the call site so browser bundlers do not try to resolve Node-only imports.
66
+ function importAtRuntime(specifier) {
67
+ return import(specifier);
68
+ }
69
+
65
70
  // Wrap stream in an identity TransformStream to avoid BYOB readers.
66
71
  // Node.js has a bug where calling controller.close() inside a BYOB stream's
67
72
  // pull() callback does not resolve pending reader.read() calls, causing
@@ -258,8 +263,8 @@ export class FileTypeParser {
258
263
  this.options.signal?.throwIfAborted();
259
264
  // TODO: Remove this when `strtok3.fromFile()` safely rejects non-regular filesystem objects without a pathname race.
260
265
  const [{default: fsPromises}, {FileTokenizer}] = await Promise.all([
261
- import('node:fs/promises'),
262
- import('strtok3'),
266
+ importAtRuntime('node:fs/promises'),
267
+ importAtRuntime('strtok3'),
263
268
  ]);
264
269
  const fileHandle = await fsPromises.open(path, fsPromises.constants.O_RDONLY | fsPromises.constants.O_NONBLOCK);
265
270
  const fileStat = await fileHandle.stat();
@@ -0,0 +1 @@
1
+ export * from './shared';
@@ -0,0 +1,255 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/browser.ts
5
+ import inspect from "object-inspect";
6
+
7
+ // src/shared.ts
8
+ import supportsColor from "supports-color";
9
+ import { Time } from "cosmokit";
10
+ var c16 = [6, 2, 3, 4, 5, 1];
11
+ var c256 = [
12
+ 20,
13
+ 21,
14
+ 26,
15
+ 27,
16
+ 32,
17
+ 33,
18
+ 38,
19
+ 39,
20
+ 40,
21
+ 41,
22
+ 42,
23
+ 43,
24
+ 44,
25
+ 45,
26
+ 56,
27
+ 57,
28
+ 62,
29
+ 63,
30
+ 68,
31
+ 69,
32
+ 74,
33
+ 75,
34
+ 76,
35
+ 77,
36
+ 78,
37
+ 79,
38
+ 80,
39
+ 81,
40
+ 92,
41
+ 93,
42
+ 98,
43
+ 99,
44
+ 112,
45
+ 113,
46
+ 129,
47
+ 134,
48
+ 135,
49
+ 148,
50
+ 149,
51
+ 160,
52
+ 161,
53
+ 162,
54
+ 163,
55
+ 164,
56
+ 165,
57
+ 166,
58
+ 167,
59
+ 168,
60
+ 169,
61
+ 170,
62
+ 171,
63
+ 172,
64
+ 173,
65
+ 178,
66
+ 179,
67
+ 184,
68
+ 185,
69
+ 196,
70
+ 197,
71
+ 198,
72
+ 199,
73
+ 200,
74
+ 201,
75
+ 202,
76
+ 203,
77
+ 204,
78
+ 205,
79
+ 206,
80
+ 207,
81
+ 208,
82
+ 209,
83
+ 214,
84
+ 215,
85
+ 220,
86
+ 221
87
+ ];
88
+ function isAggregateError(error) {
89
+ return error instanceof Error && Array.isArray(error["errors"]);
90
+ }
91
+ __name(isAggregateError, "isAggregateError");
92
+ var Level = /* @__PURE__ */ ((Level2) => {
93
+ Level2[Level2["SILENT"] = 0] = "SILENT";
94
+ Level2[Level2["SUCCESS"] = 1] = "SUCCESS";
95
+ Level2[Level2["ERROR"] = 1] = "ERROR";
96
+ Level2[Level2["INFO"] = 2] = "INFO";
97
+ Level2[Level2["WARN"] = 2] = "WARN";
98
+ Level2[Level2["DEBUG"] = 3] = "DEBUG";
99
+ return Level2;
100
+ })(Level || {});
101
+ var Logger = class {
102
+ constructor(options, factory) {
103
+ this.factory = factory;
104
+ Object.assign(this, options);
105
+ this.success = this._method("success", 1 /* SUCCESS */);
106
+ this.error = this._method("error", 1 /* ERROR */);
107
+ this.info = this._method("info", 2 /* INFO */);
108
+ this.warn = this._method("warn", 2 /* WARN */);
109
+ this.debug = this._method("debug", 3 /* DEBUG */);
110
+ }
111
+ static {
112
+ __name(this, "Logger");
113
+ }
114
+ static color(exporter, code, value, decoration = "") {
115
+ if (!exporter.colors) return "" + value;
116
+ return `\x1B[3${code < 8 ? code : "8;5;" + code}${exporter.colors >= 2 ? decoration : ""}m${value}\x1B[0m`;
117
+ }
118
+ static code(name, level) {
119
+ let hash = 0;
120
+ for (let i = 0; i < name.length; i++) {
121
+ hash = (hash << 3) - hash + name.charCodeAt(i) + 13;
122
+ hash |= 0;
123
+ }
124
+ const colors = !level ? [] : level >= 2 ? c256 : c16;
125
+ return colors[Math.abs(hash) % colors.length];
126
+ }
127
+ _method(type, level) {
128
+ return (...args) => {
129
+ if (args.length === 1 && args[0] instanceof Error) {
130
+ if (args[0].cause) {
131
+ this[type](args[0].cause);
132
+ } else if (isAggregateError(args[0])) {
133
+ args[0].errors.forEach((error) => this[type](error));
134
+ return;
135
+ }
136
+ }
137
+ const sn = ++this.factory._snMessage;
138
+ const ts = Date.now();
139
+ for (const exporter of this.factory.exporters.values()) {
140
+ const targetLevel = exporter.levels?.[this.name] ?? exporter.levels?.default ?? this.level ?? 2 /* INFO */;
141
+ if (targetLevel < level) continue;
142
+ const body = this._format(exporter, args.slice());
143
+ const message = { sn, ts, type, level, name: this.name, ...this.meta, body };
144
+ exporter.export(message);
145
+ }
146
+ };
147
+ }
148
+ _format(exporter, args) {
149
+ if (args[0] instanceof Error) {
150
+ args[0] = args[0].stack || args[0].message;
151
+ args.unshift("%s");
152
+ } else if (typeof args[0] !== "string") {
153
+ args.unshift("%o");
154
+ }
155
+ let format = args.shift();
156
+ format = format.replace(/%([a-zA-Z%])/g, (match, char) => {
157
+ if (match === "%%") return "%";
158
+ const formatter = this.factory.formatters[char];
159
+ if (typeof formatter === "function") {
160
+ const value = args.shift();
161
+ return formatter(value, exporter, this);
162
+ }
163
+ return match;
164
+ });
165
+ for (let arg of args) {
166
+ if (typeof arg === "object" && arg) {
167
+ arg = this.factory.formatters["o"](arg, exporter, this);
168
+ }
169
+ format += " " + arg;
170
+ }
171
+ const { maxLength = 10240 } = exporter;
172
+ return format.split(/\r?\n/g).map((line) => {
173
+ return line.slice(0, maxLength) + (line.length > maxLength ? "..." : "");
174
+ }).join("\n");
175
+ }
176
+ };
177
+ var Factory = class _Factory {
178
+ static {
179
+ __name(this, "Factory");
180
+ }
181
+ static formatters = {
182
+ s: /* @__PURE__ */ __name((value) => value, "s"),
183
+ j: /* @__PURE__ */ __name((value) => JSON.stringify(value), "j"),
184
+ c: /* @__PURE__ */ __name((value, exporter, logger) => {
185
+ return Logger.color(exporter, Logger.code(logger.name, exporter.colors), value);
186
+ }, "c")
187
+ };
188
+ _snMessage = 0;
189
+ _snExporter = 0;
190
+ exporters = /* @__PURE__ */ new Map();
191
+ formatters = Object.create(_Factory.formatters);
192
+ createLogger(name, options = {}) {
193
+ return new Logger({ name, ...options }, this);
194
+ }
195
+ addExporter(exporter) {
196
+ this.exporters.set(++this._snExporter, exporter);
197
+ return () => this.exporters.delete(this._snExporter);
198
+ }
199
+ };
200
+ var Exporter;
201
+ ((Exporter2) => {
202
+ class Console {
203
+ static {
204
+ __name(this, "Console");
205
+ }
206
+ constructor(options) {
207
+ Object.assign(this, {
208
+ colors: supportsColor.stdout ? supportsColor.stdout.level : 0,
209
+ showTime: "yyyy-MM-dd hh:mm:ss ",
210
+ showDiff: false,
211
+ ...options
212
+ });
213
+ }
214
+ export(message) {
215
+ console.log(this.render(message));
216
+ }
217
+ render(message) {
218
+ const prefix = `[${message.type[0].toUpperCase()}]`;
219
+ const space = " ".repeat(this.label?.margin ?? 1);
220
+ let indent = 3 + space.length, output = "";
221
+ if (this.showTime) {
222
+ indent += this.showTime.length;
223
+ output += Logger.color(this, 8, Time.template(this.showTime));
224
+ }
225
+ const code = Logger.code(message.name, this.colors);
226
+ const label = Logger.color(this, code, message.name, ";1");
227
+ const padLength = (this.label?.width ?? 0) + label.length - message.name.length;
228
+ if (this.label?.align === "right") {
229
+ output += label.padStart(padLength) + space + prefix + space;
230
+ indent += (this.label.width ?? 0) + space.length;
231
+ } else {
232
+ output += prefix + space + label.padEnd(padLength) + space;
233
+ }
234
+ output += message.body.replace(/\n/g, "\n" + " ".repeat(indent));
235
+ if (this.showDiff && this.timestamp) {
236
+ const diff = message.ts - this.timestamp;
237
+ output += Logger.color(this, code, " +" + Time.format(diff));
238
+ }
239
+ this.timestamp = message.ts;
240
+ return output;
241
+ }
242
+ }
243
+ Exporter2.Console = Console;
244
+ })(Exporter || (Exporter = {}));
245
+
246
+ // src/browser.ts
247
+ Factory.formatters["o"] = (value, target) => {
248
+ return inspect(value, { depth: Infinity });
249
+ };
250
+ export {
251
+ Exporter,
252
+ Factory,
253
+ Level,
254
+ Logger
255
+ };
@@ -0,0 +1 @@
1
+ export * from './shared';
@@ -1,31 +1,255 @@
1
- "use strict";
2
- var __create = Object.create;
3
1
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/node.ts
5
+ import { inspect } from "util";
6
+
7
+ // src/shared.ts
8
+ import supportsColor from "supports-color";
9
+ import { Time } from "cosmokit";
10
+ var c16 = [6, 2, 3, 4, 5, 1];
11
+ var c256 = [
12
+ 20,
13
+ 21,
14
+ 26,
15
+ 27,
16
+ 32,
17
+ 33,
18
+ 38,
19
+ 39,
20
+ 40,
21
+ 41,
22
+ 42,
23
+ 43,
24
+ 44,
25
+ 45,
26
+ 56,
27
+ 57,
28
+ 62,
29
+ 63,
30
+ 68,
31
+ 69,
32
+ 74,
33
+ 75,
34
+ 76,
35
+ 77,
36
+ 78,
37
+ 79,
38
+ 80,
39
+ 81,
40
+ 92,
41
+ 93,
42
+ 98,
43
+ 99,
44
+ 112,
45
+ 113,
46
+ 129,
47
+ 134,
48
+ 135,
49
+ 148,
50
+ 149,
51
+ 160,
52
+ 161,
53
+ 162,
54
+ 163,
55
+ 164,
56
+ 165,
57
+ 166,
58
+ 167,
59
+ 168,
60
+ 169,
61
+ 170,
62
+ 171,
63
+ 172,
64
+ 173,
65
+ 178,
66
+ 179,
67
+ 184,
68
+ 185,
69
+ 196,
70
+ 197,
71
+ 198,
72
+ 199,
73
+ 200,
74
+ 201,
75
+ 202,
76
+ 203,
77
+ 204,
78
+ 205,
79
+ 206,
80
+ 207,
81
+ 208,
82
+ 209,
83
+ 214,
84
+ 215,
85
+ 220,
86
+ 221
87
+ ];
88
+ function isAggregateError(error) {
89
+ return error instanceof Error && Array.isArray(error["errors"]);
90
+ }
91
+ __name(isAggregateError, "isAggregateError");
92
+ var Level = /* @__PURE__ */ ((Level2) => {
93
+ Level2[Level2["SILENT"] = 0] = "SILENT";
94
+ Level2[Level2["SUCCESS"] = 1] = "SUCCESS";
95
+ Level2[Level2["ERROR"] = 1] = "ERROR";
96
+ Level2[Level2["INFO"] = 2] = "INFO";
97
+ Level2[Level2["WARN"] = 2] = "WARN";
98
+ Level2[Level2["DEBUG"] = 3] = "DEBUG";
99
+ return Level2;
100
+ })(Level || {});
101
+ var Logger = class {
102
+ constructor(options, factory) {
103
+ this.factory = factory;
104
+ Object.assign(this, options);
105
+ this.success = this._method("success", 1 /* SUCCESS */);
106
+ this.error = this._method("error", 1 /* ERROR */);
107
+ this.info = this._method("info", 2 /* INFO */);
108
+ this.warn = this._method("warn", 2 /* WARN */);
109
+ this.debug = this._method("debug", 3 /* DEBUG */);
110
+ }
111
+ static {
112
+ __name(this, "Logger");
113
+ }
114
+ static color(exporter, code, value, decoration = "") {
115
+ if (!exporter.colors) return "" + value;
116
+ return `\x1B[3${code < 8 ? code : "8;5;" + code}${exporter.colors >= 2 ? decoration : ""}m${value}\x1B[0m`;
117
+ }
118
+ static code(name, level) {
119
+ let hash = 0;
120
+ for (let i = 0; i < name.length; i++) {
121
+ hash = (hash << 3) - hash + name.charCodeAt(i) + 13;
122
+ hash |= 0;
123
+ }
124
+ const colors = !level ? [] : level >= 2 ? c256 : c16;
125
+ return colors[Math.abs(hash) % colors.length];
126
+ }
127
+ _method(type, level) {
128
+ return (...args) => {
129
+ if (args.length === 1 && args[0] instanceof Error) {
130
+ if (args[0].cause) {
131
+ this[type](args[0].cause);
132
+ } else if (isAggregateError(args[0])) {
133
+ args[0].errors.forEach((error) => this[type](error));
134
+ return;
135
+ }
136
+ }
137
+ const sn = ++this.factory._snMessage;
138
+ const ts = Date.now();
139
+ for (const exporter of this.factory.exporters.values()) {
140
+ const targetLevel = exporter.levels?.[this.name] ?? exporter.levels?.default ?? this.level ?? 2 /* INFO */;
141
+ if (targetLevel < level) continue;
142
+ const body = this._format(exporter, args.slice());
143
+ const message = { sn, ts, type, level, name: this.name, ...this.meta, body };
144
+ exporter.export(message);
145
+ }
146
+ };
147
+ }
148
+ _format(exporter, args) {
149
+ if (args[0] instanceof Error) {
150
+ args[0] = args[0].stack || args[0].message;
151
+ args.unshift("%s");
152
+ } else if (typeof args[0] !== "string") {
153
+ args.unshift("%o");
154
+ }
155
+ let format = args.shift();
156
+ format = format.replace(/%([a-zA-Z%])/g, (match, char) => {
157
+ if (match === "%%") return "%";
158
+ const formatter = this.factory.formatters[char];
159
+ if (typeof formatter === "function") {
160
+ const value = args.shift();
161
+ return formatter(value, exporter, this);
162
+ }
163
+ return match;
164
+ });
165
+ for (let arg of args) {
166
+ if (typeof arg === "object" && arg) {
167
+ arg = this.factory.formatters["o"](arg, exporter, this);
168
+ }
169
+ format += " " + arg;
170
+ }
171
+ const { maxLength = 10240 } = exporter;
172
+ return format.split(/\r?\n/g).map((line) => {
173
+ return line.slice(0, maxLength) + (line.length > maxLength ? "..." : "");
174
+ }).join("\n");
175
+ }
176
+ };
177
+ var Factory = class _Factory {
178
+ static {
179
+ __name(this, "Factory");
180
+ }
181
+ static formatters = {
182
+ s: /* @__PURE__ */ __name((value) => value, "s"),
183
+ j: /* @__PURE__ */ __name((value) => JSON.stringify(value), "j"),
184
+ c: /* @__PURE__ */ __name((value, exporter, logger) => {
185
+ return Logger.color(exporter, Logger.code(logger.name, exporter.colors), value);
186
+ }, "c")
187
+ };
188
+ _snMessage = 0;
189
+ _snExporter = 0;
190
+ exporters = /* @__PURE__ */ new Map();
191
+ formatters = Object.create(_Factory.formatters);
192
+ createLogger(name, options = {}) {
193
+ return new Logger({ name, ...options }, this);
194
+ }
195
+ addExporter(exporter) {
196
+ this.exporters.set(++this._snExporter, exporter);
197
+ return () => this.exporters.delete(this._snExporter);
198
+ }
15
199
  };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
200
+ var Exporter;
201
+ ((Exporter2) => {
202
+ class Console {
203
+ static {
204
+ __name(this, "Console");
205
+ }
206
+ constructor(options) {
207
+ Object.assign(this, {
208
+ colors: supportsColor.stdout ? supportsColor.stdout.level : 0,
209
+ showTime: "yyyy-MM-dd hh:mm:ss ",
210
+ showDiff: false,
211
+ ...options
212
+ });
213
+ }
214
+ export(message) {
215
+ console.log(this.render(message));
216
+ }
217
+ render(message) {
218
+ const prefix = `[${message.type[0].toUpperCase()}]`;
219
+ const space = " ".repeat(this.label?.margin ?? 1);
220
+ let indent = 3 + space.length, output = "";
221
+ if (this.showTime) {
222
+ indent += this.showTime.length;
223
+ output += Logger.color(this, 8, Time.template(this.showTime));
224
+ }
225
+ const code = Logger.code(message.name, this.colors);
226
+ const label = Logger.color(this, code, message.name, ";1");
227
+ const padLength = (this.label?.width ?? 0) + label.length - message.name.length;
228
+ if (this.label?.align === "right") {
229
+ output += label.padStart(padLength) + space + prefix + space;
230
+ indent += (this.label.width ?? 0) + space.length;
231
+ } else {
232
+ output += prefix + space + label.padEnd(padLength) + space;
233
+ }
234
+ output += message.body.replace(/\n/g, "\n" + " ".repeat(indent));
235
+ if (this.showDiff && this.timestamp) {
236
+ const diff = message.ts - this.timestamp;
237
+ output += Logger.color(this, code, " +" + Time.format(diff));
238
+ }
239
+ this.timestamp = message.ts;
240
+ return output;
241
+ }
242
+ }
243
+ Exporter2.Console = Console;
244
+ })(Exporter || (Exporter = {}));
24
245
 
25
246
  // src/node.ts
26
- var import_util = require("util");
27
- var import_shared = __toESM(require("./shared"));
28
- import_shared.default.format("o", (value, target) => {
29
- return (0, import_util.inspect)(value, { colors: !!target.colors, depth: Infinity }).replace(/\s*\n\s*/g, " ");
30
- });
31
- module.exports = import_shared.default;
247
+ Factory.formatters["o"] = (value, target) => {
248
+ return inspect(value, { colors: !!target.colors, depth: Infinity, compact: true, breakLength: Infinity });
249
+ };
250
+ export {
251
+ Exporter,
252
+ Factory,
253
+ Level,
254
+ Logger
255
+ };
@@ -0,0 +1,78 @@
1
+ import { ColorSupportLevel } from 'supports-color';
2
+ export type Method = (format: any, ...param: any[]) => void;
3
+ export type Formatter = (value: any, exporter: Exporter, logger: Logger) => any;
4
+ export type Type = 'success' | 'error' | 'info' | 'warn' | 'debug';
5
+ export interface Message {
6
+ sn: number;
7
+ ts: number;
8
+ name: string;
9
+ type: Type;
10
+ level: Level;
11
+ body: string;
12
+ }
13
+ export interface Logger extends Record<Type, Method> {
14
+ }
15
+ export declare const enum Level {
16
+ SILENT = 0,
17
+ SUCCESS = 1,
18
+ ERROR = 1,
19
+ INFO = 2,
20
+ WARN = 2,
21
+ DEBUG = 3
22
+ }
23
+ export declare namespace Logger {
24
+ interface Options {
25
+ name: string;
26
+ meta?: Partial<Message>;
27
+ level?: Level;
28
+ }
29
+ }
30
+ export interface Logger extends Logger.Options {
31
+ }
32
+ export declare class Logger {
33
+ private factory;
34
+ static color(exporter: Exporter, code: number, value: any, decoration?: string): string;
35
+ static code(name: string, level?: false | ColorSupportLevel): number;
36
+ constructor(options: Logger.Options, factory: Factory);
37
+ private _method;
38
+ private _format;
39
+ }
40
+ export declare class Factory {
41
+ static formatters: Record<string, Formatter>;
42
+ _snMessage: number;
43
+ _snExporter: number;
44
+ exporters: Map<number, Exporter>;
45
+ formatters: any;
46
+ createLogger(name: string, options?: Omit<Logger.Options, 'name'>): Logger;
47
+ addExporter(exporter: Exporter): () => boolean;
48
+ }
49
+ export interface Exporter extends Exporter.Options {
50
+ export(message: Message): void;
51
+ }
52
+ export declare namespace Exporter {
53
+ interface Options {
54
+ colors?: false | ColorSupportLevel;
55
+ maxLength?: number;
56
+ levels?: Record<string, number>;
57
+ }
58
+ interface Console extends Console.Options {
59
+ }
60
+ class Console implements Exporter {
61
+ constructor(options?: Console.Options);
62
+ export(message: Message): void;
63
+ render(message: Message): string;
64
+ }
65
+ namespace Console {
66
+ interface Options extends Exporter.Options {
67
+ showDiff?: boolean;
68
+ showTime?: string;
69
+ label?: LabelStyle;
70
+ timestamp?: number;
71
+ }
72
+ interface LabelStyle {
73
+ width?: number;
74
+ margin?: number;
75
+ align?: 'left' | 'right';
76
+ }
77
+ }
78
+ }