@fast-china/utils 2.1.6 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +4 -2
  3. package/README.zh.md +4 -2
  4. package/THIRD_PARTY_LICENSES.md +26 -0
  5. package/dist/crypto/index.mjs +2240 -33
  6. package/dist/crypto/index.mjs.map +1 -1
  7. package/dist/dom/index.mjs +2 -0
  8. package/dist/env/index.mjs +4 -4
  9. package/dist/env/index.mjs.map +1 -1
  10. package/dist/index.d.mts +1918 -32
  11. package/dist/index.global.min.js +2 -2
  12. package/dist/index.global.min.js.map +1 -1
  13. package/dist/index.mjs +2 -0
  14. package/dist/internal/runtime.mjs +21 -1
  15. package/dist/internal/runtime.mjs.map +1 -1
  16. package/dist/logger/index.mjs +2 -2
  17. package/dist/logger/index.mjs.map +1 -1
  18. package/dist/storage/index.mjs +2 -2
  19. package/dist/storage/index.mjs.map +1 -1
  20. package/dist/string/index.mjs +2 -2
  21. package/dist/string/index.mjs.map +1 -1
  22. package/dist/vue/index.mjs +15 -0
  23. package/dist/vue/now.mjs +2 -2
  24. package/dist/vue/now.mjs.map +1 -1
  25. package/package.json +4 -6
  26. package/dist/array/index.d.mts +0 -94
  27. package/dist/async/index.d.mts +0 -145
  28. package/dist/base64/index.d.mts +0 -106
  29. package/dist/color/index.d.mts +0 -89
  30. package/dist/crypto/index.d.mts +0 -327
  31. package/dist/date/index.d.mts +0 -190
  32. package/dist/dom/style.d.mts +0 -29
  33. package/dist/env/index.d.mts +0 -62
  34. package/dist/function/index.d.mts +0 -13
  35. package/dist/identity/index.d.mts +0 -77
  36. package/dist/internal/text.d.mts +0 -15
  37. package/dist/logger/index.d.mts +0 -90
  38. package/dist/number/index.d.mts +0 -89
  39. package/dist/object/index.d.mts +0 -114
  40. package/dist/storage/index.d.mts +0 -115
  41. package/dist/string/index.d.mts +0 -141
  42. package/dist/vue/breakpoints.d.mts +0 -21
  43. package/dist/vue/element-size.d.mts +0 -25
  44. package/dist/vue/emits.d.mts +0 -23
  45. package/dist/vue/event-listener.d.mts +0 -16
  46. package/dist/vue/expose.d.mts +0 -11
  47. package/dist/vue/func.d.mts +0 -13
  48. package/dist/vue/index.d.mts +0 -15
  49. package/dist/vue/install.d.mts +0 -50
  50. package/dist/vue/now.d.mts +0 -13
  51. package/dist/vue/props.d.mts +0 -22
  52. package/dist/vue/render.d.mts +0 -11
  53. package/dist/vue/resize-observer.d.mts +0 -15
  54. package/dist/vue/slots.d.mts +0 -18
  55. package/dist/vue/window-size.d.mts +0 -16
  56. package/dist/vue/with.d.mts +0 -11
  57. package/docs/API.md +0 -155
  58. package/docs/API.zh-CN.md +0 -154
  59. package/docs/DEVELOPMENT_RELEASE.zh-CN.md +0 -65
  60. package/docs/RUNTIME_CONTRACT.md +0 -44
