vitepress-plugin-toolkit 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,389 @@
1
+ # vitepress-plugin-toolkit
2
+
3
+ > [English Documentation](./README.md)
4
+
5
+ VitePress 插件开发工具包,为 VitePress 插件作者提供 Node 端和 Client 端的通用工具、组件和组合式函数。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ pnpm add vitepress-plugin-toolkit
11
+ ```
12
+
13
+ ## 入口
14
+
15
+ | 入口 | 说明 |
16
+ | ----------------------------------- | -------------------------------------------------------------- |
17
+ | `vitepress-plugin-toolkit` | Node 端工具(markdown-it 插件、Vite 插件、VitePress 配置工具) |
18
+ | `vitepress-plugin-toolkit/client` | Client 端工具(Vue 组件、composables、环境检测工具) |
19
+ | `vitepress-plugin-toolkit/styles/*` | CSS 过渡动效和组件样式 |
20
+
21
+ ## Node 端 API
22
+
23
+ ### Markdown 工具
24
+
25
+ #### `createEmbedRuleBlock(md, options)`
26
+
27
+ 创建一个嵌入规则块,用于解析 `@[type info](source)` 语法的 markdown 标记。
28
+
29
+ ```ts
30
+ import { createEmbedRuleBlock } from 'vitepress-plugin-toolkit'
31
+
32
+ createEmbedRuleBlock(md, {
33
+ type: 'video',
34
+ meta: (info, source) => ({ src: source, title: info }),
35
+ content: meta => `<video src="${meta.src}" title="${meta.title}"></video>`,
36
+ })
37
+ ```
38
+
39
+ Markdown 中使用:
40
+
41
+ ```md
42
+ @[video 我的视频](https://example.com/video.mp4)
43
+ ```
44
+
45
+ **选项:**
46
+
47
+ | 参数 | 类型 | 说明 |
48
+ | --------- | ------------------------------------------ | ----------------------------------------------- |
49
+ | `type` | `string` | 嵌入类型标识,如 `'video'`、`'embed'` |
50
+ | `name` | `string` | 可选,自定义 token 名称,默认为 `embed_${type}` |
51
+ | `meta` | `(info: string, source: string) => Meta` | 解析 info 和 source 为元数据对象 |
52
+ | `content` | `(meta: Meta, env: MarkdownEnv) => string` | 可选,从元数据生成 HTML 内容 |
53
+
54
+ #### `createContainerPlugin(md, type, options?)`
55
+
56
+ 基于 `markdown-it-container` 创建自定义容器插件。内容由 markdown-it 正常处理。
57
+
58
+ ```ts
59
+ import { createContainerPlugin } from 'vitepress-plugin-toolkit'
60
+
61
+ md.use(createContainerPlugin, 'tip', {
62
+ before: info => `<div class="tip">${info}`,
63
+ after: () => '</div>',
64
+ })
65
+ ```
66
+
67
+ Markdown 中使用:
68
+
69
+ ```md
70
+ ::: tip 提示
71
+ 这是一条提示信息
72
+ :::
73
+ ```
74
+
75
+ **选项:**
76
+
77
+ | 参数 | 类型 | 说明 |
78
+ | -------- | ----------------------------------------------------- | ------------------------ |
79
+ | `before` | `(info: string, ...args: RenderRuleParams) => string` | 可选,容器开始标签的回调 |
80
+ | `after` | `(info: string, ...args: RenderRuleParams) => string` | 可选,容器结束标签的回调 |
81
+
82
+ #### `createContainerSyntaxPlugin(md, type, render?)`
83
+
84
+ 创建一个自定义容器语法插件,容器内的内容**不经过** markdown-it 处理,而是完整交给自定义渲染函数。
85
+
86
+ ```ts
87
+ import { createContainerSyntaxPlugin } from 'vitepress-plugin-toolkit'
88
+
89
+ createContainerSyntaxPlugin(md, 'chart', (tokens, idx) => {
90
+ const { content, meta } = tokens[idx]
91
+ return `<div class="chart">${content}</div>`
92
+ })
93
+ ```
94
+
95
+ ### VitePress 配置工具
96
+
97
+ #### `getVitepressConfig()`
98
+
99
+ 从 `globalThis.VITEPRESS_CONFIG` 获取当前 VitePress 站点配置。
100
+
101
+ ```ts
102
+ import { getVitepressConfig } from 'vitepress-plugin-toolkit'
103
+
104
+ const config = getVitepressConfig()
105
+ console.log(config.userConfig.title)
106
+ ```
107
+
108
+ #### `createLocales(builtinLocales, userLocales?)`
109
+
110
+ 创建多语言配置,合并内置语言数据和用户自定义语言数据。
111
+
112
+ ```ts
113
+ import { createLocales } from 'vitepress-plugin-toolkit'
114
+
115
+ const locales = createLocales(
116
+ [
117
+ [['en', 'en-US'], { title: 'English' }],
118
+ [['zh', 'zh-CN'], { title: '中文' }],
119
+ ],
120
+ { zh: { title: '我的站点' } },
121
+ )
122
+ ```
123
+
124
+ #### `resolveRouteLink(url, env)`
125
+
126
+ 根据 VitePress 路由规则解析 markdown 链接。支持:
127
+
128
+ - 外部链接原样返回
129
+ - 绝对路径自动添加 site base 前缀
130
+ - 相对 `.md` 链接按 `cleanUrls` 设置转换为 `.html`
131
+ - `index.md` 折叠为目录路径
132
+ - 哈希片段自动 slugify
133
+
134
+ ```ts
135
+ import { resolveRouteLink } from 'vitepress-plugin-toolkit'
136
+
137
+ resolveRouteLink('./guide.md', env) // -> './guide.html' (取决于 cleanUrls)
138
+ ```
139
+
140
+ #### `getLocaleWithPath(path)`
141
+
142
+ 根据路径获取对应的语言代码和语言环境前缀。
143
+
144
+ ```ts
145
+ import { getLocaleWithPath } from 'vitepress-plugin-toolkit'
146
+
147
+ getLocaleWithPath('/zh/guide/') // { lang: 'zh-CN', locale: '/zh/' }
148
+ getLocaleWithPath('/guide/') // { lang: 'en', locale: '' } (root)
149
+ ```
150
+
151
+ ### Vite 插件
152
+
153
+ #### `iconPlugin(icons)`
154
+
155
+ 创建一个 Vite 插件,将 SVG 图标注册为 CSS 自定义属性(`--icon`),生成类如 `.vpi-<name>` 的 CSS 选择器。
156
+
157
+ ```ts
158
+ import { iconPlugin } from 'vitepress-plugin-toolkit'
159
+
160
+ defineConfig({
161
+ vite: {
162
+ plugins: [
163
+ iconPlugin([
164
+ { name: 'github', svg: '<svg>...</svg>' },
165
+ { name: 'twitter', svg: '<svg>...</svg>' },
166
+ ]),
167
+ ],
168
+ },
169
+ })
170
+ ```
171
+
172
+ 使用时只需添加类名即可显示图标:
173
+
174
+ ```html
175
+ <span class="vpi-github"></span>
176
+ ```
177
+
178
+ ### 节点工具函数
179
+
180
+ #### `resolveAttrs(info)` / `resolveAttr(info, key)`
181
+
182
+ 将属性字符串解析为对象,或提取单个属性值。支持 `key="value"` 格式和布尔属性(`disabled` 等)。
183
+
184
+ ```ts
185
+ import { resolveAttrs, resolveAttr } from 'vitepress-plugin-toolkit'
186
+
187
+ resolveAttrs('width="100" height="50"') // { width: '100', height: '50' }
188
+ resolveAttr('width="100" height="50"', 'width') // '100'
189
+ ```
190
+
191
+ #### `stringifyAttrs(attrs, withUndefinedOrNull?, forceStringify?)`
192
+
193
+ 将属性对象字符串化为 HTML 属性字符串。自动处理 Boolean、Number、String 等类型。
194
+
195
+ ```ts
196
+ import { stringifyAttrs } from 'vitepress-plugin-toolkit'
197
+
198
+ stringifyAttrs({ width: 100, disabled: true })
199
+ // ' :width="100" disabled'
200
+ ```
201
+
202
+ #### `parseRect(str, unit?)`
203
+
204
+ 解析尺寸字符串,纯数字自动添加单位(默认 `px`)。
205
+
206
+ ```ts
207
+ import { parseRect } from 'vitepress-plugin-toolkit'
208
+
209
+ parseRect('100') // '100px'
210
+ parseRect('50%') // '50%'
211
+ parseRect('200', 'rpx') // '200rpx'
212
+ ```
213
+
214
+ #### `slugify(str)`
215
+
216
+ 生成 URL 友好的 slug,移除重音符号、控制字符、特殊字符,合并连续分隔符。
217
+
218
+ ```ts
219
+ import { slugify } from 'vitepress-plugin-toolkit'
220
+
221
+ slugify('Hello World!') // 'hello-world'
222
+ ```
223
+
224
+ #### `genHash(data, length?)`
225
+
226
+ 为任意数据生成 SHA-256 哈希值,可指定截断长度。
227
+
228
+ ```ts
229
+ import { genHash } from 'vitepress-plugin-toolkit'
230
+
231
+ genHash('hello') // 完整 SHA-256 哈希
232
+ genHash({ a: 1 }, 8) // 8 位哈希
233
+ ```
234
+
235
+ #### `treatAsHtml(filename)`
236
+
237
+ 判断文件是否为 HTML 路由文件(非静态资源)。
238
+
239
+ ```ts
240
+ import { treatAsHtml } from 'vitepress-plugin-toolkit'
241
+
242
+ treatAsHtml('about') // true
243
+ treatAsHtml('logo.png') // false
244
+ ```
245
+
246
+ #### `createLogger(prefix, defaultLevel?)`
247
+
248
+ 创建带颜色标签、时间戳的格式化日志实例。
249
+
250
+ ```ts
251
+ import { createLogger } from 'vitepress-plugin-toolkit'
252
+
253
+ const logger = createLogger('my-plugin', 'info')
254
+ logger.info('构建开始')
255
+ logger.warn('使用了已废弃的功能')
256
+ logger.debug('详细日志', 'debug')
257
+ ```
258
+
259
+ #### 常量
260
+
261
+ ```ts
262
+ import {
263
+ isBuild, // 是否生产构建
264
+ isDev, // 是否开发模式
265
+ EXTENSION_VIDEOS, // 浏览器支持的视频扩展名
266
+ EXTENSION_IMAGES, // 浏览器支持的图片扩展名
267
+ EXTENSION_AUDIOS, // 浏览器支持的音频扩展名
268
+ } from 'vitepress-plugin-toolkit'
269
+ ```
270
+
271
+ ## Client 端 API
272
+
273
+ ### Vue 组件
274
+
275
+ - `VPCopyButton` — 复制按钮组件
276
+ - `VPLoading` — 加载动画组件
277
+ - `VPTabSwitch` — Tab 切换组件
278
+
279
+ ```vue
280
+ <script setup>
281
+ import { VPCopyButton, VPLoading, VPTabSwitch } from 'vitepress-plugin-toolkit/client'
282
+ </script>
283
+
284
+ <template>
285
+ <VPCopyButton text="点击复制此文本" />
286
+ <VPLoading :size="40" />
287
+ <VPTabSwitch :tabs="['代码', '预览']" />
288
+ </template>
289
+ ```
290
+
291
+ ### Composables
292
+
293
+ #### `useSize(el, options, extraHeight?)`
294
+
295
+ 基于宽度、高度和宽高比选项的响应式尺寸计算。自动监听窗口 resize 和 orientationchange 事件。
296
+
297
+ ```ts
298
+ import { useSize } from 'vitepress-plugin-toolkit/client'
299
+
300
+ const el = ref<HTMLElement>()
301
+ const { width, height, resize } = useSize(
302
+ el,
303
+ toRefs({ width: '100%', ratio: '16:9' }),
304
+ )
305
+ ```
306
+
307
+ #### `useZoomAndDrag(parentEl)`
308
+
309
+ 为内容舞台提供缩放和拖拽交互功能,支持鼠标拖拽、触摸拖拽和双指缩放。
310
+
311
+ ```ts
312
+ import { useZoomAndDrag } from 'vitepress-plugin-toolkit/client'
313
+
314
+ const stageEl = ref<HTMLDivElement>()
315
+ const { actorStyle, zoom, zoomIn, zoomOut, resetZoom, reset } = useZoomAndDrag(stageEl)
316
+ ```
317
+
318
+ ### 环境检测
319
+
320
+ ```ts
321
+ import {
322
+ isiPhone, // 是否 iPhone
323
+ isiPad, // 是否 iPad
324
+ isIOS, // 是否 iOS
325
+ isWindows, // 是否 Windows
326
+ isMacOS, // 是否 macOS
327
+ isSafari, // 是否 Safari 浏览器
328
+ isMobile, // 是否移动设备
329
+ } from 'vitepress-plugin-toolkit/client'
330
+ ```
331
+
332
+ ### CSS 过渡动效
333
+
334
+ 通过 `vitepress-plugin-toolkit/styles/*` 导入预置的 CSS 过渡动效类:
335
+
336
+ ```
337
+ vitepress-plugin-toolkit/styles/transition/fade-in.css
338
+ vitepress-plugin-toolkit/styles/transition/fade-in-up.css
339
+ vitepress-plugin-toolkit/styles/transition/fade-in-down.css
340
+ vitepress-plugin-toolkit/styles/transition/fade-in-left.css
341
+ vitepress-plugin-toolkit/styles/transition/fade-in-right.css
342
+ vitepress-plugin-toolkit/styles/transition/fade-in-scale-up.css
343
+ vitepress-plugin-toolkit/styles/transition/fade-in-width-expand.css
344
+ vitepress-plugin-toolkit/styles/transition/fade-in-height-expand.css
345
+ vitepress-plugin-toolkit/styles/transition/slide-in-up.css
346
+ vitepress-plugin-toolkit/styles/transition/slide-in-down.css
347
+ vitepress-plugin-toolkit/styles/transition/slide-in-left.css
348
+ vitepress-plugin-toolkit/styles/transition/slide-in-right.css
349
+ ```
350
+
351
+ ```ts
352
+ import 'vitepress-plugin-toolkit/styles/transition/fade-in-up.css'
353
+ ```
354
+
355
+ ## Shared(共享)
356
+
357
+ 以下工具同时在 Node 端和 Client 端可用。
358
+
359
+ ### `isExternal(path)` / `isLinkWithProtocol(link)`
360
+
361
+ 判断是否为外部链接。
362
+
363
+ ```ts
364
+ import { isExternal, isLinkWithProtocol } from 'vitepress-plugin-toolkit'
365
+
366
+ isExternal('https://example.com') // true
367
+ isExternal('/about') // false
368
+ isLinkWithProtocol('//cdn.example.com/lib.js') // true
369
+ ```
370
+
371
+ ### `EXTERNAL_URL_RE` / `URL_PROTOCOL_RE`
372
+
373
+ 匹配外部 URL 和协议的正则表达式。
374
+
375
+ ### `SizeOptions`
376
+
377
+ 尺寸配置的 TypeScript 接口:
378
+
379
+ ```ts
380
+ interface SizeOptions {
381
+ width?: string // 宽度 CSS 值,如 '100%'、'640px'
382
+ height?: string // 高度 CSS 值,如 'auto'、'360px'
383
+ ratio?: number | string // 宽高比,如 16/9 或 '16:9'
384
+ }
385
+ ```
386
+
387
+ ## 许可
388
+
389
+ MIT
@@ -1,39 +1,130 @@
1
1
  import { MaybeRef, Ref, TemplateRef, ToRefs } from "vue";
2
2
 
3
3
  //#region src/shared/link.d.ts
4
+ /**
5
+ * Regular expression that matches external URLs.
6
+ *
7
+ * Matches URLs that start with a protocol (such as `http:` or `mailto:`) or
8
+ * with `//` (protocol-relative URLs).
9
+ *
10
+ * 匹配外部链接的正则表达式。
11
+ *
12
+ * 匹配以协议(如 `http:` 或 `mailto:`)或 `//`(协议相对链接)开头的 URL。
13
+ *
14
+ * @example
15
+ * EXTERNAL_URL_RE.test('https://example.com') // true
16
+ * EXTERNAL_URL_RE.test('//cdn.example.com/lib.js') // true
17
+ * EXTERNAL_URL_RE.test('/about') // false
18
+ */
4
19
  declare const EXTERNAL_URL_RE: RegExp;
