llonebot-dist 7.12.14 → 8.0.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/default_config.json +85 -85
- package/llbot.js +48383 -41473
- package/llbot.js.map +1 -1
- package/node_modules/ws/lib/receiver.js +54 -0
- package/node_modules/ws/lib/sender.js +6 -1
- package/node_modules/ws/lib/websocket-server.js +8 -0
- package/node_modules/ws/lib/websocket.js +14 -0
- package/node_modules/ws/package.json +1 -1
- package/package.json +1 -1
- package/sign-proxy.linux-arm64.node +0 -0
- package/sign-proxy.linux-x64.node +0 -0
- package/sign-proxy.package.json +7 -0
- package/sign-proxy.win-x64.node +0 -0
- package/webui/assets/index-DW9CNxRt.js +34 -0
- package/webui/assets/index-Dr4PXp_0.css +2 -0
- package/webui/index.html +13 -13
- package/webui/logo.jpg +0 -0
- package//344/275/277/347/224/250/350/257/264/346/230/216.txt +6 -6
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +892 -892
- package/node_modules/cosmokit/LICENSE +0 -21
- package/node_modules/cosmokit/README.md +0 -24
- package/node_modules/cosmokit/lib/index.cjs +0 -419
- package/node_modules/cosmokit/lib/index.cjs.map +0 -6
- package/node_modules/cosmokit/lib/index.d.ts +0 -142
- package/node_modules/cosmokit/lib/index.mjs +0 -357
- package/node_modules/cosmokit/lib/index.mjs.map +0 -6
- package/node_modules/cosmokit/package.json +0 -57
- package/node_modules/cosmokit/src/array.ts +0 -35
- package/node_modules/cosmokit/src/index.ts +0 -5
- package/node_modules/cosmokit/src/misc.ts +0 -57
- package/node_modules/cosmokit/src/string.ts +0 -101
- package/node_modules/cosmokit/src/time.ts +0 -91
- package/node_modules/cosmokit/src/types.ts +0 -131
- package/node_modules/object-inspect/CHANGELOG.md +0 -424
- package/node_modules/object-inspect/LICENSE +0 -21
- package/node_modules/object-inspect/example/all.js +0 -23
- package/node_modules/object-inspect/example/circular.js +0 -6
- package/node_modules/object-inspect/example/fn.js +0 -5
- package/node_modules/object-inspect/example/inspect.js +0 -10
- package/node_modules/object-inspect/index.js +0 -544
- package/node_modules/object-inspect/package-support.json +0 -20
- package/node_modules/object-inspect/package.json +0 -105
- package/node_modules/object-inspect/readme.markdown +0 -84
- package/node_modules/object-inspect/test/bigint.js +0 -58
- package/node_modules/object-inspect/test/browser/dom.js +0 -15
- package/node_modules/object-inspect/test/circular.js +0 -16
- package/node_modules/object-inspect/test/deep.js +0 -12
- package/node_modules/object-inspect/test/element.js +0 -53
- package/node_modules/object-inspect/test/err.js +0 -48
- package/node_modules/object-inspect/test/fakes.js +0 -29
- package/node_modules/object-inspect/test/fn.js +0 -76
- package/node_modules/object-inspect/test/global.js +0 -17
- package/node_modules/object-inspect/test/has.js +0 -15
- package/node_modules/object-inspect/test/holes.js +0 -15
- package/node_modules/object-inspect/test/indent-option.js +0 -271
- package/node_modules/object-inspect/test/inspect.js +0 -139
- package/node_modules/object-inspect/test/lowbyte.js +0 -12
- package/node_modules/object-inspect/test/number.js +0 -58
- package/node_modules/object-inspect/test/quoteStyle.js +0 -26
- package/node_modules/object-inspect/test/toStringTag.js +0 -40
- package/node_modules/object-inspect/test/undef.js +0 -12
- package/node_modules/object-inspect/test/values.js +0 -261
- package/node_modules/object-inspect/test-core-js.js +0 -26
- package/node_modules/object-inspect/util.inspect.js +0 -1
- package/node_modules/reggol/LICENSE +0 -21
- package/node_modules/reggol/README.md +0 -8
- package/node_modules/reggol/lib/browser.d.ts +0 -1
- package/node_modules/reggol/lib/browser.js +0 -255
- package/node_modules/reggol/lib/node.d.ts +0 -1
- package/node_modules/reggol/lib/node.js +0 -255
- package/node_modules/reggol/lib/shared.d.ts +0 -78
- package/node_modules/reggol/package.json +0 -61
- package/node_modules/supports-color/browser.d.ts +0 -1
- package/node_modules/supports-color/browser.js +0 -35
- package/node_modules/supports-color/index.d.ts +0 -55
- package/node_modules/supports-color/index.js +0 -202
- package/node_modules/supports-color/license +0 -9
- package/node_modules/supports-color/package.json +0 -64
- package/node_modules/supports-color/readme.md +0 -75
- package/webui/assets/index-CM5wLm3n.css +0 -2
- package/webui/assets/index-DKpc1KFv.js +0 -37
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
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
|
-
}
|
|
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/node.ts
|
|
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
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "reggol",
|
|
3
|
-
"description": "Logger for professionals",
|
|
4
|
-
"version": "2.1.0",
|
|
5
|
-
"sideEffects": false,
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "lib/node.js",
|
|
8
|
-
"types": "lib/shared.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./lib/shared.d.ts",
|
|
12
|
-
"node": "./lib/node.js",
|
|
13
|
-
"default": "./lib/browser.js"
|
|
14
|
-
},
|
|
15
|
-
"./src/*": "./src/*",
|
|
16
|
-
"./package.json": "./package.json"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"lib"
|
|
20
|
-
],
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/shigma/reggol.git"
|
|
24
|
-
},
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/shigma/reggol/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/shigma/reggol",
|
|
29
|
-
"author": "Shigma <shigma10826@gmail.com>",
|
|
30
|
-
"license": "MIT",
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build:node": "esbuild src/node.ts --outfile=lib/node.cjs --bundle --sourcemap --sources-content=false --platform=node --external:cosmokit --external:supports-color --target=es2022",
|
|
33
|
-
"build:browser": "esbuild src/browser.ts --outfile=lib/browser.mjs --bundle --sourcemap --sources-content=false --platform=browser --external:cosmokit --external:supports-color --target=es2022",
|
|
34
|
-
"build": "yarn build:node && yarn build:browser && yarn tsc -b",
|
|
35
|
-
"test": "mocha -r esbuild-register tests/*.spec.ts",
|
|
36
|
-
"test:text": "shx rm -rf coverage && c8 -r text yarn test",
|
|
37
|
-
"test:json": "shx rm -rf coverage && c8 -r json yarn test",
|
|
38
|
-
"test:html": "shx rm -rf coverage && c8 -r html yarn test"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@sinonjs/fake-timers": "^6.0.1",
|
|
42
|
-
"@types/chai": "^4.3.16",
|
|
43
|
-
"@types/mocha": "^9.1.1",
|
|
44
|
-
"@types/node": "^22.1.0",
|
|
45
|
-
"@types/object-inspect": "^1.8.4",
|
|
46
|
-
"@types/sinonjs__fake-timers": "^6.0.4",
|
|
47
|
-
"@types/supports-color": "^8.1.3",
|
|
48
|
-
"c8": "^7.14.0",
|
|
49
|
-
"chai": "^5.1.1",
|
|
50
|
-
"esbuild": "^0.23.1",
|
|
51
|
-
"esbuild-register": "^3.5.0",
|
|
52
|
-
"mocha": "^9.2.2",
|
|
53
|
-
"shx": "^0.3.4",
|
|
54
|
-
"typescript": "^5.5.3"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"cosmokit": "^1.7.3",
|
|
58
|
-
"object-inspect": "^1.13.4",
|
|
59
|
-
"supports-color": "^10.0.0"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {default} from './index.js';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
/* eslint-disable n/no-unsupported-features/node-builtins */
|
|
3
|
-
|
|
4
|
-
const level = (() => {
|
|
5
|
-
if (!('navigator' in globalThis)) {
|
|
6
|
-
return 0;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (globalThis.navigator.userAgentData) {
|
|
10
|
-
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
|
11
|
-
if (brand?.version > 93) {
|
|
12
|
-
return 3;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
|
|
17
|
-
return 1;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return 0;
|
|
21
|
-
})();
|
|
22
|
-
|
|
23
|
-
const colorSupport = level !== 0 && {
|
|
24
|
-
level,
|
|
25
|
-
hasBasic: true,
|
|
26
|
-
has256: level >= 2,
|
|
27
|
-
has16m: level >= 3,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const supportsColor = {
|
|
31
|
-
stdout: colorSupport,
|
|
32
|
-
stderr: colorSupport,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default supportsColor;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type {WriteStream} from 'node:tty';
|
|
2
|
-
|
|
3
|
-
export type Options = {
|
|
4
|
-
/**
|
|
5
|
-
Whether `process.argv` should be sniffed for `--color` and `--no-color` flags.
|
|
6
|
-
|
|
7
|
-
@default true
|
|
8
|
-
*/
|
|
9
|
-
readonly sniffFlags?: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
Levels:
|
|
14
|
-
- `0` - All colors disabled.
|
|
15
|
-
- `1` - Basic 16 colors support.
|
|
16
|
-
- `2` - ANSI 256 colors support.
|
|
17
|
-
- `3` - Truecolor 16 million colors support.
|
|
18
|
-
*/
|
|
19
|
-
export type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
Detect whether the terminal supports color.
|
|
23
|
-
*/
|
|
24
|
-
export type ColorSupport = {
|
|
25
|
-
/**
|
|
26
|
-
The color level.
|
|
27
|
-
*/
|
|
28
|
-
level: ColorSupportLevel;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
Whether basic 16 colors are supported.
|
|
32
|
-
*/
|
|
33
|
-
hasBasic: boolean;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
Whether ANSI 256 colors are supported.
|
|
37
|
-
*/
|
|
38
|
-
has256: boolean;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
Whether Truecolor 16 million colors are supported.
|
|
42
|
-
*/
|
|
43
|
-
has16m: boolean;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type ColorInfo = ColorSupport | false;
|
|
47
|
-
|
|
48
|
-
export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo;
|
|
49
|
-
|
|
50
|
-
declare const supportsColor: {
|
|
51
|
-
stdout: ColorInfo;
|
|
52
|
-
stderr: ColorInfo;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default supportsColor;
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import process from 'node:process';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import tty from 'node:tty';
|
|
4
|
-
|
|
5
|
-
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
6
|
-
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
7
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
|
8
|
-
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
9
|
-
const position = argv.indexOf(prefix + flag);
|
|
10
|
-
const terminatorPosition = argv.indexOf('--');
|
|
11
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const {env} = process;
|
|
15
|
-
|
|
16
|
-
let flagForceColor;
|
|
17
|
-
if (
|
|
18
|
-
hasFlag('no-color')
|
|
19
|
-
|| hasFlag('no-colors')
|
|
20
|
-
|| hasFlag('color=false')
|
|
21
|
-
|| hasFlag('color=never')
|
|
22
|
-
) {
|
|
23
|
-
flagForceColor = 0;
|
|
24
|
-
} else if (
|
|
25
|
-
hasFlag('color')
|
|
26
|
-
|| hasFlag('colors')
|
|
27
|
-
|| hasFlag('color=true')
|
|
28
|
-
|| hasFlag('color=always')
|
|
29
|
-
) {
|
|
30
|
-
flagForceColor = 1;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function envForceColor() {
|
|
34
|
-
if (!('FORCE_COLOR' in env)) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (env.FORCE_COLOR === 'true') {
|
|
39
|
-
return 1;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (env.FORCE_COLOR === 'false') {
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (env.FORCE_COLOR.length === 0) {
|
|
47
|
-
return 1;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
51
|
-
|
|
52
|
-
if (![0, 1, 2, 3].includes(level)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return level;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function translateLevel(level) {
|
|
60
|
-
if (level === 0) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
level,
|
|
66
|
-
hasBasic: true,
|
|
67
|
-
has256: level >= 2,
|
|
68
|
-
has16m: level >= 3,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
73
|
-
const noFlagForceColor = envForceColor();
|
|
74
|
-
if (noFlagForceColor !== undefined) {
|
|
75
|
-
flagForceColor = noFlagForceColor;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
79
|
-
|
|
80
|
-
if (forceColor === 0) {
|
|
81
|
-
return 0;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (sniffFlags) {
|
|
85
|
-
if (hasFlag('color=16m')
|
|
86
|
-
|| hasFlag('color=full')
|
|
87
|
-
|| hasFlag('color=truecolor')) {
|
|
88
|
-
return 3;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (hasFlag('color=256')) {
|
|
92
|
-
return 2;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Check for Azure DevOps pipelines.
|
|
97
|
-
// Has to be above the `!streamIsTTY` check.
|
|
98
|
-
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
99
|
-
return 1;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
103
|
-
return 0;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const min = forceColor || 0;
|
|
107
|
-
|
|
108
|
-
if (env.TERM === 'dumb') {
|
|
109
|
-
return min;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (process.platform === 'win32') {
|
|
113
|
-
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
114
|
-
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
115
|
-
const osRelease = os.release().split('.');
|
|
116
|
-
if (
|
|
117
|
-
Number(osRelease[0]) >= 10
|
|
118
|
-
&& Number(osRelease[2]) >= 10_586
|
|
119
|
-
) {
|
|
120
|
-
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return 1;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if ('CI' in env) {
|
|
127
|
-
if (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {
|
|
128
|
-
return 3;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
132
|
-
return 1;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return min;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if ('TEAMCITY_VERSION' in env) {
|
|
139
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (env.COLORTERM === 'truecolor') {
|
|
143
|
-
return 3;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (env.TERM === 'xterm-kitty') {
|
|
147
|
-
return 3;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (env.TERM === 'xterm-ghostty') {
|
|
151
|
-
return 3;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (env.TERM === 'wezterm') {
|
|
155
|
-
return 3;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if ('TERM_PROGRAM' in env) {
|
|
159
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
160
|
-
|
|
161
|
-
switch (env.TERM_PROGRAM) {
|
|
162
|
-
case 'iTerm.app': {
|
|
163
|
-
return version >= 3 ? 3 : 2;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
case 'Apple_Terminal': {
|
|
167
|
-
return 2;
|
|
168
|
-
}
|
|
169
|
-
// No default
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
174
|
-
return 2;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
178
|
-
return 1;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if ('COLORTERM' in env) {
|
|
182
|
-
return 1;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return min;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export function createSupportsColor(stream, options = {}) {
|
|
189
|
-
const level = _supportsColor(stream, {
|
|
190
|
-
streamIsTTY: stream && stream.isTTY,
|
|
191
|
-
...options,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
return translateLevel(level);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const supportsColor = {
|
|
198
|
-
stdout: createSupportsColor({isTTY: tty.isatty(1)}),
|
|
199
|
-
stderr: createSupportsColor({isTTY: tty.isatty(2)}),
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
export default supportsColor;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|