@kikiutils/shared 15.0.3 → 15.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -67
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js.map +1 -1
- package/dist/classes/path.d.ts +8 -0
- package/dist/classes/path.d.ts.map +1 -1
- package/dist/classes/path.js +5 -0
- package/dist/classes/path.js.map +1 -1
- package/dist/classes/precision-number.d.ts +215 -11
- package/dist/classes/precision-number.d.ts.map +1 -1
- package/dist/classes/precision-number.js +268 -25
- package/dist/classes/precision-number.js.map +1 -1
- package/dist/classes/ssh-client.js.map +1 -1
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js.map +1 -1
- package/dist/consola.d.ts.map +1 -1
- package/dist/consola.js.map +1 -1
- package/dist/crypto-hash.d.ts +7 -7
- package/dist/crypto-hash.d.ts.map +1 -1
- package/dist/crypto-hash.js +7 -7
- package/dist/crypto-hash.js.map +1 -1
- package/dist/datetime.d.ts.map +1 -1
- package/dist/datetime.js.map +1 -1
- package/dist/element-plus.d.ts.map +1 -1
- package/dist/element-plus.js.map +1 -1
- package/dist/enum.d.ts.map +1 -1
- package/dist/enum.js.map +1 -1
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js.map +1 -1
- package/dist/event-awaiter.d.ts.map +1 -1
- package/dist/event-awaiter.js.map +1 -1
- package/dist/general.d.ts.map +1 -1
- package/dist/general.js.map +1 -1
- package/dist/hash.d.ts +3 -3
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +3 -3
- package/dist/hash.js.map +1 -1
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js.map +1 -1
- package/dist/number.d.ts.map +1 -1
- package/dist/number.js.map +1 -1
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js.map +1 -1
- package/dist/pino.d.ts.map +1 -1
- package/dist/pino.js.map +1 -1
- package/dist/random.d.ts.map +1 -1
- package/dist/random.js.map +1 -1
- package/dist/storages/lru/keyed-store.d.ts +3 -3
- package/dist/storages/lru/keyed-store.js +3 -3
- package/dist/storages/lru/keyed-store.js.map +1 -1
- package/dist/storages/redis/keyed-store.d.ts +1 -1
- package/dist/storages/redis/keyed-store.js +1 -1
- package/dist/storages/redis/keyed-store.js.map +1 -1
- package/dist/storages/redis/msgpack.d.ts.map +1 -1
- package/dist/storages/redis/msgpack.js.map +1 -1
- package/dist/storages/redis/types.d.ts.map +1 -1
- package/dist/string.d.ts +12 -6
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +9 -6
- package/dist/string.js.map +1 -1
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js.map +1 -1
- package/dist/types/filtered-key-path.d.ts.map +1 -1
- package/dist/types/index.d.ts +30 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/url.d.ts +27 -3
- package/dist/url.d.ts.map +1 -1
- package/dist/url.js +37 -4
- package/dist/url.js.map +1 -1
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js.map +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js.map +1 -1
- package/package.json +12 -21
- package/src/classes/path.ts +9 -0
- package/src/classes/precision-number.ts +300 -25
- package/src/crypto-hash.ts +7 -7
- package/src/hash.ts +3 -3
- package/src/storages/lru/keyed-store.ts +3 -3
- package/src/storages/redis/keyed-store.ts +1 -1
- package/src/string.ts +12 -6
- package/src/types/index.ts +39 -0
- package/src/url.ts +39 -7
|
@@ -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 Redis-like storage using msgpack serialization.\n *\n * @param {RedisLikeAdapter} adapter - The Redis-like adapter to use for raw buffer operations\n *\n * @returns {Readonly<RedisLikeStorage>} A readonly storage instance\n * with getItem, setItem, hasItem, removeItem, getItemTtl, setItemWithTtl\n *\n * @example\n * ```typescript\n * import { createRedisMsgpackStorage } from '@kikiutils/shared/storages/redis/msgpack';\n * import { createClient } from 'redis';\n *\n * const client = createClient();\n * await client.connect();\n * const storage = createRedisMsgpackStorage(client as unknown as RedisLikeAdapter);\n * await storage.setItem('key', { foo: 'bar' });\n * const value = await storage.getItem('key'); // { foo: 'bar' }\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,
|
|
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 Redis-like storage using msgpack serialization.\n *\n * @param {RedisLikeAdapter} adapter - The Redis-like adapter to use for raw buffer operations\n *\n * @returns {Readonly<RedisLikeStorage>} A readonly storage instance\n * with getItem, setItem, hasItem, removeItem, getItemTtl, setItemWithTtl\n *\n * @example\n * ```typescript\n * import { createRedisMsgpackStorage } from '@kikiutils/shared/storages/redis/msgpack';\n * import { createClient } from 'redis';\n *\n * const client = createClient();\n * await client.connect();\n * const storage = createRedisMsgpackStorage(client as unknown as RedisLikeAdapter);\n * await storage.setItem('key', { foo: 'bar' });\n * const value = await storage.getItem('key'); // { foo: 'bar' }\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;;;;;;;;;;;;;;;;;;;;;AAuBtG,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/storages/redis/types.ts"],"mappings":";;;;;AAKA;UAAiB,gBAAA;;;;EAIb,MAAA,GAAS,GAAA,aAAgB,OAAA;EAKG;;;EAA5B,SAAA,GAAY,GAAA,aAAgB,OAAA,CAAQ,QAAA,CAAS,UAAA;EAeS;;;EAVtD,GAAA,GAAM,GAAA,aAAgB,OAAA;EAeO;;;EAV7B,SAAA,GAAY,GAAA,UAAa,KAAA,EAAO,UAAA,KAAe,OAAA;EAV/C;;;EAeA,WAAA,GAAc,GAAA,UAAa,UAAA,UAAoB,KAAA,EAAO,UAAA,KAAe,OAAA;EAfxB;;;EAoB7C,GAAA,GAAM,GAAA,aAAgB,OAAA;AAAA;;;;UAMT,gBAAA;EAXb;;;EAeA,OAAA,gBAAuB,GAAA,aAAgB,OAAA,CAAQ,QAAA,CAAS,CAAA;EAfT;;;EAoB/C,UAAA,GAAa,GAAA,aAAgB,OAAA;EAfP
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/storages/redis/types.ts"],"mappings":";;;;;AAKA;UAAiB,gBAAA;;;;EAIb,MAAA,GAAS,GAAA,aAAgB,OAAA;EAKG;;;EAA5B,SAAA,GAAY,GAAA,aAAgB,OAAA,CAAQ,QAAA,CAAS,UAAA;EAeS;;;EAVtD,GAAA,GAAM,GAAA,aAAgB,OAAA;EAeO;;;EAV7B,SAAA,GAAY,GAAA,UAAa,KAAA,EAAO,UAAA,KAAe,OAAA;EAV/C;;;EAeA,WAAA,GAAc,GAAA,UAAa,UAAA,UAAoB,KAAA,EAAO,UAAA,KAAe,OAAA;EAfxB;;;EAoB7C,GAAA,GAAM,GAAA,aAAgB,OAAA;AAAA;;;;UAMT,gBAAA;EAXb;;;EAeA,OAAA,gBAAuB,GAAA,aAAgB,OAAA,CAAQ,QAAA,CAAS,CAAA;EAfT;;;EAoB/C,UAAA,GAAa,GAAA,aAAgB,OAAA;EAfP;;AAAO;EAoB7B,OAAA,GAAU,GAAA,aAAgB,OAAA;EAdG;;;EAmB7B,UAAA,GAAa,GAAA,aAAgB,OAAA;EAfU;;;EAoBvC,OAAA,GAAU,GAAA,UAAa,KAAA,UAAe,OAAA;EAAA;;;EAKtC,cAAA,GAAiB,GAAA,UAAa,UAAA,UAAoB,KAAA,UAAe,OAAA;AAAA"}
|
package/dist/string.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
//#region src/string.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Character-set presets supported by `randomString`.
|
|
4
|
+
*/
|
|
2
5
|
type RandomStringMode = 'alphabetic' | 'alphanumeric' | 'lowercase' | 'lowercase-numeric' | 'numeric' | 'uppercase' | 'uppercase-numeric';
|
|
3
6
|
/**
|
|
4
|
-
* Generates a random string of a given length using a
|
|
7
|
+
* Generates a random string of a given length using a predefined character set.
|
|
8
|
+
*
|
|
9
|
+
* Uses `Math.random`, so this helper is suitable for display tokens, placeholders,
|
|
10
|
+
* and test data, but not for passwords, API keys, or other cryptographic secrets.
|
|
5
11
|
*
|
|
6
|
-
* @param {number} length - The length of the string to generate
|
|
7
|
-
* @param {RandomStringMode} [mode] - The character set to use
|
|
12
|
+
* @param {number} length - The positive integer length of the string to generate
|
|
13
|
+
* @param {RandomStringMode} [mode] - The character set to use (default: `'alphabetic'`)
|
|
8
14
|
*
|
|
9
15
|
* @returns {string} The generated random string
|
|
10
16
|
*
|
|
@@ -14,9 +20,9 @@ type RandomStringMode = 'alphabetic' | 'alphanumeric' | 'lowercase' | 'lowercase
|
|
|
14
20
|
* ```typescript
|
|
15
21
|
* import { randomString } from '@kikiutils/shared/string';
|
|
16
22
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
23
|
+
* randomString(8); // e.g. 'aZbXwTyQ'
|
|
24
|
+
* randomString(6, 'numeric'); // e.g. '402398'
|
|
25
|
+
* randomString(10, 'alphanumeric'); // e.g. 'a9Z4pQ8xY2'
|
|
20
26
|
* ```
|
|
21
27
|
*/
|
|
22
28
|
declare function randomString(length: number, mode?: RandomStringMode): string;
|
package/dist/string.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","names":[],"sources":["../src/string.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"string.d.ts","names":[],"sources":["../src/string.ts"],"mappings":";;AAGA;;KAAY,gBAAA;;AAAgB;AA4C5B;;;;;;;;AAAkF;;;;;;;;;;;;iBAAlE,YAAA,CAAa,MAAA,UAAgB,IAAA,GAAM,gBAA+B"}
|
package/dist/string.js
CHANGED
|
@@ -12,10 +12,13 @@ const CHARSETS = {
|
|
|
12
12
|
"uppercase-numeric": DIGITS + UPPERCASE
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* Generates a random string of a given length using a
|
|
15
|
+
* Generates a random string of a given length using a predefined character set.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Uses `Math.random`, so this helper is suitable for display tokens, placeholders,
|
|
18
|
+
* and test data, but not for passwords, API keys, or other cryptographic secrets.
|
|
19
|
+
*
|
|
20
|
+
* @param {number} length - The positive integer length of the string to generate
|
|
21
|
+
* @param {RandomStringMode} [mode] - The character set to use (default: `'alphabetic'`)
|
|
19
22
|
*
|
|
20
23
|
* @returns {string} The generated random string
|
|
21
24
|
*
|
|
@@ -25,9 +28,9 @@ const CHARSETS = {
|
|
|
25
28
|
* ```typescript
|
|
26
29
|
* import { randomString } from '@kikiutils/shared/string';
|
|
27
30
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
+
* randomString(8); // e.g. 'aZbXwTyQ'
|
|
32
|
+
* randomString(6, 'numeric'); // e.g. '402398'
|
|
33
|
+
* randomString(10, 'alphanumeric'); // e.g. 'a9Z4pQ8xY2'
|
|
31
34
|
* ```
|
|
32
35
|
*/
|
|
33
36
|
function randomString(length, mode = "alphabetic") {
|
package/dist/string.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","names":[],"sources":["../src/string.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"string.js","names":[],"sources":["../src/string.ts"],"sourcesContent":["/**\n * Character-set presets supported by `randomString`.\n */\nexport 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 predefined character set.\n *\n * Uses `Math.random`, so this helper is suitable for display tokens, placeholders,\n * and test data, but not for passwords, API keys, or other cryptographic secrets.\n *\n * @param {number} length - The positive integer length of the string to generate\n * @param {RandomStringMode} [mode] - The character set to use (default: `'alphabetic'`)\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 * randomString(8); // e.g. 'aZbXwTyQ'\n * randomString(6, 'numeric'); // e.g. '402398'\n * 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"],"mappings":";AAYA,MAAM,SAAS;AACf,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,WAA6C;CAC/C,cAAc,YAAY;CAC1B,gBAAgB,SAAS,YAAY;CACrC,aAAa;CACb,qBAAqB,SAAS;CAC9B,WAAW;CACX,aAAa;CACb,qBAAqB,SAAS;AAClC;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,aAAa,QAAgB,OAAyB,cAAc;CAChF,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,UAAU,GACvC,MAAM,IAAI,MAAM,mBAAmB,OAAO,6BAA6B;CAG3E,MAAM,UAAU,SAAS;CACzB,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,qBAAqB,MAAM;CACzD,OAAO,MAAM,KAAK,EAAE,OAAO,SAAS,QAAQ,KAAK,MAAM,KAAK,OAAO,IAAI,QAAQ,MAAM,EAAE,EAAE,KAAK,EAAE;AACpG"}
|
package/dist/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","names":[],"sources":["../src/time.ts"],"mappings":";;AAiBA
|
|
1
|
+
{"version":3,"file":"time.d.ts","names":[],"sources":["../src/time.ts"],"mappings":";;AAiBA;;;;;;;;;AAA+D;;;;;;;iBAA/C,cAAA,CAAe,EAAA,UAAY,MAAA,GAAS,WAAA,GAAW,OAAA"}
|
package/dist/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","names":[],"sources":["../src/time.ts"],"sourcesContent":["/**\n * Creates a delay that can be aborted via AbortSignal.\n *\n * @param {number} ms - Delay duration in milliseconds\n * @param {AbortSignal} [signal] - Optional AbortSignal to cancel the delay\n *\n * @returns {Promise<undefined>} A promise that resolves after ms or resolves immediately on abort\n *\n * @example\n * ```typescript\n * import { abortableDelay } from '@kikiutils/shared/time';\n *\n * const controller = new AbortController();\n * setTimeout(() => controller.abort(), 1000);\n * await abortableDelay(5000, controller.signal); // resolves after ~1s when aborted\n * ```\n */\nexport function abortableDelay(ms: number, signal?: AbortSignal) {\n return new Promise((resolve) => {\n const timeout = setTimeout(resolve, ms);\n if (signal) {\n signal.addEventListener(\n 'abort',\n () => {\n clearTimeout(timeout);\n resolve(undefined);\n },\n );\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,eAAe,IAAY,QAAsB;
|
|
1
|
+
{"version":3,"file":"time.js","names":[],"sources":["../src/time.ts"],"sourcesContent":["/**\n * Creates a delay that can be aborted via AbortSignal.\n *\n * @param {number} ms - Delay duration in milliseconds\n * @param {AbortSignal} [signal] - Optional AbortSignal to cancel the delay\n *\n * @returns {Promise<undefined>} A promise that resolves after ms or resolves immediately on abort\n *\n * @example\n * ```typescript\n * import { abortableDelay } from '@kikiutils/shared/time';\n *\n * const controller = new AbortController();\n * setTimeout(() => controller.abort(), 1000);\n * await abortableDelay(5000, controller.signal); // resolves after ~1s when aborted\n * ```\n */\nexport function abortableDelay(ms: number, signal?: AbortSignal) {\n return new Promise((resolve) => {\n const timeout = setTimeout(resolve, ms);\n if (signal) {\n signal.addEventListener(\n 'abort',\n () => {\n clearTimeout(timeout);\n resolve(undefined);\n },\n );\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,eAAe,IAAY,QAAsB;CAC7D,OAAO,IAAI,SAAS,YAAY;EAC5B,MAAM,UAAU,WAAW,SAAS,EAAE;EACtC,IAAI,QACA,OAAO,iBACH,eACM;GACF,aAAa,OAAO;GACpB,QAAQ,KAAA,CAAS;EACrB,CACJ;CAER,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtered-key-path.d.ts","names":[],"sources":["../../src/types/filtered-key-path.ts"],"mappings":";;;;;AAAqC;;;;;;KAWhC,eAAA,oCAAmD,CAAA,SAAU,CAAA,MAAO,CAAA,KAAM,WAAA,CAAY,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA,KAC5F,WAAA,kDAIO,CAAA,MACR,CAAA,SAAU,YAAA,GAAe,EAAA,MAAQ,CAAA,IAAK,eAAA,CAAgB,CAAA,EAAG,CAAA;;;;;;;;;KAWjD,eAAA,iBAAgC,CAAA,SAAU,aAAA,aAA0B,OAAA,CAAQ,CAAA,yBAA0B,QAAA,CAAS,CAAA,MAAO,QAAA,CAAS,OAAA,CAAQ,CAAA,WAAY,CAAA,CAAE,CAAA,GAAI,CAAA,IAAK,QAAA,CAAS,CAAA,KAAM,QAAA,SAAiB,CAAA,EAAG,CAAA,mBAAoB,CAAA,KAAM,QAAA,CAAS,OAAA,CAAQ,CAAA,WAAY,CAAA,CAAE,CAAA,GAAI,CAAA,UAAW,CAAA;AAAA,KAChR,OAAA,WAAkB,aAAA,wBAAqC,
|
|
1
|
+
{"version":3,"file":"filtered-key-path.d.ts","names":[],"sources":["../../src/types/filtered-key-path.ts"],"mappings":";;;;;AAAqC;;;;;;KAWhC,eAAA,oCAAmD,CAAA,SAAU,CAAA,MAAO,CAAA,KAAM,WAAA,CAAY,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA,KAC5F,WAAA,kDAIO,CAAA,MACR,CAAA,SAAU,YAAA,GAAe,EAAA,MAAQ,CAAA,IAAK,eAAA,CAAgB,CAAA,EAAG,CAAA;;;;;;;;;KAWjD,eAAA,iBAAgC,CAAA,SAAU,aAAA,aAA0B,OAAA,CAAQ,CAAA,yBAA0B,QAAA,CAAS,CAAA,MAAO,QAAA,CAAS,OAAA,CAAQ,CAAA,WAAY,CAAA,CAAE,CAAA,GAAI,CAAA,IAAK,QAAA,CAAS,CAAA,KAAM,QAAA,SAAiB,CAAA,EAAG,CAAA,mBAAoB,CAAA,KAAM,QAAA,CAAS,OAAA,CAAQ,CAAA,WAAY,CAAA,CAAE,CAAA,GAAI,CAAA,UAAW,CAAA;AAAA,KAChR,OAAA,WAAkB,aAAA,wBAAqC,CAAC;AAAA,KACxD,QAAA,qCAA6C,CAAA,oBAAqB,WAAA,CAAY,CAAA,EAAG,CAAA,IAAK,eAAA,CAAgB,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA,KAC5G,YAAA,YAED,IAAA,aAEA,IAAA,GACA,IAAA,mBAGA,QAAA,GACA,MAAA;AAAA,KAKC,QAAA,WAAmB,aAAA,SAAsB,OAAA,OAAc,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,15 +2,45 @@ import { FilteredKeyPath } from "./filtered-key-path.js";
|
|
|
2
2
|
import { Blob as Blob$1, Buffer, File as File$1 } from "node:buffer";
|
|
3
3
|
|
|
4
4
|
//#region src/types/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A generic string-keyed object for utility APIs that intentionally accept any value shape.
|
|
7
|
+
*/
|
|
5
8
|
type AnyRecord = Record<string, any>;
|
|
9
|
+
/**
|
|
10
|
+
* Binary-like inputs accepted by `toBuffer` across browser and Node.js runtimes.
|
|
11
|
+
*/
|
|
6
12
|
type BinaryInput = ArrayBuffer | Blob | Buffer | File | Blob$1 | File$1 | Uint8Array;
|
|
13
|
+
/**
|
|
14
|
+
* Boolean values represented either as booleans or common string literals.
|
|
15
|
+
*/
|
|
7
16
|
type Booleanish = 'false' | 'true' | boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Accepts either a full object or a partial patch of that object.
|
|
19
|
+
*/
|
|
8
20
|
type MaybePartial<T> = Partial<T> | T;
|
|
21
|
+
/**
|
|
22
|
+
* Accepts either a mutable value or a readonly view of that value.
|
|
23
|
+
*/
|
|
9
24
|
type MaybeReadonly<T> = Readonly<T> | T;
|
|
25
|
+
/**
|
|
26
|
+
* Explicitly nullable value helper.
|
|
27
|
+
*/
|
|
10
28
|
type Nullable<T> = null | T;
|
|
29
|
+
/**
|
|
30
|
+
* Number-like value represented as a number or a numeric string.
|
|
31
|
+
*/
|
|
11
32
|
type Numberish = number | string;
|
|
33
|
+
/**
|
|
34
|
+
* A `Record` where every key is optional.
|
|
35
|
+
*/
|
|
12
36
|
type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>;
|
|
37
|
+
/**
|
|
38
|
+
* A readonly `PartialRecord`.
|
|
39
|
+
*/
|
|
13
40
|
type ReadonlyPartialRecord<K extends keyof any, T> = Readonly<PartialRecord<K, T>>;
|
|
41
|
+
/**
|
|
42
|
+
* A readonly `Record`.
|
|
43
|
+
*/
|
|
14
44
|
type ReadonlyRecord<K extends keyof any, T> = Readonly<Record<K, T>>;
|
|
15
45
|
//#endregion
|
|
16
46
|
export { AnyRecord, BinaryInput, Booleanish, type FilteredKeyPath, MaybePartial, MaybeReadonly, Nullable, Numberish, PartialRecord, ReadonlyPartialRecord, ReadonlyRecord };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"mappings":";;;;;;AAWA;KAAY,SAAA,GAAY,MAAM;;;AAAA;KAKlB,WAAA,GAAc,WAAA,GAAc,IAAA,GAAO,MAAA,GAAS,IAAA,GAAO,MAAA,GAAW,MAAA,GAAW,UAAA;;;;KAKzE,UAAA;;;;KAKA,YAAA,MAAkB,OAAA,CAAQ,CAAA,IAAK,CAAA;;;;KAK/B,aAAA,MAAmB,QAAA,CAAS,CAAA,IAAK,CAAA;;;;KAKjC,QAAA,aAAqB,CAAC;;;;KAKtB,SAAA;AApBZ;;;AAAA,KAyBY,aAAA,2BAAwC,OAAA,CAAQ,MAAA,CAAO,CAAA,EAAG,CAAA;AAzBhD;AAKtB;;AALsB,KA8BV,qBAAA,2BAAgD,QAAA,CAAS,aAAA,CAAc,CAAA,EAAG,CAAA;;;;KAK1E,cAAA,2BAAyC,QAAA,CAAS,MAAA,CAAO,CAAA,EAAG,CAAA"}
|
package/dist/url.d.ts
CHANGED
|
@@ -6,13 +6,37 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @param {string} url - The target URL to modify
|
|
8
8
|
* @param {string} redirectPath - The path to use as the redirect destination
|
|
9
|
-
* (must be
|
|
9
|
+
* (must be a safe same-origin application path starting with `/`)
|
|
10
10
|
*
|
|
11
11
|
* @returns {string} A new URL string with the `redirect` query parameter
|
|
12
12
|
*
|
|
13
|
-
* @throws {Error} If redirectPath is not a
|
|
13
|
+
* @throws {Error} If redirectPath is not a safe same-origin application path
|
|
14
14
|
*/
|
|
15
15
|
declare function appendRedirectParamToUrl(url: string, redirectPath: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Returns whether a value is a safe same-origin redirect path.
|
|
18
|
+
*
|
|
19
|
+
* Safe redirect paths are absolute application paths such as `/dashboard`.
|
|
20
|
+
* Protocol-relative URLs (`//example.com`), absolute URLs, backslash paths,
|
|
21
|
+
* and non-string values are rejected.
|
|
22
|
+
*
|
|
23
|
+
* @param {unknown} value - The value to check
|
|
24
|
+
*
|
|
25
|
+
* @returns {boolean} Whether the value is safe to use as an application redirect path
|
|
26
|
+
*/
|
|
27
|
+
declare function isSafeRedirectPath(value: unknown): value is string;
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes a redirect value into a safe same-origin application path.
|
|
30
|
+
*
|
|
31
|
+
* If an array is provided, the first value is checked. Unsafe values fall back
|
|
32
|
+
* to the provided fallback path.
|
|
33
|
+
*
|
|
34
|
+
* @param {unknown} value - The redirect value to normalize
|
|
35
|
+
* @param {string} fallback - The safe fallback path
|
|
36
|
+
*
|
|
37
|
+
* @returns {string} A safe redirect path
|
|
38
|
+
*/
|
|
39
|
+
declare function normalizeRedirectPath(value: unknown, fallback?: string): string;
|
|
16
40
|
//#endregion
|
|
17
|
-
export { appendRedirectParamToUrl };
|
|
41
|
+
export { appendRedirectParamToUrl, isSafeRedirectPath, normalizeRedirectPath };
|
|
18
42
|
//# 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":";;AAaA
|
|
1
|
+
{"version":3,"file":"url.d.ts","names":[],"sources":["../src/url.ts"],"mappings":";;AAaA;;;;AAA0E;AAuB1E;;;;AAAyD;AAmBzD;;iBA1CgB,wBAAA,CAAyB,GAAA,UAAa,YAAoB;;AA0CN;;;;;;;;;;iBAnBpD,kBAAA,CAAmB,KAAA,YAAiB,KAAK;;;;;;;;;;;;iBAmBzC,qBAAA,CAAsB,KAAA,WAAgB,QAAc"}
|
package/dist/url.js
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @param {string} url - The target URL to modify
|
|
8
8
|
* @param {string} redirectPath - The path to use as the redirect destination
|
|
9
|
-
* (must be
|
|
9
|
+
* (must be a safe same-origin application path starting with `/`)
|
|
10
10
|
*
|
|
11
11
|
* @returns {string} A new URL string with the `redirect` query parameter
|
|
12
12
|
*
|
|
13
|
-
* @throws {Error} If redirectPath is not a
|
|
13
|
+
* @throws {Error} If redirectPath is not a safe same-origin application path
|
|
14
14
|
*/
|
|
15
15
|
function appendRedirectParamToUrl(url, redirectPath) {
|
|
16
|
-
if (!redirectPath
|
|
16
|
+
if (!isSafeRedirectPath(redirectPath)) throw new Error(`Invalid redirect path: "${redirectPath}". Redirect paths must be safe same-origin paths starting with '/'.`);
|
|
17
17
|
const [baseAndHash, rawQuery = ""] = url.split("?");
|
|
18
18
|
const [base, hash] = (baseAndHash || "").split("#");
|
|
19
19
|
const searchParams = new URLSearchParams(rawQuery);
|
|
@@ -21,7 +21,40 @@ function appendRedirectParamToUrl(url, redirectPath) {
|
|
|
21
21
|
const queryString = searchParams.toString();
|
|
22
22
|
return hash ? `${base}?${queryString}#${hash}` : `${base}?${queryString}`;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether a value is a safe same-origin redirect path.
|
|
26
|
+
*
|
|
27
|
+
* Safe redirect paths are absolute application paths such as `/dashboard`.
|
|
28
|
+
* Protocol-relative URLs (`//example.com`), absolute URLs, backslash paths,
|
|
29
|
+
* and non-string values are rejected.
|
|
30
|
+
*
|
|
31
|
+
* @param {unknown} value - The value to check
|
|
32
|
+
*
|
|
33
|
+
* @returns {boolean} Whether the value is safe to use as an application redirect path
|
|
34
|
+
*/
|
|
35
|
+
function isSafeRedirectPath(value) {
|
|
36
|
+
if (typeof value !== "string") return false;
|
|
37
|
+
if (!value.startsWith("/")) return false;
|
|
38
|
+
if (value.startsWith("//")) return false;
|
|
39
|
+
if (value.includes("\\")) return false;
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Normalizes a redirect value into a safe same-origin application path.
|
|
44
|
+
*
|
|
45
|
+
* If an array is provided, the first value is checked. Unsafe values fall back
|
|
46
|
+
* to the provided fallback path.
|
|
47
|
+
*
|
|
48
|
+
* @param {unknown} value - The redirect value to normalize
|
|
49
|
+
* @param {string} fallback - The safe fallback path
|
|
50
|
+
*
|
|
51
|
+
* @returns {string} A safe redirect path
|
|
52
|
+
*/
|
|
53
|
+
function normalizeRedirectPath(value, fallback = "/") {
|
|
54
|
+
const redirectPath = Array.isArray(value) ? value[0] : value;
|
|
55
|
+
return isSafeRedirectPath(redirectPath) ? redirectPath : fallback;
|
|
56
|
+
}
|
|
24
57
|
//#endregion
|
|
25
|
-
export { appendRedirectParamToUrl };
|
|
58
|
+
export { appendRedirectParamToUrl, isSafeRedirectPath, normalizeRedirectPath };
|
|
26
59
|
|
|
27
60
|
//# sourceMappingURL=url.js.map
|
package/dist/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","names":[],"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 * (must be
|
|
1
|
+
{"version":3,"file":"url.js","names":[],"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 * (must be a safe same-origin application path starting with `/`)\n *\n * @returns {string} A new URL string with the `redirect` query parameter\n *\n * @throws {Error} If redirectPath is not a safe same-origin application path\n */\nexport function appendRedirectParamToUrl(url: string, redirectPath: string) {\n // eslint-disable-next-line style/max-len\n if (!isSafeRedirectPath(redirectPath)) throw new Error(`Invalid redirect path: \"${redirectPath}\". Redirect paths must be safe same-origin paths starting with '/'.`);\n\n const [baseAndHash, rawQuery = ''] = url.split('?');\n const [base, hash] = (baseAndHash || '').split('#');\n const searchParams = new URLSearchParams(rawQuery);\n searchParams.set('redirect', redirectPath);\n const queryString = searchParams.toString();\n return hash ? `${base}?${queryString}#${hash}` : `${base}?${queryString}`;\n}\n\n/**\n * Returns whether a value is a safe same-origin redirect path.\n *\n * Safe redirect paths are absolute application paths such as `/dashboard`.\n * Protocol-relative URLs (`//example.com`), absolute URLs, backslash paths,\n * and non-string values are rejected.\n *\n * @param {unknown} value - The value to check\n *\n * @returns {boolean} Whether the value is safe to use as an application redirect path\n */\nexport function isSafeRedirectPath(value: unknown): value is string {\n if (typeof value !== 'string') return false;\n if (!value.startsWith('/')) return false;\n if (value.startsWith('//')) return false;\n if (value.includes('\\\\')) return false;\n return true;\n}\n\n/**\n * Normalizes a redirect value into a safe same-origin application path.\n *\n * If an array is provided, the first value is checked. Unsafe values fall back\n * to the provided fallback path.\n *\n * @param {unknown} value - The redirect value to normalize\n * @param {string} fallback - The safe fallback path\n *\n * @returns {string} A safe redirect path\n */\nexport function normalizeRedirectPath(value: unknown, fallback = '/') {\n const redirectPath = Array.isArray(value) ? value[0] : value;\n return isSafeRedirectPath(redirectPath) ? redirectPath : fallback;\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAgB,yBAAyB,KAAa,cAAsB;CAExE,IAAI,CAAC,mBAAmB,YAAY,GAAG,MAAM,IAAI,MAAM,2BAA2B,aAAa,oEAAoE;CAEnK,MAAM,CAAC,aAAa,WAAW,MAAM,IAAI,MAAM,GAAG;CAClD,MAAM,CAAC,MAAM,SAAS,eAAe,IAAI,MAAM,GAAG;CAClD,MAAM,eAAe,IAAI,gBAAgB,QAAQ;CACjD,aAAa,IAAI,YAAY,YAAY;CACzC,MAAM,cAAc,aAAa,SAAS;CAC1C,OAAO,OAAO,GAAG,KAAK,GAAG,YAAY,GAAG,SAAS,GAAG,KAAK,GAAG;AAChE;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,OAAiC;CAChE,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,CAAC,MAAM,WAAW,GAAG,GAAG,OAAO;CACnC,IAAI,MAAM,WAAW,IAAI,GAAG,OAAO;CACnC,IAAI,MAAM,SAAS,IAAI,GAAG,OAAO;CACjC,OAAO;AACX;;;;;;;;;;;;AAaA,SAAgB,sBAAsB,OAAgB,WAAW,KAAK;CAClE,MAAM,eAAe,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;CACvD,OAAO,mBAAmB,YAAY,IAAI,eAAe;AAC7D"}
|
package/dist/vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":";;;;;;AAiBA
|
|
1
|
+
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":";;;;;;AAiBA;;;;AAAoE;iBAApD,wCAAA,CAAyC,GAAW;;;;;;iBASpD,gBAAA,CAAiB,WAAA,EAAa,GAAA,CAAI,QAAA,CAAS,UAAA,QAAkB,WAAA;;;;;;iBAU7D,eAAA,CAAgB,UAAA,EAAY,GAAA,CAAI,QAAA,CAAS,UAAA,QAAkB,UAAA;;;AAVgB;AAU3F;;;;;;;;;;;iBAmBgB,iBAAA,WAA4B,OAAA,GAAU,WAAA,CAAA,CAAa,YAAA,EAAc,GAAA,CAAI,QAAA,CAAS,CAAA"}
|
package/dist/vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.js","names":[],"sources":["../src/vue.ts"],"sourcesContent":["import { onActivated } from 'vue';\nimport type { Ref } from 'vue';\nimport {\n onBeforeRouteLeave,\n useRoute,\n} from 'vue-router';\n\nimport type { Nullable } from './types';\nimport { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify\n *\n * @returns {string} A new URL with the current route fullPath as the `redirect` parameter\n */\nexport function appendRedirectParamFromCurrentRouteToUrl(url: string) {\n return appendRedirectParamToUrl(url, useRoute().fullPath);\n}\n\n/**\n * Clears an interval referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<Nullable<ReturnType<typeof setInterval>>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null\n */\nexport function clearIntervalRef(intervalRef: Ref<Nullable<ReturnType<typeof setInterval>>>) {\n if (intervalRef.value) clearInterval(intervalRef.value);\n intervalRef.value = null;\n}\n\n/**\n * Clears a timeout referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<Nullable<ReturnType<typeof setTimeout>>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null\n */\nexport function clearTimeoutRef(timeoutRef: Ref<Nullable<ReturnType<typeof setTimeout>>>) {\n if (timeoutRef.value) clearTimeout(timeoutRef.value);\n timeoutRef.value = null;\n}\n\n/**\n * A Vue composition function that remembers and restores scroll position\n * of a scrollable container across route changes and keep-alive activation.\n *\n * Designed for use with `<KeepAlive>` components. Scroll state is saved on\n * route leave and restored when the component is activated again.\n *\n * Note: Without `<KeepAlive>`, the component state is destroyed on unmount,\n * so scroll position will not be preserved.\n *\n * @template T - The type of the scrollable element (defaults to HTMLElement)\n *\n * @param {Ref<Nullable<T>>} containerRef - A ref to the scrollable HTML element\n */\nexport function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<Nullable<T>>) {\n let scrollLeft = 0;\n let scrollTop = 0;\n onActivated(() => {\n if (!containerRef.value) return;\n containerRef.value.scrollLeft = scrollLeft;\n containerRef.value.scrollTop = scrollTop;\n });\n\n onBeforeRouteLeave(() => {\n scrollLeft = containerRef.value?.scrollLeft || 0;\n scrollTop = containerRef.value?.scrollTop || 0;\n });\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,yCAAyC,KAAa;
|
|
1
|
+
{"version":3,"file":"vue.js","names":[],"sources":["../src/vue.ts"],"sourcesContent":["import { onActivated } from 'vue';\nimport type { Ref } from 'vue';\nimport {\n onBeforeRouteLeave,\n useRoute,\n} from 'vue-router';\n\nimport type { Nullable } from './types';\nimport { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify\n *\n * @returns {string} A new URL with the current route fullPath as the `redirect` parameter\n */\nexport function appendRedirectParamFromCurrentRouteToUrl(url: string) {\n return appendRedirectParamToUrl(url, useRoute().fullPath);\n}\n\n/**\n * Clears an interval referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<Nullable<ReturnType<typeof setInterval>>>} intervalRef - A Vue ref holding a NodeJS.Timeout or null\n */\nexport function clearIntervalRef(intervalRef: Ref<Nullable<ReturnType<typeof setInterval>>>) {\n if (intervalRef.value) clearInterval(intervalRef.value);\n intervalRef.value = null;\n}\n\n/**\n * Clears a timeout referenced by a Vue ref and sets it to null.\n *\n * @param {Ref<Nullable<ReturnType<typeof setTimeout>>>} timeoutRef - A Vue ref holding a NodeJS.Timeout or null\n */\nexport function clearTimeoutRef(timeoutRef: Ref<Nullable<ReturnType<typeof setTimeout>>>) {\n if (timeoutRef.value) clearTimeout(timeoutRef.value);\n timeoutRef.value = null;\n}\n\n/**\n * A Vue composition function that remembers and restores scroll position\n * of a scrollable container across route changes and keep-alive activation.\n *\n * Designed for use with `<KeepAlive>` components. Scroll state is saved on\n * route leave and restored when the component is activated again.\n *\n * Note: Without `<KeepAlive>`, the component state is destroyed on unmount,\n * so scroll position will not be preserved.\n *\n * @template T - The type of the scrollable element (defaults to HTMLElement)\n *\n * @param {Ref<Nullable<T>>} containerRef - A ref to the scrollable HTML element\n */\nexport function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<Nullable<T>>) {\n let scrollLeft = 0;\n let scrollTop = 0;\n onActivated(() => {\n if (!containerRef.value) return;\n containerRef.value.scrollLeft = scrollLeft;\n containerRef.value.scrollTop = scrollTop;\n });\n\n onBeforeRouteLeave(() => {\n scrollLeft = containerRef.value?.scrollLeft || 0;\n scrollTop = containerRef.value?.scrollTop || 0;\n });\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,yCAAyC,KAAa;CAClE,OAAO,yBAAyB,KAAK,SAAS,EAAE,QAAQ;AAC5D;;;;;;AAOA,SAAgB,iBAAiB,aAA4D;CACzF,IAAI,YAAY,OAAO,cAAc,YAAY,KAAK;CACtD,YAAY,QAAQ;AACxB;;;;;;AAOA,SAAgB,gBAAgB,YAA0D;CACtF,IAAI,WAAW,OAAO,aAAa,WAAW,KAAK;CACnD,WAAW,QAAQ;AACvB;;;;;;;;;;;;;;;AAgBA,SAAgB,kBAAmD,cAAgC;CAC/F,IAAI,aAAa;CACjB,IAAI,YAAY;CAChB,kBAAkB;EACd,IAAI,CAAC,aAAa,OAAO;EACzB,aAAa,MAAM,aAAa;EAChC,aAAa,MAAM,YAAY;CACnC,CAAC;CAED,yBAAyB;EACrB,aAAa,aAAa,OAAO,cAAc;EAC/C,YAAY,aAAa,OAAO,aAAa;CACjD,CAAC;AACL"}
|
package/dist/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","names":[],"sources":["../src/web.ts"],"mappings":";;AASA
|
|
1
|
+
{"version":3,"file":"web.d.ts","names":[],"sources":["../src/web.ts"],"mappings":";;AASA;;;;AAAuE;AAevE;iBAfgB,2CAAA,CAA4C,GAAW;;;;;;;;AAeoB;;;iBAA3E,6CAAA,CAA8C,GAAA,UAAa,OAAA,YAAgB,MAAA,CAAA,OAAA"}
|
package/dist/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","names":[],"sources":["../src/web.ts"],"sourcesContent":["import { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify\n *\n * @returns {string} A new URL with the current location as the `redirect` parameter\n */\nexport function appendRedirectParamFromCurrentLocationToUrl(url: string) {\n const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n return appendRedirectParamToUrl(url, currentPath);\n}\n\n/**\n * Navigates to the given URL, appending the current browser location\n * (path, query, and hash) as the `redirect` query parameter.\n *\n * Useful for redirecting to login or other gateways while preserving\n * the current location for post-auth navigation.\n *\n * @param {string} url - The destination URL to navigate to\n * @param {number} [delayMs] - Optional delay in milliseconds before navigation\n */\nexport function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number) {\n if (delayMs === undefined) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));\n else return setTimeout(() => window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url)), delayMs);\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,4CAA4C,KAAa;
|
|
1
|
+
{"version":3,"file":"web.js","names":[],"sources":["../src/web.ts"],"sourcesContent":["import { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.\n *\n * @param {string} url - The base URL to modify\n *\n * @returns {string} A new URL with the current location as the `redirect` parameter\n */\nexport function appendRedirectParamFromCurrentLocationToUrl(url: string) {\n const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n return appendRedirectParamToUrl(url, currentPath);\n}\n\n/**\n * Navigates to the given URL, appending the current browser location\n * (path, query, and hash) as the `redirect` query parameter.\n *\n * Useful for redirecting to login or other gateways while preserving\n * the current location for post-auth navigation.\n *\n * @param {string} url - The destination URL to navigate to\n * @param {number} [delayMs] - Optional delay in milliseconds before navigation\n */\nexport function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number) {\n if (delayMs === undefined) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));\n else return setTimeout(() => window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url)), delayMs);\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,4CAA4C,KAAa;CAErE,OAAO,yBAAyB,KAAK,GADd,OAAO,SAAS,WAAW,OAAO,SAAS,SAAS,OAAO,SAAS,MAC3C;AACpD;;;;;;;;;;;AAYA,SAAgB,8CAA8C,KAAa,SAAkB;CACzF,IAAI,YAAY,KAAA,GAAW,OAAO,SAAS,OAAO,4CAA4C,GAAG,CAAC;MAC7F,OAAO,iBAAiB,OAAO,SAAS,OAAO,4CAA4C,GAAG,CAAC,GAAG,OAAO;AAClH"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.1.1",
|
|
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",
|
|
@@ -135,13 +135,13 @@
|
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
"devDependencies": {
|
|
138
|
-
"@antfu/eslint-config": "^
|
|
138
|
+
"@antfu/eslint-config": "^9.0.0",
|
|
139
139
|
"@kikiutils/eslint-config": "^9.1.2",
|
|
140
140
|
"@kikiutils/tsconfigs": "^6.0.0",
|
|
141
141
|
"@noble/hashes": "^2.2.0",
|
|
142
|
-
"@types/node": "^25.
|
|
142
|
+
"@types/node": "^25.7.0",
|
|
143
143
|
"@types/ssh2": "^1.15.5",
|
|
144
|
-
"@vitest/coverage-v8": "^4.1.
|
|
144
|
+
"@vitest/coverage-v8": "^4.1.6",
|
|
145
145
|
"async-validator": "^4.2.5",
|
|
146
146
|
"bson": "^7.2.0",
|
|
147
147
|
"changelogen": "^0.6.2",
|
|
@@ -149,30 +149,21 @@
|
|
|
149
149
|
"cross-env": "^10.1.0",
|
|
150
150
|
"date-fns": "^4.1.0",
|
|
151
151
|
"decimal.js": "^10.6.0",
|
|
152
|
-
"element-plus": "^2.
|
|
152
|
+
"element-plus": "^2.14.0",
|
|
153
153
|
"jsdom": "^29.1.1",
|
|
154
|
-
"knip": "^6.
|
|
155
|
-
"lru-cache": "^11.3.
|
|
154
|
+
"knip": "^6.13.1",
|
|
155
|
+
"lru-cache": "^11.3.6",
|
|
156
156
|
"millify": "^6.1.0",
|
|
157
157
|
"msgpackr": "^2.0.1",
|
|
158
158
|
"node-ssh": "^13.2.1",
|
|
159
159
|
"pino": "^10.3.1",
|
|
160
160
|
"pino-pretty": "^13.1.3",
|
|
161
|
-
"publint": "^0.3.
|
|
162
|
-
"tsdown": "^0.
|
|
161
|
+
"publint": "^0.3.21",
|
|
162
|
+
"tsdown": "^0.22.0",
|
|
163
163
|
"typescript": "^6.0.3",
|
|
164
164
|
"unplugin-unused": "^0.5.7",
|
|
165
|
-
"vitest": "^4.1.
|
|
166
|
-
"vue": "^3.5.
|
|
167
|
-
"vue-router": "^5.0.
|
|
168
|
-
},
|
|
169
|
-
"pnpm": {
|
|
170
|
-
"onlyBuiltDependencies": [
|
|
171
|
-
"cpu-features",
|
|
172
|
-
"esbuild",
|
|
173
|
-
"msgpackr-extract",
|
|
174
|
-
"ssh2",
|
|
175
|
-
"vue-demi"
|
|
176
|
-
]
|
|
165
|
+
"vitest": "^4.1.6",
|
|
166
|
+
"vue": "^3.5.34",
|
|
167
|
+
"vue-router": "^5.0.7"
|
|
177
168
|
}
|
|
178
169
|
}
|
package/src/classes/path.ts
CHANGED
|
@@ -18,6 +18,10 @@ import {
|
|
|
18
18
|
import type * as nodePath from 'node:path';
|
|
19
19
|
|
|
20
20
|
type DropFirstParameters<T extends (...args: any) => any> = Parameters<T> extends [any, ...infer R] ? R : never;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Values accepted by the `Path` constructor and path-composition methods.
|
|
24
|
+
*/
|
|
21
25
|
export type PathLike = fs.PathLike | Path;
|
|
22
26
|
|
|
23
27
|
/**
|
|
@@ -29,6 +33,11 @@ export type PathLike = fs.PathLike | Path;
|
|
|
29
33
|
export class Path {
|
|
30
34
|
readonly #value: string;
|
|
31
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Creates a normalized path value by joining the provided path segments.
|
|
38
|
+
*
|
|
39
|
+
* @param {PathLike[]} paths - Path segments accepted by Node.js `path.join` or another `Path` instance
|
|
40
|
+
*/
|
|
32
41
|
constructor(...paths: PathLike[]) {
|
|
33
42
|
this.#value = join(...this.#toStrings(paths));
|
|
34
43
|
}
|