@arox/framework 0.1.1 → 0.1.2-beta.2

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 (44) hide show
  1. package/dist/constants/messages.d.ts +2 -0
  2. package/dist/events/interaction.d.ts +4 -1
  3. package/dist/events/message.d.ts +4 -1
  4. package/dist/events/ready.d.ts +4 -1
  5. package/dist/index.cjs +3 -0
  6. package/dist/index.d.cts +2 -0
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +3 -15
  9. package/dist/structures/builder/Builder.d.ts +18 -0
  10. package/dist/structures/builder/Command.d.ts +23 -24
  11. package/dist/structures/builder/Context.d.ts +24 -18
  12. package/dist/structures/builder/Event.d.ts +7 -9
  13. package/dist/structures/builder/index.d.ts +4 -4
  14. package/dist/structures/core/Client.d.ts +6 -7
  15. package/dist/structures/core/index.d.ts +1 -1
  16. package/dist/structures/index.d.ts +2 -2
  17. package/dist/utils/index.d.ts +3 -3
  18. package/dist/utils/logger/ILogger.d.ts +1 -43
  19. package/dist/utils/logger/Logger.d.ts +6 -41
  20. package/dist/utils/normalizeArray.d.ts +15 -0
  21. package/dist/utils/util.d.ts +5 -3
  22. package/package.json +1 -62
  23. package/types/client.d.ts +14 -13
  24. package/types/logger.d.ts +63 -0
  25. package/cliff.toml +0 -48
  26. package/dist/context.d.ts +0 -4
  27. package/dist/context.js +0 -28
  28. package/dist/events/interaction.js +0 -38
  29. package/dist/events/message.js +0 -36
  30. package/dist/events/ready.js +0 -11
  31. package/dist/structures/builder/Argument.d.ts +0 -22
  32. package/dist/structures/builder/Argument.js +0 -42
  33. package/dist/structures/builder/Command.js +0 -74
  34. package/dist/structures/builder/Context.js +0 -67
  35. package/dist/structures/builder/Event.js +0 -53
  36. package/dist/structures/builder/index.js +0 -9
  37. package/dist/structures/core/Client.js +0 -111
  38. package/dist/structures/core/index.js +0 -6
  39. package/dist/structures/index.js +0 -7
  40. package/dist/utils/Files.js +0 -47
  41. package/dist/utils/index.js +0 -8
  42. package/dist/utils/logger/ILogger.js +0 -37
  43. package/dist/utils/logger/Logger.js +0 -380
  44. package/dist/utils/util.js +0 -35
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _export_star = require("@swc/helpers/_/_export_star");
6
- _export_star._(require("./util"), exports);
7
- _export_star._(require("./Files"), exports);
8
- _export_star._(require("./logger/Logger"), exports);
@@ -1,37 +0,0 @@
1
- //https://github.com/sapphiredev/framework/tree/main/src/lib/utils/logger
2
- /**
3
- * The logger levels for the {@link ILogger}.
4
- */ "use strict";
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- Object.defineProperty(exports, "LogLevel", {
9
- enumerable: true,
10
- get: function() {
11
- return LogLevel;
12
- }
13
- });
14
- var LogLevel = /*#__PURE__*/ function(LogLevel) {
15
- /**
16
- * The lowest log level, used when calling {@link ILogger.trace}.
17
- */ LogLevel[LogLevel["Trace"] = 10] = "Trace";
18
- /**
19
- * The debug level, used when calling {@link ILogger.debug}.
20
- */ LogLevel[LogLevel["Debug"] = 20] = "Debug";
21
- /**
22
- * The info level, used when calling {@link ILogger.info}.
23
- */ LogLevel[LogLevel["Info"] = 30] = "Info";
24
- /**
25
- * The warning level, used when calling {@link ILogger.warn}.
26
- */ LogLevel[LogLevel["Warn"] = 40] = "Warn";
27
- /**
28
- * The error level, used when calling {@link ILogger.error}.
29
- */ LogLevel[LogLevel["Error"] = 50] = "Error";
30
- /**
31
- * The critical level, used when calling {@link ILogger.fatal}.
32
- */ LogLevel[LogLevel["Fatal"] = 60] = "Fatal";
33
- /**
34
- * An unknown or uncategorized level.
35
- */ LogLevel[LogLevel["None"] = 100] = "None";
36
- return LogLevel;
37
- }({});
@@ -1,380 +0,0 @@
1
- //https://github.com/sapphiredev/plugins/tree/main/packages/logger
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- function _export(target, all) {
7
- for(var name in all)Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: Object.getOwnPropertyDescriptor(all, name).get
10
- });
11
- }
12
- _export(exports, {
13
- get I18nLoggerAdapter () {
14
- return I18nLoggerAdapter;
15
- },
16
- get Logger () {
17
- return Logger;
18
- },
19
- get LoggerLevel () {
20
- return LoggerLevel;
21
- },
22
- get LoggerStyle () {
23
- return LoggerStyle;
24
- },
25
- get LoggerStyleBackground () {
26
- return LoggerStyleBackground;
27
- },
28
- get LoggerStyleEffect () {
29
- return LoggerStyleEffect;
30
- },
31
- get LoggerStyleText () {
32
- return LoggerStyleText;
33
- },
34
- get LoggerTimestamp () {
35
- return LoggerTimestamp;
36
- },
37
- get default () {
38
- return _default;
39
- }
40
- });
41
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
42
- const _console = require("console");
43
- const _util = require("util");
44
- const _colorette = /*#__PURE__*/ _interop_require_wildcard._(require("colorette"));
45
- const _timestamp = require("@sapphire/timestamp");
46
- const _ILogger = require("./ILogger");
47
- class Logger {
48
- level;
49
- formats;
50
- join;
51
- depth;
52
- console;
53
- static instance = null;
54
- static LOG_METHODS = new Map([
55
- [
56
- _ILogger.LogLevel.Trace,
57
- "trace"
58
- ],
59
- [
60
- _ILogger.LogLevel.Debug,
61
- "debug"
62
- ],
63
- [
64
- _ILogger.LogLevel.Info,
65
- "info"
66
- ],
67
- [
68
- _ILogger.LogLevel.Warn,
69
- "warn"
70
- ],
71
- [
72
- _ILogger.LogLevel.Error,
73
- "error"
74
- ],
75
- [
76
- _ILogger.LogLevel.Fatal,
77
- "error"
78
- ]
79
- ]);
80
- static DEFAULT_COLORS = new Map([
81
- [
82
- _ILogger.LogLevel.Trace,
83
- _colorette.gray
84
- ],
85
- [
86
- _ILogger.LogLevel.Debug,
87
- _colorette.magenta
88
- ],
89
- [
90
- _ILogger.LogLevel.Info,
91
- _colorette.cyan
92
- ],
93
- [
94
- _ILogger.LogLevel.Warn,
95
- _colorette.yellow
96
- ],
97
- [
98
- _ILogger.LogLevel.Error,
99
- _colorette.red
100
- ],
101
- [
102
- _ILogger.LogLevel.Fatal,
103
- _colorette.bgRed
104
- ],
105
- [
106
- _ILogger.LogLevel.None,
107
- _colorette.white
108
- ]
109
- ]);
110
- static DEFAULT_NAMES = new Map([
111
- [
112
- _ILogger.LogLevel.Trace,
113
- "TRACE"
114
- ],
115
- [
116
- _ILogger.LogLevel.Debug,
117
- "DEBUG"
118
- ],
119
- [
120
- _ILogger.LogLevel.Info,
121
- "INFO"
122
- ],
123
- [
124
- _ILogger.LogLevel.Warn,
125
- "WARN"
126
- ],
127
- [
128
- _ILogger.LogLevel.Error,
129
- "ERROR"
130
- ],
131
- [
132
- _ILogger.LogLevel.Fatal,
133
- "FATAL"
134
- ],
135
- [
136
- _ILogger.LogLevel.None,
137
- ""
138
- ]
139
- ]);
140
- constructor(options = {}){
141
- this.level = options.level ?? _ILogger.LogLevel.Info;
142
- this.console = new _console.Console(options.stdout ?? process.stdout, options.stderr ?? process.stderr);
143
- this.formats = this.createFormatMap(options.format, options.defaultFormat ?? options.format?.none ?? {});
144
- this.join = options.join ?? " ";
145
- this.depth = options.depth ?? 2;
146
- }
147
- static getInstance() {
148
- if (!this.instance) {
149
- this.instance = new Logger();
150
- }
151
- return this.instance;
152
- }
153
- static get stylize() {
154
- return _colorette.isColorSupported;
155
- }
156
- setLevel(level) {
157
- this.level = level;
158
- }
159
- has(level) {
160
- return level >= this.level;
161
- }
162
- trace(...values) {
163
- this.write(_ILogger.LogLevel.Trace, ...values);
164
- }
165
- debug(...values) {
166
- this.write(_ILogger.LogLevel.Debug, ...values);
167
- }
168
- info(...values) {
169
- this.write(_ILogger.LogLevel.Info, ...values);
170
- }
171
- log(...values) {
172
- this.write(_ILogger.LogLevel.Info, ...values);
173
- }
174
- warn(...values) {
175
- this.write(_ILogger.LogLevel.Warn, ...values);
176
- }
177
- error(...values) {
178
- this.write(_ILogger.LogLevel.Error, ...values);
179
- }
180
- fatal(...values) {
181
- this.write(_ILogger.LogLevel.Fatal, ...values);
182
- }
183
- write(level, ...values) {
184
- if (level < this.level) return;
185
- const method = Logger.LOG_METHODS.get(level);
186
- const formatter = this.formats.get(level) ?? this.formats.get(_ILogger.LogLevel.None);
187
- const message = formatter.run(this.preprocess(values));
188
- switch(method){
189
- case "trace":
190
- this.console.trace(message);
191
- break;
192
- case "debug":
193
- this.console.debug(message);
194
- break;
195
- case "info":
196
- this.console.info(message);
197
- break;
198
- case "warn":
199
- this.console.warn(message);
200
- break;
201
- case "error":
202
- this.console.error(message);
203
- break;
204
- default:
205
- this.console.log(message);
206
- }
207
- }
208
- preprocess(values) {
209
- const inspectOptions = {
210
- colors: _colorette.isColorSupported,
211
- depth: this.depth
212
- };
213
- return values.map((value)=>typeof value === "string" ? value : (0, _util.inspect)(value, inspectOptions)).join(this.join);
214
- }
215
- createFormatMap(options = {}, defaults) {
216
- const map = new Map();
217
- for (const [level, color] of Logger.DEFAULT_COLORS){
218
- const name = Logger.DEFAULT_NAMES.get(level);
219
- const levelOptions = options[this.getLevelKey(level)] ?? this.createDefaultLevel(defaults, color, name ?? "");
220
- map.set(level, levelOptions instanceof LoggerLevel ? levelOptions : new LoggerLevel(levelOptions));
221
- }
222
- return map;
223
- }
224
- createDefaultLevel(defaults, color, name) {
225
- return new LoggerLevel({
226
- ...defaults,
227
- timestamp: defaults.timestamp === null ? null : {
228
- ...defaults.timestamp,
229
- color
230
- },
231
- infix: name.length ? `${color(name.padEnd(5, " "))} ` : ""
232
- });
233
- }
234
- getLevelKey(level) {
235
- const keys = {
236
- [_ILogger.LogLevel.Trace]: "trace",
237
- [_ILogger.LogLevel.Debug]: "debug",
238
- [_ILogger.LogLevel.Info]: "info",
239
- [_ILogger.LogLevel.Warn]: "warn",
240
- [_ILogger.LogLevel.Error]: "error",
241
- [_ILogger.LogLevel.Fatal]: "fatal",
242
- [_ILogger.LogLevel.None]: "none"
243
- };
244
- return keys[level];
245
- }
246
- }
247
- class LoggerStyle {
248
- style;
249
- constructor(resolvable = {}){
250
- if (typeof resolvable === "function") {
251
- this.style = resolvable;
252
- } else {
253
- const styles = this.buildStyleArray(resolvable);
254
- this.style = this.combineStyles(styles);
255
- }
256
- }
257
- run(value) {
258
- return this.style(String(value));
259
- }
260
- buildStyleArray(options) {
261
- const styles = [];
262
- if (options.effects) {
263
- styles.push(...options.effects.map((effect)=>_colorette[effect]));
264
- }
265
- if (options.text) {
266
- styles.push(_colorette[options.text]);
267
- }
268
- if (options.background) {
269
- styles.push(_colorette[options.background]);
270
- }
271
- return styles;
272
- }
273
- combineStyles(styles) {
274
- if (styles.length === 0) return _colorette.reset;
275
- if (styles.length === 1) return styles[0];
276
- return (text)=>styles.reduce((result, style)=>style(result), text);
277
- }
278
- }
279
- class LoggerTimestamp {
280
- timestamp;
281
- utc;
282
- color;
283
- formatter;
284
- constructor(options = {}){
285
- this.timestamp = new _timestamp.Timestamp(options.pattern ?? "YYYY-MM-DD HH:mm:ss");
286
- this.utc = options.utc ?? false;
287
- this.color = options.color === null ? null : new LoggerStyle(options.color);
288
- this.formatter = options.formatter ?? ((timestamp)=>`${timestamp} `);
289
- }
290
- run() {
291
- const date = new Date();
292
- const result = this.utc ? this.timestamp.displayUTC(date) : this.timestamp.display(date);
293
- return this.formatter(this.color ? this.color.run(result) : result);
294
- }
295
- }
296
- class LoggerLevel {
297
- timestamp;
298
- infix;
299
- message;
300
- constructor(options = {}){
301
- this.timestamp = options.timestamp === null ? null : new LoggerTimestamp(options.timestamp);
302
- this.infix = options.infix ?? "";
303
- this.message = options.message === null ? null : new LoggerStyle(options.message);
304
- }
305
- run(content) {
306
- const prefix = (this.timestamp?.run() ?? "") + this.infix;
307
- if (prefix.length) {
308
- const formatter = this.message ? (line)=>prefix + this.message?.run(line) : (line)=>prefix + line;
309
- return content.split("\n").map(formatter).join("\n");
310
- }
311
- return this.message ? this.message.run(content) : content;
312
- }
313
- }
314
- const _default = Logger.getInstance();
315
- var LoggerStyleEffect = /*#__PURE__*/ function(LoggerStyleEffect) {
316
- LoggerStyleEffect["Reset"] = "reset";
317
- LoggerStyleEffect["Bold"] = "bold";
318
- LoggerStyleEffect["Dim"] = "dim";
319
- LoggerStyleEffect["Italic"] = "italic";
320
- LoggerStyleEffect["Underline"] = "underline";
321
- LoggerStyleEffect["Inverse"] = "inverse";
322
- LoggerStyleEffect["Hidden"] = "hidden";
323
- LoggerStyleEffect["Strikethrough"] = "strikethrough";
324
- return LoggerStyleEffect;
325
- }({});
326
- var LoggerStyleText = /*#__PURE__*/ function(LoggerStyleText) {
327
- LoggerStyleText["Black"] = "black";
328
- LoggerStyleText["Red"] = "red";
329
- LoggerStyleText["Green"] = "green";
330
- LoggerStyleText["Yellow"] = "yellow";
331
- LoggerStyleText["Blue"] = "blue";
332
- LoggerStyleText["Magenta"] = "magenta";
333
- LoggerStyleText["Cyan"] = "cyan";
334
- LoggerStyleText["White"] = "white";
335
- LoggerStyleText["Gray"] = "gray";
336
- LoggerStyleText["BlackBright"] = "blackBright";
337
- LoggerStyleText["RedBright"] = "redBright";
338
- LoggerStyleText["GreenBright"] = "greenBright";
339
- LoggerStyleText["YellowBright"] = "yellowBright";
340
- LoggerStyleText["BlueBright"] = "blueBright";
341
- LoggerStyleText["MagentaBright"] = "magentaBright";
342
- LoggerStyleText["CyanBright"] = "cyanBright";
343
- LoggerStyleText["WhiteBright"] = "whiteBright";
344
- return LoggerStyleText;
345
- }({});
346
- var LoggerStyleBackground = /*#__PURE__*/ function(LoggerStyleBackground) {
347
- LoggerStyleBackground["Black"] = "bgBlack";
348
- LoggerStyleBackground["Red"] = "bgRed";
349
- LoggerStyleBackground["Green"] = "bgGreen";
350
- LoggerStyleBackground["Yellow"] = "bgYellow";
351
- LoggerStyleBackground["Blue"] = "bgBlue";
352
- LoggerStyleBackground["Magenta"] = "bgMagenta";
353
- LoggerStyleBackground["Cyan"] = "bgCyan";
354
- LoggerStyleBackground["White"] = "bgWhite";
355
- LoggerStyleBackground["BlackBright"] = "bgBlackBright";
356
- LoggerStyleBackground["RedBright"] = "bgRedBright";
357
- LoggerStyleBackground["GreenBright"] = "bgGreenBright";
358
- LoggerStyleBackground["YellowBright"] = "bgYellowBright";
359
- LoggerStyleBackground["BlueBright"] = "bgBlueBright";
360
- LoggerStyleBackground["MagentaBright"] = "bgMagentaBright";
361
- LoggerStyleBackground["CyanBright"] = "bgCyanBright";
362
- LoggerStyleBackground["WhiteBright"] = "bgWhiteBright";
363
- return LoggerStyleBackground;
364
- }({});
365
- class I18nLoggerAdapter {
366
- logger;
367
- type = "logger";
368
- constructor(logger){
369
- this.logger = logger;
370
- }
371
- log(...args) {
372
- this.logger.debug("[i18next]", ...args);
373
- }
374
- warn(...args) {
375
- this.logger.warn("[i18next]", ...args);
376
- }
377
- error(...args) {
378
- this.logger.error("[i18next]", ...args);
379
- }
380
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get deleteMessageAfterSent () {
13
- return deleteMessageAfterSent;
14
- },
15
- get getPrefix () {
16
- return getPrefix;
17
- }
18
- });
19
- function deleteMessageAfterSent(message, time = 15_000) {
20
- return new Promise((r)=>{
21
- setTimeout(()=>{
22
- message.delete().catch(()=>{});
23
- r();
24
- }, time);
25
- });
26
- }
27
- function getPrefix(opts) {
28
- if (typeof opts === "string") {
29
- return opts;
30
- }
31
- if (opts.enabled && opts.prefix) {
32
- return opts.prefix;
33
- }
34
- return false;
35
- }