20
+ /**
21
+ * Checks whether the given path is an external URL.
22
+ *
23
+ * 判断给定路径是否为外部链接。
24
+ *
25
+ * @param path - The path to check / 要检查的路径
26
+ * @returns `true` if the path is an external URL, otherwise `false` / 若为外部链接返回 `true`,否则返回 `false`
27
+ * @example
28
+ * isExternal('https://example.com') // true
29
+ * isExternal('//cdn.example.com/lib.js') // true
30
+ * isExternal('/about') // false
31
+ * isExternal('mailto:foo@example.com') // true
32
+ */
5
33
  declare function isExternal(path: string): boolean;
34
+ /**
35
+ * Regular expression that matches the protocol scheme of a URL.
36
+ *
37
+ * Matches the leading protocol portion such as `http:`, `https:`, or
38
+ * `mailto:`. Does not match protocol-relative URLs (`//`).
39
+ *
40
+ * 匹配 URL 协议部分的正则表达式。
41
+ *
42
+ * 匹配前导协议部分,如 `http:`、`https:` 或 `mailto:`。
43
+ * 不匹配协议相对链接(`//`)。
44
+ *
45
+ * @example
46
+ * URL_PROTOCOL_RE.test('https://example.com') // true
47
+ * URL_PROTOCOL_RE.test('mailto:foo@example.com') // true
48
+ * URL_PROTOCOL_RE.test('//cdn.example.com/lib.js') // false
49
+ */
6
50
  declare const URL_PROTOCOL_RE: RegExp;
