@yumerijs/core 1.0.16 → 1.0.17
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/dist/logger.d.ts +1 -4
- package/dist/logger.js +9 -53
- package/dist/logger.js.map +1 -1
- package/package.json +2 -2
package/dist/logger.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @time: 2025/03/24 22:35
|
|
3
3
|
* @author: FireGuo
|
|
4
|
-
|
|
5
|
-
**/
|
|
4
|
+
*/
|
|
6
5
|
export declare class Logger {
|
|
7
6
|
private title;
|
|
8
7
|
private titleColor;
|
|
9
|
-
private chalk;
|
|
10
8
|
constructor(title: string);
|
|
11
|
-
initializeChalk(): Promise<void>;
|
|
12
9
|
private getRandomColor;
|
|
13
10
|
private log;
|
|
14
11
|
info(...args: any[]): void;
|
package/dist/logger.js
CHANGED
|
@@ -2,71 +2,27 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @time: 2025/03/24 22:35
|
|
4
4
|
* @author: FireGuo
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
40
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
10
|
exports.Logger = void 0;
|
|
42
|
-
|
|
11
|
+
const ansi_colors_1 = __importDefault(require("ansi-colors")); // 引入 ansi-colors
|
|
43
12
|
class Logger {
|
|
44
13
|
constructor(title) {
|
|
45
14
|
this.title = title;
|
|
46
|
-
this.initializeChalk(); // 在构造函数中初始化 chalk
|
|
47
|
-
}
|
|
48
|
-
async initializeChalk() {
|
|
49
|
-
const { default: chalk } = await Promise.resolve().then(() => __importStar(require('chalk')));
|
|
50
|
-
this.chalk = chalk;
|
|
51
15
|
this.titleColor = this.getRandomColor();
|
|
52
16
|
}
|
|
53
17
|
getRandomColor() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
const colors = [this.chalk.red, this.chalk.green, this.chalk.yellow, this.chalk.blue, this.chalk.magenta, this.chalk.cyan, this.chalk.white, this.chalk.gray];
|
|
59
|
-
const randomIndex = Math.floor(Math.random() * colors.length);
|
|
60
|
-
return colors[randomIndex];
|
|
18
|
+
const availableColors = [ansi_colors_1.default.red, ansi_colors_1.default.green, ansi_colors_1.default.yellow, ansi_colors_1.default.blue, ansi_colors_1.default.magenta, ansi_colors_1.default.cyan, ansi_colors_1.default.white, ansi_colors_1.default.gray];
|
|
19
|
+
const randomIndex = Math.floor(Math.random() * availableColors.length);
|
|
20
|
+
return availableColors[randomIndex];
|
|
61
21
|
}
|
|
62
22
|
log(level, ...args) {
|
|
63
|
-
if (!this.chalk) {
|
|
64
|
-
//console.error("Chalk is not initialized yet. Cannot log with colors.");
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
23
|
const now = new Date();
|
|
68
24
|
const timestamp = `${now.getFullYear()}/${String(now.getMonth() + 1).padStart(2, '0')}/${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
|
|
69
|
-
console.log(`${timestamp} [${level}] ${this.titleColor(this.title)}`, ...args);
|
|
25
|
+
console.log(`${timestamp} [${level}] ${this.titleColor(this.title)} `, ...args);
|
|
70
26
|
}
|
|
71
27
|
info(...args) {
|
|
72
28
|
this.log('I', ...args);
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,8DAAiC,CAAC,iBAAiB;AAEnD,MAAa,MAAM;IAIjB,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IAC1C,CAAC;IAEO,cAAc;QACpB,MAAM,eAAe,GAAG,CAAC,qBAAM,CAAC,GAAG,EAAE,qBAAM,CAAC,KAAK,EAAE,qBAAM,CAAC,MAAM,EAAE,qBAAM,CAAC,IAAI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GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACzB,CAAC;CACF;AAhCD,wBAgCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yumerijs/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Core module for yumeri",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@types/chalk": "^2.2.4",
|
|
35
|
-
"
|
|
35
|
+
"ansi-colors": "^4.1.3",
|
|
36
36
|
"chokidar": "^4.0.3",
|
|
37
37
|
"js-sha256": "^0.11.0",
|
|
38
38
|
"js-yaml": "^4.1.0"
|