@@ -1,114 +0,0 @@
1
- //#region src/object/index.d.ts
2
- /** URL 查询参数支持的单值类型。 */
3
- export type QueryPrimitive = bigint | boolean | number | string | null | undefined;
4
- /** URL 查询参数值;数组使用重复键表示。 */
5
- export type QueryValue = QueryPrimitive | readonly QueryPrimitive[];
6
- /** {@link toQueryString} 的序列化选项。 */
7
- export interface QueryStringOptions {
8
- /** 返回非空结果时是否添加 `?`;默认 `false`。 */
9
- prefixQuestionMark?: boolean;
10
- /** 是否按键的 UTF-16 码元顺序稳定排序;默认保留对象枚举顺序。 */
11
- sort?: boolean;
12
- /** 空格编码方式;默认遵循表单编码并输出 `+`。 */
13
- space?: "percent" | "plus";
14
- }
15
- /**
16
- * 判断值是否是普通对象。
17
- *
18
- * @param value - 任意待检查值。
19
- * @returns 原型为 `Object.prototype` 或 `null` 时返回 `true`。
20
- */
21
- export declare function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
22
- /**
23
- * 安全判断对象是否拥有自己的属性。
24
- *
25
- * @remarks 不调用可能被对象覆盖的 `hasOwnProperty`。
26
- * @param value - 待检查对象。
27
- * @param key - 字符串、数字或 Symbol 属性键。
28
- * @returns 属性为对象自有属性时返回 `true`,并收窄键类型。
29
- */
30
- export declare function hasOwn<ObjectType extends object, Key extends PropertyKey>(value: ObjectType, key: Key): key is Key & keyof ObjectType;
31
- /**
32
- * 递归创建值的深层副本。
33
- *
34
- * @remarks 支持循环引用、共享引用、Symbol 键、对象原型、ArrayBuffer、DataView、Date、Map、RegExp、Set 和 TypedArray。
35
- * Map 的键保持原引用,函数及其他不可克隆值在嵌套位置保持原引用;只复制自有可枚举属性。
36
- * @param value - 需要深复制的任意值。
37
- * @returns 与输入类型一致且不共享可克隆嵌套值的新值;原始类型直接返回自身。
38
- */
39
- export declare function cloneDeep<Value>(value: Value): Value;
40
- /**
41
- * 深度比较两个值是否等价。
42
- *
43
- * @remarks 原始值使用 SameValueZero 语义;支持循环引用、数组、对象、ArrayBuffer、DataView、Date、Error、Map、RegExp、Set、Symbol 和 TypedArray。
44
- * 对象只比较自有可枚举字符串与 Symbol 属性,函数及其他不支持的宿主对象仅在引用相同时相等。
45
- * @param left - 第一待比较值。
46
- * @param right - 第二待比较值。
47
- * @returns 两个值深度等价时返回 `true`。
48
- */
49
- export declare function isEqual(left: unknown, right: unknown): boolean;
50
- /**
51
- * 从对象中选择指定自有可枚举属性。
52
- *
53
- * @remarks 字面量键数组保留精确返回类型;普通 `string[]` 等动态键数组返回 `Partial<Source>`。
54
- * @param source - 不会被修改的源对象。
55
- * @param keys - 需要保留的键;不存在的键被忽略。
56
- * @returns 新对象,保持 `keys` 的遍历顺序。
57
- */
58
- export declare function pick<Source extends object, const Keys extends readonly (keyof Source)[]>(source: Source, keys: Keys): Pick<Source, Keys[number]>;
59
- export declare function pick<Source extends object>(source: Source, keys: readonly PropertyKey[]): Partial<Source>;
60
- /**
61
- * 浅复制对象并删除指定属性。
62
- *
63
- * @remarks 字面量键数组保留精确返回类型;普通 `string[]` 等动态键数组返回 `Partial<Source>`。
64
- * @param source - 不会被修改的源对象。
65
- * @param keys - 需要排除的键。
66
- * @returns 包含其余自有可枚举字符串与 Symbol 属性的新对象。
67
- */
68
- export declare function omit<Source extends object, const Keys extends readonly (keyof Source)[]>(source: Source, keys: Keys): Omit<Source, Keys[number]>;
69
- export declare function omit<Source extends object>(source: Source, keys: readonly PropertyKey[]): Partial<Source>;
70
- /**
71
- * 按条件排除对象的自有可枚举属性。
72
- *
73
- * @param source - 不会被修改的源对象。
74
- * @param predicate - 接收属性值、键和源对象;返回真值时排除该属性。
75
- * @returns 由未匹配属性组成的新对象。
76
- */
77
- export declare function omitBy<Source extends object>(source: Source, predicate: (value: Source[keyof Source], key: keyof Source, source: Source) => unknown): Partial<Source>;
78
- /**
79
- * 按条件选择对象的自有可枚举属性。
80
- *
81
- * @param source - 不会被修改的源对象。
82
- * @param predicate - 接收属性值、键和源对象;返回真值时保留该属性。
83
- * @returns 由匹配属性组成的新对象。
84
- */
85
- export declare function pickBy<Source extends object>(source: Source, predicate: (value: Source[keyof Source], key: keyof Source, source: Source) => unknown): Partial<Source>;
86
- /**
87
- * 映射对象的自有可枚举属性值。
88
- *
89
- * @param source - 不会被修改的源对象。
90
- * @param mapper - 接收值、键和源对象的映射函数。
91
- * @returns 保留原键的新对象。
92
- */
93
- export declare function mapValues<Source extends object, Result>(source: Source, mapper: (value: Source[keyof Source], key: keyof Source, source: Source) => Result): { [Key in keyof Source]: Result; };
94
- /**
95
- * 对自有可枚举属性执行 SameValue 浅比较。
96
- *
97
- * @remarks 嵌套对象只比较引用;`NaN` 相等,`0` 与 `-0` 不相等。
98
- * @param left - 第一对象。
99
- * @param right - 第二对象。
100
- * @returns 自有可枚举键集合与对应值均满足 SameValue 时返回 `true`。
101
- */
102
- export declare function shallowEqual(left: object, right: object): boolean;
103
- /**
104
- * 将对象序列化为标准 URL 查询字符串。
105
- *
106
- * @remarks `null` 与 `undefined` 被跳过;数组使用重复键;返回值不会修改输入。
107
- * @param value - 查询参数对象。
108
- * @param options - 排序、空格和问号前缀选项。
109
- * @returns URL 编码后的查询字符串;没有参数时始终返回空字符串。
110
- * @throws `RangeError` 当参数包含 `NaN` 或无穷数字。
111
- */
112
- export declare function toQueryString(value: Readonly<Record<string, QueryValue>>, options?: QueryStringOptions): string;
113
- //#endregion
114
- //# sourceMappingURL=index.d.mts.map
@@ -1,115 +0,0 @@
1
- //#region src/storage/index.d.ts
2
- /** Storage 业务值编码器。 */
3
- export interface StorageCodec {
4
- /**
5
- * 把已编码文本恢复为业务值。
6
- * @param value - 由同一 Codec 的 `encode` 生成并持久化的文本。
7
- * @returns 解码后的业务值。
8
- * @throws 当文本损坏、格式不受支持或无法反序列化时应抛出错误。
9
- */
10
- decode: (value: string) => unknown;
11
- /**
12
- * 把业务值编码为可持久化字符串。
13
- * @param value - 调用方传入的业务值。
14
- * @returns 可由同一 Codec 的 `decode` 无损恢复的文本。
15
- * @throws 当值不受支持或无法序列化时应抛出错误。
16
- */
17
- encode: (value: unknown) => string;
18
- }
19
- /** 程序入口调用 {@link configureStorage} 时使用的全局配置。 */
20
- export interface StorageConfiguration {
21
- /** 自定义值编码器;默认使用严格 JSON Codec,同一应用生命周期内必须保持同一引用。 */
22
- codec?: StorageCodec;
23
- /** 启用 Base64 可逆混淆;不提供加密、完整性或认证,不能与 `codec` 同时使用。 */
24
- crypto?: boolean;
25
- /** 返回 Unix 毫秒时间戳的时钟;默认使用 `Date.now`,主要用于 TTL 测试与受控时间源。 */
26
- now?: () => number;
27
- /** 所有物理键使用的非空命名空间前缀; */
28
- prefix?: string;
29
- }
30
- /** 单次 Storage 读取配置。 */
31
- export interface StorageReadOptions {
32
- /**
33
- * 仅覆盖本次读取使用的 Codec;`true` 使用 Base64 混淆,`false` 使用 JSON,省略时使用全局配置。
34
- * 必须与写入该条目时使用的单次设置一致。
35
- */
36
- crypto?: boolean;
37
- }
38
- /** 单次 Storage 写入配置。 */
39
- export interface StorageWriteOptions extends StorageReadOptions {
40
- /** 从写入时刻开始的有效毫秒数;必须是大于 0 的有限数,省略时永久有效。 */
41
- ttlMs?: number;
42
- }
43
- /** `Local` 与 `Session` 的统一操作接口。 */
44
- export interface StorageArea {
45
- /** 当前全局 Storage 配置的物理键前缀;首次读取会激活默认配置。 */
46
- readonly prefix: string;
47
- /**
48
- * 删除当前命名空间内的全部键,不影响同一后端中的其他应用键。
49
- * @throws `Error` 当当前平台后端不可用。
50
- */
51
- clear: () => void;
52
- /**
53
- * 获取并解码业务值;已过期记录会在读取时删除。
54
- * @param key - 不含全局前缀的非空业务键。
55
- * @param options - 可选的单次 Base64 混淆开关;必须与写入时一致。
56
- * @returns 解码后的值;未传泛型时静态类型默认为 `string`,键缺失或过期时返回 `undefined`。
57
- * @throws 当键非法、包络损坏、Codec 解码失败或后端不可用时抛出错误。
58
- */
59
- get: <Value = string>(key: string, options?: StorageReadOptions) => Value | undefined;
60
- /**
61
- * 判断一个可成功读取且未过期的业务键是否存在。
62
- * @param key - 不含全局前缀的非空业务键。
63
- * @returns 键存在且包络有效时返回 `true`。
64
- */
65
- has: (key: string) => boolean;
66
- /**
67
- * 返回当前命名空间内的业务键快照。
68
- * @returns 已移除全局前缀并按字典序排列的新数组;不会自动清理过期项。
69
- */
70
- keys: () => string[];
71
- /**
72
- * 扫描当前命名空间并删除全部过期记录。
73
- * @returns 本次实际删除的记录数量。
74
- * @throws 当发现损坏包络或后端不可用时抛出错误。
75
- */
76
- pruneExpired: () => number;
77
- /**
78
- * 删除单个业务键;键不存在时保持幂等。
79
- * @param key - 不含全局前缀的非空业务键。
80
- */
81
- remove: (key: string) => void;
82
- /**
83
- * 删除业务键以指定文本开头的全部条目,范围仍受全局命名空间限制。
84
- * @param keyPrefix - 不含全局前缀的非空业务键前缀。
85
- */
86
- removeByPrefix: (keyPrefix: string) => void;
87
- /**
88
- * 编码并写入业务值,可附加惰性清理的 TTL。
89
- * @param key - 不含全局前缀的非空业务键。
90
- * @param value - 必须受当前 Codec 支持的业务值。
91
- * @param options - 可选的单次写入 TTL 与 Base64 混淆开关。
92
- * @throws 当键、TTL、业务值或后端写入无效时抛出错误。
93
- */
94
- set: <Value>(key: string, value: Value, options?: StorageWriteOptions) => void;
95
- }
96
- /** Base64 混淆 Codec;只隐藏明文外观,不提供加密、完整性或认证。 */
97
- export declare const base64StorageCodec: StorageCodec;
98
- /** 浏览器 localStorage 或自动检测的 uni-app Storage 全局业务入口。 */
99
- export declare const Local: StorageArea;
100
- /** 浏览器 sessionStorage 的全局业务入口;uni-app 不提供会话存储。 */
101
- export declare const Session: StorageArea;
102
- /**
103
- * 在首次 Storage 操作前可选配置 `Local` 与 `Session`。
104
- *
105
- * @remarks 不调用时在首次操作上使用 `fast__`、JSON Codec 与 `Date.now`。首次激活后只允许以完全相同的值和引用重复调用。若检测到
106
- * 全局 `uni`,则自动使用其同步 Storage 且只启用 `Local`,否则使用浏览器 `localStorage` 与 `sessionStorage`。
107
- * `crypto: true` 仅恢复旧版 Base64 混淆行为,不能保护敏感数据。
108
- * @param options - 可选的全局键前缀、Codec、旧版混淆选项与时钟。
109
- * @throws 配置非法、重复配置冲突或目标平台 Storage 不可用时抛出错误。
110
- */
111
- export declare function configureStorage(options?: StorageConfiguration): void;
112
- /** 返回全局 Storage 是否已经由应用入口配置。 */
113
- export declare function isStorageConfigured(): boolean;
114
- //#endregion
115
- //# sourceMappingURL=index.d.mts.map
@@ -1,141 +0,0 @@
1
- //#region src/string/index.d.ts
2
- /** 查询字符串解析结果;重复键保留为数组,不存在的键读取为 `undefined`。 */
3
- export type ParsedQueryParameters = Record<string, string | string[] | undefined>;
4
- /** 大小写与字素分割可接受的显式语言;省略时固定使用 `en-US` 以保持输出稳定。 */
5
- export type StringLocale = string | readonly string[] | undefined;
6
- /**
7
- * 重复执行 URI 组件解码,直到值稳定或达到深度上限。
8
- *
9
- * @param value - 不包含 URI 路径语义的编码组件。
10
- * @param maxDepth - 最大解码次数,默认 `10`。
11
- * @returns 解码稳定或达到上限后的组件文本。
12
- * @throws `URIError` 当任一层包含非法百分号序列;深度非法时抛出 `RangeError`。
13
- */
14
- export declare function decodeURIComponentRepeatedly(value: string, maxDepth?: number): string;
15
- /**
16
- * 解析带 `://` 的绝对 URL、`?query` 或纯查询字符串。
17
- *
18
- * @remarks 纯查询字符串值中的未编码 `?` 会作为值内容保留;片段标识及其后内容被忽略。
19
- * @param input - 完整 URL、带前导问号或不带前导问号的查询文本。
20
- * @returns 重复键对应字符串数组,空值保留为空字符串。
21
- */
22
- export declare function parseQueryString(input: string): ParsedQueryParameters;
23
- /**
24
- * 判断文本是否为任意合法 JSON 值,包括标量与 `null`。
25
- *
26
- * @param value - 待解析文本;纯空白不视为 JSON。
27
- * @returns `JSON.parse` 能完整解析时返回 `true`。
28
- */
29
- export declare function isValidJson(value: string): boolean;
30
- /**
31
- * 按大小写边界、连字符、下划线与空白切分单词。
32
- *
33
- * @example `XMLHttp_request` 返回 `["XML", "Http", "request"]`。
34
- * @param value - 待拆分文本。
35
- * @returns 删除空项、保持输入顺序的单词数组。
36
- */
37
- export declare function splitWords(value: string): string[];
38
- /**
39
- * 将首个 Unicode 码点转为大写。
40
- *
41
- * @param value - 输入文本;空字符串保持为空。
42
- * @param locale - 显式语言,默认固定为 `en-US`。
43
- * @returns 首个 Unicode 码点转换后的文本。
44
- */
45
- export declare function upperFirst(value: string, locale?: StringLocale): string;
46
- /**
47
- * 将首个 Unicode 码点转为小写。
48
- *
49
- * @param value - 输入文本;空字符串保持为空。
50
- * @param locale - 显式语言,默认固定为 `en-US`。
51
- * @returns 首个 Unicode 码点转换后的文本。
52
- */
53
- export declare function lowerFirst(value: string, locale?: StringLocale): string;
54
- /**
55
- * 将文本转换为 camelCase。
56
- *
57
- * @param value - 由大小写、连字符、下划线或空白分隔的文本。
58
- * @param locale - 大小写转换使用的语言,默认固定为 `en-US`。
59
- * @returns camelCase 文本。
60
- */
61
- export declare function camelCase(value: string, locale?: StringLocale): string;
62
- /**
63
- * 将文本转换为 PascalCase。
64
- *
65
- * @param value - 参数语义与 {@link camelCase} 一致。
66
- * @param locale - 大小写转换使用的显式语言。
67
- * @returns PascalCase 文本。
68
- */
69
- export declare function pascalCase(value: string, locale?: StringLocale): string;
70
- /**
71
- * 将文本转换为 kebab-case。
72
- *
73
- * @param value - 参数语义与 {@link camelCase} 一致。
74
- * @param locale - 大小写转换使用的显式语言。
75
- * @returns kebab-case 文本。
76
- */
77
- export declare function kebabCase(value: string, locale?: StringLocale): string;
78
- /**
79
- * 按 Unicode 字素簇截断文本,避免拆开 emoji、组合音标或代理对。
80
- *
81
- * @param value - 输入文本。
82
- * @param maxLength - 保留的最大字素簇数量。
83
- * @param suffix - 被截断时追加的文本,默认单字符省略号 `…`;不计入上限。
84
- * @param locale - 字素分割语言,默认固定为 `en-US`。
85
- * @returns 未超限时返回原字符串,否则返回截断内容与后缀。
86
- * @throws `RangeError` 当 `maxLength` 不是非负安全整数或 Locale 无效;缺少
87
- * `Intl.Segmenter` 时抛出 `Error`。
88
- */
89
- export declare function truncateGraphemes(value: string, maxLength: number, suffix?: string, locale?: StringLocale): string;
90
- /**
91
- * 把文本复制到系统剪贴板。
92
- *
93
- * @remarks uni-app 使用 `setClipboardData`;浏览器优先使用 Clipboard API,并在该 API 不可用时
94
- * 回退到 `document.execCommand("copy")`。平台拒绝访问剪贴板时不会静默忽略错误。
95
- * @param value - 要复制的文本。
96
- * @returns 复制完成后兑现的 Promise。
97
- * @throws `Error` 当运行时没有可用的剪贴板能力或复制失败。
98
- */
99
- export declare function copy(value: string): Promise<void>;
100
- /**
101
- * 生成随机字符串。
102
- *
103
- * @remarks 优先使用 Web Crypto;平台缺少安全随机能力时回退到 `Math.random()`。
104
- * @param length - 字符数量,必须是 0 至 1,000,000 的安全整数。
105
- * @param alphabet - 不得为空、包含重复字符或超过 2^32 个 Unicode 码点。
106
- * @returns 由 `alphabet` 中 Unicode 码点组成的随机文本。
107
- * @throws `RangeError` 当长度或字母表非法。
108
- */
109
- export declare function randomString(length: number, alphabet?: string): string;
110
- /**
111
- * 生成 RFC 4122 version 4 UUID。
112
- *
113
- * @remarks 优先使用 Web Crypto;平台缺少安全随机能力时回退到 `Math.random()`。
114
- * 该 UUID 适合普通唯一标识,不应作为安全令牌或秘密。
115
- * @returns 小写、带连字符的 UUID v4。
116
- */
117
- export declare function generateUuidV4(): string;
118
- /**
119
- * 判断字符串是否为 RFC 4122 version 4 UUID。
120
- *
121
- * @param value - 待验证文本;十六进制字母大小写均可。
122
- * @returns 版本位与 Variant 位均正确时返回 `true`。
123
- */
124
- export declare function isUuidV4(value: string): boolean;
125
- /**
126
- * 转义 HTML 文本上下文中的五个特殊字符。
127
- *
128
- * @remarks 这不是 HTML 清洗器,不能让不可信文本安全进入 URL、CSS、脚本或属性名上下文。
129
- * @param value - 将作为 HTML 文本节点内容的字符串。
130
- * @returns 转义 `&`、`<`、`>`、双引号与单引号后的文本。
131
- */
132
- export declare function escapeHtml(value: string): string;
133
- /**
134
- * 把连续 Unicode 空白折叠为单个空格并删除两端空白。
135
- *
136
- * @param value - 输入文本。
137
- * @returns 规范化后的文本;全空白输入返回空字符串。
138
- */
139
- export declare function normalizeWhitespace(value: string): string;
140
- //#endregion
141
- //# sourceMappingURL=index.d.mts.map
@@ -1,21 +0,0 @@
1
- import { ComputedRef, ShallowRef } from "vue";
2
- //#region src/vue/breakpoints.d.ts
3
- /** 断点名称与最小视口宽度的映射。 */
4
- export type Breakpoints<Key extends string = string> = Readonly<Record<Key, number>>;
5
- /** `useBreakpoints` 返回的断点状态。 */
6
- export type UseBreakpointsReturn<Key extends string> = Readonly<Record<Key, Readonly<ShallowRef<boolean>>>> & {
7
- /** 返回当前命中的最大断点名称。 */
8
- active: () => ComputedRef<Key | "">;
9
- };
10
- /**
11
- * 使用原生 Media Query 创建响应式最小宽度断点。
12
- *
13
- * @param breakpoints - 断点名称与非负像素宽度的映射。
14
- * @returns 每个断点的只读状态和当前最大命中断点。
15
- * @throws `Error` 当浏览器环境中不存在可用于自动清理的 Vue 响应式作用域。
16
- * @throws `TypeError` 当断点使用保留名称 `active`。
17
- * @throws `RangeError` 当断点宽度不是非负有限数值。
18
- */
19
- export declare function useBreakpoints<Key extends string>(breakpoints: Breakpoints<Key>): UseBreakpointsReturn<Key>;
20
- //#endregion
21
- //# sourceMappingURL=breakpoints.d.mts.map
@@ -1,25 +0,0 @@
1
- import { ResizeObserverTarget } from "./resize-observer.mjs";
2
- import { ShallowRef } from "vue";
3
- //#region src/vue/element-size.d.ts
4
- /** 元素的二维尺寸。 */
5
- export interface ElementSize {
6
- readonly width: number;
7
- readonly height: number;
8
- }
9
- /** `useElementSize` 返回的响应式尺寸和停止函数。 */
10
- export interface UseElementSizeReturn {
11
- readonly width: Readonly<ShallowRef<number>>;
12
- readonly height: Readonly<ShallowRef<number>>;
13
- readonly stop: () => void;
14
- }
15
- /**
16
- * 响应式读取元素 Content Rect 尺寸。
17
- *
18
- * @param target - 原生元素、Ref 或 Getter。
19
- * @param initialSize - 收到首次观察结果前的尺寸,默认均为 `0`。
20
- * @param options - 原生元素观察选项。
21
- * @returns 只读宽度、高度和手动停止函数。
22
- */
23
- export declare function useElementSize(target: ResizeObserverTarget, initialSize?: ElementSize, options?: ResizeObserverOptions): UseElementSizeReturn;
24
- //#endregion
25
- //# sourceMappingURL=element-size.d.mts.map
@@ -1,23 +0,0 @@
1
- import { ComputedRef } from "vue";
2
- //#region src/vue/emits.d.ts
3
- /** Vue Emits 对象中允许的校验器形状。 */
4
- type EmitValidator = ((...arguments_: never[]) => unknown) | null;
5
- /** 事件名到可选参数校验器的内部映射。 */
6
- type EmitsOptions = Record<string, EmitValidator>;
7
- /** 从校验器中提取事件参数;无校验器时保留未知参数。 */
8
- type EventArguments<Validator> = Validator extends ((...arguments_: infer Arguments) => unknown) ? Arguments : unknown[];
9
- /** 在类型层递归把 kebab-case 事件名转换为 PascalCase。 */
10
- type PascalEventName<Value extends string> = Value extends `${infer Head}-${infer Tail}` ? `${Capitalize<Head>}${PascalEventName<Tail>}` : Capitalize<Value>;
11
- /** 把事件配置映射为 Vue `onXxx` 属性。 */
12
- export type EmitHandlers<Emits extends EmitsOptions> = { [Name in keyof Emits as Name extends string ? `on${PascalEventName<Name>}` : never]: (...arguments_: EventArguments<Emits[Name]>) => void; };
13
- /**
14
- * 构建响应式 Vue 事件处理器。
15
- *
16
- * @param emits - Vue emits 配置对象。
17
- * @param emit - `setup` 上下文提供的 emit 函数。
18
- * @param ignoredEvents - 不需要向子组件透传的事件名。
19
- * @returns 随配置重新计算的事件处理器对象。
20
- */
21
- export declare function useEmits<Emits extends EmitsOptions>(emits: Emits, emit: (...arguments_: never[]) => unknown, ignoredEvents?: readonly (keyof Emits)[]): ComputedRef<Partial<EmitHandlers<Emits>>>;
22
- //#endregion
23
- //# sourceMappingURL=emits.d.mts.map
@@ -1,16 +0,0 @@
1
- import { MaybeRefOrGetter } from "vue";
2
- //#region src/vue/event-listener.d.ts
3
- /** `useEventListener` 接受的原生事件目标或响应式事件目标。 */
4
- export type EventTargetSource = MaybeRefOrGetter<EventTarget | null | undefined>;
5
- /**
6
- * 注册原生事件监听器,并在目标变化或 Vue 作用域销毁时自动移除。
7
- *
8
- * @param target - 原生事件目标、Ref 或 Getter。
9
- * @param event - 原生事件名称。
10
- * @param listener - 事件回调。
11
- * @param options - 原生事件监听选项。
12
- * @returns 可提前移除监听器的停止函数。
13
- */
14
- export declare function useEventListener<EventType extends Event = Event>(target: EventTargetSource, event: string, listener: (event: EventType) => void, options?: boolean | AddEventListenerOptions): () => void;
15
- //#endregion
16
- //# sourceMappingURL=event-listener.d.mts.map
@@ -1,11 +0,0 @@
1
- //#region src/vue/expose.d.ts
2
- /**
3
- * 同时暴露组件实例能力并返回同一个对象,便于 `setup` 返回状态供 Vue Devtools 查看。
4
- *
5
- * @param expose - `setup` 上下文提供的 expose 函数。
6
- * @param exposed - 需要暴露的状态和方法。
7
- * @returns 原始 exposed 对象。
8
- */
9
- export declare function useExpose<Exposed extends object>(expose: (exposed?: Exposed) => void, exposed: Exposed): Exposed;
10
- //#endregion
11
- //# sourceMappingURL=expose.d.mts.map
@@ -1,13 +0,0 @@
1
- //#region src/vue/func.d.ts
2
- /** 可同步或异步返回结果的函数。 */
3
- export type AwaitableFunction<Arguments extends readonly unknown[], Result> = (...arguments_: Arguments) => Result | PromiseLike<Result>;
4
- /**
5
- * 统一执行同步或异步函数,异常保持原样向调用方传播。
6
- *
7
- * @param function_ - 可选的待执行函数。
8
- * @param arguments_ - 原样传入函数的参数。
9
- * @returns 函数结果;未传函数时返回 `undefined`。
10
- */
11
- export declare function callOptionalFunction<Arguments extends readonly unknown[], Result>(function_: AwaitableFunction<Arguments, Result> | null | undefined, ...arguments_: Arguments): Promise<Awaited<Result> | undefined>;
12
- //#endregion
13
- //# sourceMappingURL=func.d.mts.map
@@ -1,15 +0,0 @@
1
- import { Breakpoints, UseBreakpointsReturn, useBreakpoints } from "./breakpoints.mjs";
2
- import { ResizeObserverTarget, useResizeObserver } from "./resize-observer.mjs";
3
- import { ElementSize, UseElementSizeReturn, useElementSize } from "./element-size.mjs";
4
- import { EmitHandlers, useEmits } from "./emits.mjs";
5
- import { EventTargetSource, useEventListener } from "./event-listener.mjs";
6
- import { useExpose } from "./expose.mjs";
7
- import { AwaitableFunction, callOptionalFunction } from "./func.mjs";
8
- import { Installable, TSXWithInstall, VueInstallValue, withInstall, withInstallDirective, withNoopInstall } from "./install.mjs";
9
- import { useNow } from "./now.mjs";
10
- import { definePropType, useProps } from "./props.mjs";
11
- import { useRender } from "./render.mjs";
12
- import { TypedSlots, TypedSlotsDeclaration, makeSlots } from "./slots.mjs";
13
- import { UseWindowSizeReturn, useWindowSize } from "./window-size.mjs";
14
- import { withDefineType } from "./with.mjs";
15
- export { AwaitableFunction, Breakpoints, ElementSize, EmitHandlers, EventTargetSource, Installable, ResizeObserverTarget, TSXWithInstall, TypedSlots, TypedSlotsDeclaration, UseBreakpointsReturn, UseElementSizeReturn, UseWindowSizeReturn, VueInstallValue, callOptionalFunction, definePropType, makeSlots, useBreakpoints, useElementSize, useEmits, useEventListener, useExpose, useNow, useProps, useRender, useResizeObserver, useWindowSize, withDefineType, withInstall, withInstallDirective, withNoopInstall };
@@ -1,50 +0,0 @@
1
- import { App } from "vue";
2
- //#region src/vue/install.d.ts
3
- /** Vue 组件对象、函数组件或指令对象可接受的最小结构类型。 */
4
- export type VueInstallValue = object | ((...arguments_: never[]) => unknown);
5
- /** 为 Vue 组件或指令附加供 Vue 3 `app.use()` 调用的安装能力。 */
6
- export type Installable<Value> = Value & {
7
- /**
8
- * 把当前组件或指令安装到 Vue 3 App。
9
- * @param app - Vue 3 App 实例。
10
- */
11
- install: (app: App) => void;
12
- };
13
- /** TSX 组件安装类型;与 {@link Installable} 保持同一运行时契约。 */
14
- export type TSXWithInstall<Value> = Installable<Value>;
15
- /**
16
- * 为主组件附加 Vue 3 `app.use()` 安装能力。
17
- *
18
- * @remarks 函数会直接为 `main` 定义附属组件属性和 `install`。所有组件名称、附属属性
19
- * 冲突会在修改 `main` 前完成校验;安装到 App 时也会先预检全部全局名称,再统一注册。
20
- * @param main - 具有非空 `name` 的组件。
21
- * @param extras - 同时注册并以可枚举属性挂到主组件的附属组件映射。
22
- * @returns 原始 `main` 引用,并附加类型化的 `install` 与 `extras` 属性。
23
- * @throws `TypeError` 当组件缺少合法名称、已有 `install`、附属键或名称发生冲突。
24
- * @throws `Error` 当 App 中同名位置已经注册其他组件。
25
- */
26
- export declare function withInstall<Main extends VueInstallValue, Extras extends Record<string, VueInstallValue> = Record<never, never>>(main: Main, extras?: Extras): Installable<Main> & Extras;
27
- /**
28
- * 为不需要单独注册的附属组件附加空安装函数。
29
- *
30
- * @remarks 适用于只能作为主组件附属属性使用、但仍需满足 Vue Plugin 类型的组件。
31
- * 函数直接修改并返回传入组件,不会向 Vue 3 App 注册内容。
32
- * @param component - 尚未定义或继承 `install` 属性的组件。
33
- * @returns 原组件引用及无副作用的 `install` 方法。
34
- * @throws `TypeError` 当组件自身或原型链已经存在 `install`。
35
- */
36
- export declare function withNoopInstall<Value extends VueInstallValue>(component: Value): TSXWithInstall<Value>;
37
- /**
38
- * 为 Vue 3 指令附加插件安装能力。
39
- *
40
- * @remarks 函数直接修改并返回指令。安装时重复注册同一引用保持幂等,不会覆盖同名的
41
- * 其他指令。名称只传给 `directive()`,不得包含 `v-` 前缀。
42
- * @param directive - 尚未定义或继承 `install` 属性的 Vue 指令对象。
43
- * @param name - 非空、无空白且不以 `v-` 开头的全局指令名。
44
- * @returns 原指令引用及 Vue Plugin `install` 方法。
45
- * @throws `TypeError` 当名称非法、指令已有 `install`,或安装目标无效。
46
- * @throws `Error` 当 App 中同名位置已经注册其他指令。
47
- */
48
- export declare function withInstallDirective<Value extends VueInstallValue>(directive: Value, name: string): Installable<Value>;
49
- //#endregion
50
- //# sourceMappingURL=install.d.mts.map
@@ -1,13 +0,0 @@
1
- import { ShallowRef } from "vue";
2
- //#region src/vue/now.d.ts
3
- /**
4
- * 按固定间隔提供响应式当前时间。
5
- *
6
- * @param intervalMilliseconds - 更新时间间隔,默认 `1000` 毫秒。
7
- * @returns 当前 Date 的只读 ShallowRef;SSR 环境只返回调用时的时间。
8
- * @throws `Error` 当浏览器或 uni-app 环境中不存在可用于自动清理的 Vue 响应式作用域。
9
- * @throws `RangeError` 当间隔不是平台计时器支持的非负有限整数。
10
- */
11
- export declare function useNow(intervalMilliseconds?: number): Readonly<ShallowRef<Date>>;
12
- //#endregion
13
- //# sourceMappingURL=now.d.mts.map
@@ -1,22 +0,0 @@
1
- import { ComputedRef, PropType } from "vue";
2
- //#region src/vue/props.d.ts
3
- /**
4
- * 为 Vue 运行时 Props 构造器附加泛型类型。
5
- *
6
- * @remarks 该函数只帮助 TypeScript 建模,不验证运行时值与 `Value` 一致;调用方仍应
7
- * 传入 Vue 支持的构造器或构造器数组。
8
- * @param runtimeType - Vue 支持的运行时构造器或构造器数组。
9
- * @returns 同一引用,仅在类型层收窄为 `PropType<Value>`。
10
- */
11
- export declare function definePropType<Value>(runtimeType: unknown): PropType<Value>;
12
- /**
13
- * 构建需要透传给子组件的响应式 Props。
14
- *
15
- * @param props - Vue `setup` 接收的只读响应式 Props 对象。
16
- * @param rawProps - 子组件的运行时 Props 配置。
17
- * @param ignoredProps - 不需要透传的 Props 名称。
18
- * @returns 只包含 `rawProps` 声明键且随 Props 更新的 ComputedRef。
19
- */
20
- export declare function useProps<Props extends object, RawProps extends object, IgnoredProp extends keyof RawProps = never>(props: Props, rawProps: RawProps, ignoredProps?: readonly IgnoredProp[]): ComputedRef<Omit<Pick<Props, Extract<keyof Props, keyof RawProps>>, Extract<IgnoredProp, keyof Props>>>;
21
- //#endregion
22
- //# sourceMappingURL=props.d.mts.map
@@ -1,11 +0,0 @@
1
- import { VNode } from "vue";
2
- //#region src/vue/render.d.ts
3
- /**
4
- * 在当前 Vue 3 组件实例上安装 TSX 渲染函数。
5
- * @remarks `setup` 仍可返回状态对象,因此状态能够显示在 Vue Devtools 中。
6
- * @param render - 当前组件的渲染函数。
7
- * @throws 不在组件 `setup` 调用栈中使用时抛出 `Error`。
8
- */
9
- export declare function useRender(render: () => VNode): void;
10
- //#endregion
11
- //# sourceMappingURL=render.d.mts.map
@@ -1,15 +0,0 @@
1
- import { MaybeRefOrGetter } from "vue";
2
- //#region src/vue/resize-observer.d.ts
3
- /** `useResizeObserver` 接受的元素或响应式元素。 */
4
- export type ResizeObserverTarget = MaybeRefOrGetter<Element | null | undefined>;
5
- /**
6
- * 监听元素尺寸变化,并随响应式目标切换和 Vue 作用域销毁自动断开。
7
- *
8
- * @param target - 原生元素、Ref 或 Getter。
9
- * @param callback - 原生 ResizeObserver 回调。
10
- * @param options - 原生元素观察选项。
11
- * @returns 可提前断开观察的停止函数;运行时不支持 ResizeObserver 时为空操作。
12
- */
13
- export declare function useResizeObserver(target: ResizeObserverTarget, callback: ResizeObserverCallback, options?: ResizeObserverOptions): () => void;
14
- //#endregion
15
- //# sourceMappingURL=resize-observer.d.mts.map
@@ -1,18 +0,0 @@
1
- import { SlotsType, VNode } from "vue";
2
- //#region src/vue/slots.d.ts
3
- /** Slot 名到 Props 类型的内部声明映射。 */
4
- type RawSlots = Record<string, unknown>;
5
- /** 根据 Slot Props 是否为 never 生成无参数或有参数的 Slot 签名。 */
6
- type VueSlot<Properties> = [Properties] extends [never] ? () => VNode[] : (properties: Properties) => VNode[];
7
- /** 把 Slot 名称与作用域参数映射为 Vue 3 Slot 函数。 */
8
- export type TypedSlots<Slots extends RawSlots> = { [Name in keyof Slots]: VueSlot<Slots[Name]>; };
9
- /** Vue 3 `slots` 选项接受的运行时声明与官方静态类型标记。 */
10
- export type TypedSlotsDeclaration<Slots extends RawSlots> = SlotsType<Partial<TypedSlots<Slots>>>;
11
- /**
12
- * 为 Options API 的 `slots` 选项创建带作用域参数的类型声明。
13
- *
14
- * @returns 运行时 `Object` 构造器,并携带仅供 TypeScript 使用的 Slot 类型标记。
15
- */
16
- export declare function makeSlots<Slots extends RawSlots>(): TypedSlotsDeclaration<Slots>;
17
- //#endregion
18
- //# sourceMappingURL=slots.d.mts.map