51
+ /**
52
+ * Checks whether the given link contains a URL protocol scheme or is a
53
+ * protocol-relative URL.
54
+ *
55
+ * Unlike {@link isExternal}, this function also matches links that start with
56
+ * `//` via an additional check, in addition to those matched by
57
+ * {@link URL_PROTOCOL_RE}.
58
+ *
59
+ * 判断给定链接是否包含 URL 协议部分或为协议相对链接。
60
+ *
61
+ * 与 {@link isExternal} 不同,此函数除了匹配 {@link URL_PROTOCOL_RE} 之外,
62
+ * 还会通过额外检查匹配以 `//` 开头的链接。
63
+ *
64
+ * @param link - The link to check / 要检查的链接
65
+ * @returns `true` if the link has a protocol or starts with `//` / 若链接包含协议或以 `//` 开头则返回 `true`
66
+ * @example
67
+ * isLinkWithProtocol('https://example.com') // true
68
+ * isLinkWithProtocol('mailto:foo@example.com') // true
69
+ * isLinkWithProtocol('//cdn.example.com/lib.js') // true
70
+ * isLinkWithProtocol('/about') // false
71
+ */
7
72
  declare function isLinkWithProtocol(link: string): boolean;
8
73
  //#endregion
9
74
  //#region src/shared/size.d.ts
