@kikiutils/shared 12.0.0 → 13.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 (210) hide show
  1. package/README.md +1 -1
  2. package/dist/buffer.d.ts +7 -3
  3. package/dist/buffer.d.ts.map +1 -1
  4. package/dist/buffer.js +42 -0
  5. package/dist/buffer.js.map +1 -0
  6. package/dist/clipboard.d.ts +8 -6
  7. package/dist/clipboard.d.ts.map +1 -1
  8. package/dist/clipboard.js +86 -0
  9. package/dist/clipboard.js.map +1 -0
  10. package/dist/consola.d.ts +8 -2
  11. package/dist/consola.d.ts.map +1 -1
  12. package/dist/consola.js +32 -0
  13. package/dist/consola.js.map +1 -0
  14. package/dist/crypto-hash.d.ts +16 -26
  15. package/dist/crypto-hash.d.ts.map +1 -1
  16. package/dist/crypto-hash.js +37 -0
  17. package/dist/crypto-hash.js.map +1 -0
  18. package/dist/datetime.d.ts +13 -9
  19. package/dist/datetime.d.ts.map +1 -1
  20. package/dist/datetime.js +131 -0
  21. package/dist/datetime.js.map +1 -0
  22. package/dist/element-plus.d.ts +8 -4
  23. package/dist/element-plus.d.ts.map +1 -1
  24. package/dist/element-plus.js +37 -0
  25. package/dist/element-plus.js.map +1 -0
  26. package/dist/enum.d.ts +6 -3
  27. package/dist/enum.d.ts.map +1 -1
  28. package/dist/enum.js +108 -0
  29. package/dist/enum.js.map +1 -0
  30. package/dist/env.d.ts +12 -9
  31. package/dist/env.d.ts.map +1 -1
  32. package/dist/env.js +51 -0
  33. package/dist/env.js.map +1 -0
  34. package/dist/general.d.ts +5 -2
  35. package/dist/general.d.ts.map +1 -1
  36. package/dist/general.js +8 -0
  37. package/dist/general.js.map +1 -0
  38. package/dist/hash.d.ts +7 -4
  39. package/dist/hash.d.ts.map +1 -1
  40. package/dist/hash.js +20 -0
  41. package/dist/hash.js.map +1 -0
  42. package/dist/math.d.ts +20 -17
  43. package/dist/math.d.ts.map +1 -1
  44. package/dist/math.js +36 -0
  45. package/dist/math.js.map +1 -0
  46. package/dist/number.d.ts +7 -2
  47. package/dist/number.d.ts.map +1 -1
  48. package/dist/number.js +32 -0
  49. package/dist/number.js.map +1 -0
  50. package/dist/object.d.ts +4 -1
  51. package/dist/object.d.ts.map +1 -1
  52. package/dist/object.js +42 -0
  53. package/dist/object.js.map +1 -0
  54. package/dist/pino.d.ts +8 -2
  55. package/dist/pino.d.ts.map +1 -1
  56. package/dist/pino.js +40 -0
  57. package/dist/pino.js.map +1 -0
  58. package/dist/random.d.ts +4 -1
  59. package/dist/random.d.ts.map +1 -1
  60. package/dist/random.js +31 -0
  61. package/dist/random.js.map +1 -0
  62. package/dist/storage/enhanced/local/core.d.ts +45 -42
  63. package/dist/storage/enhanced/local/core.d.ts.map +1 -1
  64. package/dist/storage/enhanced/local/core.js +63 -0
  65. package/dist/storage/enhanced/local/core.js.map +1 -0
  66. package/dist/storage/enhanced/local/index.d.ts +3 -3
  67. package/dist/storage/enhanced/local/index.js +4 -0
  68. package/dist/storage/enhanced/local/keyed-store.d.ts +14 -11
  69. package/dist/storage/enhanced/local/keyed-store.d.ts.map +1 -1
  70. package/dist/storage/enhanced/local/keyed-store.js +36 -0
  71. package/dist/storage/enhanced/local/keyed-store.js.map +1 -0
  72. package/dist/storage/enhanced/redis/core.d.ts +64 -59
  73. package/dist/storage/enhanced/redis/core.d.ts.map +1 -1
  74. package/dist/storage/enhanced/redis/core.js +85 -0
  75. package/dist/storage/enhanced/redis/core.js.map +1 -0
  76. package/dist/storage/enhanced/redis/index.d.ts +3 -3
  77. package/dist/storage/enhanced/redis/index.js +4 -0
  78. package/dist/storage/enhanced/redis/keyed-store.d.ts +19 -14
  79. package/dist/storage/enhanced/redis/keyed-store.d.ts.map +1 -1
  80. package/dist/storage/enhanced/redis/keyed-store.js +41 -0
  81. package/dist/storage/enhanced/redis/keyed-store.js.map +1 -0
  82. package/dist/storage/lru/keyed-store.d.ts +21 -16
  83. package/dist/storage/lru/keyed-store.d.ts.map +1 -1
  84. package/dist/storage/lru/keyed-store.js +40 -0
  85. package/dist/storage/lru/keyed-store.js.map +1 -0
  86. package/dist/string.d.ts +5 -2
  87. package/dist/string.d.ts.map +1 -1
  88. package/dist/string.js +42 -0
  89. package/dist/string.js.map +1 -0
  90. package/dist/url.d.ts +4 -1
  91. package/dist/url.d.ts.map +1 -1
  92. package/dist/url.js +21 -0
  93. package/dist/url.js.map +1 -0
  94. package/dist/vue.d.ts +10 -5
  95. package/dist/vue.d.ts.map +1 -1
  96. package/dist/vue.js +58 -0
  97. package/dist/vue.js.map +1 -0
  98. package/dist/web.d.ts +5 -2
  99. package/dist/web.d.ts.map +1 -1
  100. package/dist/web.js +32 -0
  101. package/dist/web.js.map +1 -0
  102. package/package.json +42 -26
  103. package/src/vue.ts +1 -1
  104. package/src/web.ts +1 -1
  105. package/dist/buffer.cjs +0 -43
  106. package/dist/buffer.cjs.map +0 -1
  107. package/dist/buffer.mjs +0 -41
  108. package/dist/buffer.mjs.map +0 -1
  109. package/dist/clipboard.cjs +0 -91
  110. package/dist/clipboard.cjs.map +0 -1
  111. package/dist/clipboard.mjs +0 -88
  112. package/dist/clipboard.mjs.map +0 -1
  113. package/dist/consola.cjs +0 -35
  114. package/dist/consola.cjs.map +0 -1
  115. package/dist/consola.mjs +0 -32
  116. package/dist/consola.mjs.map +0 -1
  117. package/dist/crypto-hash.cjs +0 -61
  118. package/dist/crypto-hash.cjs.map +0 -1
  119. package/dist/crypto-hash.mjs +0 -50
  120. package/dist/crypto-hash.mjs.map +0 -1
  121. package/dist/datetime.cjs +0 -134
  122. package/dist/datetime.cjs.map +0 -1
  123. package/dist/datetime.mjs +0 -130
  124. package/dist/datetime.mjs.map +0 -1
  125. package/dist/element-plus.cjs +0 -37
  126. package/dist/element-plus.cjs.map +0 -1
  127. package/dist/element-plus.mjs +0 -35
  128. package/dist/element-plus.mjs.map +0 -1
  129. package/dist/enum.cjs +0 -112
  130. package/dist/enum.cjs.map +0 -1
  131. package/dist/enum.mjs +0 -108
  132. package/dist/enum.mjs.map +0 -1
  133. package/dist/env.cjs +0 -53
  134. package/dist/env.cjs.map +0 -1
  135. package/dist/env.mjs +0 -50
  136. package/dist/env.mjs.map +0 -1
  137. package/dist/general.cjs +0 -10
  138. package/dist/general.cjs.map +0 -1
  139. package/dist/general.mjs +0 -8
  140. package/dist/general.mjs.map +0 -1
  141. package/dist/hash.cjs +0 -36
  142. package/dist/hash.cjs.map +0 -1
  143. package/dist/hash.mjs +0 -31
  144. package/dist/hash.mjs.map +0 -1
  145. package/dist/math.cjs +0 -38
  146. package/dist/math.cjs.map +0 -1
  147. package/dist/math.mjs +0 -36
  148. package/dist/math.mjs.map +0 -1
  149. package/dist/number.cjs +0 -32
  150. package/dist/number.cjs.map +0 -1
  151. package/dist/number.mjs +0 -30
  152. package/dist/number.mjs.map +0 -1
  153. package/dist/object.cjs +0 -55
  154. package/dist/object.cjs.map +0 -1
  155. package/dist/object.mjs +0 -53
  156. package/dist/object.mjs.map +0 -1
  157. package/dist/pino.cjs +0 -42
  158. package/dist/pino.cjs.map +0 -1
  159. package/dist/pino.mjs +0 -39
  160. package/dist/pino.mjs.map +0 -1
  161. package/dist/random.cjs +0 -31
  162. package/dist/random.cjs.map +0 -1
  163. package/dist/random.mjs +0 -29
  164. package/dist/random.mjs.map +0 -1
  165. package/dist/storage/enhanced/local/core.cjs +0 -105
  166. package/dist/storage/enhanced/local/core.cjs.map +0 -1
  167. package/dist/storage/enhanced/local/core.mjs +0 -103
  168. package/dist/storage/enhanced/local/core.mjs.map +0 -1
  169. package/dist/storage/enhanced/local/index.cjs +0 -10
  170. package/dist/storage/enhanced/local/index.cjs.map +0 -1
  171. package/dist/storage/enhanced/local/index.d.ts.map +0 -1
  172. package/dist/storage/enhanced/local/index.mjs +0 -3
  173. package/dist/storage/enhanced/local/index.mjs.map +0 -1
  174. package/dist/storage/enhanced/local/keyed-store.cjs +0 -41
  175. package/dist/storage/enhanced/local/keyed-store.cjs.map +0 -1
  176. package/dist/storage/enhanced/local/keyed-store.mjs +0 -39
  177. package/dist/storage/enhanced/local/keyed-store.mjs.map +0 -1
  178. package/dist/storage/enhanced/redis/core.cjs +0 -144
  179. package/dist/storage/enhanced/redis/core.cjs.map +0 -1
  180. package/dist/storage/enhanced/redis/core.mjs +0 -142
  181. package/dist/storage/enhanced/redis/core.mjs.map +0 -1
  182. package/dist/storage/enhanced/redis/index.cjs +0 -10
  183. package/dist/storage/enhanced/redis/index.cjs.map +0 -1
  184. package/dist/storage/enhanced/redis/index.d.ts.map +0 -1
  185. package/dist/storage/enhanced/redis/index.mjs +0 -3
  186. package/dist/storage/enhanced/redis/index.mjs.map +0 -1
  187. package/dist/storage/enhanced/redis/keyed-store.cjs +0 -46
  188. package/dist/storage/enhanced/redis/keyed-store.cjs.map +0 -1
  189. package/dist/storage/enhanced/redis/keyed-store.mjs +0 -44
  190. package/dist/storage/enhanced/redis/keyed-store.mjs.map +0 -1
  191. package/dist/storage/lru/keyed-store.cjs +0 -49
  192. package/dist/storage/lru/keyed-store.cjs.map +0 -1
  193. package/dist/storage/lru/keyed-store.mjs +0 -47
  194. package/dist/storage/lru/keyed-store.mjs.map +0 -1
  195. package/dist/string.cjs +0 -45
  196. package/dist/string.cjs.map +0 -1
  197. package/dist/string.mjs +0 -43
  198. package/dist/string.mjs.map +0 -1
  199. package/dist/url.cjs +0 -21
  200. package/dist/url.cjs.map +0 -1
  201. package/dist/url.mjs +0 -19
  202. package/dist/url.mjs.map +0 -1
  203. package/dist/vue.cjs +0 -64
  204. package/dist/vue.cjs.map +0 -1
  205. package/dist/vue.mjs +0 -59
  206. package/dist/vue.mjs.map +0 -1
  207. package/dist/web.cjs +0 -35
  208. package/dist/web.cjs.map +0 -1
  209. package/dist/web.mjs +0 -32
  210. package/dist/web.mjs.map +0 -1
