@kikiutils/shared 18.3.0 → 19.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/README.md +0 -7
- package/dist/buffer.d.ts +0 -2
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +1 -2
- package/dist/classes/enhanced-date.d.ts +0 -2
- package/dist/classes/enhanced-date.d.ts.map +1 -1
- package/dist/classes/enhanced-date.js +1 -2
- package/dist/classes/path.d.ts +1 -3
- package/dist/classes/path.d.ts.map +1 -1
- package/dist/classes/path.js +1 -2
- package/dist/classes/precision-number.d.ts +0 -2
- package/dist/classes/precision-number.d.ts.map +1 -1
- package/dist/classes/precision-number.js +1 -2
- package/dist/clipboard.d.ts +0 -2
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +1 -2
- package/dist/crypto-hash.d.ts +0 -2
- package/dist/crypto-hash.d.ts.map +1 -1
- package/dist/crypto-hash.js +1 -2
- package/dist/datetime.d.ts +0 -2
- package/dist/datetime.d.ts.map +1 -1
- package/dist/datetime.js +1 -2
- package/dist/element-plus.d.ts +0 -2
- package/dist/element-plus.d.ts.map +1 -1
- package/dist/element-plus.js +1 -2
- package/dist/enum.d.ts +0 -2
- package/dist/enum.d.ts.map +1 -1
- package/dist/enum.js +1 -2
- package/dist/env.d.ts +0 -2
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +1 -2
- package/dist/event-awaiter.d.ts +0 -2
- package/dist/event-awaiter.d.ts.map +1 -1
- package/dist/event-awaiter.js +1 -2
- package/dist/file.d.ts +0 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +1 -2
- package/dist/general.d.ts +0 -2
- package/dist/general.d.ts.map +1 -1
- package/dist/general.js +1 -2
- package/dist/hash.d.ts +0 -2
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +1 -2
- package/dist/logger/_internals/formatter.d.ts +13 -0
- package/dist/logger/_internals/formatter.d.ts.map +1 -0
- package/dist/logger/_internals/formatter.js +57 -0
- package/dist/logger/_internals/formatter.js.map +1 -0
- package/dist/logger/_internals/levels.d.ts +54 -0
- package/dist/logger/_internals/levels.d.ts.map +1 -0
- package/dist/logger/_internals/levels.js +59 -0
- package/dist/logger/_internals/levels.js.map +1 -0
- package/dist/logger/_internals/logger.d.ts +12 -0
- package/dist/logger/_internals/logger.d.ts.map +1 -0
- package/dist/logger/_internals/logger.js +147 -0
- package/dist/logger/_internals/logger.js.map +1 -0
- package/dist/logger/_internals/types.d.ts +12 -0
- package/dist/logger/_internals/types.d.ts.map +1 -0
- package/dist/logger/_internals/types.js +1 -0
- package/dist/logger/index.d.ts +10 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +25 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/node/_internals/file-writer.d.ts +11 -0
- package/dist/logger/node/_internals/file-writer.d.ts.map +1 -0
- package/dist/logger/node/_internals/file-writer.js +188 -0
- package/dist/logger/node/_internals/file-writer.js.map +1 -0
- package/dist/logger/node/_internals/formatter.d.ts +4 -0
- package/dist/logger/node/_internals/formatter.d.ts.map +1 -0
- package/dist/logger/node/_internals/formatter.js +21 -0
- package/dist/logger/node/_internals/formatter.js.map +1 -0
- package/dist/logger/node/index.d.ts +10 -0
- package/dist/logger/node/index.d.ts.map +1 -0
- package/dist/logger/node/index.js +122 -0
- package/dist/logger/node/index.js.map +1 -0
- package/dist/logger/node/types.d.ts +43 -0
- package/dist/logger/node/types.d.ts.map +1 -0
- package/dist/logger/node/types.js +1 -0
- package/dist/logger/types.d.ts +49 -0
- package/dist/logger/types.d.ts.map +1 -0
- package/dist/logger/types.js +1 -0
- package/dist/math.d.ts +0 -2
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +1 -2
- package/dist/number.d.ts +0 -2
- package/dist/number.d.ts.map +1 -1
- package/dist/number.js +1 -2
- package/dist/random.d.ts +0 -2
- package/dist/random.d.ts.map +1 -1
- package/dist/random.js +1 -2
- package/dist/redis/script-runner.d.ts +0 -2
- package/dist/redis/script-runner.d.ts.map +1 -1
- package/dist/redis/script-runner.js +1 -2
- package/dist/storages/lru/keyed-store.d.ts +0 -2
- package/dist/storages/lru/keyed-store.d.ts.map +1 -1
- package/dist/storages/lru/keyed-store.js +1 -2
- package/dist/storages/redis/keyed-store.d.ts +0 -2
- package/dist/storages/redis/keyed-store.d.ts.map +1 -1
- package/dist/storages/redis/keyed-store.js +1 -2
- package/dist/storages/redis/msgpack.d.ts +0 -2
- package/dist/storages/redis/msgpack.d.ts.map +1 -1
- package/dist/storages/redis/msgpack.js +1 -2
- package/dist/storages/redis/types.d.ts +0 -2
- package/dist/storages/redis/types.d.ts.map +1 -1
- package/dist/string.d.ts +0 -2
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +1 -2
- package/dist/time.d.ts +0 -2
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js +1 -2
- package/dist/types/filtered-key-path.d.ts +0 -2
- package/dist/types/filtered-key-path.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/vue.d.ts +0 -2
- package/dist/types/vue.d.ts.map +1 -1
- package/dist/url.d.ts +0 -2
- package/dist/url.d.ts.map +1 -1
- package/dist/url.js +1 -2
- package/dist/vue.d.ts +0 -2
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +1 -2
- package/dist/web.d.ts +0 -2
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +1 -2
- package/package.json +73 -45
- package/src/logger/_internals/formatter.ts +80 -0
- package/src/logger/_internals/levels.ts +60 -0
- package/src/logger/_internals/logger.ts +224 -0
- package/src/logger/_internals/types.ts +12 -0
- package/src/logger/index.ts +34 -0
- package/src/logger/node/_internals/file-writer.ts +298 -0
- package/src/logger/node/_internals/formatter.ts +33 -0
- package/src/logger/node/index.ts +175 -0
- package/src/logger/node/types.ts +58 -0
- package/src/logger/types.ts +59 -0
- package/src/types/index.ts +0 -10
- package/dist/classes/ssh-client.d.ts +0 -40
- package/dist/classes/ssh-client.d.ts.map +0 -1
- package/dist/classes/ssh-client.js +0 -130
- package/dist/classes/ssh-client.js.map +0 -1
- package/dist/consola.d.ts +0 -24
- package/dist/consola.d.ts.map +0 -1
- package/dist/consola.js +0 -29
- package/dist/consola.js.map +0 -1
- package/dist/object.d.ts +0 -44
- package/dist/object.d.ts.map +0 -1
- package/dist/object.js +0 -59
- package/dist/object.js.map +0 -1
- package/dist/pino.d.ts +0 -25
- package/dist/pino.d.ts.map +0 -1
- package/dist/pino.js +0 -34
- package/dist/pino.js.map +0 -1
- package/src/classes/ssh-client.ts +0 -175
- package/src/consola.ts +0 -25
- package/src/object.ts +0 -78
- package/src/pino.ts +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["NodeBlob","NodeFile"],"sources":["../../src/types/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["NodeBlob","NodeFile"],"sources":["../../src/types/index.ts"],"mappings":";;;;;YAWY,cAAc,cAAc,OAAO,SAAS,OAAOA,SAAWC,SAAW;;;;YAKzE;;;;YAKA,aAAa,KAAK,QAAQ,KAAK;;;;YAK/B,cAAc,KAAK,SAAS,KAAK;;;;YAKjC,cAAc,qBAAqB,KAAK,QAAQ,OAAO,GAAG;;;;YAK1D,sBAAsB,qBAAqB,KAAK,SAAS,cAAc,GAAG;;;;YAK1E,eAAe,qBAAqB,KAAK,SAAS,OAAO,GAAG"}
|
package/dist/types/vue.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GlobalComponents } from "vue";
|
|
2
|
-
//#region src/types/vue.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* A nullable reference to an instance of a globally registered Vue component.
|
|
5
4
|
*
|
|
@@ -15,5 +14,4 @@ import { GlobalComponents } from "vue";
|
|
|
15
14
|
* ```
|
|
16
15
|
*/
|
|
17
16
|
export type ComponentRef<K extends keyof GlobalComponents> = InstanceType<GlobalComponents[K]> | null;
|
|
18
|
-
//#endregion
|
|
19
17
|
//# sourceMappingURL=vue.d.ts.map
|
package/dist/types/vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","names":[],"sources":["../../src/types/vue.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vue.d.ts","names":[],"sources":["../../src/types/vue.ts"],"mappings":";;;;;;;;;;;;;;;YAgBY,aAAa,gBAAgB,oBAAoB,aAAa,iBAAiB"}
|
package/dist/url.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/url.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Appends or updates the `redirect` query parameter on a given URL.
|
|
4
3
|
*
|
|
@@ -39,5 +38,4 @@ export declare function isSafeRedirectPath(value: unknown): value is string;
|
|
|
39
38
|
* @returns The validated input path, or the unvalidated fallback path.
|
|
40
39
|
*/
|
|
41
40
|
export declare function normalizeRedirectPath(value: unknown, fallback?: string): string;
|
|
42
|
-
//#endregion
|
|
43
41
|
//# sourceMappingURL=url.d.ts.map
|
package/dist/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","names":[],"sources":["../src/url.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"url.d.ts","names":[],"sources":["../src/url.ts"],"mappings":";;;;;;;;;;;;;wBAagB,yBAAyB,aAAa;;;;;;;;;;;;;wBAwBtC,mBAAmB,iBAAiB;;;;;;;;;;;;;wBAoBpC,sBAAsB,gBAAgB"}
|
package/dist/url.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/url.ts
|
|
2
2
|
/**
|
|
3
3
|
* Appends or updates the `redirect` query parameter on a given URL.
|
|
4
4
|
*
|
|
@@ -56,7 +56,6 @@ function normalizeRedirectPath(value, fallback = "/") {
|
|
|
56
56
|
const redirectPath = Array.isArray(value) ? value[0] : value;
|
|
57
57
|
return isSafeRedirectPath(redirectPath) ? redirectPath : fallback;
|
|
58
58
|
}
|
|
59
|
-
//#endregion
|
|
60
59
|
export { appendRedirectParamToUrl, isSafeRedirectPath, normalizeRedirectPath };
|
|
61
60
|
|
|
62
61
|
//# sourceMappingURL=url.js.map
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Ref } from "vue";
|
|
2
|
-
//#region src/vue.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Appends the current Vue Router route's `fullPath` as the `redirect` query parameter to the given URL.
|
|
5
4
|
*
|
|
@@ -34,5 +33,4 @@ export declare function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof
|
|
|
34
33
|
* @param containerRef - The reference to the scrollable element, or `null` while it is unavailable.
|
|
35
34
|
*/
|
|
36
35
|
export declare function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>): void;
|
|
37
|
-
//#endregion
|
|
38
36
|
//# sourceMappingURL=vue.d.ts.map
|
package/dist/vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":";;;;;;;;wBAgBgB,yCAAyC;;;;;;wBASzC,iBAAiB,aAAa,WAAW,kBAAkB;;;;;;wBAU3D,gBAAgB,YAAY,WAAW,kBAAkB;;;;;;;;;;;;;;wBAkBzD,kBAAkB,UAAU,UAAU,aAAa,cAAc,WAAW"}
|
package/dist/vue.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { appendRedirectParamToUrl } from "./url.js";
|
|
2
2
|
import { onActivated } from "vue";
|
|
3
3
|
import { onBeforeRouteLeave, useRoute } from "vue-router";
|
|
4
|
-
|
|
4
|
+
// src/vue.ts
|
|
5
5
|
/**
|
|
6
6
|
* Appends the current Vue Router route's `fullPath` as the `redirect` query parameter to the given URL.
|
|
7
7
|
*
|
|
@@ -56,7 +56,6 @@ function usePreserveScroll(containerRef) {
|
|
|
56
56
|
scrollTop = containerRef.value?.scrollTop || 0;
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
//#endregion
|
|
60
59
|
export { appendRedirectParamFromCurrentRouteToUrl, clearIntervalRef, clearTimeoutRef, usePreserveScroll };
|
|
61
60
|
|
|
62
61
|
//# sourceMappingURL=vue.js.map
|
package/dist/web.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/web.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.
|
|
4
3
|
*
|
|
@@ -22,5 +21,4 @@ export declare function appendRedirectParamFromCurrentLocationToUrl(url: string)
|
|
|
22
21
|
* when navigation is immediate.
|
|
23
22
|
*/
|
|
24
23
|
export declare function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number): NodeJS.Timeout | undefined;
|
|
25
|
-
//#endregion
|
|
26
24
|
//# sourceMappingURL=web.d.ts.map
|
package/dist/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","names":[],"sources":["../src/web.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"web.d.ts","names":[],"sources":["../src/web.ts"],"mappings":";;;;;;;wBASgB,4CAA4C;;;;;;;;;;;;;;;wBAmB5C,8CAA8C,aAAa,mBAAgB,OAAA"}
|
package/dist/web.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { appendRedirectParamToUrl } from "./url.js";
|
|
2
|
-
|
|
2
|
+
// src/web.ts
|
|
3
3
|
/**
|
|
4
4
|
* Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.
|
|
5
5
|
*
|
|
@@ -29,7 +29,6 @@ function assignUrlWithRedirectParamFromCurrentLocation(url, delayMs) {
|
|
|
29
29
|
if (delayMs === void 0) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));
|
|
30
30
|
else return setTimeout(() => window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url)), delayMs);
|
|
31
31
|
}
|
|
32
|
-
//#endregion
|
|
33
32
|
export { appendRedirectParamFromCurrentLocationToUrl, assignUrlWithRedirectParamFromCurrentLocation };
|
|
34
33
|
|
|
35
34
|
//# sourceMappingURL=web.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "19.0.0",
|
|
5
5
|
"description": "A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.",
|
|
6
6
|
"author": "kiki-kanri",
|
|
7
7
|
"license": "MIT",
|
|
@@ -27,12 +27,60 @@
|
|
|
27
27
|
"crypto",
|
|
28
28
|
"hashing",
|
|
29
29
|
"storage",
|
|
30
|
-
"logging"
|
|
31
|
-
"consola",
|
|
32
|
-
"pino"
|
|
30
|
+
"logging"
|
|
33
31
|
],
|
|
34
32
|
"sideEffects": false,
|
|
35
33
|
"exports": {
|
|
34
|
+
"./logger": {
|
|
35
|
+
"types": "./dist/logger/index.d.ts",
|
|
36
|
+
"import": "./dist/logger/index.js",
|
|
37
|
+
"require": null
|
|
38
|
+
},
|
|
39
|
+
"./logger/_internals/formatter": {
|
|
40
|
+
"types": null,
|
|
41
|
+
"import": null,
|
|
42
|
+
"require": null
|
|
43
|
+
},
|
|
44
|
+
"./logger/_internals/levels": {
|
|
45
|
+
"types": null,
|
|
46
|
+
"import": null,
|
|
47
|
+
"require": null
|
|
48
|
+
},
|
|
49
|
+
"./logger/_internals/logger": {
|
|
50
|
+
"types": null,
|
|
51
|
+
"import": null,
|
|
52
|
+
"require": null
|
|
53
|
+
},
|
|
54
|
+
"./logger/_internals/types": {
|
|
55
|
+
"types": null,
|
|
56
|
+
"import": null,
|
|
57
|
+
"require": null
|
|
58
|
+
},
|
|
59
|
+
"./logger/index": {
|
|
60
|
+
"types": null,
|
|
61
|
+
"import": null,
|
|
62
|
+
"require": null
|
|
63
|
+
},
|
|
64
|
+
"./logger/node": {
|
|
65
|
+
"types": "./dist/logger/node/index.d.ts",
|
|
66
|
+
"import": "./dist/logger/node/index.js",
|
|
67
|
+
"require": null
|
|
68
|
+
},
|
|
69
|
+
"./logger/node/_internals/file-writer": {
|
|
70
|
+
"types": null,
|
|
71
|
+
"import": null,
|
|
72
|
+
"require": null
|
|
73
|
+
},
|
|
74
|
+
"./logger/node/_internals/formatter": {
|
|
75
|
+
"types": null,
|
|
76
|
+
"import": null,
|
|
77
|
+
"require": null
|
|
78
|
+
},
|
|
79
|
+
"./logger/node/index": {
|
|
80
|
+
"types": null,
|
|
81
|
+
"import": null,
|
|
82
|
+
"require": null
|
|
83
|
+
},
|
|
36
84
|
"./package.json": "./package.json",
|
|
37
85
|
"./types": {
|
|
38
86
|
"types": "./dist/types/index.d.ts",
|
|
@@ -67,40 +115,30 @@
|
|
|
67
115
|
"typecheck": "tsc -b --noEmit"
|
|
68
116
|
},
|
|
69
117
|
"peerDependencies": {
|
|
70
|
-
"@noble/hashes": "^2.
|
|
71
|
-
"@types/ssh2": "^1.15.5",
|
|
118
|
+
"@noble/hashes": "^2.4.0",
|
|
72
119
|
"async-validator": "^4.2.5",
|
|
73
|
-
"bson": "^7.3.
|
|
74
|
-
"consola": "^3.4.2",
|
|
120
|
+
"bson": "^7.3.3",
|
|
75
121
|
"date-fns": "^4.4.0",
|
|
76
122
|
"decimal.js": "^10.6.0",
|
|
77
|
-
"element-plus": "^2.14.
|
|
78
|
-
"file-type": "^22.
|
|
79
|
-
"lru-cache": "^11.5.
|
|
123
|
+
"element-plus": "^2.14.7",
|
|
124
|
+
"file-type": "^22.2.0",
|
|
125
|
+
"lru-cache": "^11.5.3",
|
|
80
126
|
"millify": "^6.1.0",
|
|
81
|
-
"msgpackr": "^2.0
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"pino-pretty": "^13.1.3",
|
|
85
|
-
"vue": "^3.5.41",
|
|
127
|
+
"msgpackr": "^2.1.0",
|
|
128
|
+
"rotating-file-stream": "^3.2.10",
|
|
129
|
+
"vue": "^3.5.44",
|
|
86
130
|
"vue-router": ">= 4.6.4"
|
|
87
131
|
},
|
|
88
132
|
"peerDependenciesMeta": {
|
|
89
133
|
"@noble/hashes": {
|
|
90
134
|
"optional": true
|
|
91
135
|
},
|
|
92
|
-
"@types/ssh2": {
|
|
93
|
-
"optional": true
|
|
94
|
-
},
|
|
95
136
|
"async-validator": {
|
|
96
137
|
"optional": true
|
|
97
138
|
},
|
|
98
139
|
"bson": {
|
|
99
140
|
"optional": true
|
|
100
141
|
},
|
|
101
|
-
"consola": {
|
|
102
|
-
"optional": true
|
|
103
|
-
},
|
|
104
142
|
"date-fns": {
|
|
105
143
|
"optional": true
|
|
106
144
|
},
|
|
@@ -122,13 +160,7 @@
|
|
|
122
160
|
"msgpackr": {
|
|
123
161
|
"optional": true
|
|
124
162
|
},
|
|
125
|
-
"
|
|
126
|
-
"optional": true
|
|
127
|
-
},
|
|
128
|
-
"pino": {
|
|
129
|
-
"optional": true
|
|
130
|
-
},
|
|
131
|
-
"pino-pretty": {
|
|
163
|
+
"rotating-file-stream": {
|
|
132
164
|
"optional": true
|
|
133
165
|
},
|
|
134
166
|
"vue": {
|
|
@@ -139,37 +171,33 @@
|
|
|
139
171
|
}
|
|
140
172
|
},
|
|
141
173
|
"devDependencies": {
|
|
142
|
-
"@antfu/eslint-config": "^
|
|
143
|
-
"@kikiutils/eslint-config": "^9.3.
|
|
174
|
+
"@antfu/eslint-config": "^10.0.0",
|
|
175
|
+
"@kikiutils/eslint-config": "^9.3.1",
|
|
144
176
|
"@kikiutils/tsconfigs": "^7.0.0",
|
|
145
177
|
"@noble/hashes": "^2.4.0",
|
|
146
178
|
"@types/node": "^26.6.5",
|
|
147
|
-
"@
|
|
148
|
-
"@vitest/coverage-v8": "^5.0.4",
|
|
179
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
149
180
|
"async-validator": "^4.2.5",
|
|
150
181
|
"bson": "^7.3.3",
|
|
151
182
|
"changelogen": "^0.6.2",
|
|
152
|
-
"consola": "^3.4.2",
|
|
153
183
|
"cross-env": "^10.1.0",
|
|
154
184
|
"date-fns": "^4.4.0",
|
|
155
185
|
"decimal.js": "^10.6.0",
|
|
156
186
|
"element-plus": "^2.14.7",
|
|
157
|
-
"eslint": "^10.
|
|
158
|
-
"file-type": "^22.
|
|
159
|
-
"jsdom": "^30.1.
|
|
160
|
-
"knip": "^6.
|
|
187
|
+
"eslint": "^10.13.0",
|
|
188
|
+
"file-type": "^22.2.0",
|
|
189
|
+
"jsdom": "^30.1.3",
|
|
190
|
+
"knip": "^6.42.1",
|
|
161
191
|
"lru-cache": "^11.5.3",
|
|
162
192
|
"millify": "^6.1.0",
|
|
163
|
-
"msgpackr": "^2.1.
|
|
164
|
-
"node-ssh": "^13.2.1",
|
|
165
|
-
"pino": "^10.4.0",
|
|
166
|
-
"pino-pretty": "^13.2.0",
|
|
193
|
+
"msgpackr": "^2.1.2",
|
|
167
194
|
"publint": "^0.3.25",
|
|
168
|
-
"
|
|
195
|
+
"rotating-file-stream": "^3.2.10",
|
|
196
|
+
"tsdown": "^0.23.2",
|
|
169
197
|
"typescript": "^6.0.3",
|
|
170
198
|
"unplugin-unused": "^0.6.0",
|
|
171
|
-
"vitest": "^5.0.
|
|
172
|
-
"vue": "^3.5.
|
|
199
|
+
"vitest": "^5.0.5",
|
|
200
|
+
"vue": "^3.5.44",
|
|
173
201
|
"vue-router": "^5.4.0"
|
|
174
202
|
}
|
|
175
203
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLoggerStreamName,
|
|
3
|
+
loggerMethods,
|
|
4
|
+
} from './levels';
|
|
5
|
+
import type { LoggerRecord } from './types';
|
|
6
|
+
|
|
7
|
+
// Functions
|
|
8
|
+
|
|
9
|
+
/** Native console formatting keeps user strings literal and objects expandable. */
|
|
10
|
+
export function formatLoggerConsoleArgs(record: LoggerRecord): unknown[] {
|
|
11
|
+
if (typeof process !== 'undefined' && process.versions?.node) {
|
|
12
|
+
const target = process[getLoggerStreamName(record.type)];
|
|
13
|
+
const parts = formatLoggerParts(record, supportsLoggerColor(target));
|
|
14
|
+
return [
|
|
15
|
+
parts.map((part) => typeof part === 'string' ? '%s' : '%O').join(' '),
|
|
16
|
+
...parts,
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const format: string[] = [];
|
|
21
|
+
const args: unknown[] = [];
|
|
22
|
+
const decorate = (text: string, color: string) => {
|
|
23
|
+
format.push('%c%s%c');
|
|
24
|
+
args.push(`color: ${color}`, text, '');
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (record.icons) decorate(loggerMethods[record.type].icon, loggerMethods[record.type].cssColor);
|
|
28
|
+
if (record.timestamp) decorate(formatLoggerTime(record.date), '#808080');
|
|
29
|
+
if (record.prefix) decorate(record.prefix, '#0891b2');
|
|
30
|
+
for (const arg of record.args) {
|
|
31
|
+
format.push(typeof arg === 'string' ? '%s' : '%o');
|
|
32
|
+
args.push(arg);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (record.suffix) decorate(record.suffix, '#0891b2');
|
|
36
|
+
return [
|
|
37
|
+
format.join(' '),
|
|
38
|
+
...args,
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Keeps data arguments intact so browser developer tools can expand objects. */
|
|
43
|
+
export function formatLoggerParts(record: LoggerRecord, colors = false): unknown[] {
|
|
44
|
+
const parts: unknown[] = [];
|
|
45
|
+
const paint = (text: string, color: string) => colors ? `\u001B[${color}m${text}\u001B[0m` : text;
|
|
46
|
+
if (record.icons) parts.push(paint(loggerMethods[record.type].icon, loggerMethods[record.type].ansiColor));
|
|
47
|
+
if (record.timestamp) parts.push(paint(formatLoggerTime(record.date), '90'));
|
|
48
|
+
if (record.prefix) parts.push(paint(record.prefix, '36'));
|
|
49
|
+
parts.push(...record.args);
|
|
50
|
+
if (record.suffix) parts.push(paint(record.suffix, '36'));
|
|
51
|
+
return parts;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Fixed local-time representation, deliberately without a per-second cache. */
|
|
55
|
+
export function formatLoggerTime(date: Date): string {
|
|
56
|
+
const pad = (value: number, width = 2) => String(value).padStart(width, '0');
|
|
57
|
+
const day = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
58
|
+
const time = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
59
|
+
return `[${day} ${time}.${pad(date.getMilliseconds(), 3)}]`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Use native terminal detection; redirected streams still honor FORCE_COLOR. */
|
|
63
|
+
export function supportsLoggerColor(target: { hasColors?: () => boolean; isTTY?: boolean }): boolean {
|
|
64
|
+
if (target.hasColors) return target.hasColors();
|
|
65
|
+
const forced = process.env.FORCE_COLOR;
|
|
66
|
+
if (forced !== undefined) {
|
|
67
|
+
return [
|
|
68
|
+
'',
|
|
69
|
+
'1',
|
|
70
|
+
'2',
|
|
71
|
+
'3',
|
|
72
|
+
'true',
|
|
73
|
+
].includes(forced);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return Boolean(target.isTTY)
|
|
77
|
+
&& !process.env.NO_COLOR
|
|
78
|
+
&& !process.env.NODE_DISABLE_COLORS
|
|
79
|
+
&& process.env.TERM !== 'dumb';
|
|
80
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { LoggerMethod } from '../types';
|
|
2
|
+
|
|
3
|
+
// Constants/Variables
|
|
4
|
+
export const loggerMethods = {
|
|
5
|
+
debug: {
|
|
6
|
+
ansiColor: '36',
|
|
7
|
+
consoleMethod: 'debug',
|
|
8
|
+
cssColor: '#0891b2',
|
|
9
|
+
icon: '⚙',
|
|
10
|
+
severity: 20,
|
|
11
|
+
},
|
|
12
|
+
error: {
|
|
13
|
+
ansiColor: '31',
|
|
14
|
+
consoleMethod: 'error',
|
|
15
|
+
cssColor: '#dc2626',
|
|
16
|
+
icon: '✖',
|
|
17
|
+
severity: 50,
|
|
18
|
+
},
|
|
19
|
+
fatal: {
|
|
20
|
+
ansiColor: '31',
|
|
21
|
+
consoleMethod: 'error',
|
|
22
|
+
cssColor: '#dc2626',
|
|
23
|
+
icon: '✖',
|
|
24
|
+
severity: 60,
|
|
25
|
+
},
|
|
26
|
+
info: {
|
|
27
|
+
ansiColor: '36',
|
|
28
|
+
consoleMethod: 'info',
|
|
29
|
+
cssColor: '#0891b2',
|
|
30
|
+
icon: 'ℹ',
|
|
31
|
+
severity: 30,
|
|
32
|
+
},
|
|
33
|
+
success: {
|
|
34
|
+
ansiColor: '32',
|
|
35
|
+
consoleMethod: 'info',
|
|
36
|
+
cssColor: '#16a34a',
|
|
37
|
+
icon: '✔',
|
|
38
|
+
severity: 30,
|
|
39
|
+
},
|
|
40
|
+
trace: {
|
|
41
|
+
ansiColor: '90',
|
|
42
|
+
consoleMethod: 'debug',
|
|
43
|
+
cssColor: '#808080',
|
|
44
|
+
icon: '·',
|
|
45
|
+
severity: 10,
|
|
46
|
+
},
|
|
47
|
+
warn: {
|
|
48
|
+
ansiColor: '33',
|
|
49
|
+
consoleMethod: 'warn',
|
|
50
|
+
cssColor: '#ca8a04',
|
|
51
|
+
icon: '⚠',
|
|
52
|
+
severity: 40,
|
|
53
|
+
},
|
|
54
|
+
} as const;
|
|
55
|
+
|
|
56
|
+
// Functions
|
|
57
|
+
export function getLoggerStreamName(type: LoggerMethod): 'stderr' | 'stdout' {
|
|
58
|
+
const method = loggerMethods[type].consoleMethod;
|
|
59
|
+
return method === 'warn' || method === 'error' ? 'stderr' : 'stdout';
|
|
60
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Logger,
|
|
3
|
+
LoggerDiagnostic,
|
|
4
|
+
LoggerLevel,
|
|
5
|
+
LoggerMethod,
|
|
6
|
+
LoggerOptions,
|
|
7
|
+
} from '../types';
|
|
8
|
+
|
|
9
|
+
import { loggerMethods } from './levels';
|
|
10
|
+
import type { LoggerRecord } from './types';
|
|
11
|
+
|
|
12
|
+
interface LoggerHooks {
|
|
13
|
+
/** A non-throwing reporter created by createDiagnosticReporter. */
|
|
14
|
+
report: (event: LoggerDiagnostic) => void;
|
|
15
|
+
write: (record: LoggerRecord) => Promise<void> | void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Constants/Variables
|
|
19
|
+
const booleanPresentationKeys = [
|
|
20
|
+
'console',
|
|
21
|
+
'icons',
|
|
22
|
+
'timestamp',
|
|
23
|
+
] as const;
|
|
24
|
+
|
|
25
|
+
const stringPresentationKeys = [
|
|
26
|
+
'prefix',
|
|
27
|
+
'suffix',
|
|
28
|
+
] as const;
|
|
29
|
+
|
|
30
|
+
// Functions
|
|
31
|
+
|
|
32
|
+
/** A non-recursive, rate-limited diagnostic boundary shared by server and browser adapters. */
|
|
33
|
+
export function createDiagnosticReporter(
|
|
34
|
+
onError?: (event: LoggerDiagnostic) => void,
|
|
35
|
+
fallback?: (message: string) => void,
|
|
36
|
+
): (event: LoggerDiagnostic) => void {
|
|
37
|
+
let reporting = false;
|
|
38
|
+
let callbackPending = false;
|
|
39
|
+
const stateByType = new Map<LoggerDiagnostic['type'], { lastReportedAt: number; suppressedCount: number }>();
|
|
40
|
+
|
|
41
|
+
return (event) => {
|
|
42
|
+
if (reporting) return;
|
|
43
|
+
try {
|
|
44
|
+
const now = Date.now();
|
|
45
|
+
const state = stateByType.get(event.type);
|
|
46
|
+
if (state && now - state.lastReportedAt < 1000) {
|
|
47
|
+
state.suppressedCount++;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
reporting = true;
|
|
52
|
+
const suppressedCount = state?.suppressedCount ?? 0;
|
|
53
|
+
if (suppressedCount) {
|
|
54
|
+
event = {
|
|
55
|
+
...event,
|
|
56
|
+
suppressedCount,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
stateByType.set(
|
|
61
|
+
event.type,
|
|
62
|
+
{
|
|
63
|
+
lastReportedAt: now,
|
|
64
|
+
suppressedCount: 0,
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const summary = suppressedCount ? ` (${suppressedCount} similar diagnostics suppressed)` : '';
|
|
70
|
+
fallback?.(`[logger] ${event.message}${summary}\n`);
|
|
71
|
+
} catch {
|
|
72
|
+
// Diagnostics must never re-enter the normal logging pipeline.
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!callbackPending) {
|
|
76
|
+
try {
|
|
77
|
+
callbackPending = true;
|
|
78
|
+
const result: unknown = onError?.(event);
|
|
79
|
+
if (result !== null && (typeof result === 'object' || typeof result === 'function')) {
|
|
80
|
+
void Promise.resolve(result).then(
|
|
81
|
+
() => {
|
|
82
|
+
callbackPending = false;
|
|
83
|
+
},
|
|
84
|
+
() => {
|
|
85
|
+
callbackPending = false;
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
} else {
|
|
89
|
+
callbackPending = false;
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
callbackPending = false;
|
|
93
|
+
// User diagnostic callbacks have the same non-throwing boundary.
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} catch { /* Diagnostics must never escape into the logging pipeline. */ } finally {
|
|
97
|
+
reporting = false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function createLoggerCore(options: LoggerOptions, hooks: LoggerHooks): Logger {
|
|
103
|
+
validateLevel(options.level);
|
|
104
|
+
validatePresentation(options);
|
|
105
|
+
if (options.onError !== undefined && typeof options.onError !== 'function') {
|
|
106
|
+
throw new TypeError('Logger onError must be a function');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const presentation = {
|
|
110
|
+
console: options.console ?? true,
|
|
111
|
+
icons: options.icons ?? true,
|
|
112
|
+
prefix: options.prefix ?? '',
|
|
113
|
+
suffix: options.suffix ?? '',
|
|
114
|
+
timestamp: options.timestamp ?? true,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const { report } = hooks;
|
|
118
|
+
|
|
119
|
+
let override = options.level === 'env' ? undefined : options.level;
|
|
120
|
+
let previousEnvironment: string | undefined;
|
|
121
|
+
let currentLevel: LoggerLevel = override ?? 'info';
|
|
122
|
+
let environmentRead = false;
|
|
123
|
+
|
|
124
|
+
function refreshLevel() {
|
|
125
|
+
if (override !== undefined) return;
|
|
126
|
+
const input = readEnvironmentLevel();
|
|
127
|
+
if (environmentRead && input === previousEnvironment) return;
|
|
128
|
+
environmentRead = true;
|
|
129
|
+
previousEnvironment = input;
|
|
130
|
+
const normalized = input?.trim().toLowerCase() || undefined;
|
|
131
|
+
currentLevel = isLevel(normalized) ? normalized : 'info';
|
|
132
|
+
if (normalized !== undefined && !isLevel(normalized)) {
|
|
133
|
+
report({
|
|
134
|
+
message: 'Invalid LOG_LEVEL; using info',
|
|
135
|
+
type: 'invalid-level',
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const logger = {
|
|
141
|
+
configure(configuration) {
|
|
142
|
+
validatePresentation(configuration);
|
|
143
|
+
for (const name of booleanPresentationKeys) {
|
|
144
|
+
const value = configuration[name];
|
|
145
|
+
if (value !== undefined) presentation[name] = value;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
for (const name of stringPresentationKeys) {
|
|
149
|
+
const value = configuration[name];
|
|
150
|
+
if (value !== undefined) presentation[name] = value;
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
isLevelEnabled(level) {
|
|
154
|
+
if (level !== 'success' && !isLevel(level)) throw new TypeError('Invalid logger level');
|
|
155
|
+
refreshLevel();
|
|
156
|
+
return level !== 'silent' && getLevelSeverity(level) >= getLevelSeverity(currentLevel);
|
|
157
|
+
},
|
|
158
|
+
setLevel(level) {
|
|
159
|
+
validateLevel(level);
|
|
160
|
+
if (level === undefined) throw new TypeError('Invalid logger level');
|
|
161
|
+
override = level === 'env' ? undefined : level;
|
|
162
|
+
environmentRead = false;
|
|
163
|
+
if (override !== undefined) {
|
|
164
|
+
currentLevel = override;
|
|
165
|
+
} else {
|
|
166
|
+
refreshLevel();
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
} as Logger;
|
|
170
|
+
|
|
171
|
+
for (const type of Object.keys(loggerMethods) as LoggerMethod[]) {
|
|
172
|
+
logger[type] = async (...args: unknown[]) => {
|
|
173
|
+
try {
|
|
174
|
+
refreshLevel();
|
|
175
|
+
if (loggerMethods[type].severity < getLevelSeverity(currentLevel)) return;
|
|
176
|
+
await hooks.write({
|
|
177
|
+
...presentation,
|
|
178
|
+
args,
|
|
179
|
+
date: new Date(),
|
|
180
|
+
type,
|
|
181
|
+
});
|
|
182
|
+
} catch (error) {
|
|
183
|
+
report({
|
|
184
|
+
error,
|
|
185
|
+
message: 'Logger output failed',
|
|
186
|
+
type: 'format',
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return logger;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function getLevelSeverity(level: LoggerLevel | LoggerMethod): number {
|
|
196
|
+
return level === 'silent' ? Number.POSITIVE_INFINITY : loggerMethods[level].severity;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function isLevel(value: unknown): value is LoggerLevel {
|
|
200
|
+
return typeof value === 'string'
|
|
201
|
+
&& (value === 'silent' || (value !== 'success' && Object.hasOwn(loggerMethods, value)));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function readEnvironmentLevel(): string | undefined {
|
|
205
|
+
return (globalThis as { process?: { env?: { LOG_LEVEL?: string } } }).process?.env?.LOG_LEVEL;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function validateLevel(value: unknown): asserts value is 'env' | LoggerLevel | undefined {
|
|
209
|
+
if (value !== undefined && value !== 'env' && !isLevel(value)) throw new TypeError('Invalid logger level');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function validatePresentation(options: Pick<LoggerOptions, 'console' | 'icons' | 'prefix' | 'suffix' | 'timestamp'>) {
|
|
213
|
+
for (const name of booleanPresentationKeys) {
|
|
214
|
+
if (options[name] !== undefined && typeof options[name] !== 'boolean') {
|
|
215
|
+
throw new TypeError(`Logger ${name} must be a boolean`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
for (const name of stringPresentationKeys) {
|
|
220
|
+
if (options[name] !== undefined && typeof options[name] !== 'string') {
|
|
221
|
+
throw new TypeError(`Logger ${name} must be a string`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|