10
75
  /**
11
- * Size Options
76
+ * Options for describing the size of an element.
77
+ *
78
+ * Used by plugins to normalize width, height, and aspect ratio inputs into a
79
+ * consistent CSS-friendly form.
12
80
  *
13
- * 尺寸选项
81
+ * 描述元素尺寸的选项。
82
+ *
83
+ * 供插件使用,将宽度、高度和宽高比输入归一化为一致的 CSS 友好形式。
84
+ *
85
+ * @example
86
+ * const options: SizeOptions = {
87
+ * width: '100%',
88
+ * ratio: 16 / 9,
89
+ * }
14
90
  */
15
91
  interface SizeOptions {
16
92
  /**
17
- * Width
93
+ * Width of the element, expressed as a CSS value.
94
+ *
95
+ * 元素的宽度,以 CSS 值表示。
18
96
  *
19
- * 宽度
97
+ * @example
98
+ * '100%' | '640px' | 'auto'
20
99
  */
21
100
  width?: string;
22
101
  /**
23
- * Height
102
+ * Height of the element, expressed as a CSS value.
24
103
  *
25
- * 高度
104
+ * 元素的高度,以 CSS 值表示。
105
+ *
106
+ * @example
107
+ * '100%' | '360px' | 'auto'
26
108
  */
27
109
  height?: string;
28
110
  /**
29
- * Aspect ratio
111
+ * Aspect ratio of the element. Can be:
112
+ * - `number`: Numeric ratio (for example `16 / 9` represents 16:9)
113
+ * - `string`: CSS aspect-ratio value (for example `'16 / 9'` or `'1.77'`)
114
+ *
115
+ * 元素的宽高比。可以是:
116
+ * - `number`:数字比例(例如 `16 / 9` 表示 16:9)
117
+ * - `string`:CSS aspect-ratio 值(例如 `'16 / 9'` 或 `'1.77'`)
30
118
  *
31
- * 宽高比
119
+ * @example
120
+ * 16 / 9
121
+ * '16 / 9'
32
122
  */
33
123
  ratio?: number | string;
34
124
  }
