@kikiutils/shared 18.3.0 → 20.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.
Files changed (161) hide show
  1. package/README.md +0 -7
  2. package/dist/buffer.d.ts +0 -2
  3. package/dist/buffer.d.ts.map +1 -1
  4. package/dist/buffer.js +1 -2
  5. package/dist/classes/enhanced-date.d.ts +0 -2
  6. package/dist/classes/enhanced-date.d.ts.map +1 -1
  7. package/dist/classes/enhanced-date.js +1 -2
  8. package/dist/classes/path.d.ts +1 -3
  9. package/dist/classes/path.d.ts.map +1 -1
  10. package/dist/classes/path.js +1 -2
  11. package/dist/classes/precision-number.d.ts +0 -2
  12. package/dist/classes/precision-number.d.ts.map +1 -1
  13. package/dist/classes/precision-number.js +1 -2
  14. package/dist/clipboard.d.ts +0 -2
  15. package/dist/clipboard.d.ts.map +1 -1
  16. package/dist/clipboard.js +1 -2
  17. package/dist/crypto-hash.d.ts +0 -2
  18. package/dist/crypto-hash.d.ts.map +1 -1
  19. package/dist/crypto-hash.js +1 -2
  20. package/dist/datetime.d.ts +0 -2
  21. package/dist/datetime.d.ts.map +1 -1
  22. package/dist/datetime.js +1 -2
  23. package/dist/element-plus.d.ts +0 -2
  24. package/dist/element-plus.d.ts.map +1 -1
  25. package/dist/element-plus.js +1 -2
  26. package/dist/enum.d.ts +0 -2
  27. package/dist/enum.d.ts.map +1 -1
  28. package/dist/enum.js +1 -2
  29. package/dist/env.d.ts +0 -2
  30. package/dist/env.d.ts.map +1 -1
  31. package/dist/env.js +1 -2
  32. package/dist/event-awaiter.d.ts +0 -2
  33. package/dist/event-awaiter.d.ts.map +1 -1
  34. package/dist/event-awaiter.js +1 -2
  35. package/dist/file.d.ts +0 -2
  36. package/dist/file.d.ts.map +1 -1
  37. package/dist/file.js +1 -2
  38. package/dist/general.d.ts +0 -2
  39. package/dist/general.d.ts.map +1 -1
  40. package/dist/general.js +1 -2
  41. package/dist/hash.d.ts +0 -2
  42. package/dist/hash.d.ts.map +1 -1
  43. package/dist/hash.js +1 -2
  44. package/dist/logger/_internals/formatter.d.ts +13 -0
  45. package/dist/logger/_internals/formatter.d.ts.map +1 -0
  46. package/dist/logger/_internals/formatter.js +57 -0
  47. package/dist/logger/_internals/formatter.js.map +1 -0
  48. package/dist/logger/_internals/levels.d.ts +54 -0
  49. package/dist/logger/_internals/levels.d.ts.map +1 -0
  50. package/dist/logger/_internals/levels.js +59 -0
  51. package/dist/logger/_internals/levels.js.map +1 -0
  52. package/dist/logger/_internals/logger.d.ts +12 -0
  53. package/dist/logger/_internals/logger.d.ts.map +1 -0
  54. package/dist/logger/_internals/logger.js +147 -0
  55. package/dist/logger/_internals/logger.js.map +1 -0
  56. package/dist/logger/_internals/types.d.ts +12 -0
  57. package/dist/logger/_internals/types.d.ts.map +1 -0
  58. package/dist/logger/_internals/types.js +1 -0
  59. package/dist/logger/index.d.ts +10 -0
  60. package/dist/logger/index.d.ts.map +1 -0
  61. package/dist/logger/index.js +25 -0
  62. package/dist/logger/index.js.map +1 -0
  63. package/dist/logger/node/_internals/file-writer.d.ts +11 -0
  64. package/dist/logger/node/_internals/file-writer.d.ts.map +1 -0
  65. package/dist/logger/node/_internals/file-writer.js +188 -0
  66. package/dist/logger/node/_internals/file-writer.js.map +1 -0
  67. package/dist/logger/node/_internals/formatter.d.ts +4 -0
  68. package/dist/logger/node/_internals/formatter.d.ts.map +1 -0
  69. package/dist/logger/node/_internals/formatter.js +21 -0
  70. package/dist/logger/node/_internals/formatter.js.map +1 -0
  71. package/dist/logger/node/index.d.ts +10 -0
  72. package/dist/logger/node/index.d.ts.map +1 -0
  73. package/dist/logger/node/index.js +123 -0
  74. package/dist/logger/node/index.js.map +1 -0
  75. package/dist/logger/node/types.d.ts +43 -0
  76. package/dist/logger/node/types.d.ts.map +1 -0
  77. package/dist/logger/node/types.js +1 -0
  78. package/dist/logger/types.d.ts +50 -0
  79. package/dist/logger/types.d.ts.map +1 -0
  80. package/dist/logger/types.js +1 -0
  81. package/dist/math.d.ts +0 -2
  82. package/dist/math.d.ts.map +1 -1
  83. package/dist/math.js +1 -2
  84. package/dist/number.d.ts +0 -2
  85. package/dist/number.d.ts.map +1 -1
  86. package/dist/number.js +1 -2
  87. package/dist/random.d.ts +0 -2
  88. package/dist/random.d.ts.map +1 -1
  89. package/dist/random.js +1 -2
  90. package/dist/redis/script-runner.d.ts +0 -2
  91. package/dist/redis/script-runner.d.ts.map +1 -1
  92. package/dist/redis/script-runner.js +1 -2
  93. package/dist/storages/lru/keyed-store.d.ts +0 -2
  94. package/dist/storages/lru/keyed-store.d.ts.map +1 -1
  95. package/dist/storages/lru/keyed-store.js +1 -2
  96. package/dist/storages/redis/keyed-store.d.ts +4 -4
  97. package/dist/storages/redis/keyed-store.d.ts.map +1 -1
  98. package/dist/storages/redis/keyed-store.js +7 -4
  99. package/dist/storages/redis/keyed-store.js.map +1 -1
  100. package/dist/storages/redis/msgpack.d.ts +10 -3
  101. package/dist/storages/redis/msgpack.d.ts.map +1 -1
  102. package/dist/storages/redis/msgpack.js +18 -3
  103. package/dist/storages/redis/msgpack.js.map +1 -1
  104. package/dist/storages/redis/types.d.ts +30 -2
  105. package/dist/storages/redis/types.d.ts.map +1 -1
  106. package/dist/string.d.ts +0 -2
  107. package/dist/string.d.ts.map +1 -1
  108. package/dist/string.js +1 -2
  109. package/dist/time.d.ts +0 -2
  110. package/dist/time.d.ts.map +1 -1
  111. package/dist/time.js +1 -2
  112. package/dist/types/filtered-key-path.d.ts +0 -2
  113. package/dist/types/filtered-key-path.d.ts.map +1 -1
  114. package/dist/types/index.d.ts +0 -10
  115. package/dist/types/index.d.ts.map +1 -1
  116. package/dist/types/vue.d.ts +0 -2
  117. package/dist/types/vue.d.ts.map +1 -1
  118. package/dist/url.d.ts +0 -2
  119. package/dist/url.d.ts.map +1 -1
  120. package/dist/url.js +1 -2
  121. package/dist/vue.d.ts +0 -2
  122. package/dist/vue.d.ts.map +1 -1
  123. package/dist/vue.js +1 -2
  124. package/dist/web.d.ts +0 -2
  125. package/dist/web.d.ts.map +1 -1
  126. package/dist/web.js +1 -2
  127. package/package.json +73 -45
  128. package/src/logger/_internals/formatter.ts +80 -0
  129. package/src/logger/_internals/levels.ts +60 -0
  130. package/src/logger/_internals/logger.ts +224 -0
  131. package/src/logger/_internals/types.ts +12 -0
  132. package/src/logger/index.ts +34 -0
  133. package/src/logger/node/_internals/file-writer.ts +298 -0
  134. package/src/logger/node/_internals/formatter.ts +33 -0
  135. package/src/logger/node/index.ts +173 -0
  136. package/src/logger/node/types.ts +58 -0
  137. package/src/logger/types.ts +60 -0
  138. package/src/storages/redis/keyed-store.ts +6 -2
  139. package/src/storages/redis/msgpack.ts +17 -1
  140. package/src/storages/redis/types.ts +34 -0
  141. package/src/types/index.ts +0 -10
  142. package/dist/classes/ssh-client.d.ts +0 -40
  143. package/dist/classes/ssh-client.d.ts.map +0 -1
  144. package/dist/classes/ssh-client.js +0 -130
  145. package/dist/classes/ssh-client.js.map +0 -1
  146. package/dist/consola.d.ts +0 -24
  147. package/dist/consola.d.ts.map +0 -1
  148. package/dist/consola.js +0 -29
  149. package/dist/consola.js.map +0 -1
  150. package/dist/object.d.ts +0 -44
  151. package/dist/object.d.ts.map +0 -1
  152. package/dist/object.js +0 -59
  153. package/dist/object.js.map +0 -1
  154. package/dist/pino.d.ts +0 -25
  155. package/dist/pino.d.ts.map +0 -1
  156. package/dist/pino.js +0 -34
  157. package/dist/pino.js.map +0 -1
  158. package/src/classes/ssh-client.ts +0 -175
  159. package/src/consola.ts +0 -25
  160. package/src/object.ts +0 -78
  161. package/src/pino.ts +0 -33