@@ -1,142 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import { Redis } from 'ioredis';
3
- import { serialize, deserialize } from 'superjson';
4
-
5
- var StorageValueEncodingType;
6
- (function (StorageValueEncodingType) {
7
- StorageValueEncodingType[StorageValueEncodingType["Buffer"] = 0] = "Buffer";
8
- StorageValueEncodingType[StorageValueEncodingType["Json"] = 1] = "Json";
9
- StorageValueEncodingType[StorageValueEncodingType["String"] = 2] = "String";
10
- })(StorageValueEncodingType || (StorageValueEncodingType = {}));
11
- const customValueHeader = Buffer.of(0xE2, 0x81, 0xA0);
12
- const customValueHeaderLength = customValueHeader.byteLength + 1;
13
- /**
14
- * Creates an enhanced Redis-based storage interface using SuperJSON encoding.
15
- *
16
- * This utility provides a typed, serializable key-value store backed by Redis,
17
- * supporting TTL operations and safe deserialization of complex types (e.g. Date, Map).
18
- *
19
- * @param {Redis | string} ioRedisInstanceOrUrl - Either an existing `ioredis` instance or a Redis connection string
20
- *
21
- * @returns A frozen object that wraps Redis commands with typed get/set logic and encoding
22
- *
23
- * @example
24
- * ```typescript
25
- * import { createEnhancedRedisStorage } from '@kikiutils/shared/storage/enhanced/redis';
26
- *
27
- * const redisStorage = createEnhancedRedisStorage('redis://localhost');
28
- * await redisStorage.setItem('user:1', { name: 'user' });
29
- * const user = await redisStorage.getItem<{ name: string }>('user:1');
30
- * ```
31
- */
32
- function createEnhancedRedisStorage(ioRedisInstanceOrUrl) {
33
- const instance = ioRedisInstanceOrUrl instanceof Redis ? ioRedisInstanceOrUrl : new Redis(ioRedisInstanceOrUrl);
34
- return Object.freeze({
35
- /**
36
- * Retrieves a value from Redis and decodes it.
37
- *
38
- * @template T - The expected return type
39
- *
40
- * @param {string} key - The Redis key
41
- *
42
- * @returns {Promise<null | T>} The decoded value or null if not found
43
- */
44
- async getItem(key) {
45
- const rawValue = await instance.getBuffer(key);
46
- return rawValue ? decodeStorageValue(rawValue) : null;
47
- },
48
- /**
49
- * Gets the remaining TTL (in seconds) for a given key.
50
- *
51
- * @param {string} key - The Redis key
52
- *
53
- * @returns {Promise<number>} The number of seconds until the key expires, or -1 if no expiration is set
54
- */
55
- getItemTtl: (key) => instance.ttl(key),
56
- /**
57
- * Checks whether a key exists in Redis.
58
- *
59
- * @param {string} key - The Redis key
60
- *
61
- * @returns {Promise<boolean>} True if the key exists, false otherwise
62
- */
63
- hasItem: async (key) => await instance.exists(key) === 1,
64
- /**
65
- * The underlying Redis instance, exposed for advanced operations.
66
- * Use with caution; most use cases should rely on the wrapper methods.
67
- *
68
- * @returns {Redis} The underlying Redis instance
69
- */
70
- get instance() {
71
- return instance;
72
- },
73
- /**
74
- * Removes a key from Redis.
75
- *
76
- * @param {string} key - The Redis key to delete
77
- *
78
- * @returns {Promise<boolean>} A Promise that resolves to `true` if the key was removed,
79
- * or `false` if it did not exist.
80
- */
81
- removeItem: async (key) => await instance.del(key) === 1,
82
- /**
83
- * Stores a value in Redis without expiration.
84
- *
85
- * @param {string} key - The Redis key
86
- * @param {any} value - The value to store. Will be serialized
87
- */
88
- setItem: (key, value) => instance.set(key, encodeToStorageValue(value)),
89
- /**
90
- * Stores a value in Redis with a time-to-live (TTL).
91
- *
92
- * @param {string} key - The Redis key
93
- * @param {number} seconds - Expiration time in seconds
94
- * @param {any} value - The value to store. Will be serialized
95
- */
96
- setItemWithTtl(key, seconds, value) {
97
- return instance.setex(key, seconds, encodeToStorageValue(value));
98
- },
99
- });
100
- }
101
- function decodeStorageValue(data) {
102
- if (!isCustomFormat(data))
103
- return data;
104
- const payload = data.subarray(customValueHeaderLength);
105
- const type = data[customValueHeader.byteLength];
106
- switch (type) {
107
- case StorageValueEncodingType.Buffer: return payload;
108
- case StorageValueEncodingType.Json:
109
- try {
110
- return deserialize(JSON.parse(payload.toString()));
111
- }
112
- catch {
113
- throw new Error('[RedisStorage] Failed to parse JSON payload');
114
- }
115
- case StorageValueEncodingType.String: return payload.toString();
116
- default:
117
- throw new Error(`[RedisStorage] Unknown encoding type: ${type}`);
118
- }
119
- }
120
- function encodeToStorageValue(value) {
121
- if (Buffer.isBuffer(value))
122
- return toCustomValue(StorageValueEncodingType.Buffer, value);
123
- if (typeof value === 'string')
124
- return toCustomValue(StorageValueEncodingType.String, Buffer.from(value));
125
- return toCustomValue(StorageValueEncodingType.Json, Buffer.from(JSON.stringify(serialize(value))));
126
- }
127
- function isCustomFormat(buffer) {
128
- return (buffer.length >= customValueHeaderLength
129
- && buffer[0] === customValueHeader[0]
130
- && buffer[1] === customValueHeader[1]
131
- && buffer[2] === customValueHeader[2]);
132
- }
133
- function toCustomValue(type, payload) {
134
- return Buffer.concat([
135
- customValueHeader,
136
- Buffer.of(type),
137
- payload,
138
- ]);
139
- }
140
-
141
- export { createEnhancedRedisStorage };
142
- //# sourceMappingURL=core.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.mjs","sources":["../../../../src/storage/enhanced/redis/core.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\nimport { Redis } from 'ioredis';\nimport {\n deserialize,\n serialize,\n} from 'superjson';\n\nenum StorageValueEncodingType {\n Buffer = 0,\n Json = 1,\n String = 2,\n}\n\nconst customValueHeader = Buffer.of(\n 0xE2,\n 0x81,\n 0xA0,\n);\n\nconst customValueHeaderLength = customValueHeader.byteLength + 1;\n\n/**\n * Creates an enhanced Redis-based storage interface using SuperJSON encoding.\n *\n * This utility provides a typed, serializable key-value store backed by Redis,\n * supporting TTL operations and safe deserialization of complex types (e.g. Date, Map).\n *\n * @param {Redis | string} ioRedisInstanceOrUrl - Either an existing `ioredis` instance or a Redis connection string\n *\n * @returns A frozen object that wraps Redis commands with typed get/set logic and encoding\n *\n * @example\n * ```typescript\n * import { createEnhancedRedisStorage } from '@kikiutils/shared/storage/enhanced/redis';\n *\n * const redisStorage = createEnhancedRedisStorage('redis://localhost');\n * await redisStorage.setItem('user:1', { name: 'user' });\n * const user = await redisStorage.getItem<{ name: string }>('user:1');\n * ```\n */\nexport function createEnhancedRedisStorage(ioRedisInstanceOrUrl: Redis | string) {\n const instance = ioRedisInstanceOrUrl instanceof Redis ? ioRedisInstanceOrUrl : new Redis(ioRedisInstanceOrUrl);\n return Object.freeze({\n /**\n * Retrieves a value from Redis and decodes it.\n *\n * @template T - The expected return type\n *\n * @param {string} key - The Redis key\n *\n * @returns {Promise<null | T>} The decoded value or null if not found\n */\n async getItem<T = unknown>(key: string) {\n const rawValue = await instance.getBuffer(key);\n return rawValue ? decodeStorageValue(rawValue) as T : null;\n },\n /**\n * Gets the remaining TTL (in seconds) for a given key.\n *\n * @param {string} key - The Redis key\n *\n * @returns {Promise<number>} The number of seconds until the key expires, or -1 if no expiration is set\n */\n getItemTtl: (key: string) => instance.ttl(key),\n /**\n * Checks whether a key exists in Redis.\n *\n * @param {string} key - The Redis key\n *\n * @returns {Promise<boolean>} True if the key exists, false otherwise\n */\n hasItem: async (key: string) => await instance.exists(key) === 1,\n /**\n * The underlying Redis instance, exposed for advanced operations.\n * Use with caution; most use cases should rely on the wrapper methods.\n *\n * @returns {Redis} The underlying Redis instance\n */\n get instance() {\n return instance;\n },\n /**\n * Removes a key from Redis.\n *\n * @param {string} key - The Redis key to delete\n *\n * @returns {Promise<boolean>} A Promise that resolves to `true` if the key was removed,\n * or `false` if it did not exist.\n */\n removeItem: async (key: string) => await instance.del(key) === 1,\n /**\n * Stores a value in Redis without expiration.\n *\n * @param {string} key - The Redis key\n * @param {any} value - The value to store. Will be serialized\n */\n setItem: (key: string, value: any) => instance.set(key, encodeToStorageValue(value)),\n /**\n * Stores a value in Redis with a time-to-live (TTL).\n *\n * @param {string} key - The Redis key\n * @param {number} seconds - Expiration time in seconds\n * @param {any} value - The value to store. Will be serialized\n */\n setItemWithTtl(key: string, seconds: number, value: any) {\n return instance.setex(key, seconds, encodeToStorageValue(value));\n },\n });\n}\n\nfunction decodeStorageValue(data: Buffer) {\n if (!isCustomFormat(data)) return data;\n const payload = data.subarray(customValueHeaderLength);\n const type = data[customValueHeader.byteLength];\n switch (type) {\n case StorageValueEncodingType.Buffer: return payload;\n case StorageValueEncodingType.Json:\n try {\n return deserialize(JSON.parse(payload.toString()));\n } catch {\n throw new Error('[RedisStorage] Failed to parse JSON payload');\n }\n case StorageValueEncodingType.String: return payload.toString();\n default:\n throw new Error(`[RedisStorage] Unknown encoding type: ${type}`);\n }\n}\n\nfunction encodeToStorageValue(value: any) {\n if (Buffer.isBuffer(value)) return toCustomValue(StorageValueEncodingType.Buffer, value);\n if (typeof value === 'string') return toCustomValue(StorageValueEncodingType.String, Buffer.from(value));\n return toCustomValue(StorageValueEncodingType.Json, Buffer.from(JSON.stringify(serialize(value))));\n}\n\nfunction isCustomFormat(buffer: Buffer) {\n return (\n buffer.length >= customValueHeaderLength\n && buffer[0] === customValueHeader[0]\n && buffer[1] === customValueHeader[1]\n && buffer[2] === customValueHeader[2]\n );\n}\n\nfunction toCustomValue(type: StorageValueEncodingType, payload: Buffer) {\n return Buffer.concat([\n customValueHeader,\n Buffer.of(type),\n payload,\n ]);\n}\n"],"names":[],"mappings":";;;;AAQA,IAAK,wBAIJ;AAJD,CAAA,UAAK,wBAAwB,EAAA;AACzB,IAAA,wBAAA,CAAA,wBAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAU;AACV,IAAA,wBAAA,CAAA,wBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,wBAAA,CAAA,wBAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAU;AACd,CAAC,EAJI,wBAAwB,KAAxB,wBAAwB,GAAA,EAAA,CAAA,CAAA;AAM7B,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAC/B,IAAI,EACJ,IAAI,EACJ,IAAI,CACP;AAED,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,UAAU,GAAG,CAAC;AAEhE;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,0BAA0B,CAAC,oBAAoC,EAAA;AAC3E,IAAA,MAAM,QAAQ,GAAG,oBAAoB,YAAY,KAAK,GAAG,oBAAoB,GAAG,IAAI,KAAK,CAAC,oBAAoB,CAAC;IAC/G,OAAO,MAAM,CAAC,MAAM,CAAC;AACjB;;;;;;;;AAQG;QACH,MAAM,OAAO,CAAc,GAAW,EAAA;YAClC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC;AAC9C,YAAA,OAAO,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAM,GAAG,IAAI;QAC9D,CAAC;AACD;;;;;;AAMG;QACH,UAAU,EAAE,CAAC,GAAW,KAAK,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;AAC9C;;;;;;AAMG;AACH,QAAA,OAAO,EAAE,OAAO,GAAW,KAAK,MAAM,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;AAChE;;;;;AAKG;AACH,QAAA,IAAI,QAAQ,GAAA;AACR,YAAA,OAAO,QAAQ;QACnB,CAAC;AACD;;;;;;;AAOG;AACH,QAAA,UAAU,EAAE,OAAO,GAAW,KAAK,MAAM,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC;AAChE;;;;;AAKG;AACH,QAAA,OAAO,EAAE,CAAC,GAAW,EAAE,KAAU,KAAK,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACpF;;;;;;AAMG;AACH,QAAA,cAAc,CAAC,GAAW,EAAE,OAAe,EAAE,KAAU,EAAA;AACnD,YAAA,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACpE,CAAC;AACJ,KAAA,CAAC;AACN;AAEA,SAAS,kBAAkB,CAAC,IAAY,EAAA;AACpC,IAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC;IAC/C,QAAQ,IAAI;AACR,QAAA,KAAK,wBAAwB,CAAC,MAAM,EAAE,OAAO,OAAO;QACpD,KAAK,wBAAwB,CAAC,IAAI;AAC9B,YAAA,IAAI;AACA,gBAAA,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YACtD;AAAE,YAAA,MAAM;AACJ,gBAAA,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC;YAClE;QACJ,KAAK,wBAAwB,CAAC,MAAM,EAAE,OAAO,OAAO,CAAC,QAAQ,EAAE;AAC/D,QAAA;AACI,YAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,CAAA,CAAE,CAAC;;AAE5E;AAEA,SAAS,oBAAoB,CAAC,KAAU,EAAA;AACpC,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,aAAa,CAAC,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC;IACxF,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,aAAa,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxG,OAAO,aAAa,CAAC,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtG;AAEA,SAAS,cAAc,CAAC,MAAc,EAAA;AAClC,IAAA,QACI,MAAM,CAAC,MAAM,IAAI;AACd,WAAA,MAAM,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC;AACjC,WAAA,MAAM,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC;WACjC,MAAM,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC;AAE7C;AAEA,SAAS,aAAa,CAAC,IAA8B,EAAE,OAAe,EAAA;IAClE,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,iBAAiB;AACjB,QAAA,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QACf,OAAO;AACV,KAAA,CAAC;AACN;;;;"}
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- const core = require('./core.cjs');
4
- const keyedStore = require('./keyed-store.cjs');
5
-
6
-
7
-
8
- exports.createEnhancedRedisStorage = core.createEnhancedRedisStorage;
9
- exports.createKeyedEnhancedRedisStore = keyedStore.createKeyedEnhancedRedisStore;
10
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/enhanced/redis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC"}
@@ -1,3 +0,0 @@
1
- export { createEnhancedRedisStorage } from './core.mjs';
2
- export { createKeyedEnhancedRedisStore } from './keyed-store.mjs';
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Creates a reusable, type-safe Redis-backed storage interface based on `createEnhancedRedisStorage`
5
- * and a dynamic key-generation function.
6
- *
7
- * This utility abstracts away key construction and provides high-level access
8
- * to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.
9
- * It is ideal for namespaced data, caching, and session handling.
10
- *
11
- * @template D - The value type to store
12
- *
13
- * @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance
14
- *
15
- * @returns A factory that accepts a key generator function and returns a scoped Redis storage interface
16
- *
17
- * @example
18
- * ```typescript
19
- * import { createKeyedEnhancedRedisStore } from '@kikiutils/shared/storage/enhanced/redis';
20
- *
21
- * const userStore = createKeyedEnhancedRedisStore<User>(redisStorage)((id: number) => `user:${id}`);
22
- * await userStore.setItem({ id: 123, name: 'user' }, 123);
23
- * const user = await userStore.getItem(123);
24
- * ```
25
- */
26
- function createKeyedEnhancedRedisStore(storage) {
27
- return (getKeyFunction) => Object.freeze({
28
- getItem: (...args) => storage.getItem(getKeyFunction(...args)),
29
- getItemTtl: (...args) => storage.getItemTtl(getKeyFunction(...args)),
30
- hasItem: (...args) => storage.hasItem(getKeyFunction(...args)),
31
- removeItem: (...args) => storage.removeItem(getKeyFunction(...args)),
32
- /**
33
- * Resolves the storage key from the given arguments.
34
- *
35
- * @returns {string} The final string key used internally
36
- */
37
- resolveKey: (...args) => getKeyFunction(...args),
38
- setItem: (value, ...args) => storage.setItem(getKeyFunction(...args), value),
39
- setItemWithTtl(seconds, value, ...args) {
40
- return storage.setItemWithTtl(getKeyFunction(...args), seconds, value);
41
- },
42
- });
43
- }
44
-
45
- exports.createKeyedEnhancedRedisStore = createKeyedEnhancedRedisStore;
46
- //# sourceMappingURL=keyed-store.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyed-store.cjs","sources":["../../../../src/storage/enhanced/redis/keyed-store.ts"],"sourcesContent":["import type { createEnhancedRedisStorage } from './core';\n\n/**\n * Creates a reusable, type-safe Redis-backed storage interface based on `createEnhancedRedisStorage`\n * and a dynamic key-generation function.\n *\n * This utility abstracts away key construction and provides high-level access\n * to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.\n * It is ideal for namespaced data, caching, and session handling.\n *\n * @template D - The value type to store\n *\n * @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance\n *\n * @returns A factory that accepts a key generator function and returns a scoped Redis storage interface\n *\n * @example\n * ```typescript\n * import { createKeyedEnhancedRedisStore } from '@kikiutils/shared/storage/enhanced/redis';\n *\n * const userStore = createKeyedEnhancedRedisStore<User>(redisStorage)((id: number) => `user:${id}`);\n * await userStore.setItem({ id: 123, name: 'user' }, 123);\n * const user = await userStore.getItem(123);\n * ```\n */\nexport function createKeyedEnhancedRedisStore<D = unknown>(storage: ReturnType<typeof createEnhancedRedisStorage>) {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n getItem: (...args: P) => storage.getItem<D>(getKeyFunction(...args)),\n getItemTtl: (...args: P) => storage.getItemTtl(getKeyFunction(...args)),\n hasItem: (...args: P) => storage.hasItem(getKeyFunction(...args)),\n removeItem: (...args: P) => storage.removeItem(getKeyFunction(...args)),\n /**\n * Resolves the storage key from the given arguments.\n *\n * @returns {string} The final string key used internally\n */\n resolveKey: (...args: P) => getKeyFunction(...args),\n setItem: (value: D, ...args: P) => storage.setItem(getKeyFunction(...args), value),\n setItemWithTtl(seconds: number, value: D, ...args: P) {\n return storage.setItemWithTtl(getKeyFunction(...args), seconds, value);\n },\n });\n}\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,6BAA6B,CAAc,OAAsD,EAAA;IAC7G,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAI,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACpE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE;;;;AAIG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;QACnD,OAAO,EAAE,CAAC,KAAQ,EAAE,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;AAClF,QAAA,cAAc,CAAC,OAAe,EAAE,KAAQ,EAAE,GAAG,IAAO,EAAA;AAChD,YAAA,OAAO,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC;QAC1E,CAAC;AACJ,KAAA,CAAC;AACN;;;;"}
@@ -1,44 +0,0 @@
1
- /**
2
- * Creates a reusable, type-safe Redis-backed storage interface based on `createEnhancedRedisStorage`
3
- * and a dynamic key-generation function.
4
- *
5
- * This utility abstracts away key construction and provides high-level access
6
- * to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.
7
- * It is ideal for namespaced data, caching, and session handling.
8
- *
9
- * @template D - The value type to store
10
- *
11
- * @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance
12
- *
13
- * @returns A factory that accepts a key generator function and returns a scoped Redis storage interface
14
- *
15
- * @example
16
- * ```typescript
17
- * import { createKeyedEnhancedRedisStore } from '@kikiutils/shared/storage/enhanced/redis';
18
- *
19
- * const userStore = createKeyedEnhancedRedisStore<User>(redisStorage)((id: number) => `user:${id}`);
20
- * await userStore.setItem({ id: 123, name: 'user' }, 123);
21
- * const user = await userStore.getItem(123);
22
- * ```
23
- */
24
- function createKeyedEnhancedRedisStore(storage) {
25
- return (getKeyFunction) => Object.freeze({
26
- getItem: (...args) => storage.getItem(getKeyFunction(...args)),
27
- getItemTtl: (...args) => storage.getItemTtl(getKeyFunction(...args)),
28
- hasItem: (...args) => storage.hasItem(getKeyFunction(...args)),
29
- removeItem: (...args) => storage.removeItem(getKeyFunction(...args)),
30
- /**
31
- * Resolves the storage key from the given arguments.
32
- *
33
- * @returns {string} The final string key used internally
34
- */
35
- resolveKey: (...args) => getKeyFunction(...args),
36
- setItem: (value, ...args) => storage.setItem(getKeyFunction(...args), value),
37
- setItemWithTtl(seconds, value, ...args) {
38
- return storage.setItemWithTtl(getKeyFunction(...args), seconds, value);
39
- },
40
- });
41
- }
42
-
43
- export { createKeyedEnhancedRedisStore };
44
- //# sourceMappingURL=keyed-store.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyed-store.mjs","sources":["../../../../src/storage/enhanced/redis/keyed-store.ts"],"sourcesContent":["import type { createEnhancedRedisStorage } from './core';\n\n/**\n * Creates a reusable, type-safe Redis-backed storage interface based on `createEnhancedRedisStorage`\n * and a dynamic key-generation function.\n *\n * This utility abstracts away key construction and provides high-level access\n * to Redis operations such as `getItem`, `setItem`, `setItemWithTtl`, and `getItemTtl`.\n * It is ideal for namespaced data, caching, and session handling.\n *\n * @template D - The value type to store\n *\n * @param {ReturnType<typeof createEnhancedRedisStorage>} storage - The enhanced Redis storage instance\n *\n * @returns A factory that accepts a key generator function and returns a scoped Redis storage interface\n *\n * @example\n * ```typescript\n * import { createKeyedEnhancedRedisStore } from '@kikiutils/shared/storage/enhanced/redis';\n *\n * const userStore = createKeyedEnhancedRedisStore<User>(redisStorage)((id: number) => `user:${id}`);\n * await userStore.setItem({ id: 123, name: 'user' }, 123);\n * const user = await userStore.getItem(123);\n * ```\n */\nexport function createKeyedEnhancedRedisStore<D = unknown>(storage: ReturnType<typeof createEnhancedRedisStorage>) {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n getItem: (...args: P) => storage.getItem<D>(getKeyFunction(...args)),\n getItemTtl: (...args: P) => storage.getItemTtl(getKeyFunction(...args)),\n hasItem: (...args: P) => storage.hasItem(getKeyFunction(...args)),\n removeItem: (...args: P) => storage.removeItem(getKeyFunction(...args)),\n /**\n * Resolves the storage key from the given arguments.\n *\n * @returns {string} The final string key used internally\n */\n resolveKey: (...args: P) => getKeyFunction(...args),\n setItem: (value: D, ...args: P) => storage.setItem(getKeyFunction(...args), value),\n setItemWithTtl(seconds: number, value: D, ...args: P) {\n return storage.setItemWithTtl(getKeyFunction(...args), seconds, value);\n },\n });\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAU,6BAA6B,CAAc,OAAsD,EAAA;IAC7G,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAI,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACpE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE;;;;AAIG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;QACnD,OAAO,EAAE,CAAC,KAAQ,EAAE,GAAG,IAAO,KAAK,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;AAClF,QAAA,cAAc,CAAC,OAAe,EAAE,KAAQ,EAAE,GAAG,IAAO,EAAA;AAChD,YAAA,OAAO,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC;QAC1E,CAAC;AACJ,KAAA,CAAC;AACN;;;;"}
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Creates a reusable, type-safe keyed store wrapper for an LRUCache instance.
5
- *
6
- * This utility allows structured access to cache entries using a dynamic key-generation function.
7
- *
8
- * @template D - The specific value type exposed by this store (must extend `V`)
9
- *
10
- * @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`
11
- *
12
- * @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store
13
- *
14
- * @example
15
- * ```typescript
16
- * import { createKeyedLruStore } from '@kikiutils/shared/storage/lru/keyed-store';
17
- *
18
- * const lruCache = new LRUCache({ max: 5000 });
19
- * const userStore = createKeyedLruStore<User>(lruCache)((id: number) => `user:${id}`);
20
- * userStore.setItem({ id: 1 }, 1);
21
- * const user = userStore.getItem(1);
22
- * ```
23
- */
24
- function createKeyedLruStore(lruInstance) {
25
- return (getKeyFunction) => Object.freeze({
26
- /**
27
- * Return a value from the cache. Will update the recency of the cache entry found.
28
- *
29
- * If the key is not found, returns `null`.
30
- */
31
- getItem(...args) {
32
- const rawValue = lruInstance.get(getKeyFunction(...args));
33
- return rawValue ?? null;
34
- },
35
- getItemTtl: (...args) => lruInstance.getRemainingTTL(getKeyFunction(...args)),
36
- hasItem: (...args) => lruInstance.has(getKeyFunction(...args)),
37
- removeItem: (...args) => lruInstance.delete(getKeyFunction(...args)),
38
- /**
39
- * Resolves the full cache key from the given arguments.
40
- */
41
- resolveKey: (...args) => getKeyFunction(...args),
42
- setItem(value, ...args) {
43
- lruInstance.set(getKeyFunction(...args), value);
44
- },
45
- });
46
- }
47
-
48
- exports.createKeyedLruStore = createKeyedLruStore;
49
- //# sourceMappingURL=keyed-store.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyed-store.cjs","sources":["../../../src/storage/lru/keyed-store.ts"],"sourcesContent":["import type { LRUCache } from 'lru-cache';\n\n/**\n * Creates a reusable, type-safe keyed store wrapper for an LRUCache instance.\n *\n * This utility allows structured access to cache entries using a dynamic key-generation function.\n *\n * @template D - The specific value type exposed by this store (must extend `V`)\n *\n * @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`\n *\n * @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store\n *\n * @example\n * ```typescript\n * import { createKeyedLruStore } from '@kikiutils/shared/storage/lru/keyed-store';\n *\n * const lruCache = new LRUCache({ max: 5000 });\n * const userStore = createKeyedLruStore<User>(lruCache)((id: number) => `user:${id}`);\n * userStore.setItem({ id: 1 }, 1);\n * const user = userStore.getItem(1);\n * ```\n */\nexport function createKeyedLruStore<D = unknown>(lruInstance: LRUCache<any, any, any>) {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n /**\n * Return a value from the cache. Will update the recency of the cache entry found.\n *\n * If the key is not found, returns `null`.\n */\n getItem(...args: P) {\n const rawValue = lruInstance.get(getKeyFunction(...args));\n return rawValue as D ?? null;\n },\n getItemTtl: (...args: P) => lruInstance.getRemainingTTL(getKeyFunction(...args)),\n hasItem: (...args: P) => lruInstance.has(getKeyFunction(...args)),\n removeItem: (...args: P) => lruInstance.delete(getKeyFunction(...args)),\n /**\n * Resolves the full cache key from the given arguments.\n */\n resolveKey: (...args: P) => getKeyFunction(...args),\n setItem(value: D, ...args: P) {\n lruInstance.set(getKeyFunction(...args), value);\n },\n });\n}\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAc,WAAoC,EAAA;IACjF,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E;;;;AAIG;QACH,OAAO,CAAC,GAAG,IAAO,EAAA;AACd,YAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;YACzD,OAAO,QAAa,IAAI,IAAI;QAChC,CAAC;AACD,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AAChF,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE;;AAEG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;AACnD,QAAA,OAAO,CAAC,KAAQ,EAAE,GAAG,IAAO,EAAA;YACxB,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;QACnD,CAAC;AACJ,KAAA,CAAC;AACN;;;;"}
@@ -1,47 +0,0 @@
1
- /**
2
- * Creates a reusable, type-safe keyed store wrapper for an LRUCache instance.
3
- *
4
- * This utility allows structured access to cache entries using a dynamic key-generation function.
5
- *
6
- * @template D - The specific value type exposed by this store (must extend `V`)
7
- *
8
- * @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`
9
- *
10
- * @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store
11
- *
12
- * @example
13
- * ```typescript
14
- * import { createKeyedLruStore } from '@kikiutils/shared/storage/lru/keyed-store';
15
- *
16
- * const lruCache = new LRUCache({ max: 5000 });
17
- * const userStore = createKeyedLruStore<User>(lruCache)((id: number) => `user:${id}`);
18
- * userStore.setItem({ id: 1 }, 1);
19
- * const user = userStore.getItem(1);
20
- * ```
21
- */
22
- function createKeyedLruStore(lruInstance) {
23
- return (getKeyFunction) => Object.freeze({
24
- /**
25
- * Return a value from the cache. Will update the recency of the cache entry found.
26
- *
27
- * If the key is not found, returns `null`.
28
- */
29
- getItem(...args) {
30
- const rawValue = lruInstance.get(getKeyFunction(...args));
31
- return rawValue ?? null;
32
- },
33
- getItemTtl: (...args) => lruInstance.getRemainingTTL(getKeyFunction(...args)),
34
- hasItem: (...args) => lruInstance.has(getKeyFunction(...args)),
35
- removeItem: (...args) => lruInstance.delete(getKeyFunction(...args)),
36
- /**
37
- * Resolves the full cache key from the given arguments.
38
- */
39
- resolveKey: (...args) => getKeyFunction(...args),
40
- setItem(value, ...args) {
41
- lruInstance.set(getKeyFunction(...args), value);
42
- },
43
- });
44
- }
45
-
46
- export { createKeyedLruStore };
47
- //# sourceMappingURL=keyed-store.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"keyed-store.mjs","sources":["../../../src/storage/lru/keyed-store.ts"],"sourcesContent":["import type { LRUCache } from 'lru-cache';\n\n/**\n * Creates a reusable, type-safe keyed store wrapper for an LRUCache instance.\n *\n * This utility allows structured access to cache entries using a dynamic key-generation function.\n *\n * @template D - The specific value type exposed by this store (must extend `V`)\n *\n * @param {LRUCache<any, any, any>} lruInstance - An instance of `lru-cache`\n *\n * @returns A factory that accepts a key generator and returns a scoped, type-safe LRU-based store\n *\n * @example\n * ```typescript\n * import { createKeyedLruStore } from '@kikiutils/shared/storage/lru/keyed-store';\n *\n * const lruCache = new LRUCache({ max: 5000 });\n * const userStore = createKeyedLruStore<User>(lruCache)((id: number) => `user:${id}`);\n * userStore.setItem({ id: 1 }, 1);\n * const user = userStore.getItem(1);\n * ```\n */\nexport function createKeyedLruStore<D = unknown>(lruInstance: LRUCache<any, any, any>) {\n return <P extends any[]>(getKeyFunction: (...args: P) => string) => Object.freeze({\n /**\n * Return a value from the cache. Will update the recency of the cache entry found.\n *\n * If the key is not found, returns `null`.\n */\n getItem(...args: P) {\n const rawValue = lruInstance.get(getKeyFunction(...args));\n return rawValue as D ?? null;\n },\n getItemTtl: (...args: P) => lruInstance.getRemainingTTL(getKeyFunction(...args)),\n hasItem: (...args: P) => lruInstance.has(getKeyFunction(...args)),\n removeItem: (...args: P) => lruInstance.delete(getKeyFunction(...args)),\n /**\n * Resolves the full cache key from the given arguments.\n */\n resolveKey: (...args: P) => getKeyFunction(...args),\n setItem(value: D, ...args: P) {\n lruInstance.set(getKeyFunction(...args), value);\n },\n });\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,mBAAmB,CAAc,WAAoC,EAAA;IACjF,OAAO,CAAkB,cAAsC,KAAK,MAAM,CAAC,MAAM,CAAC;AAC9E;;;;AAIG;QACH,OAAO,CAAC,GAAG,IAAO,EAAA;AACd,YAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;YACzD,OAAO,QAAa,IAAI,IAAI;QAChC,CAAC;AACD,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AAChF,QAAA,OAAO,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACjE,QAAA,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE;;AAEG;QACH,UAAU,EAAE,CAAC,GAAG,IAAO,KAAK,cAAc,CAAC,GAAG,IAAI,CAAC;AACnD,QAAA,OAAO,CAAC,KAAQ,EAAE,GAAG,IAAO,EAAA;YACxB,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,EAAE,KAAK,CAAC;QACnD,CAAC;AACJ,KAAA,CAAC;AACN;;;;"}
package/dist/string.cjs DELETED
@@ -1,45 +0,0 @@
1
- 'use strict';
2
-
3
- const DIGITS = '0123456789';
4
- const LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';
5
- const UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
6
- const CHARSETS = {
7
- 'alphabetic': LOWERCASE + UPPERCASE,
8
- 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,
9
- 'lowercase': LOWERCASE,
10
- 'lowercase-numeric': DIGITS + LOWERCASE,
11
- 'numeric': DIGITS,
12
- 'uppercase': UPPERCASE,
13
- 'uppercase-numeric': DIGITS + UPPERCASE,
14
- };
15
- /**
16
- * Generates a random string of a given length using a specified character set.
17
- *
18
- * @param {number} length - The length of the string to generate. Must be a positive integer
19
- * @param {RandomStringMode} [mode] - The character set to use
20
- *
21
- * @returns {string} The generated random string
22
- *
23
- * @throws {Error} If the length is not a positive integer or the mode is unsupported
24
- *
25
- * @example
26
- * ```typescript
27
- * import { randomString } from '@kikiutils/shared/string';
28
- *
29
- * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)
30
- * console.log(randomString(6, 'numeric')); // e.g. '402398'
31
- * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'
32
- * ```
33
- */
34
- function randomString(length, mode = 'alphabetic') {
35
- if (!Number.isInteger(length) || length <= 0) {
36
- throw new Error(`Invalid length: ${length}. Must be a positive integer`);
37
- }
38
- const charset = CHARSETS[mode];
39
- if (!charset)
40
- throw new Error(`Unsupported mode: ${mode}`);
41
- return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');
42
- }
43
-
44
- exports.randomString = randomString;
45
- //# sourceMappingURL=string.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.cjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer\n * @param {RandomStringMode} [mode] - The character set to use\n *\n * @returns {string} The generated random string\n *\n * @throws {Error} If the length is not a positive integer or the mode is unsupported\n *\n * @example\n * ```typescript\n * import { randomString } from '@kikiutils/shared/string';\n *\n * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)\n * console.log(randomString(6, 'numeric')); // e.g. '402398'\n * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'\n * ```\n */\nexport function randomString(length: number, mode: RandomStringMode = 'alphabetic') {\n if (!Number.isInteger(length) || length <= 0) {\n throw new Error(`Invalid length: ${length}. Must be a positive integer`);\n }\n\n const charset = CHARSETS[mode];\n if (!charset) throw new Error(`Unsupported mode: ${mode}`);\n return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');\n}\n"],"names":[],"mappings":";;AASA,MAAM,MAAM,GAAG,YAAY;AAC3B,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,QAAQ,GAAqC;IAC/C,YAAY,EAAE,SAAS,GAAG,SAAS;AACnC,IAAA,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;AAC9C,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;AACvC,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;CAC1C;AAED;;;;;;;;;;;;;;;;;;AAkBG;SACa,YAAY,CAAC,MAAc,EAAE,OAAyB,YAAY,EAAA;AAC9E,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAA,4BAAA,CAA8B,CAAC;IAC5E;AAEA,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC9B,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAA,CAAE,CAAC;AAC1D,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACrG;;;;"}
package/dist/string.mjs DELETED
@@ -1,43 +0,0 @@
1
- const DIGITS = '0123456789';
2
- const LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';
3
- const UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
4
- const CHARSETS = {
5
- 'alphabetic': LOWERCASE + UPPERCASE,
6
- 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,
7
- 'lowercase': LOWERCASE,
8
- 'lowercase-numeric': DIGITS + LOWERCASE,
9
- 'numeric': DIGITS,
10
- 'uppercase': UPPERCASE,
11
- 'uppercase-numeric': DIGITS + UPPERCASE,
12
- };
13
- /**
14
- * Generates a random string of a given length using a specified character set.
15
- *
16
- * @param {number} length - The length of the string to generate. Must be a positive integer
17
- * @param {RandomStringMode} [mode] - The character set to use
18
- *
19
- * @returns {string} The generated random string
20
- *
21
- * @throws {Error} If the length is not a positive integer or the mode is unsupported
22
- *
23
- * @example
24
- * ```typescript
25
- * import { randomString } from '@kikiutils/shared/string';
26
- *
27
- * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)
28
- * console.log(randomString(6, 'numeric')); // e.g. '402398'
29
- * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'
30
- * ```
31
- */
32
- function randomString(length, mode = 'alphabetic') {
33
- if (!Number.isInteger(length) || length <= 0) {
34
- throw new Error(`Invalid length: ${length}. Must be a positive integer`);
35
- }
36
- const charset = CHARSETS[mode];
37
- if (!charset)
38
- throw new Error(`Unsupported mode: ${mode}`);
39
- return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');
40
- }
41
-
42
- export { randomString };
43
- //# sourceMappingURL=string.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.mjs","sources":["../src/string.ts"],"sourcesContent":["export type RandomStringMode =\n | 'alphabetic'\n | 'alphanumeric'\n | 'lowercase'\n | 'lowercase-numeric'\n | 'numeric'\n | 'uppercase'\n | 'uppercase-numeric';\n\nconst DIGITS = '0123456789';\nconst LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst CHARSETS: Record<RandomStringMode, string> = {\n 'alphabetic': LOWERCASE + UPPERCASE,\n 'alphanumeric': DIGITS + LOWERCASE + UPPERCASE,\n 'lowercase': LOWERCASE,\n 'lowercase-numeric': DIGITS + LOWERCASE,\n 'numeric': DIGITS,\n 'uppercase': UPPERCASE,\n 'uppercase-numeric': DIGITS + UPPERCASE,\n};\n\n/**\n * Generates a random string of a given length using a specified character set.\n *\n * @param {number} length - The length of the string to generate. Must be a positive integer\n * @param {RandomStringMode} [mode] - The character set to use\n *\n * @returns {string} The generated random string\n *\n * @throws {Error} If the length is not a positive integer or the mode is unsupported\n *\n * @example\n * ```typescript\n * import { randomString } from '@kikiutils/shared/string';\n *\n * console.log(randomString(8)); // e.g. 'aZbXwTyQ' (alphabetic)\n * console.log(randomString(6, 'numeric')); // e.g. '402398'\n * console.log(randomString(10, 'alphanumeric')); // e.g. 'a9Z4pQ8xY2'\n * ```\n */\nexport function randomString(length: number, mode: RandomStringMode = 'alphabetic') {\n if (!Number.isInteger(length) || length <= 0) {\n throw new Error(`Invalid length: ${length}. Must be a positive integer`);\n }\n\n const charset = CHARSETS[mode];\n if (!charset) throw new Error(`Unsupported mode: ${mode}`);\n return Array.from({ length }, () => charset[Math.floor(Math.random() * charset.length)]).join('');\n}\n"],"names":[],"mappings":"AASA,MAAM,MAAM,GAAG,YAAY;AAC3B,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,SAAS,GAAG,4BAA4B;AAC9C,MAAM,QAAQ,GAAqC;IAC/C,YAAY,EAAE,SAAS,GAAG,SAAS;AACnC,IAAA,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;AAC9C,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;AACvC,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,WAAW,EAAE,SAAS;IACtB,mBAAmB,EAAE,MAAM,GAAG,SAAS;CAC1C;AAED;;;;;;;;;;;;;;;;;;AAkBG;SACa,YAAY,CAAC,MAAc,EAAE,OAAyB,YAAY,EAAA;AAC9E,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAA,4BAAA,CAA8B,CAAC;IAC5E;AAEA,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;AAC9B,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAA,CAAE,CAAC;AAC1D,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACrG;;;;"}
package/dist/url.cjs DELETED
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Appends or updates the `redirect` query parameter on a given URL.
5
- *
6
- * Typically used to preserve the user's current path for post-login navigation.
7
- *
8
- * @param {string} url - The target URL to modify
9
- * @param {string} redirectPath - The path to use as the redirect destination
10
- *
11
- * @returns {string} A new URL string with the `redirect` query parameter
12
- */
13
- function appendRedirectParamToUrl(url, redirectPath) {
14
- const [base, rawQuery = ''] = url.split('?');
15
- const searchParams = new URLSearchParams(rawQuery);
16
- searchParams.set('redirect', redirectPath);
17
- return `${base}?${searchParams.toString()}`;
18
- }
19
-
20
- exports.appendRedirectParamToUrl = appendRedirectParamToUrl;
21
- //# sourceMappingURL=url.cjs.map
package/dist/url.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.cjs","sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param {string} url - The target URL to modify\n * @param {string} redirectPath - The path to use as the redirect destination\n *\n * @returns {string} A new URL string with the `redirect` query parameter\n */\nexport function appendRedirectParamToUrl(url: string, redirectPath: string) {\n const [base, rawQuery = ''] = url.split('?');\n const searchParams = new URLSearchParams(rawQuery);\n searchParams.set('redirect', redirectPath);\n return `${base}?${searchParams.toString()}`;\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;AASG;AACG,SAAU,wBAAwB,CAAC,GAAW,EAAE,YAAoB,EAAA;AACtE,IAAA,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,IAAA,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC;AAClD,IAAA,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1C,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,YAAY,CAAC,QAAQ,EAAE,EAAE;AAC/C;;;;"}
package/dist/url.mjs DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * Appends or updates the `redirect` query parameter on a given URL.
3
- *
4
- * Typically used to preserve the user's current path for post-login navigation.
5
- *
6
- * @param {string} url - The target URL to modify
7
- * @param {string} redirectPath - The path to use as the redirect destination
8
- *
9
- * @returns {string} A new URL string with the `redirect` query parameter
10
- */
11
- function appendRedirectParamToUrl(url, redirectPath) {
12
- const [base, rawQuery = ''] = url.split('?');
13
- const searchParams = new URLSearchParams(rawQuery);
14
- searchParams.set('redirect', redirectPath);
15
- return `${base}?${searchParams.toString()}`;
16
- }
17
-
18
- export { appendRedirectParamToUrl };
19
- //# sourceMappingURL=url.mjs.map
package/dist/url.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.mjs","sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param {string} url - The target URL to modify\n * @param {string} redirectPath - The path to use as the redirect destination\n *\n * @returns {string} A new URL string with the `redirect` query parameter\n */\nexport function appendRedirectParamToUrl(url: string, redirectPath: string) {\n const [base, rawQuery = ''] = url.split('?');\n const searchParams = new URLSearchParams(rawQuery);\n searchParams.set('redirect', redirectPath);\n return `${base}?${searchParams.toString()}`;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AACG,SAAU,wBAAwB,CAAC,GAAW,EAAE,YAAoB,EAAA;AACtE,IAAA,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,IAAA,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC;AAClD,IAAA,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1C,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,YAAY,CAAC,QAAQ,EAAE,EAAE;AAC/C;;;;"}
package/dist/vue.cjs DELETED
@@ -1,64 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
- const vueRouter = require('vue-router');
5
- const url = require('./url.cjs');
6
-
7
- /**
8
- * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.
9
- *
10
- * @param {string} url - The base URL to modify
11
- *
12
- * @returns {string} A new URL with the current route fullPath as the `redirect` parameter
13
- */
14
- function appendRedirectParamFromCurrentRouteToUrl(url$1) {
15
- return url.appendRedirectParamToUrl(url$1, vueRouter.useRoute().fullPath);
16
- }
17
- /**
18
- * Clears an interval referenced by a Vue ref and sets it to null.
19
- *
20
- * @param {Ref<null | ReturnType<typeof setInterval>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null
21
- */
22
- function clearIntervalRef(intervalRef) {
23
- if (intervalRef.value)
24
- clearInterval(intervalRef.value);
25
- intervalRef.value = null;
26
- }
27
- /**
28
- * Clears a timeout referenced by a Vue ref and sets it to null.
29
- *
30
- * @param {Ref<null | ReturnType<typeof setTimeout>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null
31
- */
32
- function clearTimeoutRef(timeoutRef) {
33
- if (timeoutRef.value)
34
- clearTimeout(timeoutRef.value);
35
- timeoutRef.value = null;
36
- }
37
- /**
38
- * A Vue composition function that remembers and restores scroll position
39
- * of a scrollable container across route changes and keep-alive activation.
40
- *
41
- * @template T - The type of the scrollable element (defaults to HTMLElement)
42
- *
43
- * @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element
44
- */
45
- function usePreserveScroll(containerRef) {
46
- let scrollLeft = 0;
47
- let scrollTop = 0;
48
- vue.onActivated(() => {
49
- if (!containerRef.value)
50
- return;
51
- containerRef.value.scrollLeft = scrollLeft;
52
- containerRef.value.scrollTop = scrollTop;
53
- });
54
- vueRouter.onBeforeRouteLeave(() => {
55
- scrollLeft = containerRef.value?.scrollLeft || 0;
56
- scrollTop = containerRef.value?.scrollTop || 0;
57
- });
58
- }
59
-
60
- exports.appendRedirectParamFromCurrentRouteToUrl = appendRedirectParamFromCurrentRouteToUrl;
61
- exports.clearIntervalRef = clearIntervalRef;
62
- exports.clearTimeoutRef = clearTimeoutRef;
63
- exports.usePreserveScroll = usePreserveScroll;
64
- //# sourceMappingURL=vue.cjs.map