@movk/core 1.2.0 → 1.2.2
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/bin/clean.mjs +54 -48
- package/dist/index.d.mts +131 -27
- package/dist/index.d.ts +131 -27
- package/dist/index.mjs +1 -1
- package/package.json +6 -6
package/bin/clean.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { rm } from 'node:fs/promises'
|
|
3
|
-
import { relative, resolve } from 'node:path'
|
|
2
|
+
import { lstat, rm } from 'node:fs/promises'
|
|
3
|
+
import { basename, relative, resolve } from 'node:path'
|
|
4
4
|
import process from 'node:process'
|
|
5
|
-
import
|
|
5
|
+
import { glob } from 'tinyglobby'
|
|
6
6
|
|
|
7
7
|
const DEFAULT_TARGETS = [
|
|
8
8
|
'node_modules',
|
|
@@ -11,69 +11,75 @@ const DEFAULT_TARGETS = [
|
|
|
11
11
|
'.output',
|
|
12
12
|
'.cache',
|
|
13
13
|
'dist',
|
|
14
|
-
'dist.zip'
|
|
14
|
+
'dist.zip',
|
|
15
15
|
]
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
async function removePath(path) {
|
|
19
|
-
try {
|
|
20
|
-
await rm(path, { recursive: true, force: true, maxRetries: 3 })
|
|
21
|
-
return { path, success: true }
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
if (e.code === 'ENOENT')
|
|
25
|
-
return { path, success: true }
|
|
26
|
-
return { path, success: false, error: e.message }
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function processBatch(paths) {
|
|
31
|
-
const results = []
|
|
32
|
-
for (let i = 0; i < paths.length; i += BATCH_SIZE) {
|
|
33
|
-
const batch = paths.slice(i, i + BATCH_SIZE)
|
|
34
|
-
results.push(...await Promise.all(batch.map(removePath)))
|
|
35
|
-
}
|
|
36
|
-
return results
|
|
37
|
-
}
|
|
16
|
+
const RE_PATH_SEP = /[/\\]/
|
|
17
|
+
const RE_TRAILING_SLASH = /\/+$/
|
|
38
18
|
|
|
39
19
|
async function clean() {
|
|
40
20
|
const start = Date.now()
|
|
41
21
|
const args = process.argv.slice(2)
|
|
42
|
-
const targets = args.length > 0 ? args : DEFAULT_TARGETS
|
|
22
|
+
const targets = (args.length > 0 ? args : DEFAULT_TARGETS)
|
|
23
|
+
.filter(t => t && !RE_PATH_SEP.test(t) && t !== '.' && t !== '..')
|
|
43
24
|
const root = resolve(process.cwd())
|
|
25
|
+
const targetSet = new Set(targets)
|
|
26
|
+
|
|
27
|
+
if (targets.length === 0) {
|
|
28
|
+
console.log('没有有效的清理目标')
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const rawPaths = await glob(targets.map(t => `**/${t}`), {
|
|
33
|
+
cwd: root,
|
|
34
|
+
onlyFiles: false,
|
|
35
|
+
dot: true,
|
|
36
|
+
absolute: true,
|
|
37
|
+
followSymbolicLinks: false,
|
|
38
|
+
ignore: ['**/.git/**'],
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const matched = Array.from(new Set(rawPaths), p => p.replace(RE_TRAILING_SLASH, ''))
|
|
42
|
+
.filter(p => p !== root && p.startsWith(`${root}/`) && targetSet.has(basename(p)))
|
|
43
|
+
.sort((a, b) => a.length - b.length)
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onlyFiles: false,
|
|
50
|
-
dot: true,
|
|
51
|
-
absolute: true,
|
|
52
|
-
ignore: ['**/node_modules/**/node_modules/**'],
|
|
53
|
-
suppressErrors: true
|
|
54
|
-
})
|
|
45
|
+
const deduped = []
|
|
46
|
+
for (const p of matched) {
|
|
47
|
+
if (!deduped.some(parent => p.startsWith(`${parent}/`)))
|
|
48
|
+
deduped.push(p)
|
|
55
49
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
|
|
51
|
+
const paths = []
|
|
52
|
+
for (const p of deduped) {
|
|
53
|
+
try {
|
|
54
|
+
if ((await lstat(p)).isSymbolicLink())
|
|
55
|
+
continue
|
|
56
|
+
}
|
|
57
|
+
catch { continue }
|
|
58
|
+
paths.push(p)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (
|
|
61
|
+
if (paths.length === 0) {
|
|
62
62
|
console.log('未找到需要清理的目标')
|
|
63
63
|
return
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
paths
|
|
66
|
+
paths.forEach(p => console.log(` ${relative(root, p)}`))
|
|
67
67
|
|
|
68
|
-
const results = await
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const results = await Promise.all(paths.map(async (p) => {
|
|
69
|
+
try {
|
|
70
|
+
await rm(p, { recursive: true, force: true, maxRetries: 3 })
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
return e.code === 'ENOENT' ? null : { path: p, error: e.message }
|
|
75
|
+
}
|
|
76
|
+
}))
|
|
72
77
|
|
|
73
|
-
|
|
78
|
+
const failed = results.filter(Boolean)
|
|
79
|
+
const duration = ((Date.now() - start) / 1000).toFixed(2)
|
|
80
|
+
console.log(`已清理 ${paths.length - failed.length}/${paths.length} 项,耗时 ${duration}s`)
|
|
74
81
|
|
|
75
82
|
if (failed.length) {
|
|
76
|
-
console.warn(`\n${failed.length} 项清理失败:`)
|
|
77
83
|
failed.forEach(f => console.warn(` ${relative(root, f.path)}: ${f.error}`))
|
|
78
84
|
process.exit(1)
|
|
79
85
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -538,6 +538,44 @@ type FirstParam<T, K extends keyof T> = T[K] extends [infer P, ...any[]] ? P : n
|
|
|
538
538
|
* // 结果: R 为 number; 若 T 非函数,则为 undefined
|
|
539
539
|
*/
|
|
540
540
|
type FirstParameter<T> = T extends (arg: infer P, ...args: any[]) => any ? P : undefined;
|
|
541
|
+
/**
|
|
542
|
+
* 强制 TypeScript 展平类型别名,使 IntelliSense 能完整枚举对象的所有属性。
|
|
543
|
+
*
|
|
544
|
+
* 常用于消除交叉类型(`A & B`)的「折叠」显示,让 IDE 悬停时直接展示合并后的属性列表。
|
|
545
|
+
*
|
|
546
|
+
* @typeParam T - 要展平的对象类型
|
|
547
|
+
* @example
|
|
548
|
+
* ```ts
|
|
549
|
+
* type A = { a: number } & { b: string }
|
|
550
|
+
* // IDE hover 显示 "{ a: number } & { b: string }"
|
|
551
|
+
*
|
|
552
|
+
* type B = Prettify<A>
|
|
553
|
+
* // IDE hover 显示 "{ a: number; b: string }"
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
type Prettify<T> = {
|
|
557
|
+
[K in keyof T]: T[K];
|
|
558
|
+
} & {};
|
|
559
|
+
/**
|
|
560
|
+
* 从对象类型中提取所有字面量键,过滤掉索引签名(`string`、`number`、`symbol`)。
|
|
561
|
+
*
|
|
562
|
+
* 用于需要精确枚举已知属性而不被索引签名污染 IntelliSense 的场景。
|
|
563
|
+
*
|
|
564
|
+
* @typeParam T - 可能含索引签名的对象类型
|
|
565
|
+
* @example
|
|
566
|
+
* ```ts
|
|
567
|
+
* interface Config {
|
|
568
|
+
* debug: boolean
|
|
569
|
+
* timeout: number
|
|
570
|
+
* [key: string]: unknown
|
|
571
|
+
* }
|
|
572
|
+
* // K = 'debug' | 'timeout'(索引签名 string 被过滤掉)
|
|
573
|
+
* type K = KnownKeys<Config>
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
type KnownKeys<T> = {
|
|
577
|
+
[K in keyof T]-?: string extends K ? never : number extends K ? never : symbol extends K ? never : K;
|
|
578
|
+
}[keyof T];
|
|
541
579
|
|
|
542
580
|
/**
|
|
543
581
|
* 数组合并策略
|
|
@@ -1723,6 +1761,40 @@ type Suggest<T extends string> = T | (string & {});
|
|
|
1723
1761
|
*/
|
|
1724
1762
|
type ReactiveValue<T, CTX = never> = [CTX] extends [never] ? MaybeRefOrGetter<T> : MaybeRefOrGetter<T> | ((ctx: CTX) => T);
|
|
1725
1763
|
type StripNullable<T> = T extends null | undefined ? never : T;
|
|
1764
|
+
/**
|
|
1765
|
+
* 检测类型 T 是否为 `any`
|
|
1766
|
+
*
|
|
1767
|
+
* 利用 `any` 会穿透类型运算的特性(`1 & any` 为 `any`,`0 extends any` 为 `true`)实现检测。
|
|
1768
|
+
*
|
|
1769
|
+
* @example
|
|
1770
|
+
* ```ts
|
|
1771
|
+
* type A = IsAny<any> // true
|
|
1772
|
+
* type B = IsAny<string> // false
|
|
1773
|
+
* type C = IsAny<never> // false
|
|
1774
|
+
* type D = IsAny<unknown> // false
|
|
1775
|
+
* ```
|
|
1776
|
+
*/
|
|
1777
|
+
type IsAny<T> = 0 extends (1 & T) ? true : false;
|
|
1778
|
+
/**
|
|
1779
|
+
* 将字面量类型宽化为其对应的基础类型,同时保留可选性(`undefined`)。
|
|
1780
|
+
*
|
|
1781
|
+
* - `any` → 保持原样
|
|
1782
|
+
* - `undefined | never` → `unknown`
|
|
1783
|
+
* - `boolean` 字面量 → `boolean`
|
|
1784
|
+
* - `string` 字面量 → `string`
|
|
1785
|
+
* - 其他类型 → 保持原样
|
|
1786
|
+
*
|
|
1787
|
+
* 主要用于工厂方法的 props 推断,防止 SFC 泛型默认参数产生的字面量类型污染调用签名。
|
|
1788
|
+
*
|
|
1789
|
+
* @example
|
|
1790
|
+
* ```ts
|
|
1791
|
+
* type A = WidenLiteral<'hello'> // string
|
|
1792
|
+
* type B = WidenLiteral<true> // boolean
|
|
1793
|
+
* type C = WidenLiteral<'foo' | undefined> // string | undefined
|
|
1794
|
+
* type D = WidenLiteral<number> // number
|
|
1795
|
+
* ```
|
|
1796
|
+
*/
|
|
1797
|
+
type WidenLiteral<T> = IsAny<T> extends true ? T : [NonNullable<T>] extends [never] ? unknown : NonNullable<T> extends boolean ? boolean | Extract<T, undefined> : NonNullable<T> extends string ? string | Extract<T, undefined> : T;
|
|
1726
1798
|
|
|
1727
1799
|
interface ParsedUrl {
|
|
1728
1800
|
/** 完整的原始 URL */
|
|
@@ -1756,35 +1828,67 @@ type QueryParamValue = string | number | boolean | null | undefined;
|
|
|
1756
1828
|
type QueryParams = Record<string, QueryParamValue | QueryParamValue[]>;
|
|
1757
1829
|
|
|
1758
1830
|
/**
|
|
1759
|
-
* vue-
|
|
1760
|
-
*
|
|
1831
|
+
* 增强版组件类型提取,支持泛型 SFC 的三种 vue-tsc 编译签名模式:
|
|
1832
|
+
* - 模式 A:函数参数可直接解析 → Parameters<T>[0]
|
|
1833
|
+
* - 模式 A':参数自引用(返回 any)→ 返回值 __ctx 成员
|
|
1834
|
+
* - 模式 B:DefineComponent 包装 → InstanceType<T>['$props']
|
|
1761
1835
|
*/
|
|
1762
1836
|
type IsComponent = StringOrVNode | Component | DefineComponent | ((...args: any[]) => any);
|
|
1763
1837
|
type ComponentType<T> = T extends new (...args: any) => {} ? 1 : T extends (...args: any) => any ? 2 : 0;
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
type
|
|
1768
|
-
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1838
|
+
/** 检测 any 类型 */
|
|
1839
|
+
type _IsAny<T> = 0 extends (1 & T) ? true : false;
|
|
1840
|
+
/** 从构造器组件提取 InstanceType 成员,映射展平避免 TS 延迟求值 */
|
|
1841
|
+
type _InstanceTypeMember<T, K extends string> = T extends abstract new (...args: any) => infer I ? K extends keyof I ? {
|
|
1842
|
+
[P in keyof I[K]]: I[K][P];
|
|
1843
|
+
} : never : never;
|
|
1844
|
+
/** 从可调用组件提取第一个参数(props),排除 any/never */
|
|
1845
|
+
type _FnParam<T> = T extends (...args: any) => any ? [Parameters<T>[0]] extends [never] ? never : _IsAny<Parameters<T>[0]> extends true ? never : Parameters<T>[0] : never;
|
|
1846
|
+
/** 从可调用组件的 ctx 参数提取指定成员(slots/attrs/emit) */
|
|
1847
|
+
type _FnCtxMember<T, K extends string> = T extends (props: any, ctx: infer Ctx, ...args: any) => any ? Ctx extends Record<K, infer M> ? NonNullable<M> : never : never;
|
|
1848
|
+
/** 从返回值 __ctx 提取指定字段(模式 A':参数自引用时 __ctx 仍可解析) */
|
|
1849
|
+
type _ReturnCtxMember<T, K extends string> = T extends (...args: any) => infer R ? R extends {
|
|
1850
|
+
__ctx?: infer Ctx;
|
|
1851
|
+
} ? Ctx extends Record<K, infer M> ? _IsAny<M> extends true ? never : {
|
|
1852
|
+
[P in keyof M]: M[P];
|
|
1853
|
+
} : never : never : never;
|
|
1854
|
+
/**
|
|
1855
|
+
* 组件 Props 提取
|
|
1856
|
+
* - 模式 A → Parameters[0]
|
|
1857
|
+
* - 模式 A' → __ctx.props
|
|
1858
|
+
* - 模式 B → $props
|
|
1859
|
+
* - 回退 → {}
|
|
1860
|
+
*/
|
|
1861
|
+
type ComponentProps<T> = _FnParam<T> extends never ? _ReturnCtxMember<T, 'props'> extends never ? _InstanceTypeMember<T, '$props'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$props'>> : NonNullable<_ReturnCtxMember<T, 'props'>> : _FnParam<T>;
|
|
1862
|
+
/**
|
|
1863
|
+
* 组件 Slots 提取
|
|
1864
|
+
* - 模式 A → ctx.slots
|
|
1865
|
+
* - 模式 A' → __ctx.slots
|
|
1866
|
+
* - 模式 B → $slots
|
|
1867
|
+
* - 回退 → {}
|
|
1868
|
+
*/
|
|
1869
|
+
type ComponentSlots<T> = _IsAny<_FnCtxMember<T, 'slots'>> extends true ? _ReturnCtxMember<T, 'slots'> extends never ? _InstanceTypeMember<T, '$slots'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$slots'>> : _ReturnCtxMember<T, 'slots'> : [_FnCtxMember<T, 'slots'>] extends [never] ? _ReturnCtxMember<T, 'slots'> extends never ? _InstanceTypeMember<T, '$slots'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$slots'>> : _ReturnCtxMember<T, 'slots'> : _FnCtxMember<T, 'slots'>;
|
|
1870
|
+
/**
|
|
1871
|
+
* 组件 Attrs 提取
|
|
1872
|
+
* - 模式 A → ctx.attrs
|
|
1873
|
+
* - 模式 A' → __ctx.attrs
|
|
1874
|
+
* - 模式 B → $attrs
|
|
1875
|
+
* - 回退 → {}
|
|
1876
|
+
*/
|
|
1877
|
+
type ComponentAttrs<T> = _IsAny<_FnCtxMember<T, 'attrs'>> extends true ? _ReturnCtxMember<T, 'attrs'> extends never ? _InstanceTypeMember<T, '$attrs'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$attrs'>> : _ReturnCtxMember<T, 'attrs'> : [_FnCtxMember<T, 'attrs'>] extends [never] ? _ReturnCtxMember<T, 'attrs'> extends never ? _InstanceTypeMember<T, '$attrs'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$attrs'>> : _ReturnCtxMember<T, 'attrs'> : _FnCtxMember<T, 'attrs'>;
|
|
1878
|
+
/**
|
|
1879
|
+
* 组件 Emit 提取
|
|
1880
|
+
* - 模式 A → ctx.emit
|
|
1881
|
+
* - 模式 A' → __ctx.emit
|
|
1882
|
+
* - 模式 B → $emit
|
|
1883
|
+
* - 回退 → {}
|
|
1884
|
+
*/
|
|
1885
|
+
type ComponentEmit<T> = _IsAny<_FnCtxMember<T, 'emit'>> extends true ? _ReturnCtxMember<T, 'emit'> extends never ? _InstanceTypeMember<T, '$emit'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$emit'>> : _ReturnCtxMember<T, 'emit'> : [_FnCtxMember<T, 'emit'>] extends [never] ? _ReturnCtxMember<T, 'emit'> extends never ? _InstanceTypeMember<T, '$emit'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$emit'>> : _ReturnCtxMember<T, 'emit'> : _FnCtxMember<T, 'emit'>;
|
|
1886
|
+
/**
|
|
1887
|
+
* 组件 Exposed 提取
|
|
1888
|
+
* - 构造器 → InstanceType<T>
|
|
1889
|
+
* - 可调用 → expose 参数
|
|
1890
|
+
* - 回退 → {}
|
|
1891
|
+
*/
|
|
1788
1892
|
type ComponentExposed<T> = T extends new (...args: any) => infer E ? E : T extends (props: any, ctx: any, expose: (exposed: infer E) => any, ...args: any) => any ? NonNullable<E> : {};
|
|
1789
1893
|
|
|
1790
1894
|
/**
|
|
@@ -2576,4 +2680,4 @@ declare function isString(value: any): value is string;
|
|
|
2576
2680
|
declare function isValidContainer(value: any): boolean;
|
|
2577
2681
|
|
|
2578
2682
|
export { Tree, appendQueryParam, buildUrl, camelCase, capitalize, chunk, convertSvgToPng, convertToKebabCase, createDeepMerge, debounce, deepClone, deepMerge, ensureLeadingSlash, ensureTrailingSlash, extractFilename, flatten, formatFileSize, getDomain, getPath, getQueryParam, getQueryParams, getRandomUUID, getRelativePath, getRootDomain, getUrlExtension, getUrlFilename, hasQueryParam, isAbsoluteUrl, isArray, isEmpty, isFunction, isNumber, isObject, isPlainObject, isRelativeUrl, isSameOrigin, isString, isValidContainer, isValidUrl, joinPath, joinUrl, kebabCase, lowerCase, lowerFirst, normalizeUrl, omit, omitUndefined, parseQuery, parseUrl, pascalCase, pick, removeLeadingSlash, removeQueryParam, removeTrailingSlash, replaceCurrentColor, safeDecodeURIComponent, safeEncodeURIComponent, separate, separateMany, setPath, setQueryParam, setQueryParams, simpleHash, sleep, sleepWithCancel, snakeCase, startCase, stringifyQuery, throttle, toAbsoluteUrl, toPath, triggerDownload, unique, upperCase, upperFirst, useAppStorage, useCopyCode, words };
|
|
2579
|
-
export type { AnyObject, ApiAwaitable, ApiAwaitedReturn, ApiUnwrapPromise, AppStorageReturn, ArrayFieldKeys, ArrayMergeStrategy, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ComponentType, CustomMerger, DeepMerge, DeepMergeOptions, DeepPartial, FirstParam, FirstParameter, GetFieldValue, GetObjectField, IsComponent, IsPlainObject, Merge, MutableByKeys, NestedKeys, NonObjectFieldKeys, NullHandlingStrategy, ObjectFieldKeys, OmitByKey, ParsedUrl, PartialByKeys, PathInput, PathSegment, PathSegments, PickByKey, QueryParamValue, QueryParams, ReactiveValue, ReadonlyByKeys, RenameKeys, RequiredByKeys, StorageConfig, StorageConfigInput, StorageType, StringOrVNode, StripNullable, Suggest, TreeConfig, TreeConfigInput, TreeNode, TreePredicate, TreeStats, TreeTransformer, TreeVisitor, UnionToIntersection, UnknownObject };
|
|
2683
|
+
export type { AnyObject, ApiAwaitable, ApiAwaitedReturn, ApiUnwrapPromise, AppStorageReturn, ArrayFieldKeys, ArrayMergeStrategy, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ComponentType, CustomMerger, DeepMerge, DeepMergeOptions, DeepPartial, FirstParam, FirstParameter, GetFieldValue, GetObjectField, IsAny, IsComponent, IsPlainObject, KnownKeys, Merge, MutableByKeys, NestedKeys, NonObjectFieldKeys, NullHandlingStrategy, ObjectFieldKeys, OmitByKey, ParsedUrl, PartialByKeys, PathInput, PathSegment, PathSegments, PickByKey, Prettify, QueryParamValue, QueryParams, ReactiveValue, ReadonlyByKeys, RenameKeys, RequiredByKeys, StorageConfig, StorageConfigInput, StorageType, StringOrVNode, StripNullable, Suggest, TreeConfig, TreeConfigInput, TreeNode, TreePredicate, TreeStats, TreeTransformer, TreeVisitor, UnionToIntersection, UnknownObject, WidenLiteral };
|
package/dist/index.d.ts
CHANGED
|
@@ -538,6 +538,44 @@ type FirstParam<T, K extends keyof T> = T[K] extends [infer P, ...any[]] ? P : n
|
|
|
538
538
|
* // 结果: R 为 number; 若 T 非函数,则为 undefined
|
|
539
539
|
*/
|
|
540
540
|
type FirstParameter<T> = T extends (arg: infer P, ...args: any[]) => any ? P : undefined;
|
|
541
|
+
/**
|
|
542
|
+
* 强制 TypeScript 展平类型别名,使 IntelliSense 能完整枚举对象的所有属性。
|
|
543
|
+
*
|
|
544
|
+
* 常用于消除交叉类型(`A & B`)的「折叠」显示,让 IDE 悬停时直接展示合并后的属性列表。
|
|
545
|
+
*
|
|
546
|
+
* @typeParam T - 要展平的对象类型
|
|
547
|
+
* @example
|
|
548
|
+
* ```ts
|
|
549
|
+
* type A = { a: number } & { b: string }
|
|
550
|
+
* // IDE hover 显示 "{ a: number } & { b: string }"
|
|
551
|
+
*
|
|
552
|
+
* type B = Prettify<A>
|
|
553
|
+
* // IDE hover 显示 "{ a: number; b: string }"
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
type Prettify<T> = {
|
|
557
|
+
[K in keyof T]: T[K];
|
|
558
|
+
} & {};
|
|
559
|
+
/**
|
|
560
|
+
* 从对象类型中提取所有字面量键,过滤掉索引签名(`string`、`number`、`symbol`)。
|
|
561
|
+
*
|
|
562
|
+
* 用于需要精确枚举已知属性而不被索引签名污染 IntelliSense 的场景。
|
|
563
|
+
*
|
|
564
|
+
* @typeParam T - 可能含索引签名的对象类型
|
|
565
|
+
* @example
|
|
566
|
+
* ```ts
|
|
567
|
+
* interface Config {
|
|
568
|
+
* debug: boolean
|
|
569
|
+
* timeout: number
|
|
570
|
+
* [key: string]: unknown
|
|
571
|
+
* }
|
|
572
|
+
* // K = 'debug' | 'timeout'(索引签名 string 被过滤掉)
|
|
573
|
+
* type K = KnownKeys<Config>
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
type KnownKeys<T> = {
|
|
577
|
+
[K in keyof T]-?: string extends K ? never : number extends K ? never : symbol extends K ? never : K;
|
|
578
|
+
}[keyof T];
|
|
541
579
|
|
|
542
580
|
/**
|
|
543
581
|
* 数组合并策略
|
|
@@ -1723,6 +1761,40 @@ type Suggest<T extends string> = T | (string & {});
|
|
|
1723
1761
|
*/
|
|
1724
1762
|
type ReactiveValue<T, CTX = never> = [CTX] extends [never] ? MaybeRefOrGetter<T> : MaybeRefOrGetter<T> | ((ctx: CTX) => T);
|
|
1725
1763
|
type StripNullable<T> = T extends null | undefined ? never : T;
|
|
1764
|
+
/**
|
|
1765
|
+
* 检测类型 T 是否为 `any`
|
|
1766
|
+
*
|
|
1767
|
+
* 利用 `any` 会穿透类型运算的特性(`1 & any` 为 `any`,`0 extends any` 为 `true`)实现检测。
|
|
1768
|
+
*
|
|
1769
|
+
* @example
|
|
1770
|
+
* ```ts
|
|
1771
|
+
* type A = IsAny<any> // true
|
|
1772
|
+
* type B = IsAny<string> // false
|
|
1773
|
+
* type C = IsAny<never> // false
|
|
1774
|
+
* type D = IsAny<unknown> // false
|
|
1775
|
+
* ```
|
|
1776
|
+
*/
|
|
1777
|
+
type IsAny<T> = 0 extends (1 & T) ? true : false;
|
|
1778
|
+
/**
|
|
1779
|
+
* 将字面量类型宽化为其对应的基础类型,同时保留可选性(`undefined`)。
|
|
1780
|
+
*
|
|
1781
|
+
* - `any` → 保持原样
|
|
1782
|
+
* - `undefined | never` → `unknown`
|
|
1783
|
+
* - `boolean` 字面量 → `boolean`
|
|
1784
|
+
* - `string` 字面量 → `string`
|
|
1785
|
+
* - 其他类型 → 保持原样
|
|
1786
|
+
*
|
|
1787
|
+
* 主要用于工厂方法的 props 推断,防止 SFC 泛型默认参数产生的字面量类型污染调用签名。
|
|
1788
|
+
*
|
|
1789
|
+
* @example
|
|
1790
|
+
* ```ts
|
|
1791
|
+
* type A = WidenLiteral<'hello'> // string
|
|
1792
|
+
* type B = WidenLiteral<true> // boolean
|
|
1793
|
+
* type C = WidenLiteral<'foo' | undefined> // string | undefined
|
|
1794
|
+
* type D = WidenLiteral<number> // number
|
|
1795
|
+
* ```
|
|
1796
|
+
*/
|
|
1797
|
+
type WidenLiteral<T> = IsAny<T> extends true ? T : [NonNullable<T>] extends [never] ? unknown : NonNullable<T> extends boolean ? boolean | Extract<T, undefined> : NonNullable<T> extends string ? string | Extract<T, undefined> : T;
|
|
1726
1798
|
|
|
1727
1799
|
interface ParsedUrl {
|
|
1728
1800
|
/** 完整的原始 URL */
|
|
@@ -1756,35 +1828,67 @@ type QueryParamValue = string | number | boolean | null | undefined;
|
|
|
1756
1828
|
type QueryParams = Record<string, QueryParamValue | QueryParamValue[]>;
|
|
1757
1829
|
|
|
1758
1830
|
/**
|
|
1759
|
-
* vue-
|
|
1760
|
-
*
|
|
1831
|
+
* 增强版组件类型提取,支持泛型 SFC 的三种 vue-tsc 编译签名模式:
|
|
1832
|
+
* - 模式 A:函数参数可直接解析 → Parameters<T>[0]
|
|
1833
|
+
* - 模式 A':参数自引用(返回 any)→ 返回值 __ctx 成员
|
|
1834
|
+
* - 模式 B:DefineComponent 包装 → InstanceType<T>['$props']
|
|
1761
1835
|
*/
|
|
1762
1836
|
type IsComponent = StringOrVNode | Component | DefineComponent | ((...args: any[]) => any);
|
|
1763
1837
|
type ComponentType<T> = T extends new (...args: any) => {} ? 1 : T extends (...args: any) => any ? 2 : 0;
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
type
|
|
1768
|
-
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1838
|
+
/** 检测 any 类型 */
|
|
1839
|
+
type _IsAny<T> = 0 extends (1 & T) ? true : false;
|
|
1840
|
+
/** 从构造器组件提取 InstanceType 成员,映射展平避免 TS 延迟求值 */
|
|
1841
|
+
type _InstanceTypeMember<T, K extends string> = T extends abstract new (...args: any) => infer I ? K extends keyof I ? {
|
|
1842
|
+
[P in keyof I[K]]: I[K][P];
|
|
1843
|
+
} : never : never;
|
|
1844
|
+
/** 从可调用组件提取第一个参数(props),排除 any/never */
|
|
1845
|
+
type _FnParam<T> = T extends (...args: any) => any ? [Parameters<T>[0]] extends [never] ? never : _IsAny<Parameters<T>[0]> extends true ? never : Parameters<T>[0] : never;
|
|
1846
|
+
/** 从可调用组件的 ctx 参数提取指定成员(slots/attrs/emit) */
|
|
1847
|
+
type _FnCtxMember<T, K extends string> = T extends (props: any, ctx: infer Ctx, ...args: any) => any ? Ctx extends Record<K, infer M> ? NonNullable<M> : never : never;
|
|
1848
|
+
/** 从返回值 __ctx 提取指定字段(模式 A':参数自引用时 __ctx 仍可解析) */
|
|
1849
|
+
type _ReturnCtxMember<T, K extends string> = T extends (...args: any) => infer R ? R extends {
|
|
1850
|
+
__ctx?: infer Ctx;
|
|
1851
|
+
} ? Ctx extends Record<K, infer M> ? _IsAny<M> extends true ? never : {
|
|
1852
|
+
[P in keyof M]: M[P];
|
|
1853
|
+
} : never : never : never;
|
|
1854
|
+
/**
|
|
1855
|
+
* 组件 Props 提取
|
|
1856
|
+
* - 模式 A → Parameters[0]
|
|
1857
|
+
* - 模式 A' → __ctx.props
|
|
1858
|
+
* - 模式 B → $props
|
|
1859
|
+
* - 回退 → {}
|
|
1860
|
+
*/
|
|
1861
|
+
type ComponentProps<T> = _FnParam<T> extends never ? _ReturnCtxMember<T, 'props'> extends never ? _InstanceTypeMember<T, '$props'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$props'>> : NonNullable<_ReturnCtxMember<T, 'props'>> : _FnParam<T>;
|
|
1862
|
+
/**
|
|
1863
|
+
* 组件 Slots 提取
|
|
1864
|
+
* - 模式 A → ctx.slots
|
|
1865
|
+
* - 模式 A' → __ctx.slots
|
|
1866
|
+
* - 模式 B → $slots
|
|
1867
|
+
* - 回退 → {}
|
|
1868
|
+
*/
|
|
1869
|
+
type ComponentSlots<T> = _IsAny<_FnCtxMember<T, 'slots'>> extends true ? _ReturnCtxMember<T, 'slots'> extends never ? _InstanceTypeMember<T, '$slots'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$slots'>> : _ReturnCtxMember<T, 'slots'> : [_FnCtxMember<T, 'slots'>] extends [never] ? _ReturnCtxMember<T, 'slots'> extends never ? _InstanceTypeMember<T, '$slots'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$slots'>> : _ReturnCtxMember<T, 'slots'> : _FnCtxMember<T, 'slots'>;
|
|
1870
|
+
/**
|
|
1871
|
+
* 组件 Attrs 提取
|
|
1872
|
+
* - 模式 A → ctx.attrs
|
|
1873
|
+
* - 模式 A' → __ctx.attrs
|
|
1874
|
+
* - 模式 B → $attrs
|
|
1875
|
+
* - 回退 → {}
|
|
1876
|
+
*/
|
|
1877
|
+
type ComponentAttrs<T> = _IsAny<_FnCtxMember<T, 'attrs'>> extends true ? _ReturnCtxMember<T, 'attrs'> extends never ? _InstanceTypeMember<T, '$attrs'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$attrs'>> : _ReturnCtxMember<T, 'attrs'> : [_FnCtxMember<T, 'attrs'>] extends [never] ? _ReturnCtxMember<T, 'attrs'> extends never ? _InstanceTypeMember<T, '$attrs'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$attrs'>> : _ReturnCtxMember<T, 'attrs'> : _FnCtxMember<T, 'attrs'>;
|
|
1878
|
+
/**
|
|
1879
|
+
* 组件 Emit 提取
|
|
1880
|
+
* - 模式 A → ctx.emit
|
|
1881
|
+
* - 模式 A' → __ctx.emit
|
|
1882
|
+
* - 模式 B → $emit
|
|
1883
|
+
* - 回退 → {}
|
|
1884
|
+
*/
|
|
1885
|
+
type ComponentEmit<T> = _IsAny<_FnCtxMember<T, 'emit'>> extends true ? _ReturnCtxMember<T, 'emit'> extends never ? _InstanceTypeMember<T, '$emit'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$emit'>> : _ReturnCtxMember<T, 'emit'> : [_FnCtxMember<T, 'emit'>] extends [never] ? _ReturnCtxMember<T, 'emit'> extends never ? _InstanceTypeMember<T, '$emit'> extends never ? {} : NonNullable<_InstanceTypeMember<T, '$emit'>> : _ReturnCtxMember<T, 'emit'> : _FnCtxMember<T, 'emit'>;
|
|
1886
|
+
/**
|
|
1887
|
+
* 组件 Exposed 提取
|
|
1888
|
+
* - 构造器 → InstanceType<T>
|
|
1889
|
+
* - 可调用 → expose 参数
|
|
1890
|
+
* - 回退 → {}
|
|
1891
|
+
*/
|
|
1788
1892
|
type ComponentExposed<T> = T extends new (...args: any) => infer E ? E : T extends (props: any, ctx: any, expose: (exposed: infer E) => any, ...args: any) => any ? NonNullable<E> : {};
|
|
1789
1893
|
|
|
1790
1894
|
/**
|
|
@@ -2576,4 +2680,4 @@ declare function isString(value: any): value is string;
|
|
|
2576
2680
|
declare function isValidContainer(value: any): boolean;
|
|
2577
2681
|
|
|
2578
2682
|
export { Tree, appendQueryParam, buildUrl, camelCase, capitalize, chunk, convertSvgToPng, convertToKebabCase, createDeepMerge, debounce, deepClone, deepMerge, ensureLeadingSlash, ensureTrailingSlash, extractFilename, flatten, formatFileSize, getDomain, getPath, getQueryParam, getQueryParams, getRandomUUID, getRelativePath, getRootDomain, getUrlExtension, getUrlFilename, hasQueryParam, isAbsoluteUrl, isArray, isEmpty, isFunction, isNumber, isObject, isPlainObject, isRelativeUrl, isSameOrigin, isString, isValidContainer, isValidUrl, joinPath, joinUrl, kebabCase, lowerCase, lowerFirst, normalizeUrl, omit, omitUndefined, parseQuery, parseUrl, pascalCase, pick, removeLeadingSlash, removeQueryParam, removeTrailingSlash, replaceCurrentColor, safeDecodeURIComponent, safeEncodeURIComponent, separate, separateMany, setPath, setQueryParam, setQueryParams, simpleHash, sleep, sleepWithCancel, snakeCase, startCase, stringifyQuery, throttle, toAbsoluteUrl, toPath, triggerDownload, unique, upperCase, upperFirst, useAppStorage, useCopyCode, words };
|
|
2579
|
-
export type { AnyObject, ApiAwaitable, ApiAwaitedReturn, ApiUnwrapPromise, AppStorageReturn, ArrayFieldKeys, ArrayMergeStrategy, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ComponentType, CustomMerger, DeepMerge, DeepMergeOptions, DeepPartial, FirstParam, FirstParameter, GetFieldValue, GetObjectField, IsComponent, IsPlainObject, Merge, MutableByKeys, NestedKeys, NonObjectFieldKeys, NullHandlingStrategy, ObjectFieldKeys, OmitByKey, ParsedUrl, PartialByKeys, PathInput, PathSegment, PathSegments, PickByKey, QueryParamValue, QueryParams, ReactiveValue, ReadonlyByKeys, RenameKeys, RequiredByKeys, StorageConfig, StorageConfigInput, StorageType, StringOrVNode, StripNullable, Suggest, TreeConfig, TreeConfigInput, TreeNode, TreePredicate, TreeStats, TreeTransformer, TreeVisitor, UnionToIntersection, UnknownObject };
|
|
2683
|
+
export type { AnyObject, ApiAwaitable, ApiAwaitedReturn, ApiUnwrapPromise, AppStorageReturn, ArrayFieldKeys, ArrayMergeStrategy, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ComponentType, CustomMerger, DeepMerge, DeepMergeOptions, DeepPartial, FirstParam, FirstParameter, GetFieldValue, GetObjectField, IsAny, IsComponent, IsPlainObject, KnownKeys, Merge, MutableByKeys, NestedKeys, NonObjectFieldKeys, NullHandlingStrategy, ObjectFieldKeys, OmitByKey, ParsedUrl, PartialByKeys, PathInput, PathSegment, PathSegments, PickByKey, Prettify, QueryParamValue, QueryParams, ReactiveValue, ReadonlyByKeys, RenameKeys, RequiredByKeys, StorageConfig, StorageConfigInput, StorageType, StringOrVNode, StripNullable, Suggest, TreeConfig, TreeConfigInput, TreeNode, TreePredicate, TreeStats, TreeTransformer, TreeVisitor, UnionToIntersection, UnknownObject, WidenLiteral };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useStorage as H}from"@vueuse/core";function Z(e){const{key:t,defaultValue:r,storage:n="localStorage",prefix:i="movk"}=e,o=`${i}:${t}`,s=(()=>{if(!(typeof window>"u"))return n==="localStorage"?localStorage:sessionStorage})();function a(h){if(h===null)return r;try{return JSON.parse(h)}catch(p){return console.warn(`[AppStorage] Failed to parse value for key "${o}". Using default value.`,p),r}}const c=H(o,r,s,{mergeDefaults:!0,serializer:{read:a,write:h=>JSON.stringify(h)}});function u(){if(!s)return r;const h=s.getItem(o);return a(h)}function l(h){c.value=h}function f(){s&&(c.value=null)}return{state:c,getItem:u,setItem:l,removeItem:f}}async function K(e){if(typeof e!="string")throw new TypeError("Text must be a string");if(typeof window>"u")return console.warn("useCopyCode: Not available in server environment"),!1;if(navigator.clipboard&&window.isSecureContext)try{return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard API failed, falling back to legacy method:",t)}try{return J(e)}catch(t){return console.error("Failed to copy text:",t),!1}}function J(e){if(typeof document>"u")return console.warn("copyTextLegacy: Document not available"),!1;const t=document.createElement("textarea"),r=document.activeElement,n=document.getSelection(),i=n&&n.rangeCount>0?n.getRangeAt(0):null;try{return t.value=e,t.setAttribute("readonly",""),t.setAttribute("contenteditable","true"),Object.assign(t.style,{contain:"strict",position:"absolute",left:"-9999px",top:"-9999px",fontSize:"12pt",border:"0",padding:"0",margin:"0",outline:"none",boxShadow:"none",background:"transparent"}),document.body.appendChild(t),t.focus(),t.select(),t.setSelectionRange&&t.setSelectionRange(0,e.length),document.execCommand("copy")}catch(o){return console.error("Legacy copy method failed:",o),!1}finally{t.parentNode&&document.body.removeChild(t),i&&n&&(n.removeAllRanges(),n.addRange(i)),r instanceof HTMLElement&&r.focus()}}async function X(e){if(!e||typeof e!="string")throw new Error("Invalid SVG string provided");if(typeof window>"u"||typeof document>"u")throw new TypeError("convertSvgToPng is only available in browser environment");return new Promise((t,r)=>{const n=new Image,i=document.createElement("canvas"),o=i.getContext("2d");if(!o){r(new Error("Canvas context not available"));return}n.onload=()=>{try{i.width=n.width,i.height=n.height,o.drawImage(n,0,0),i.toBlob(s=>{s?t(s):r(new Error("Failed to convert canvas to Blob"))},"image/png")}catch(s){r(new Error(`Error during canvas conversion: ${s}`))}},n.onerror=()=>{r(new Error("Failed to load SVG image"))};try{n.src=`data:image/svg+xml;base64,${btoa(e)}`}catch(s){r(new Error(`Failed to encode SVG: ${s}`))}})}function Y(e,t="file"){if(!e)return t;const r=e.get("content-disposition");if(r){const n=r.match(/filename\*?=(?:"([^"]+)"|([^;]+))/i);if(n){let i=n[1]??n[2];if(!i)return t;if(i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1)),r.includes("filename*=")){const o=i.split("''");if(o.length===2&&o[1])try{i=decodeURIComponent(o[1])}catch{return t}}return i}}return t}function ee(e){if(!Number.isFinite(e)||e<0||e===0)return"0 Bytes";const t=1024,r=["Bytes","KB","MB","GB","TB","PB"],n=Math.floor(Math.log(e)/Math.log(t));return n>=r.length?`${Number.parseFloat((e/t**(r.length-1)).toFixed(2))} ${r[r.length-1]}`:`${Number.parseFloat((e/t**n).toFixed(2))} ${r[n]}`}async function te(e,t){if(!e||typeof e!="string")throw new Error("Invalid SVG path provided");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch SVG file: ${r.status} ${r.statusText}`);const n=await r.text();if(!t)return n;if(typeof window>"u"||typeof DOMParser>"u")return console.warn("replaceCurrentColor: DOM manipulation not available in server environment, returning original SVG"),n;const i=new DOMParser().parseFromString(n,"image/svg+xml");if(i.querySelector("parsererror"))throw new Error("Invalid SVG content");const o=i.querySelector("svg");if(!o)throw new Error("No SVG element found in the document");o.hasAttribute("fill")||o.setAttribute("fill","currentColor");const s=a=>{a.getAttribute("fill")==="currentColor"&&a.setAttribute("fill",t),a.getAttribute("stroke")==="currentColor"&&a.setAttribute("stroke",t),Array.from(a.children).forEach(c=>{s(c)})};return s(o),new XMLSerializer().serializeToString(i)}catch(r){throw r instanceof Error?r:new Error(`Unexpected error occurred: ${r}`)}}function ne(e,t){if(typeof window>"u"||typeof document>"u"){console.warn("triggerDownload: Not available in server environment");return}const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}function w(e,t=new WeakMap){if(e===null||typeof e!="object")return e;try{const a=globalThis.structuredClone;if(typeof a=="function")return a(e)}catch(a){console.error("Error occurred while cloning:",a)}const r=e,n=t.get(r);if(n)return n;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const a=new Map;t.set(r,a);for(const[c,u]of e.entries())a.set(w(c,t),w(u,t));return a}if(e instanceof Set){const a=new Set;t.set(r,a);for(const c of e.values())a.add(w(c,t));return a}if(e instanceof ArrayBuffer)return e.slice(0);if(ArrayBuffer.isView(e)){const a=e.constructor;return new a(e)}if(e instanceof URL)return new URL(e.toString());if(e instanceof Error){const a=new e.constructor(e.message);return a.name=e.name,a.stack=e.stack,a}if(Array.isArray(e)){const a=[];t.set(r,a);for(const c of e)a.push(w(c,t));return a}const i=Object.getPrototypeOf(e),o=Object.create(i);t.set(r,o);const s=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const a of s){const c=Object.getOwnPropertyDescriptor(e,a);c&&("value"in c&&(c.value=w(e[a],t)),Object.defineProperty(o,a,c))}return o}function v(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.prototype.toString.call(e)==="[object Object]"}const re=new Set(["__proto__","constructor"]);function oe(e){return{arrayStrategy:e?.arrayStrategy??"concat",nullHandling:e?.nullHandling??"skip",customMerger:e?.customMerger}}function ie(e){return[...Object.keys(e),...Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))]}function $(e,t,r,n,i){const o={...e};for(const s of ie(t)){if(typeof s=="string"&&re.has(s))continue;const a=o[s],c=t[s];if(r.customMerger){const u=r.customMerger(s,a,c,n);if(u!==void 0){o[s]=u;continue}}if(c==null){if(r.nullHandling==="skip"&&s in o)continue;o[s]=c;continue}if(Array.isArray(c)){if(Array.isArray(a))switch(r.arrayStrategy){case"replace":o[s]=[...c];break;case"unique":o[s]=[...new Set([...a,...c])];break;case"concat":default:o[s]=[...a,...c];break}else o[s]=[...c];continue}if(v(c)){if(i.has(c)){o[s]=i.get(c);continue}const u=[...n,s],l={};if(i.set(c,l),v(a)){const f=$(a,c,r,u,i);Object.assign(l,f),o[s]=l}else{const f=$({},c,r,u,i);Object.assign(l,f),o[s]=l}continue}o[s]=c}return o}function R(e,t){if(!Array.isArray(e))return{};const r=oe(t),n=e.filter(v);if(n.length===0)return{};const i=new WeakMap;return n.reduce((o,s)=>$(o,s,r,[],i),{})}function se(e){return t=>R(t,e)}function ce(e,t){if(!e||typeof e!="object")return{};const r=new Set(t),n={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&!r.has(i)&&(n[i]=e[i]);return n}function ae(e){return!e||typeof e!="object"||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function ue(e,t){if(!e||typeof e!="object")return{};const r={};for(const n of t)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}function le(e,t){if(!e||typeof e!="object")return{picked:{},omitted:{}};if(t.length===0)return{picked:{},omitted:{...e}};const r=new Set(t),n={},i={};for(const o in e)if(Object.hasOwn(e,o)){const s=o;r.has(s)?n[o]=e[s]:i[o]=e[s]}return{picked:n,omitted:i}}function fe(e,t){if(!e||typeof e!="object")return{...Object.fromEntries(Object.keys(t).map(o=>[o,{}])),others:{}};const r=Object.keys(t),n=new Map;for(const o of r){const s=new Set(t[o]);n.set(o,s)}const i=Object.create(null);for(const o of r)i[o]={};i.others={};for(const o in e)if(Object.hasOwn(e,o)){const s=o;let a=!1;for(const c of r)if(n.get(c).has(s)){i[c][o]=e[s],a=!0;break}a||(i.others[o]=e[s])}return i}function j(e){if(Array.isArray(e))return e.slice();const t=[];if(e==="")return t;let r=0;const n=e,i=n.length;function o(a){let c="",u=a;for(;u<i;){const l=n.charCodeAt(u);if(l===46)break;if(l===92){u++,u<i&&(c+=n[u]),u++;continue}if(l===91)break;c+=n[u],u++}return{value:c,next:u}}function s(a){let c=a+1;for(;c<i&&/\s/.test(n[c]);)c++;if(c>=i)throw new Error('Invalid path: missing closing "]"');const u=n[c];if(u==='"'||u==="'"){const h=u;c++;let p="",d=!1;for(;c<i;){if(n.charCodeAt(c)===92){c++,c<i&&(p+=n[c]),c++;continue}if(n[c]===h){d=!0,c++;break}p+=n[c],c++}if(!d)throw new Error("Invalid path: missing closing quote in bracket");for(;c<i&&/\s/.test(n[c]);)c++;if(c>=i||n[c]!=="]")throw new Error('Invalid path: missing closing "]"');return c++,{segment:p,next:c}}let l="";for(;c<i&&n[c]!=="]";)l+=n[c],c++;if(c>=i)throw new Error('Invalid path: missing closing "]"');const f=l.trim();return/^(?:0|[1-9]\d*)$/.test(f)?(c++,{segment:Number(f),next:c}):(c++,{segment:f,next:c})}for(;r<i;){const a=n.charCodeAt(r);if(a===46){r++;continue}if(a===91){const{segment:l,next:f}=s(r);l!==null&&t.push(l),r=f;continue}const{value:c,next:u}=o(r);(c.length>0||u<i&&n[u]===".")&&t.push(c),r=u}return t}function he(e,t,r){const n=j(t);if(n.length===0)return e;let i=e;for(let o=0;o<n.length;o++){if(i==null)return r;const s=n[o];i=i[s]}return i===void 0?r:i}function pe(e){let t="";for(let r=0;r<e.length;r++){const n=e[r];if(typeof n=="number"&&Number.isInteger(n)&&n>=0){t+=`[${n}]`;continue}const i=String(n),o=/^[A-Z_$][\w$]*$/i.test(i);if(t.length===0&&o){t+=i;continue}if(o){t+=`.${i}`;continue}const s=i.replace(/\\/g,"\\\\").replace(/'/g,"\\'");t+=`['${s}']`}return t}function I(e){return e!==null&&typeof e=="object"}function de(e,t,r){const n=j(t);if(n.length===0)return e;let i=e;for(let o=0;o<n.length;o++){const s=n[o];if(o===n.length-1){i[s]=r;break}const a=n[o+1];let c=i[s];const u=typeof a=="number";if(I(c)?u&&!Array.isArray(c)&&(c=[],i[s]=c):(c=u?[]:{},i[s]=c),u&&Array.isArray(c)){const l=Number(a);Number.isInteger(l)&&l>=0&&c.length<=l&&(c.length=l+1)}i=c}return e}function ge(e){let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return Math.abs(t).toString(36)}function me(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function P(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return e;const r=i=>i.replace(/([a-z\d])([A-Z])/g,"$1-$2").toLowerCase(),n={};for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)){const o=r(i),s=e[i];t&&s&&typeof s=="object"&&!Array.isArray(s)?n[o]=P(s,!0):n[o]=s}return n}function E(e){return e?e.replace(/[_-]/g," ").match(/[A-Z]{2,}(?=[A-Z][a-z]|\b)|[A-Z]?[a-z]+|\d+/g)||[]:[]}function b(e,t){if(!e)return"";const r=E(e);return r.length===0?"":r.map((n,i)=>{const o=n.toLowerCase(),s=n.toUpperCase();if(t.transform)return t.transform(n,i,o,s);switch(t.casing){case"lower":return o;case"upper":return s;case"capitalize":return o.charAt(0).toUpperCase()+o.slice(1);default:return n}}).join(t.separator??"")}function L(e,t){if(!e)return"";const r=e.charAt(0);return(t?r.toUpperCase():r.toLowerCase())+e.slice(1)}function ye(e){return b(e,{separator:"",transform:(t,r,n)=>r===0?n:n.charAt(0).toUpperCase()+n.slice(1)})}function we(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():""}function be(e){return b(e,{separator:"-",casing:"lower"})}function Ae(e){return b(e,{separator:" ",casing:"lower"})}function xe(e){return L(e,!1)}function ve(e){return b(e,{separator:"",casing:"capitalize"})}function Se(e){return b(e,{separator:"_",casing:"lower"})}function Ce(e){return e?E(e).map(t=>t.toUpperCase()===t&&t.length>1?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" "):""}function $e(e){return b(e,{separator:" ",casing:"upper"})}function je(e){return L(e,!0)}const U={id:"id",pid:"pid",children:"children"};function g(e={}){return{id:e.id??U.id,pid:e.pid??U.pid,children:e.children??U.children}}function*S(e,t={},r=[]){const{children:n}=g(t);let i=0;for(const o of e){const s=[...r,o];yield{node:o,path:s,depth:r.length,index:i++};const a=o[n];a&&a.length>0&&(yield*S(a,t,s))}}function*O(e,t={}){const{children:r}=g(t),n=e.map((o,s)=>({node:o,path:[o],depth:0,index:s}));let i=e.length;for(;n.length>0;){const o=n.shift();yield o;const s=o.node[r];s&&s.length>0&&s.forEach(a=>{const c=[...o.path,a];n.push({node:a,path:c,depth:o.depth+1,index:i++})})}}function k(e){switch(e){case"find":case"findAll":case"filter":case"transform":case"forEach":case"stats":case"validate":return"dfs";default:return"dfs"}}function Ee(e,t={}){const{id:r,pid:n,children:i}=g(t);if(!Array.isArray(e)||e.length===0)return[];const o=new Map,s=[];return e.forEach(a=>{const{[i]:c,...u}=a,l={...u,[i]:[]};o.set(a[r],l)}),e.forEach(a=>{const c=o.get(a[r]),u=a[n];u&&o.has(u)?o.get(u)[i].push(c):s.push(c)}),s}function Ue(e,t={}){const{children:r}=g(t),n=[],i=Array.isArray(e)?e:[e],o=s=>{const{[r]:a,...c}=s;n.push(c),a&&a.length>0&&a.forEach(o)};return i.forEach(o),n}function Oe(e,t={}){const{children:r}=g(t),n=Array.isArray(e)?e:[e];let i=0;const o=s=>{i++;const a=s[r];a&&a.length>0&&a.forEach(o)};return n.forEach(o),i}function ke(e,t,r,n={}){const{id:i,children:o}=g(n),{[o]:s,...a}=r,c={...a,[o]:[]},u=(l,f)=>{for(let h=0;h<l.length;h++){const p=l[h];if(!p)continue;if(p[i]===t)return l.splice(h,0,c),!0;const d=p[o];if(d&&d.length>0){const y=[...f,p];if(u(d,y))return!0}}return!1};return u(e,[])}function Re(e,t,r,n={}){const{id:i,children:o}=g(n),{[o]:s,...a}=r,c={...a,[o]:[]},u=(l,f)=>{for(let h=0;h<l.length;h++){const p=l[h];if(!p)continue;if(p[i]===t)return l.splice(h+1,0,c),!0;const d=p[o];if(d&&d.length>0){const y=[...f,p];if(u(d,y))return!0}}return!1};return u(e,[])}function Ie(e,t,r={}){const{id:n,children:i}=g(r),o=s=>{for(let a=0;a<s.length;a++){const c=s[a];if(!c)continue;if(c[n]===t)return s.splice(a,1)[0];const u=c[i];if(u&&u.length>0){const l=o(u);if(l)return l}}};return o(e)}function T(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("find")==="dfs"?S(n,r):O(n,r);for(const o of i)if(t({node:o.node,depth:o.depth,path:o.path,index:o.index}))return o.node}function Pe(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("findAll"),o=[],s=i==="dfs"?S(n,r):O(n,r);for(const a of s)t({node:a.node,depth:a.depth,path:a.path,index:a.index})&&o.push(a.node);return o}function Le(e,t,r={}){const{id:n}=g(r);return T(e,({node:i})=>i[n]===t,r)}function Te(e,t,r={}){const{children:n}=g(r),i=Array.isArray(e)?e:[e],o=[],s=(a,c,u,l=0)=>{const f=a[n],h=[];if(f&&f.length>0){const p=[...u,a];f.forEach((d,y)=>{const x=s(d,c+1,p,y);x&&h.push(x)})}if(t({node:a,depth:c,path:u,index:l})||h.length>0){const{[n]:p,...d}=a;return{...d,[n]:h}}return null};return i.forEach((a,c)=>{const u=s(a,0,[a],c);u&&o.push(u)}),o}function Me(e,t,r={}){const{children:n}=g(r),i=Array.isArray(e)?e:[e],o=[],s=(a,c,u,l=0)=>{const f=a[n],h=[];if(f&&f.length>0){const x=[...u,a];f.forEach((_,q)=>{h.push(s(_,c+1,x,q))})}const p=t({node:a,depth:c,path:u,index:l}),{[n]:d,...y}=p;return{...y,[n]:h}};return i.forEach((a,c)=>{o.push(s(a,0,[a],c))}),o}function Ne(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("forEach")==="dfs"?S(n,r):O(n,r);for(const o of i)if(t({node:o.node,depth:o.depth,path:o.path,index:o.index})===!1)break}function Fe(e,t={}){const{children:r}=g(t),n=Array.isArray(e)?e:[e];let i=0,o=0,s=0,a=0;const c=(u,l)=>{i++,s=Math.max(s,l);const f=u[r];f&&f.length>0?(a++,f.forEach(h=>c(h,l+1))):o++};return n.forEach(u=>c(u,1)),{total:i,leaves:o,depth:s,branches:a}}function De(e,t={}){const{id:r,children:n}=g(t),i=Array.isArray(e)?e:[e],o=[],s=new Set,a=(c,u,l)=>{const f=c[r];if(!f||typeof f!="string"){o.push(`Node at depth ${u} has invalid or missing ID`);return}if(s.has(f)){o.push(`Duplicate ID found: ${f}`);return}if(s.add(f),l.some(p=>p[r]===f)){o.push(`Circular reference detected for ID: ${f}`);return}const h=c[n];if(h!==void 0&&!Array.isArray(h)){o.push(`Node ${f} has invalid children property (not an array)`);return}if(h&&h.length>0){const p=[...l,c];h.forEach(d=>{a(d,u+1,p)})}};return i.forEach(c=>a(c,0,[])),{isValid:o.length===0,errors:o}}class ze{static fromList=Ee;static toList=Ue;static estimateSize=Oe;static find=T;static findAll=Pe;static findById=Le;static insertBefore=ke;static insertAfter=Re;static remove=Ie;static filter=Te;static transform=Me;static forEach=Ne;static getStats=Fe;static validate=De}function Be(e,t){const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function We(e,t=1){return t===1?e.flat():e.flat(t)}function Ve(e){return[...new Set(e)]}function Ge(e,t){let r;return(...n)=>{clearTimeout(r),r=setTimeout(()=>e(...n),t)}}function Qe(e){return new Promise(t=>setTimeout(t,e))}function _e(e){let t,r;return{promise:new Promise((n,i)=>{r=i,t=setTimeout(n,e)}),cancel:()=>{clearTimeout(t),r(new Error("Sleep was cancelled"))}}}function qe(e,t){let r=!1;return function(...n){r||(e.apply(this,n),r=!0,setTimeout(()=>{r=!1},t))}}function m(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);return{href:r.href,protocol:r.protocol,host:r.host,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search,hash:r.hash,auth:r.username?`${r.username}${r.password?`:${r.password}`:""}`:"",origin:r.origin}}catch{return null}}function He(e){if(!e)return!1;try{return!!new URL(e)}catch{return!1}}function M(e){return e?e.startsWith("//")?!0:/^[a-z][a-z0-9+.-]*:/i.test(e):!1}function Ze(e){return e?!M(e):!1}function N(e){return m(e)?.hostname??""}function Ke(e){const t=N(e);if(!t)return"";const r=["co.uk","co.jp","co.kr","co.nz","co.za","co.in","com.au","com.br","com.cn","com.tw","com.hk","com.sg","org.uk","org.au","net.au","net.cn","gov.uk","gov.au","edu.au","edu.cn","ac.uk","ac.jp"],n=t.split(".");if(n.length>=3){const i=n.slice(-2).join(".");if(r.includes(i))return n.slice(-3).join(".")}return n.length>=2?n.slice(-2).join("."):t}function Je(e){const t=m(e);if(!t)return"";const r=t.pathname.split("/").pop()||"",n=r.lastIndexOf(".");return n===-1||n===0?"":r.slice(n+1).toLowerCase()}function Xe(e,t=!0){const r=m(e);if(!r)return"";const n=r.pathname.split("/").pop()||"";if(!n||n==="/")return"";if(t)return n;const i=n.lastIndexOf(".");return i>0?n.slice(0,i):n}function A(e){if(!e)return{};const t=e.startsWith("?")?e.slice(1):e;if(!t)return{};const r={},n=new URLSearchParams(t);for(const[i,o]of n.entries()){const s=r[i];s!==void 0?Array.isArray(s)?s.push(o):r[i]=[s,o]:r[i]=o}return r}function C(e,t={}){const{skipNull:r=!1,skipEmpty:n=!1,arrayFormat:i="repeat"}=t,o=[];for(const[s,a]of Object.entries(e)){if(a==null){if(r)continue;o.push(`${encodeURIComponent(s)}=`);continue}if(Array.isArray(a)){const u=a.filter(l=>l==null?!r:l===""?!n:!0);if(u.length===0)continue;switch(i){case"bracket":for(const l of u)o.push(`${encodeURIComponent(s)}[]=${encodeURIComponent(String(l??""))}`);break;case"index":u.forEach((l,f)=>{o.push(`${encodeURIComponent(s)}[${f}]=${encodeURIComponent(String(l??""))}`)});break;case"comma":o.push(`${encodeURIComponent(s)}=${u.map(l=>encodeURIComponent(String(l??""))).join(",")}`);break;default:for(const l of u)o.push(`${encodeURIComponent(s)}=${encodeURIComponent(String(l??""))}`)}continue}const c=String(a);c===""&&n||o.push(`${encodeURIComponent(s)}=${encodeURIComponent(c)}`)}return o.join("&")}function Ye(e,t){if(!e||!t)return null;try{return new URL(e,"http://localhost").searchParams.get(t)}catch{const r=e.indexOf("?");if(r===-1)return null;const n=A(e.slice(r))[t];return Array.isArray(n)?n[0]??null:n??null}}function et(e,t){if(!e||!t)return[];try{return new URL(e,"http://localhost").searchParams.getAll(t)}catch{const r=e.indexOf("?");if(r===-1)return[];const n=A(e.slice(r))[t];return n?Array.isArray(n)?n:[n]:[]}}function F(e,t,r){if(!e||!t)return e;try{const n=new URL(e);return r==null?n.searchParams.delete(t):n.searchParams.set(t,String(r)),n.toString()}catch{const n=e.indexOf("#"),i=n!==-1?e.slice(n+1):"",o=n!==-1?e.slice(0,n):e,s=o.indexOf("?"),a=s!==-1?o.slice(0,s):o,c=s!==-1?o.slice(s+1):"",u=A(c);r==null?delete u[t]:u[t]=String(r);const l=C(u);let f=a;return l&&(f+=`?${l}`),i&&(f+=`#${i}`),f}}function tt(e,t){let r=e;for(const[n,i]of Object.entries(t))if(Array.isArray(i)){r=z(r,n);for(const o of i)r=D(r,n,o)}else r=F(r,n,i);return r}function D(e,t,r){if(!e||!t||r===null||r===void 0)return e;try{const n=new URL(e);return n.searchParams.append(t,String(r)),n.toString()}catch{const[n,i]=e.split("?"),[o,s]=(i||"").split("#"),a=o?"&":"",c=`${encodeURIComponent(t)}=${encodeURIComponent(String(r))}`;let u=n||"";return u+=`?${o||""}${a}${c}`,s&&(u+=`#${s}`),u}}function z(e,t){if(!e||!t)return e;try{const r=new URL(e);return r.searchParams.delete(t),r.toString()}catch{const[r,n]=e.split("?"),[i,o]=(n||"").split("#"),s=A(i||"");delete s[t];const a=C(s);let c=r||"";return a&&(c+=`?${a}`),o&&(c+=`#${o}`),c}}function nt(e,t){if(!e||!t)return!1;try{return new URL(e,"http://localhost").searchParams.has(t)}catch{const r=e.indexOf("?");if(r===-1)return!1;const n=A(e.slice(r));return t in n}}function B(...e){if(e.length===0)return"";const t=e.filter(n=>n!=null&&n!=="");if(t.length===0)return"";let r=t[0];for(let n=1;n<t.length;n++){const i=t[n],o=r.endsWith("/"),s=i.startsWith("/");o&&s?r+=i.slice(1):!o&&!s?r+=`/${i}`:r+=i}return r}function rt(e){if(!e)return"";const t=m(e);if(t){const i=W(t.pathname);return`${t.origin}${i}${t.search}${t.hash}`}const[r,n]=e.split(/(?=[?#])/);return W(r||"")+(n||"")}function W(e){if(!e)return"";const t=e.startsWith("/"),r=e.endsWith("/")&&e.length>1,n=e.split("/").filter(Boolean),i=[];for(const s of n)if(s!=="."){if(s===".."){i.pop();continue}i.push(s)}let o=i.join("/");return t&&(o=`/${o}`),r&&o!=="/"&&(o+="/"),o||(t?"/":"")}function ot(e){if(!e)return"";const[t,...r]=e.split(/(?=[?#])/);return t?(t.length>1&&t.endsWith("/")?t.slice(0,-1):t)+r.join(""):e}function it(e){if(!e)return"/";const t=e.search(/[?#]/),r=t===-1?e:e.slice(0,t),n=t===-1?"":e.slice(t);return r?(r.endsWith("/")?r:`${r}/`)+n:`/${n}`}function st(e){return e?e.replace(/^\/+/,""):""}function ct(e){return e?e.startsWith("/")?e:`/${e}`:"/"}function at(e,t,r,n){let i=e;if(t&&(i=B(i,t)),r&&Object.keys(r).length>0){const o=C(r);o&&(i+=(i.includes("?")?"&":"?")+o)}if(n){const o=n.startsWith("#")?n:`#${n}`;i+=o}return i}function ut(e){if(!e)return"";try{return decodeURIComponent(e)}catch{return e}}function lt(e){if(!e)return"";try{return encodeURIComponent(e)}catch{return e}}function ft(e,t){const r=m(e),n=m(t);return!r||!n?!1:r.origin===n.origin}function ht(e,t){if(!e)return t;try{return new URL(e,t).href}catch{return e}}function pt(e,t){const r=m(e),n=m(t);if(!r||!n||r.origin!==n.origin)return t;const i=r.pathname.split("/").filter(Boolean),o=n.pathname.split("/").filter(Boolean);let s=0;const a=Math.min(i.length,o.length);for(let h=0;h<a&&i[h]===o[h];h++)s++;const c=i.length-s,u=o.slice(s),l=[];for(let h=0;h<c;h++)l.push("..");l.push(...u);let f=l.join("/")||".";return n.search&&(f+=n.search),n.hash&&(f+=n.hash),f}function V(e){return Array.isArray(e)}function G(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Q(e){return typeof e=="string"}function dt(e){return e==null?!0:V(e)||Q(e)?e.length===0:G(e)?Object.keys(e).length===0:!1}function gt(e){return typeof e=="function"}function mt(e){return typeof e=="number"&&!Number.isNaN(e)}export{ze as Tree,D as appendQueryParam,at as buildUrl,ye as camelCase,we as capitalize,Be as chunk,X as convertSvgToPng,P as convertToKebabCase,se as createDeepMerge,Ge as debounce,w as deepClone,R as deepMerge,ct as ensureLeadingSlash,it as ensureTrailingSlash,Y as extractFilename,We as flatten,ee as formatFileSize,N as getDomain,he as getPath,Ye as getQueryParam,et as getQueryParams,me as getRandomUUID,pt as getRelativePath,Ke as getRootDomain,Je as getUrlExtension,Xe as getUrlFilename,nt as hasQueryParam,M as isAbsoluteUrl,V as isArray,dt as isEmpty,gt as isFunction,mt as isNumber,G as isObject,v as isPlainObject,Ze as isRelativeUrl,ft as isSameOrigin,Q as isString,I as isValidContainer,He as isValidUrl,pe as joinPath,B as joinUrl,be as kebabCase,Ae as lowerCase,xe as lowerFirst,rt as normalizeUrl,ce as omit,ae as omitUndefined,A as parseQuery,m as parseUrl,ve as pascalCase,ue as pick,st as removeLeadingSlash,z as removeQueryParam,ot as removeTrailingSlash,te as replaceCurrentColor,ut as safeDecodeURIComponent,lt as safeEncodeURIComponent,le as separate,fe as separateMany,de as setPath,F as setQueryParam,tt as setQueryParams,ge as simpleHash,Qe as sleep,_e as sleepWithCancel,Se as snakeCase,Ce as startCase,C as stringifyQuery,qe as throttle,ht as toAbsoluteUrl,j as toPath,ne as triggerDownload,Ve as unique,$e as upperCase,je as upperFirst,Z as useAppStorage,K as useCopyCode,E as words};
|
|
1
|
+
import{useStorage as K}from"@vueuse/core";function J(e){const{key:t,defaultValue:r,storage:n="localStorage",prefix:i="movk"}=e,o=`${i}:${t}`,s=(()=>{if(!(typeof window>"u"))return n==="localStorage"?localStorage:sessionStorage})();function a(h){if(h===null)return r;try{return JSON.parse(h)}catch(p){return console.warn(`[AppStorage] Failed to parse value for key "${o}". Using default value.`,p),r}}const c=K(o,r,s,{mergeDefaults:!0,serializer:{read:a,write:h=>JSON.stringify(h)}});function u(){if(!s)return r;const h=s.getItem(o);return a(h)}function f(h){c.value=h}function l(){s&&(c.value=null)}return{state:c,getItem:u,setItem:f,removeItem:l}}async function X(e){if(typeof e!="string")throw new TypeError("Text must be a string");if(typeof window>"u")return console.warn("useCopyCode: Not available in server environment"),!1;if(navigator.clipboard&&window.isSecureContext)try{return await navigator.clipboard.writeText(e),!0}catch(t){console.warn("Clipboard API failed, falling back to legacy method:",t)}try{return Y(e)}catch(t){return console.error("Failed to copy text:",t),!1}}function Y(e){if(typeof document>"u")return console.warn("copyTextLegacy: Document not available"),!1;const t=document.createElement("textarea"),r=document.activeElement,n=document.getSelection(),i=n&&n.rangeCount>0?n.getRangeAt(0):null;try{return t.value=e,t.setAttribute("readonly",""),t.setAttribute("contenteditable","true"),Object.assign(t.style,{contain:"strict",position:"absolute",left:"-9999px",top:"-9999px",fontSize:"12pt",border:"0",padding:"0",margin:"0",outline:"none",boxShadow:"none",background:"transparent"}),document.body.appendChild(t),t.focus(),t.select(),t.setSelectionRange&&t.setSelectionRange(0,e.length),document.execCommand("copy")}catch(o){return console.error("Legacy copy method failed:",o),!1}finally{t.parentNode&&document.body.removeChild(t),i&&n&&(n.removeAllRanges(),n.addRange(i)),r instanceof HTMLElement&&r.focus()}}async function ee(e){if(!e||typeof e!="string")throw new Error("Invalid SVG string provided");if(typeof window>"u"||typeof document>"u")throw new TypeError("convertSvgToPng is only available in browser environment");return new Promise((t,r)=>{const n=new Image,i=document.createElement("canvas"),o=i.getContext("2d");if(!o){r(new Error("Canvas context not available"));return}n.onload=()=>{try{i.width=n.width,i.height=n.height,o.drawImage(n,0,0),i.toBlob(s=>{s?t(s):r(new Error("Failed to convert canvas to Blob"))},"image/png")}catch(s){r(new Error(`Error during canvas conversion: ${s}`))}},n.onerror=()=>{r(new Error("Failed to load SVG image"))};try{n.src=`data:image/svg+xml;base64,${btoa(e)}`}catch(s){r(new Error(`Failed to encode SVG: ${s}`))}})}const te=/filename\*?=(?:"([^"]+)"|([^;]+))/i;function ne(e,t="file"){if(!e)return t;const r=e.get("content-disposition");if(r){const n=r.match(te);if(n){let i=n[1]??n[2];if(!i)return t;if(i.startsWith('"')&&i.endsWith('"')&&(i=i.slice(1,-1)),r.includes("filename*=")){const o=i.split("''");if(o.length===2&&o[1])try{i=decodeURIComponent(o[1])}catch{return t}}return i}}return t}function re(e){if(!Number.isFinite(e)||e<0||e===0)return"0 Bytes";const t=1024,r=["Bytes","KB","MB","GB","TB","PB"],n=Math.floor(Math.log(e)/Math.log(t));return n>=r.length?`${Number.parseFloat((e/t**(r.length-1)).toFixed(2))} ${r.at(-1)}`:`${Number.parseFloat((e/t**n).toFixed(2))} ${r[n]}`}async function oe(e,t){if(!e||typeof e!="string")throw new Error("Invalid SVG path provided");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch SVG file: ${r.status} ${r.statusText}`);const n=await r.text();if(!t)return n;if(typeof window>"u"||typeof DOMParser>"u")return console.warn("replaceCurrentColor: DOM manipulation not available in server environment, returning original SVG"),n;const i=new DOMParser().parseFromString(n,"image/svg+xml");if(i.querySelector("parsererror"))throw new Error("Invalid SVG content");const o=i.querySelector("svg");if(!o)throw new Error("No SVG element found in the document");o.hasAttribute("fill")||o.setAttribute("fill","currentColor");const s=a=>{a.getAttribute("fill")==="currentColor"&&a.setAttribute("fill",t),a.getAttribute("stroke")==="currentColor"&&a.setAttribute("stroke",t),[...a.children].forEach(c=>{s(c)})};return s(o),new XMLSerializer().serializeToString(i)}catch(r){throw r instanceof Error?r:new Error(`Unexpected error occurred: ${r}`)}}function ie(e,t){if(typeof window>"u"||typeof document>"u"){console.warn("triggerDownload: Not available in server environment");return}const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}function w(e,t=new WeakMap){if(e===null||typeof e!="object")return e;try{const a=globalThis.structuredClone;if(typeof a=="function")return a(e)}catch(a){console.error("Error occurred while cloning:",a)}const r=e,n=t.get(r);if(n)return n;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const a=new Map;t.set(r,a);for(const[c,u]of e.entries())a.set(w(c,t),w(u,t));return a}if(e instanceof Set){const a=new Set;t.set(r,a);for(const c of e.values())a.add(w(c,t));return a}if(e instanceof ArrayBuffer)return e.slice(0);if(ArrayBuffer.isView(e)){const a=e.constructor;return new a(e)}if(e instanceof URL)return new URL(e.toString());if(e instanceof Error){const a=new e.constructor(e.message);return a.name=e.name,a.stack=e.stack,a}if(Array.isArray(e)){const a=[];t.set(r,a);for(const c of e)a.push(w(c,t));return a}const i=Object.getPrototypeOf(e),o=Object.create(i);t.set(r,o);const s=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const a of s){const c=Object.getOwnPropertyDescriptor(e,a);c&&("value"in c&&(c.value=w(e[a],t)),Object.defineProperty(o,a,c))}return o}function v(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.prototype.toString.call(e)==="[object Object]"}const se=new Set(["__proto__","constructor"]);function ce(e){return{arrayStrategy:e?.arrayStrategy??"concat",nullHandling:e?.nullHandling??"skip",customMerger:e?.customMerger}}function ae(e){return[...Object.keys(e),...Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))]}function C(e,t,r,n,i){const o={...e};for(const s of ae(t)){if(typeof s=="string"&&se.has(s))continue;const a=o[s],c=t[s];if(r.customMerger){const u=r.customMerger(s,a,c,n);if(u!==void 0){o[s]=u;continue}}if(c==null){if(r.nullHandling==="skip"&&s in o)continue;o[s]=c;continue}if(Array.isArray(c)){if(Array.isArray(a))switch(r.arrayStrategy){case"replace":o[s]=[...c];break;case"unique":o[s]=[...new Set([...a,...c])];break;case"concat":default:o[s]=[...a,...c];break}else o[s]=[...c];continue}if(v(c)){if(i.has(c)){o[s]=i.get(c);continue}const u=[...n,s],f={};if(i.set(c,f),v(a)){const l=C(a,c,r,u,i);Object.assign(f,l),o[s]=f}else{const l=C({},c,r,u,i);Object.assign(f,l),o[s]=f}continue}o[s]=c}return o}function R(e,t){if(!Array.isArray(e))return{};const r=ce(t),n=e.filter(v);if(n.length===0)return{};const i=new WeakMap;return n.reduce((o,s)=>C(o,s,r,[],i),{})}function ue(e){return t=>R(t,e)}function fe(e,t){if(!e||typeof e!="object")return{};const r=new Set(t),n={};for(const i in e)Object.hasOwn(e,i)&&!r.has(i)&&(n[i]=e[i]);return n}function le(e){return!e||typeof e!="object"||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function he(e,t){if(!e||typeof e!="object")return{};const r={};for(const n of t)Object.hasOwn(e,n)&&(r[n]=e[n]);return r}function pe(e,t){if(!e||typeof e!="object")return{picked:{},omitted:{}};if(t.length===0)return{picked:{},omitted:{...e}};const r=new Set(t),n={},i={};for(const o in e)if(Object.hasOwn(e,o)){const s=o;r.has(s)?n[o]=e[s]:i[o]=e[s]}return{picked:n,omitted:i}}function de(e,t){if(!e||typeof e!="object")return{...Object.fromEntries(Object.keys(t).map(o=>[o,{}])),others:{}};const r=Object.keys(t),n=new Map;for(const o of r){const s=new Set(t[o]);n.set(o,s)}const i=Object.create(null);for(const o of r)i[o]={};i.others={};for(const o in e)if(Object.hasOwn(e,o)){const s=o;let a=!1;for(const c of r)if(n.get(c).has(s)){i[c][o]=e[s],a=!0;break}a||(i.others[o]=e[s])}return i}const I=/\s/,ge=/^(?:0|[1-9]\d*)$/;function j(e){if(Array.isArray(e))return e.slice();const t=[];if(e==="")return t;let r=0;const n=e,i=n.length;function o(a){let c="",u=a;for(;u<i;){const f=n.charCodeAt(u);if(f===46)break;if(f===92){u++,u<i&&(c+=n[u]),u++;continue}if(f===91)break;c+=n[u],u++}return{value:c,next:u}}function s(a){let c=a+1;for(;c<i&&I.test(n[c]);)c++;if(c>=i)throw new Error('Invalid path: missing closing "]"');const u=n[c];if(u==='"'||u==="'"){const h=u;c++;let p="",d=!1;for(;c<i;){if(n.charCodeAt(c)===92){c++,c<i&&(p+=n[c]),c++;continue}if(n[c]===h){d=!0,c++;break}p+=n[c],c++}if(!d)throw new Error("Invalid path: missing closing quote in bracket");for(;c<i&&I.test(n[c]);)c++;if(c>=i||n[c]!=="]")throw new Error('Invalid path: missing closing "]"');return c++,{segment:p,next:c}}let f="";for(;c<i&&n[c]!=="]";)f+=n[c],c++;if(c>=i)throw new Error('Invalid path: missing closing "]"');const l=f.trim();return ge.test(l)?(c++,{segment:Number(l),next:c}):(c++,{segment:l,next:c})}for(;r<i;){const a=n.charCodeAt(r);if(a===46){r++;continue}if(a===91){const{segment:f,next:l}=s(r);f!==null&&t.push(f),r=l;continue}const{value:c,next:u}=o(r);(c.length>0||u<i&&n[u]===".")&&t.push(c),r=u}return t}function me(e,t,r){const n=j(t);if(n.length===0)return e;let i=e;for(let o=0;o<n.length;o++){if(i==null)return r;const s=n[o];i=i[s]}return i===void 0?r:i}const ye=/^[A-Z_$][\w$]*$/i,we=/\\/g,be=/'/g;function Ae(e){let t="";for(let r=0;r<e.length;r++){const n=e[r];if(typeof n=="number"&&Number.isInteger(n)&&n>=0){t+=`[${n}]`;continue}const i=String(n),o=ye.test(i);if(t.length===0&&o){t+=i;continue}if(o){t+=`.${i}`;continue}const s=i.replace(we,"\\\\").replace(be,"\\'");t+=`['${s}']`}return t}function P(e){return e!==null&&typeof e=="object"}function xe(e,t,r){const n=j(t);if(n.length===0)return e;let i=e;for(let o=0;o<n.length;o++){const s=n[o];if(o===n.length-1){i[s]=r;break}const a=n[o+1];let c=i[s];const u=typeof a=="number";if(P(c)?u&&!Array.isArray(c)&&(c=[],i[s]=c):(c=u?[]:{},i[s]=c),u&&Array.isArray(c)){const f=Number(a);Number.isInteger(f)&&f>=0&&c.length<=f&&(c.length=f+1)}i=c}return e}function ve(e){let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return Math.abs(t).toString(36)}const $e=/[xy]/g;function Se(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace($e,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}const Ce=/([a-z\d])([A-Z])/g;function L(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return e;const r=i=>i.replace(Ce,"$1-$2").toLowerCase(),n={};for(const i in e)if(Object.hasOwn(e,i)){const o=r(i),s=e[i];t&&s&&typeof s=="object"&&!Array.isArray(s)?n[o]=L(s,!0):n[o]=s}return n}const je=/[_-]/g,Ee=/[A-Z]{2,}(?=[A-Z][a-z]|\b)|[A-Z]?[a-z]+|\d+/g;function E(e){return e?e.replace(je," ").match(Ee)||[]:[]}function b(e,t){if(!e)return"";const r=E(e);return r.length===0?"":r.map((n,i)=>{const o=n.toLowerCase(),s=n.toUpperCase();if(t.transform)return t.transform(n,i,o,s);switch(t.casing){case"lower":return o;case"upper":return s;case"capitalize":return o.charAt(0).toUpperCase()+o.slice(1);default:return n}}).join(t.separator??"")}function T(e,t){if(!e)return"";const r=e.charAt(0);return(t?r.toUpperCase():r.toLowerCase())+e.slice(1)}function Ue(e){return b(e,{separator:"",transform:(t,r,n)=>r===0?n:n.charAt(0).toUpperCase()+n.slice(1)})}function Oe(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():""}function ke(e){return b(e,{separator:"-",casing:"lower"})}function Re(e){return b(e,{separator:" ",casing:"lower"})}function Ie(e){return T(e,!1)}function Pe(e){return b(e,{separator:"",casing:"capitalize"})}function Le(e){return b(e,{separator:"_",casing:"lower"})}function Te(e){return e?E(e).map(t=>t.toUpperCase()===t&&t.length>1?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" "):""}function Me(e){return b(e,{separator:" ",casing:"upper"})}function Ne(e){return T(e,!0)}const U={id:"id",pid:"pid",children:"children"};function g(e={}){return{id:e.id??U.id,pid:e.pid??U.pid,children:e.children??U.children}}function*$(e,t={},r=[]){const{children:n}=g(t);let i=0;for(const o of e){const s=[...r,o];yield{node:o,path:s,depth:r.length,index:i++};const a=o[n];a&&a.length>0&&(yield*$(a,t,s))}}function*O(e,t={}){const{children:r}=g(t),n=e.map((o,s)=>({node:o,path:[o],depth:0,index:s}));let i=e.length;for(;n.length>0;){const o=n.shift();yield o;const s=o.node[r];s&&s.length>0&&s.forEach(a=>{const c=[...o.path,a];n.push({node:a,path:c,depth:o.depth+1,index:i++})})}}function k(e){switch(e){case"find":case"findAll":case"filter":case"transform":case"forEach":case"stats":case"validate":return"dfs";default:return"dfs"}}function Fe(e,t={}){const{id:r,pid:n,children:i}=g(t);if(!Array.isArray(e)||e.length===0)return[];const o=new Map,s=[];return e.forEach(a=>{const{[i]:c,...u}=a,f={...u,[i]:[]};o.set(a[r],f)}),e.forEach(a=>{const c=o.get(a[r]),u=a[n];u&&o.has(u)?o.get(u)[i].push(c):s.push(c)}),s}function De(e,t={}){const{children:r}=g(t),n=[],i=Array.isArray(e)?e:[e],o=s=>{const{[r]:a,...c}=s;n.push(c),a&&a.length>0&&a.forEach(o)};return i.forEach(o),n}function ze(e,t={}){const{children:r}=g(t),n=Array.isArray(e)?e:[e];let i=0;const o=s=>{i++;const a=s[r];a&&a.length>0&&a.forEach(o)};return n.forEach(o),i}function Be(e,t,r,n={}){const{id:i,children:o}=g(n),{[o]:s,...a}=r,c={...a,[o]:[]},u=(f,l)=>{for(let h=0;h<f.length;h++){const p=f[h];if(!p)continue;if(p[i]===t)return f.splice(h,0,c),!0;const d=p[o];if(d&&d.length>0){const y=[...l,p];if(u(d,y))return!0}}return!1};return u(e,[])}function We(e,t,r,n={}){const{id:i,children:o}=g(n),{[o]:s,...a}=r,c={...a,[o]:[]},u=(f,l)=>{for(let h=0;h<f.length;h++){const p=f[h];if(!p)continue;if(p[i]===t)return f.splice(h+1,0,c),!0;const d=p[o];if(d&&d.length>0){const y=[...l,p];if(u(d,y))return!0}}return!1};return u(e,[])}function Ve(e,t,r={}){const{id:n,children:i}=g(r),o=s=>{for(let a=0;a<s.length;a++){const c=s[a];if(!c)continue;if(c[n]===t)return s.splice(a,1)[0];const u=c[i];if(u&&u.length>0){const f=o(u);if(f)return f}}};return o(e)}function M(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("find")==="dfs"?$(n,r):O(n,r);for(const o of i)if(t({node:o.node,depth:o.depth,path:o.path,index:o.index}))return o.node}function Ge(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("findAll"),o=[],s=i==="dfs"?$(n,r):O(n,r);for(const a of s)t({node:a.node,depth:a.depth,path:a.path,index:a.index})&&o.push(a.node);return o}function Qe(e,t,r={}){const{id:n}=g(r);return M(e,({node:i})=>i[n]===t,r)}function _e(e,t,r={}){const{children:n}=g(r),i=Array.isArray(e)?e:[e],o=[],s=(a,c,u,f=0)=>{const l=a[n],h=[];if(l&&l.length>0){const p=[...u,a];l.forEach((d,y)=>{const x=s(d,c+1,p,y);x&&h.push(x)})}if(t({node:a,depth:c,path:u,index:f})||h.length>0){const{[n]:p,...d}=a;return{...d,[n]:h}}return null};return i.forEach((a,c)=>{const u=s(a,0,[a],c);u&&o.push(u)}),o}function qe(e,t,r={}){const{children:n}=g(r),i=Array.isArray(e)?e:[e],o=[],s=(a,c,u,f=0)=>{const l=a[n],h=[];if(l&&l.length>0){const x=[...u,a];l.forEach((H,Z)=>{h.push(s(H,c+1,x,Z))})}const p=t({node:a,depth:c,path:u,index:f}),{[n]:d,...y}=p;return{...y,[n]:h}};return i.forEach((a,c)=>{o.push(s(a,0,[a],c))}),o}function He(e,t,r={}){const n=Array.isArray(e)?e:[e],i=k("forEach")==="dfs"?$(n,r):O(n,r);for(const o of i)if(t({node:o.node,depth:o.depth,path:o.path,index:o.index})===!1)break}function Ze(e,t={}){const{children:r}=g(t),n=Array.isArray(e)?e:[e];let i=0,o=0,s=0,a=0;const c=(u,f)=>{i++,s=Math.max(s,f);const l=u[r];l&&l.length>0?(a++,l.forEach(h=>c(h,f+1))):o++};return n.forEach(u=>c(u,1)),{total:i,leaves:o,depth:s,branches:a}}function Ke(e,t={}){const{id:r,children:n}=g(t),i=Array.isArray(e)?e:[e],o=[],s=new Set,a=(c,u,f)=>{const l=c[r];if(!l||typeof l!="string"){o.push(`Node at depth ${u} has invalid or missing ID`);return}if(s.has(l)){o.push(`Duplicate ID found: ${l}`);return}if(s.add(l),f.some(p=>p[r]===l)){o.push(`Circular reference detected for ID: ${l}`);return}const h=c[n];if(h!==void 0&&!Array.isArray(h)){o.push(`Node ${l} has invalid children property (not an array)`);return}if(h&&h.length>0){const p=[...f,c];h.forEach(d=>{a(d,u+1,p)})}};return i.forEach(c=>a(c,0,[])),{isValid:o.length===0,errors:o}}class Je{static fromList=Fe;static toList=De;static estimateSize=ze;static find=M;static findAll=Ge;static findById=Qe;static insertBefore=Be;static insertAfter=We;static remove=Ve;static filter=_e;static transform=qe;static forEach=He;static getStats=Ze;static validate=Ke}function Xe(e,t){const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}function Ye(e,t=1){return t===1?e.flat():e.flat(t)}function et(e){return[...new Set(e)]}function tt(e,t){let r;return(...n)=>{clearTimeout(r),r=setTimeout(e,t,...n)}}function nt(e){return new Promise(t=>setTimeout(t,e))}function rt(e){let t,r;return{promise:new Promise((n,i)=>{r=i,t=setTimeout(n,e)}),cancel:()=>{clearTimeout(t),r(new Error("Sleep was cancelled"))}}}function ot(e,t){let r=!1;return function(...n){r||(e.apply(this,n),r=!0,setTimeout(()=>{r=!1},t))}}const it=/^[a-z][a-z0-9+.-]*:/i;function m(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);return{href:r.href,protocol:r.protocol,host:r.host,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search,hash:r.hash,auth:r.username?`${r.username}${r.password?`:${r.password}`:""}`:"",origin:r.origin}}catch{return null}}function st(e){if(!e)return!1;try{return!!new URL(e)}catch{return!1}}function N(e){return e?e.startsWith("//")?!0:it.test(e):!1}function ct(e){return e?!N(e):!1}function F(e){return m(e)?.hostname??""}function at(e){const t=F(e);if(!t)return"";const r=["co.uk","co.jp","co.kr","co.nz","co.za","co.in","com.au","com.br","com.cn","com.tw","com.hk","com.sg","org.uk","org.au","net.au","net.cn","gov.uk","gov.au","edu.au","edu.cn","ac.uk","ac.jp"],n=t.split(".");if(n.length>=3){const i=n.slice(-2).join(".");if(r.includes(i))return n.slice(-3).join(".")}return n.length>=2?n.slice(-2).join("."):t}function ut(e){const t=m(e);if(!t)return"";const r=t.pathname.split("/").pop()||"",n=r.lastIndexOf(".");return n===-1||n===0?"":r.slice(n+1).toLowerCase()}function ft(e,t=!0){const r=m(e);if(!r)return"";const n=r.pathname.split("/").pop()||"";if(!n||n==="/")return"";if(t)return n;const i=n.lastIndexOf(".");return i>0?n.slice(0,i):n}function A(e){if(!e)return{};const t=e.startsWith("?")?e.slice(1):e;if(!t)return{};const r={},n=new URLSearchParams(t);for(const[i,o]of n.entries()){const s=r[i];s!==void 0?Array.isArray(s)?s.push(o):r[i]=[s,o]:r[i]=o}return r}function S(e,t={}){const{skipNull:r=!1,skipEmpty:n=!1,arrayFormat:i="repeat"}=t,o=[];for(const[s,a]of Object.entries(e)){if(a==null){if(r)continue;o.push(`${encodeURIComponent(s)}=`);continue}if(Array.isArray(a)){const u=a.filter(f=>f==null?!r:f===""?!n:!0);if(u.length===0)continue;switch(i){case"bracket":for(const f of u)o.push(`${encodeURIComponent(s)}[]=${encodeURIComponent(String(f??""))}`);break;case"index":u.forEach((f,l)=>{o.push(`${encodeURIComponent(s)}[${l}]=${encodeURIComponent(String(f??""))}`)});break;case"comma":o.push(`${encodeURIComponent(s)}=${u.map(f=>encodeURIComponent(String(f??""))).join(",")}`);break;default:for(const f of u)o.push(`${encodeURIComponent(s)}=${encodeURIComponent(String(f??""))}`)}continue}const c=String(a);c===""&&n||o.push(`${encodeURIComponent(s)}=${encodeURIComponent(c)}`)}return o.join("&")}function lt(e,t){if(!e||!t)return null;try{return new URL(e,"http://localhost").searchParams.get(t)}catch{const r=e.indexOf("?");if(r===-1)return null;const n=A(e.slice(r))[t];return Array.isArray(n)?n[0]??null:n??null}}function ht(e,t){if(!e||!t)return[];try{return new URL(e,"http://localhost").searchParams.getAll(t)}catch{const r=e.indexOf("?");if(r===-1)return[];const n=A(e.slice(r))[t];return n?Array.isArray(n)?n:[n]:[]}}function D(e,t,r){if(!e||!t)return e;try{const n=new URL(e);return r==null?n.searchParams.delete(t):n.searchParams.set(t,String(r)),n.toString()}catch{const n=e.indexOf("#"),i=n!==-1?e.slice(n+1):"",o=n!==-1?e.slice(0,n):e,s=o.indexOf("?"),a=s!==-1?o.slice(0,s):o,c=s!==-1?o.slice(s+1):"",u=A(c);r==null?delete u[t]:u[t]=String(r);const f=S(u);let l=a;return f&&(l+=`?${f}`),i&&(l+=`#${i}`),l}}function pt(e,t){let r=e;for(const[n,i]of Object.entries(t))if(Array.isArray(i)){r=B(r,n);for(const o of i)r=z(r,n,o)}else r=D(r,n,i);return r}function z(e,t,r){if(!e||!t||r===null||r===void 0)return e;try{const n=new URL(e);return n.searchParams.append(t,String(r)),n.toString()}catch{const[n,i]=e.split("?"),[o,s]=(i||"").split("#"),a=o?"&":"",c=`${encodeURIComponent(t)}=${encodeURIComponent(String(r))}`;let u=n||"";return u+=`?${o||""}${a}${c}`,s&&(u+=`#${s}`),u}}function B(e,t){if(!e||!t)return e;try{const r=new URL(e);return r.searchParams.delete(t),r.toString()}catch{const[r,n]=e.split("?"),[i,o]=(n||"").split("#"),s=A(i||"");delete s[t];const a=S(s);let c=r||"";return a&&(c+=`?${a}`),o&&(c+=`#${o}`),c}}function dt(e,t){if(!e||!t)return!1;try{return new URL(e,"http://localhost").searchParams.has(t)}catch{const r=e.indexOf("?");if(r===-1)return!1;const n=A(e.slice(r));return t in n}}const W=/(?=[?#])/,gt=/[?#]/,mt=/^\/+/;function V(...e){if(e.length===0)return"";const t=e.filter(n=>n!=null&&n!=="");if(t.length===0)return"";let r=t[0];for(let n=1;n<t.length;n++){const i=t[n],o=r.endsWith("/"),s=i.startsWith("/");o&&s?r+=i.slice(1):!o&&!s?r+=`/${i}`:r+=i}return r}function yt(e){if(!e)return"";const t=m(e);if(t){const i=G(t.pathname);return`${t.origin}${i}${t.search}${t.hash}`}const[r,n]=e.split(W);return G(r||"")+(n||"")}function G(e){if(!e)return"";const t=e.startsWith("/"),r=e.endsWith("/")&&e.length>1,n=e.split("/").filter(Boolean),i=[];for(const s of n)if(s!=="."){if(s===".."){i.pop();continue}i.push(s)}let o=i.join("/");return t&&(o=`/${o}`),r&&o!=="/"&&(o+="/"),o||(t?"/":"")}function wt(e){if(!e)return"";const[t,...r]=e.split(W);return t?(t.length>1&&t.endsWith("/")?t.slice(0,-1):t)+r.join(""):e}function bt(e){if(!e)return"/";const t=e.search(gt),r=t===-1?e:e.slice(0,t),n=t===-1?"":e.slice(t);return r?(r.endsWith("/")?r:`${r}/`)+n:`/${n}`}function At(e){return e?e.replace(mt,""):""}function xt(e){return e?e.startsWith("/")?e:`/${e}`:"/"}function vt(e,t,r,n){let i=e;if(t&&(i=V(i,t)),r&&Object.keys(r).length>0){const o=S(r);o&&(i+=(i.includes("?")?"&":"?")+o)}if(n){const o=n.startsWith("#")?n:`#${n}`;i+=o}return i}function $t(e){if(!e)return"";try{return decodeURIComponent(e)}catch{return e}}function St(e){if(!e)return"";try{return encodeURIComponent(e)}catch{return e}}function Ct(e,t){const r=m(e),n=m(t);return!r||!n?!1:r.origin===n.origin}function jt(e,t){if(!e)return t;try{return new URL(e,t).href}catch{return e}}function Et(e,t){const r=m(e),n=m(t);if(!r||!n||r.origin!==n.origin)return t;const i=r.pathname.split("/").filter(Boolean),o=n.pathname.split("/").filter(Boolean);let s=0;const a=Math.min(i.length,o.length);for(let h=0;h<a&&i[h]===o[h];h++)s++;const c=i.length-s,u=o.slice(s),f=[];for(let h=0;h<c;h++)f.push("..");f.push(...u);let l=f.join("/")||".";return n.search&&(l+=n.search),n.hash&&(l+=n.hash),l}function Q(e){return Array.isArray(e)}function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function q(e){return typeof e=="string"}function Ut(e){return e==null?!0:Q(e)||q(e)?e.length===0:_(e)?Object.keys(e).length===0:!1}function Ot(e){return typeof e=="function"}function kt(e){return typeof e=="number"&&!Number.isNaN(e)}export{Je as Tree,z as appendQueryParam,vt as buildUrl,Ue as camelCase,Oe as capitalize,Xe as chunk,ee as convertSvgToPng,L as convertToKebabCase,ue as createDeepMerge,tt as debounce,w as deepClone,R as deepMerge,xt as ensureLeadingSlash,bt as ensureTrailingSlash,ne as extractFilename,Ye as flatten,re as formatFileSize,F as getDomain,me as getPath,lt as getQueryParam,ht as getQueryParams,Se as getRandomUUID,Et as getRelativePath,at as getRootDomain,ut as getUrlExtension,ft as getUrlFilename,dt as hasQueryParam,N as isAbsoluteUrl,Q as isArray,Ut as isEmpty,Ot as isFunction,kt as isNumber,_ as isObject,v as isPlainObject,ct as isRelativeUrl,Ct as isSameOrigin,q as isString,P as isValidContainer,st as isValidUrl,Ae as joinPath,V as joinUrl,ke as kebabCase,Re as lowerCase,Ie as lowerFirst,yt as normalizeUrl,fe as omit,le as omitUndefined,A as parseQuery,m as parseUrl,Pe as pascalCase,he as pick,At as removeLeadingSlash,B as removeQueryParam,wt as removeTrailingSlash,oe as replaceCurrentColor,$t as safeDecodeURIComponent,St as safeEncodeURIComponent,pe as separate,de as separateMany,xe as setPath,D as setQueryParam,pt as setQueryParams,ve as simpleHash,nt as sleep,rt as sleepWithCancel,Le as snakeCase,Te as startCase,S as stringifyQuery,ot as throttle,jt as toAbsoluteUrl,j as toPath,ie as triggerDownload,et as unique,Me as upperCase,Ne as upperFirst,J as useAppStorage,X as useCopyCode,E as words};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movk/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
5
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "1.2.2",
|
|
5
|
+
"packageManager": "pnpm@10.32.0",
|
|
6
6
|
"description": "为 TypeScript 项目设计的现代化、支持 Tree-Shaking 的工具函数库。",
|
|
7
7
|
"author": "YiXuan <mhaibaraai@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@vueuse/core": "^14.2.1",
|
|
56
|
-
"
|
|
56
|
+
"tinyglobby": "^0.2.15"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@antfu/eslint-config": "^7.
|
|
59
|
+
"@antfu/eslint-config": "^7.7.0",
|
|
60
60
|
"@release-it/conventional-changelog": "^10.0.5",
|
|
61
|
-
"@types/node": "^25.
|
|
62
|
-
"eslint": "^10.0.
|
|
61
|
+
"@types/node": "^25.4.0",
|
|
62
|
+
"eslint": "^10.0.3",
|
|
63
63
|
"release-it": "^19.2.4",
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
65
|
"unbuild": "^3.6.1",
|