35
125
  //#endregion
36
126
  //#region src/client/components/VPCopyButton.vue.d.ts
127
+ /** Text to copy to the clipboard / 要复制到剪贴板的文本 */
37
128
  type __VLS_Props$1 = {
38
129
  text: string;
39
130
  };
@@ -41,23 +132,44 @@ declare const __VLS_export$2: import("vue").DefineComponent<__VLS_Props$1, {}, {
41
132
  declare const _default: typeof __VLS_export$2;
42
133
  //#endregion
43
134
  //#region src/client/components/VPLoading.vue.d.ts
135
+ /**
136
+ * A loading indicator component with an animated SVG spinner.
137
+ *
138
+ * 带有 SVG 动画旋转图标的加载指示器组件。
139
+ *
140
+ * @example
141
+ * ```vue
142
+ * <VPLoading />
143
+ *
144
+ * <VPLoading absolute height="200px" />
145
+ * ```
146
+ */
44
147
  type __VLS_Props = {
45
- absolute?: boolean;
148
+ /** Whether to position the loader absolutely / 是否以绝对定位渲染加载器 */absolute?: boolean; /** Custom height for the loading container / 加载容器的自定义高度 */
46
149
  height?: string;
47
150
  };
48
151
  declare const __VLS_export$1: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
49
152
  declare const _default$1: typeof __VLS_export$1;
50
153
  //#endregion
51
154
  //#region src/client/components/VPTabSwitch.vue.d.ts
155
+ /**
156
+ * Represents a single tab item.
157
+ *
158
+ * 表示单个标签项。
159
+ *
160
+ * @template T - Type of the tab value / 标签值的类型
161
+ */
52
162
  interface Item<T> {
163
+ /** Value of the tab item / 标签项的值 */
53
164
  value: T;
165
+ /** Display label of the tab item / 标签项的显示文本 */
54
166
  label: string;
55
167
  }
56
168
  declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
57
169
  props: import("vue").PublicProps & __VLS_PrettifyLocal<({
58
170
  items: Item<T>[];
59
171
  } & {
60
- modelValue?: T;
172
+ /** Current active tab value (v-model) / 当前活动标签的值(v-model) */modelValue?: T;
61
173
  }) & {
62
174
  onUpdate?: ((tab: T) => any) | undefined;
63
175
  "onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
@@ -75,14 +187,59 @@ declare const _default$2: typeof __VLS_export;
75
187
  type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
76
188
  //#endregion
77
189
  //#region src/client/composables/use-size.d.ts
190
+ /**
191
+ * Reactive size information returned by `useSize`.
192
+ *
193
+ * `useSize` 返回的响应式尺寸信息。
194
+ */
78
195
  interface SizeInfo {
196
+ /** Reactive width value (e.g. "100%" or "500px") / 响应式宽度值(例如 "100%" 或 "500px") */
79
197
  width: Ref<string>;
198
+ /** Reactive height value (e.g. "auto" or "300px") / 响应式高度值(例如 "auto" 或 "300px") */
80
199
  height: Ref<string>;
200
+ /** Manually trigger a size recalculation / 手动触发尺寸重新计算 */
81
201
  resize: () => void;
82
202
  }
203
+ /**
204
+ * Composable that provides reactive size tracking for an element based on width,
205
+ * height, and aspect ratio options.
206
+ *
207
+ * 基于宽度、高度和宽高比选项为元素提供响应式尺寸追踪的组合式函数。
208
+ *
209
+ * @template T - HTMLElement type of the target element / 目标元素的 HTMLElement 类型
210
+ * @param el - Template ref to the target element / 目标元素的模板 ref
211
+ * @param options - Reactive size options (width, height, ratio) / 响应式尺寸选项(width、height、ratio)
212
+ * @param extraHeight - Extra height in pixels to add to the computed height / 要加到计算高度上的额外像素高度
213
+ * @returns Reactive size info with width, height, and a resize function / 包含 width、height 和 resize 函数的响应式尺寸信息
214
+ * @example
215
+ * ```ts
216
+ * const el = ref<HTMLElement>()
217
+ * const { width, height, resize } = useSize(el, toRefs({ width: '100%', ratio: '16:9' }))
218
+ * ```
219
+ */
83
220
  declare function useSize<T extends HTMLElement>(el: TemplateRef<T>, options: ToRefs<SizeOptions>, extraHeight?: MaybeRef<number>): SizeInfo;
84
221
  //#endregion
85
222
  //#region src/client/composables/use-zoom-and-drag.d.ts
223
+ /**
224
+ * Composable that provides zoom and drag interaction for a content stage,
225
+ * supporting mouse drag, touch drag, pinch-to-zoom, and programmatic zoom.
226
+ *
227
+ * 为内容舞台提供缩放和拖拽交互的组合式函数,支持鼠标拖拽、触摸拖拽、双指缩放和编程式缩放。
228
+ *
229
+ * @param parentEl - Template ref to the stage container element / 舞台容器元素的模板 ref
230
+ * @returns Interaction controls and reactive state, including:
231
+ * - `actorStyle`: Reactive style object for the actor element / actor 元素的响应式样式对象
232
+ * - `zoom`: Reactive zoom percentage string / 响应式缩放百分比字符串
233
+ * - `reset`: Reset layout to fit the stage / 重置布局以适配舞台
234
+ * - `zoomIn`: Zoom in by one step / 放大一个步长
235
+ * - `zoomOut`: Zoom out by one step / 缩小一个步长
236
+ * - `resetZoom`: Reset zoom to the initial state / 重置缩放至初始状态
237
+ * @example
238
+ * ```ts
239
+ * const stageEl = ref<HTMLDivElement>()
240
+ * const { actorStyle, zoom, zoomIn, zoomOut, resetZoom, reset } = useZoomAndDrag(stageEl)
241
+ * ```
242
+ */
86
243
  declare function useZoomAndDrag(parentEl: TemplateRef<HTMLDivElement>): {
87
244
  actorStyle: import("vue").ComputedRef<{
88
245
  left: string;
@@ -98,8 +255,15 @@ declare function useZoomAndDrag(parentEl: TemplateRef<HTMLDivElement>): {
98
255
  };
99
256
  //#endregion
100
257
  //#region src/client/utils/env.d.ts
258
+ /**
259
+ * User-Agent Client Hints data provided by modern browsers.
260
+ *
261
+ * 现代浏览器提供的 User-Agent 客户端提示数据。
262
+ */
101
263
  interface NavigatorUAData {
264
+ /** Operating system platform identifier / 操作系统平台标识符 */
102
265
  platform?: string;
266
+ /** Whether the device is a mobile device / 设备是否为移动设备 */
103
267
  mobile?: boolean;
104
268
  }
105
269
  declare global {