@@ -1,12 +1,13 @@
1
1
  import { decode, encode, isNativeAccelerationEnabled } from "msgpackr";
2
- //#region src/storages/redis/msgpack.ts
2
+ // src/storages/redis/msgpack.ts
3
3
  if (!isNativeAccelerationEnabled) console.warn("Native acceleration not enabled for msgpackr, verify that install finished properly");
4
4
  /**
5
5
  * Creates a frozen Redis-like storage facade using MessagePack serialization.
6
6
  *
7
7
  * @remarks
8
8
  * Adapter rejections and MessagePack serialization errors propagate to the caller.
9
- * Reads resolve to `null` when no raw value exists. Writes resolve to `true` only when the adapter returns `OK`;
9
+ * Reads resolve to `null` when no raw value exists; `getAndRemoveItem` reads and deletes in one atomic adapter call.
10
+ * Writes resolve to `true` only when the adapter returns `OK`;
10
11
  * removal resolves to `true` only when exactly one key is deleted.
11
12
  * The adapter remains caller-owned; creating the facade does not open or close a connection.
12
13
  *
@@ -25,6 +26,11 @@ if (!isNativeAccelerationEnabled) console.warn("Native acceleration not enabled
25
26
  * const adapter: RedisLikeAdapter = {
26
27
  * delete: async (key) => values.delete(key) ? 1 : 0,
27
28
  * getBuffer: async (key) => values.get(key) ?? null,
29
+ * getBufferAndDelete: async (key) => {
30
+ * const value = values.get(key) ?? null;
31
+ * values.delete(key);
32
+ * return value;
33
+ * },
28
34
  * has: async (key) => values.has(key),
29
35
  * setBuffer: async (key, value) => {
30
36
  * values.set(key, value);
@@ -33,6 +39,9 @@ if (!isNativeAccelerationEnabled) console.warn("Native acceleration not enabled
33
39
  * setBufferEx: async () => {
34
40
  * throw new Error('TTL writes are not supported by this example adapter');
35
41
  * },
42
+ * setBufferExNx: async () => {
43
+ * throw new Error('TTL writes are not supported by this example adapter');
44
+ * },
36
45
  * ttl: async (key) => values.has(key) ? -1 : -2,
37
46
  * };
38
47
  *
@@ -44,6 +53,10 @@ if (!isNativeAccelerationEnabled) console.warn("Native acceleration not enabled
44
53
  */
45
54
  function createRedisMsgpackStorage(adapter) {
46
55
  return Object.freeze({
56
+ async getAndRemoveItem(key) {
57
+ const rawValue = await adapter.getBufferAndDelete(key);
58
+ return rawValue ? decode(rawValue) : null;
59
+ },
47
60
  async getItem(key) {
48
61
  const rawValue = await adapter.getBuffer(key);
49
62
  return rawValue ? decode(rawValue) : null;
@@ -54,10 +67,12 @@ function createRedisMsgpackStorage(adapter) {
54
67
  setItem: async (key, value) => await adapter.setBuffer(key, encode(value)) === "OK",
55
68
  async setItemWithTtl(key, ttlSeconds, value) {
56
69
  return await adapter.setBufferEx(key, ttlSeconds, encode(value)) === "OK";
70
+ },
71
+ async setItemWithTtlIfAbsent(key, ttlSeconds, value) {
72
+ return await adapter.setBufferExNx(key, ttlSeconds, encode(value)) === "OK";
57
73
  }
58
74
  });
59
75
  }
60
- //#endregion
61
76
  export { createRedisMsgpackStorage };
62
77
 
63
78
  //# sourceMappingURL=msgpack.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"msgpack.js","names":[],"sources":["../../../src/storages/redis/msgpack.ts"],"sourcesContent":["import {\n decode,\n encode,\n isNativeAccelerationEnabled,\n} from 'msgpackr';\n\nimport type {\n RedisLikeAdapter,\n RedisLikeStorage,\n} from './types';\n\nif (!isNativeAccelerationEnabled) {\n console.warn('Native acceleration not enabled for msgpackr, verify that install finished properly');\n}\n\n/**\n * Creates a frozen Redis-like storage facade using MessagePack serialization.\n *\n * @remarks\n * Adapter rejections and MessagePack serialization errors propagate to the caller.\n * Reads resolve to `null` when no raw value exists. Writes resolve to `true` only when the adapter returns `OK`;\n * removal resolves to `true` only when exactly one key is deleted.\n * The adapter remains caller-owned; creating the facade does not open or close a connection.\n *\n * @param adapter - The caller-owned adapter for raw binary operations.\n *\n * @returns A new frozen facade sharing the supplied adapter.\n *\n * @example\n *\n * ```ts\n * import { createRedisMsgpackStorage } from '@kikiutils/shared/storages/redis/msgpack';\n * import type { RedisLikeAdapter } from '@kikiutils/shared/storages/redis/types';\n *\n * // This in-memory adapter demonstrates non-expiring operations without an external service.\n * const values = new Map<string, Uint8Array>();\n * const adapter: RedisLikeAdapter = {\n * delete: async (key) => values.delete(key) ? 1 : 0,\n * getBuffer: async (key) => values.get(key) ?? null,\n * has: async (key) => values.has(key),\n * setBuffer: async (key, value) => {\n * values.set(key, value);\n * return 'OK';\n * },\n * setBufferEx: async () => {\n * throw new Error('TTL writes are not supported by this example adapter');\n * },\n * ttl: async (key) => values.has(key) ? -1 : -2,\n * };\n *\n * const storage = createRedisMsgpackStorage(adapter);\n * await storage.setItem('profile', { name: 'Alice' });\n * const profile = await storage.getItem<{ name: string }>('profile');\n * console.log(profile); // => { name: 'Alice' }\n * ```\n */\nexport function createRedisMsgpackStorage(adapter: RedisLikeAdapter): Readonly<RedisLikeStorage> {\n return Object.freeze({\n async getItem<T = unknown>(key: string) {\n const rawValue = await adapter.getBuffer(key);\n return rawValue ? decode(rawValue) as T : null;\n },\n getItemTtl: (key: string) => adapter.ttl(key),\n hasItem: (key: string) => adapter.has(key),\n removeItem: async (key: string) => await adapter.delete(key) === 1,\n setItem: async (key: string, value: any) => await adapter.setBuffer(key, encode(value)) === 'OK',\n async setItemWithTtl(key: string, ttlSeconds: number, value: any) {\n return await adapter.setBufferEx(key, ttlSeconds, encode(value)) === 'OK';\n },\n });\n}\n"],"mappings":";;AAWA,IAAI,CAAC,6BACD,QAAQ,KAAK,qFAAqF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CtG,SAAgB,0BAA0B,SAAuD;CAC7F,OAAO,OAAO,OAAO;EACjB,MAAM,QAAqB,KAAa;GACpC,MAAM,WAAW,MAAM,QAAQ,UAAU,GAAG;GAC5C,OAAO,WAAW,OAAO,QAAQ,IAAS;EAC9C;EACA,aAAa,QAAgB,QAAQ,IAAI,GAAG;EAC5C,UAAU,QAAgB,QAAQ,IAAI,GAAG;EACzC,YAAY,OAAO,QAAgB,MAAM,QAAQ,OAAO,GAAG,MAAM;EACjE,SAAS,OAAO,KAAa,UAAe,MAAM,QAAQ,UAAU,KAAK,OAAO,KAAK,CAAC,MAAM;EAC5F,MAAM,eAAe,KAAa,YAAoB,OAAY;GAC9D,OAAO,MAAM,QAAQ,YAAY,KAAK,YAAY,OAAO,KAAK,CAAC,MAAM;EACzE;CACJ,CAAC;AACL"}
1
+ {"version":3,"file":"msgpack.js","names":[],"sources":["../../../src/storages/redis/msgpack.ts"],"sourcesContent":["import {\n decode,\n encode,\n isNativeAccelerationEnabled,\n} from 'msgpackr';\n\nimport type {\n RedisLikeAdapter,\n RedisLikeStorage,\n} from './types';\n\nif (!isNativeAccelerationEnabled) {\n console.warn('Native acceleration not enabled for msgpackr, verify that install finished properly');\n}\n\n/**\n * Creates a frozen Redis-like storage facade using MessagePack serialization.\n *\n * @remarks\n * Adapter rejections and MessagePack serialization errors propagate to the caller.\n * Reads resolve to `null` when no raw value exists; `getAndRemoveItem` reads and deletes in one atomic adapter call.\n * Writes resolve to `true` only when the adapter returns `OK`;\n * removal resolves to `true` only when exactly one key is deleted.\n * The adapter remains caller-owned; creating the facade does not open or close a connection.\n *\n * @param adapter - The caller-owned adapter for raw binary operations.\n *\n * @returns A new frozen facade sharing the supplied adapter.\n *\n * @example\n *\n * ```ts\n * import { createRedisMsgpackStorage } from '@kikiutils/shared/storages/redis/msgpack';\n * import type { RedisLikeAdapter } from '@kikiutils/shared/storages/redis/types';\n *\n * // This in-memory adapter demonstrates non-expiring operations without an external service.\n * const values = new Map<string, Uint8Array>();\n * const adapter: RedisLikeAdapter = {\n * delete: async (key) => values.delete(key) ? 1 : 0,\n * getBuffer: async (key) => values.get(key) ?? null,\n * getBufferAndDelete: async (key) => {\n * const value = values.get(key) ?? null;\n * values.delete(key);\n * return value;\n * },\n * has: async (key) => values.has(key),\n * setBuffer: async (key, value) => {\n * values.set(key, value);\n * return 'OK';\n * },\n * setBufferEx: async () => {\n * throw new Error('TTL writes are not supported by this example adapter');\n * },\n * setBufferExNx: async () => {\n * throw new Error('TTL writes are not supported by this example adapter');\n * },\n * ttl: async (key) => values.has(key) ? -1 : -2,\n * };\n *\n * const storage = createRedisMsgpackStorage(adapter);\n * await storage.setItem('profile', { name: 'Alice' });\n * const profile = await storage.getItem<{ name: string }>('profile');\n * console.log(profile); // => { name: 'Alice' }\n * ```\n */\nexport function createRedisMsgpackStorage(adapter: RedisLikeAdapter): Readonly<RedisLikeStorage> {\n return Object.freeze({\n async getAndRemoveItem<T = unknown>(key: string) {\n const rawValue = await adapter.getBufferAndDelete(key);\n return rawValue ? decode(rawValue) as T : null;\n },\n async getItem<T = unknown>(key: string) {\n const rawValue = await adapter.getBuffer(key);\n return rawValue ? decode(rawValue) as T : null;\n },\n getItemTtl: (key: string) => adapter.ttl(key),\n hasItem: (key: string) => adapter.has(key),\n removeItem: async (key: string) => await adapter.delete(key) === 1,\n setItem: async (key: string, value: any) => await adapter.setBuffer(key, encode(value)) === 'OK',\n async setItemWithTtl(key: string, ttlSeconds: number, value: any) {\n return await adapter.setBufferEx(key, ttlSeconds, encode(value)) === 'OK';\n },\n async setItemWithTtlIfAbsent(key: string, ttlSeconds: number, value: any) {\n return await adapter.setBufferExNx(key, ttlSeconds, encode(value)) === 'OK';\n },\n });\n}\n"],"mappings":";;AAWA,IAAI,CAAC,6BACD,QAAQ,KAAK,qFAAqF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDtG,SAAgB,0BAA0B,SAAuD;CAC7F,OAAO,OAAO,OAAO;EACjB,MAAM,iBAA8B,KAAa;GAC7C,MAAM,WAAW,MAAM,QAAQ,mBAAmB,GAAG;GACrD,OAAO,WAAW,OAAO,QAAQ,IAAS;EAC9C;EACA,MAAM,QAAqB,KAAa;GACpC,MAAM,WAAW,MAAM,QAAQ,UAAU,GAAG;GAC5C,OAAO,WAAW,OAAO,QAAQ,IAAS;EAC9C;EACA,aAAa,QAAgB,QAAQ,IAAI,GAAG;EAC5C,UAAU,QAAgB,QAAQ,IAAI,GAAG;EACzC,YAAY,OAAO,QAAgB,MAAM,QAAQ,OAAO,GAAG,MAAM;EACjE,SAAS,OAAO,KAAa,UAAe,MAAM,QAAQ,UAAU,KAAK,OAAO,KAAK,CAAC,MAAM;EAC5F,MAAM,eAAe,KAAa,YAAoB,OAAY;GAC9D,OAAO,MAAM,QAAQ,YAAY,KAAK,YAAY,OAAO,KAAK,CAAC,MAAM;EACzE;EACA,MAAM,uBAAuB,KAAa,YAAoB,OAAY;GACtE,OAAO,MAAM,QAAQ,cAAc,KAAK,YAAY,OAAO,KAAK,CAAC,MAAM;EAC3E;CACJ,CAAC;AACL"}
@@ -1,4 +1,3 @@
1
- //#region src/storages/redis/types.d.ts
2
1
  /**
3
2
  * A caller-owned asynchronous adapter for Redis-like binary operations.
4
3
  *
@@ -15,6 +14,11 @@ export interface RedisLikeAdapter {
15
14
  * Reads a key and resolves to its raw bytes, or `null` when the key is missing.
16
15
  */
17
16
  getBuffer: (key: string) => Promise<null | Uint8Array>;
17
+ /**
18
+ * Atomically reads and deletes a key, such as with Redis `GETDEL`,
19
+ * and resolves to its raw bytes, or `null` when the key is missing.
20
+ */
21
+ getBufferAndDelete: (key: string) => Promise<null | Uint8Array>;
18
22
  /**
19
23
  * Checks a key and resolves to whether it exists.
20
24
  */
@@ -31,6 +35,15 @@ export interface RedisLikeAdapter {
31
35
  * @param value - The raw bytes to store.
32
36
  */
33
37
  setBufferEx: (key: string, ttlSeconds: number, value: Uint8Array) => Promise<'OK' | void>;
38
+ /**
39
+ * Writes raw bytes with an expiry only when the key is missing, such as with Redis `SET key value EX ttl NX`,
40
+ * and resolves to the backend acknowledgment, or `null` or no value when the key already exists.
41
+ *
42
+ * @param key - The storage key.
43
+ * @param ttlSeconds - The expiry duration in seconds.
44
+ * @param value - The raw bytes to store.
45
+ */
46
+ setBufferExNx: (key: string, ttlSeconds: number, value: Uint8Array) => Promise<'OK' | null | void>;
34
47
  /**
35
48
  * Reads a key's remaining TTL in seconds, or `-1` for no expiry and `-2` for a missing key.
36
49
  */
@@ -44,6 +57,13 @@ export interface RedisLikeAdapter {
44
57
  * `-1` means no expiry, and `-2` means the key is missing. Connection cleanup remains caller-owned.
45
58
  */
46
59
  export interface RedisLikeStorage {
60
+ /**
61
+ * Atomically reads and removes a deserialized value and resolves to `null` when the key is missing.
62
+ * Concurrent callers on the same key receive the value at most once.
63
+ *
64
+ * @typeParam T - The expected value type; deserialization does not validate this type.
65
+ */
66
+ getAndRemoveItem: <T = unknown>(key: string) => Promise<null | T>;
47
67
  /**
48
68
  * Reads a deserialized value and resolves to `null` when the key is missing.
49
69
  *
@@ -74,6 +94,14 @@ export interface RedisLikeStorage {
74
94
  * @param value - The value to serialize and store.
75
95
  */
76
96
  setItemWithTtl: (key: string, ttlSeconds: number, value: any) => Promise<boolean>;
97
+ /**
98
+ * Atomically stores a value with an expiry only when the key is missing
99
+ * and resolves to whether the backend acknowledges the write.
100
+ *
101
+ * @param key - The storage key.
102
+ * @param ttlSeconds - The expiry duration in seconds.
103
+ * @param value - The value to serialize and store.
104
+ */
105
+ setItemWithTtlIfAbsent: (key: string, ttlSeconds: number, value: any) => Promise<boolean>;
77
106
  }
78
- //#endregion
79
107
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/storages/redis/types.ts"],"mappings":";;;;;;;;iBAOiB;;;;EAIb,SAAS,gBAAgB;;;;EAKzB,YAAY,gBAAgB,eAAe;;;;EAK3C,MAAM,gBAAgB;;;;EAKtB,YAAY,aAAa,OAAO,eAAe;;;;;;;;EAS/C,cAAc,aAAa,oBAAoB,OAAO,eAAe;;;;EAKrE,MAAM,gBAAgB;;;;;;;;;iBAUT;;;;;;EAMb,UAAU,aAAa,gBAAgB,eAAe;;;;EAKtD,aAAa,gBAAgB;;;;EAK7B,UAAU,gBAAgB;;;;EAK1B,aAAa,gBAAgB;;;;EAK7B,UAAU,aAAa,eAAe;;;;;;;;EAStC,iBAAiB,aAAa,oBAAoB,eAAe"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/storages/redis/types.ts"],"mappings":";;;;;;;iBAOiB;;;;EAIb,SAAS,gBAAgB;;;;EAKzB,YAAY,gBAAgB,eAAe;;;;;EAM3C,qBAAqB,gBAAgB,eAAe;;;;EAKpD,MAAM,gBAAgB;;;;EAKtB,YAAY,aAAa,OAAO,eAAe;;;;;;;;EAS/C,cAAc,aAAa,oBAAoB,OAAO,eAAe;;;;;;;;;EAUrE,gBAAgB,aAAa,oBAAoB,OAAO,eAAe;;;;EAKvE,MAAM,gBAAgB;;;;;;;;;iBAUT;;;;;;;EAOb,mBAAmB,aAAa,gBAAgB,eAAe;;;;;;EAO/D,UAAU,aAAa,gBAAgB,eAAe;;;;EAKtD,aAAa,gBAAgB;;;;EAK7B,UAAU,gBAAgB;;;;EAK1B,aAAa,gBAAgB;;;;EAK7B,UAAU,aAAa,eAAe;;;;;;;;EAStC,iBAAiB,aAAa,oBAAoB,eAAe;;;;;;;;;EAUjE,yBAAyB,aAAa,oBAAoB,eAAe"}
package/dist/string.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/string.d.ts
2
1
  /**
3
2
  * Character-set presets supported by `randomString`.
4
3
  */
@@ -28,5 +27,4 @@ export type RandomStringMode = 'alphabetic' | 'alphanumeric' | 'lowercase' | 'lo
28
27
  * ```
29
28
  */
30
29
  export declare function randomString(length: number, mode?: RandomStringMode): string;
31
- //#endregion
32
30
  //# sourceMappingURL=string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","names":[],"sources":["../src/string.ts"],"mappings":";;;;YAGY;;;;;;;;;;;;;;;;;;;;;;;;;wBA8CI,aAAa,gBAAgB,OAAM"}
1
+ {"version":3,"file":"string.d.ts","names":[],"sources":["../src/string.ts"],"mappings":";;;YAGY;;;;;;;;;;;;;;;;;;;;;;;;;wBA8CI,aAAa,gBAAgB,OAAM"}
package/dist/string.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/string.ts
1
+ // src/string.ts
2
2
  const DIGITS = "0123456789";
3
3
  const LOWERCASE = "abcdefghijklmnopqrstuvwxyz";
4
4
  const UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -41,7 +41,6 @@ function randomString(length, mode = "alphabetic") {
41
41
  if (!charset) throw new Error(`Unsupported mode: ${mode}`);
42
42
  return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join("");
43
43
  }
44
- //#endregion
45
44
  export { randomString };
46
45
 
47
46
  //# sourceMappingURL=string.js.map
package/dist/time.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/time.d.ts
2
1
  /**
3
2
  * Waits until a duration elapses or cancellation occurs without rejecting on cancellation.
4
3
  *
@@ -45,5 +44,4 @@ export declare function delay(ms: number, signal?: AbortSignal): Promise<void>;
45
44
  * ```
46
45
  */
47
46
  export declare function delayOrThrow(ms: number, signal?: AbortSignal): Promise<void>;
48
- //#endregion
49
47
  //# sourceMappingURL=time.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"time.d.ts","names":[],"sources":["../src/time.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;wBAoBgB,MAAM,YAAY,SAAS,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;wBA2CzC,aAAa,YAAY,SAAS,cAAc"}
1
+ {"version":3,"file":"time.d.ts","names":[],"sources":["../src/time.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;wBAoBgB,MAAM,YAAY,SAAS,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;wBA2CzC,aAAa,YAAY,SAAS,cAAc"}
package/dist/time.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/time.ts
1
+ // src/time.ts
2
2
  /**
3
3
  * Waits until a duration elapses or cancellation occurs without rejecting on cancellation.
4
4
  *
@@ -75,7 +75,6 @@ function delayOrThrow(ms, signal) {
75
75
  signal?.addEventListener("abort", onAbort, { once: true });
76
76
  });
77
77
  }
78
- //#endregion
79
78
  export { delay, delayOrThrow };
80
79
 
81
80
  //# sourceMappingURL=time.js.map
@@ -1,5 +1,4 @@
1
1
  import { ObjectId } from "bson";
2
- //#region src/types/filtered-key-path.d.ts
3
2
  type ConditionalPath<K extends number | string, V, U> = V extends U ? `${K}` : DefaultPath<K, V, U, never>;
4
3
  type DefaultPath<K extends number | string, V, U = never, RK = `${K}`> = V extends TerminalType ? RK : `${K}.${FilteredKeyPath<V, U>}`;
5
4
  /**
@@ -13,6 +12,5 @@ type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false
13
12
  type PathImpl<K extends number | string, V, U> = [U] extends [never] ? DefaultPath<K, V> : ConditionalPath<K, V, U>;
14
13
  type TerminalType = bigint | Blob | boolean | Date | File | null | number | ObjectId | RegExp | string | symbol | undefined;
15
14
  type TupleKey<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
16
- //#endregion
17
15
  export {};
18
16
  //# sourceMappingURL=filtered-key-path.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filtered-key-path.d.ts","names":[],"sources":["../../src/types/filtered-key-path.ts"],"mappings":";;KAKK,gBAAgB,2BAA2B,GAAG,KAAK,UAAU,OAAO,MAAM,YAAY,GAAG,GAAG;KAC5F,YACD,2BACA,GACA,WACA,QAAQ,OACR,UAAU,eAAe,QAAQ,KAAK,gBAAgB,GAAG;;;;;;;YAUjD,gBAAgB,GAAG,aAAa,UAAU,oBAAoB,MAAM,QAAQ,qBAAqB,KAAK,SAAS,OAAO,SAAS,QAAQ,YAAY,EAAE,IAAI,MAAK,SAAS,MAAM,iBAAiB,GAAG,SAAS,WAAW,MAAM,SAAS,QAAQ,YAAY,EAAE,IAAI,YAAW;KAGhR,QAAQ,UAAU,qCAAqC;KACvD,SAAS,2BAA2B,GAAG,MAAM,qBAAqB,YAAY,GAAG,KAAK,gBAAgB,GAAG,GAAG;KAC5G,wBAED,iBAEA,OACA,uBAGA,WACA;KAKC,SAAS,UAAU,sBAAsB,cAAc"}
1
+ {"version":3,"file":"filtered-key-path.d.ts","names":[],"sources":["../../src/types/filtered-key-path.ts"],"mappings":";KAKK,gBAAgB,2BAA2B,GAAG,KAAK,UAAU,OAAO,MAAM,YAAY,GAAG,GAAG;KAC5F,YACD,2BACA,GACA,WACA,QAAQ,OACR,UAAU,eAAe,QAAQ,KAAK,gBAAgB,GAAG;;;;;;;YAUjD,gBAAgB,GAAG,aAAa,UAAU,oBAAoB,MAAM,QAAQ,qBAAqB,KAAK,SAAS,OAAO,SAAS,QAAQ,YAAY,EAAE,IAAI,MAAK,SAAS,MAAM,iBAAiB,GAAG,SAAS,WAAW,MAAM,SAAS,QAAQ,YAAY,EAAE,IAAI,YAAW;KAGhR,QAAQ,UAAU,qCAAqC;KACvD,SAAS,2BAA2B,GAAG,MAAM,qBAAqB,YAAY,GAAG,KAAK,gBAAgB,GAAG,GAAG;KAC5G,wBAED,iBAEA,OACA,uBAGA,WACA;KAKC,SAAS,UAAU,sBAAsB,cAAc"}
@@ -1,10 +1,5 @@
1
1
  import { FilteredKeyPath } from "./filtered-key-path.js";
2
2
  import { Blob as Blob$1, Buffer, File as File$1 } from "node:buffer";
3
- //#region src/types/index.d.ts
4
- /**
5
- * A generic string-keyed object for utility APIs that intentionally accept any value shape.
6
- */
7
- export type AnyRecord = Record<string, any>;
8
3
  /**
9
4
  * Binary-like inputs accepted by `toBuffer` across browser and Node.js runtimes.
10
5
  */
@@ -21,10 +16,6 @@ export type MaybePartial<T> = Partial<T> | T;
21
16
  * Accepts either a mutable value or a readonly view of that value.
22
17
  */
23
18
  export type MaybeReadonly<T> = Readonly<T> | T;
24
- /**
25
- * Number-like value represented as a number or a numeric string.
26
- */
27
- export type Numberish = number | string;
28
19
  /**
29
20
  * A `Record` where every key is optional.
30
21
  */
@@ -37,6 +28,5 @@ export type ReadonlyPartialRecord<K extends keyof any, T> = Readonly<PartialReco
37
28
  * A readonly `Record`.
38
29
  */
39
30
  export type ReadonlyRecord<K extends keyof any, T> = Readonly<Record<K, T>>;
40
- //#endregion
41
31
  export type { FilteredKeyPath };
42
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["NodeBlob","NodeFile"],"sources":["../../src/types/index.ts"],"mappings":";;;;;;YAWY,YAAY;;;;YAKZ,cAAc,cAAc,OAAO,SAAS,OAAOA,SAAWC,SAAW;;;;YAKzE;;;;YAKA,aAAa,KAAK,QAAQ,KAAK;;;;YAK/B,cAAc,KAAK,SAAS,KAAK;;;;YAKjC;;;;YAKA,cAAc,qBAAqB,KAAK,QAAQ,OAAO,GAAG;;;;YAK1D,sBAAsB,qBAAqB,KAAK,SAAS,cAAc,GAAG;;;;YAK1E,eAAe,qBAAqB,KAAK,SAAS,OAAO,GAAG"}
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"}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"vue.d.ts","names":[],"sources":["../../src/types/vue.ts"],"mappings":";;;;;;;;;;;;;;;;YAgBY,aAAa,gBAAgB,oBAAoB,aAAa,iBAAiB"}
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":";;;;;;;;;;;;;;wBAagB,yBAAyB,aAAa;;;;;;;;;;;;;wBAwBtC,mBAAmB,iBAAiB;;;;;;;;;;;;;wBAoBpC,sBAAsB,gBAAgB"}
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
- //#region src/url.ts
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":";;;;;;;;;wBAgBgB,yCAAyC;;;;;;wBASzC,iBAAiB,aAAa,WAAW,kBAAkB;;;;;;wBAU3D,gBAAgB,YAAY,WAAW,kBAAkB;;;;;;;;;;;;;;wBAkBzD,kBAAkB,UAAU,UAAU,aAAa,cAAc,WAAW"}
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
- //#region src/vue.ts
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":";;;;;;;;wBASgB,4CAA4C;;;;;;;;;;;;;;;wBAmB5C,8CAA8C,aAAa,mBAAgB,OAAA"}
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
- //#region src/web.ts
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": "18.3.0",
4
+ "version": "20.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.3.0",
71
- "@types/ssh2": "^1.15.5",
118
+ "@noble/hashes": "^2.4.0",
72
119
  "async-validator": "^4.2.5",
73
- "bson": "^7.3.2",
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.4",
78
- "file-type": "^22.1.1",
79
- "lru-cache": "^11.5.2",
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.5",
82
- "node-ssh": "^13.2.1",
83
- "pino": "^10.3.1",
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
- "node-ssh": {
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": "^9.5.1",
143
- "@kikiutils/eslint-config": "^9.3.0",
174
+ "@antfu/eslint-config": "^10.0.0",
175
+ "@kikiutils/eslint-config": "^9.3.2",
144
176
  "@kikiutils/tsconfigs": "^7.0.0",
145
177
  "@noble/hashes": "^2.4.0",
146
178
  "@types/node": "^26.6.5",
147
- "@types/ssh2": "^1.15.6",
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.12.0",
158
- "file-type": "^22.1.1",
159
- "jsdom": "^30.1.2",
160
- "knip": "^6.41.0",
187
+ "eslint": "^10.13.0",
188
+ "file-type": "^22.2.0",
189
+ "jsdom": "^30.1.3",
190
+ "knip": "^6.43.0",
161
191
  "lru-cache": "^11.5.3",
162
192
  "millify": "^6.1.0",
163
- "msgpackr": "^2.1.0",
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
- "tsdown": "^0.23.1",
195
+ "rotating-file-stream": "^3.2.10",
196
+ "tsdown": "^0.23.3",
169
197
  "typescript": "^6.0.3",
170
198
  "unplugin-unused": "^0.6.0",
171
- "vitest": "^5.0.4",
172
- "vue": "^3.5.43",
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
+ }