vitepress-plugin-toolkit 0.2.0 → 0.4.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.
- package/README.md +391 -0
- package/README.zh-CN.md +389 -0
- package/dist/client/browser/index.d.ts +219 -14
- package/dist/client/browser/index.js +400 -5
- package/dist/client/ssr/index.d.ts +219 -14
- package/dist/client/ssr/index.js +380 -9
- package/dist/client/styles/tab-switch.css +31 -0
- package/dist/node/index.d.ts +434 -46
- package/dist/node/index.js +476 -25
- package/package.json +7 -2
|
@@ -1,64 +1,269 @@
|
|
|
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
|
-
*
|
|
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.
|
|
80
|
+
*
|
|
81
|
+
* 描述元素尺寸的选项。
|
|
82
|
+
*
|
|
83
|
+
* 供插件使用,将宽度、高度和宽高比输入归一化为一致的 CSS 友好形式。
|
|
12
84
|
*
|
|
13
|
-
*
|
|
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.
|
|
18
94
|
*
|
|
19
|
-
*
|
|
95
|
+
* 元素的宽度,以 CSS 值表示。
|
|
96
|
+
*
|
|
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.
|
|
103
|
+
*
|
|
104
|
+
* 元素的高度,以 CSS 值表示。
|
|
24
105
|
*
|
|
25
|
-
*
|
|
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
|
};
|
|
40
|
-
declare const __VLS_export$
|
|
41
|
-
declare const _default: typeof __VLS_export$
|
|
131
|
+
declare const __VLS_export$2: import("vue").DefineComponent<__VLS_Props$1, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props$1> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
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
|
-
declare const __VLS_export: 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
|
-
declare const _default$1: typeof __VLS_export;
|
|
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>;
|
|
152
|
+
declare const _default$1: typeof __VLS_export$1;
|
|
153
|
+
//#endregion
|
|
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
|
+
*/
|
|
162
|
+
interface Item<T> {
|
|
163
|
+
/** Value of the tab item / 标签项的值 */
|
|
164
|
+
value: T;
|
|
165
|
+
/** Display label of the tab item / 标签项的显示文本 */
|
|
166
|
+
label: string;
|
|
167
|
+
}
|
|
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<{
|
|
169
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
170
|
+
items: Item<T>[];
|
|
171
|
+
} & {
|
|
172
|
+
/** Current active tab value (v-model) / 当前活动标签的值(v-model) */modelValue?: T;
|
|
173
|
+
}) & {
|
|
174
|
+
onUpdate?: ((tab: T) => any) | undefined;
|
|
175
|
+
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
176
|
+
}> & (typeof globalThis extends {
|
|
177
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
178
|
+
} ? P : {});
|
|
179
|
+
expose: (exposed: {}) => void;
|
|
180
|
+
attrs: any;
|
|
181
|
+
slots: {};
|
|
182
|
+
emit: ((evt: "update", tab: T) => void) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
183
|
+
}>) => import("vue").VNode & {
|
|
184
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
185
|
+
};
|
|
186
|
+
declare const _default$2: typeof __VLS_export;
|
|
187
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
50
188
|
//#endregion
|
|
51
189
|
//#region src/client/composables/use-size.d.ts
|
|
190
|
+
/**
|
|
191
|
+
* Reactive size information returned by `useSize`.
|
|
192
|
+
*
|
|
193
|
+
* `useSize` 返回的响应式尺寸信息。
|
|
194
|
+
*/
|
|
52
195
|
interface SizeInfo {
|
|
196
|
+
/** Reactive width value (e.g. "100%" or "500px") / 响应式宽度值(例如 "100%" 或 "500px") */
|
|
53
197
|
width: Ref<string>;
|
|
198
|
+
/** Reactive height value (e.g. "auto" or "300px") / 响应式高度值(例如 "auto" 或 "300px") */
|
|
54
199
|
height: Ref<string>;
|
|
200
|
+
/** Manually trigger a size recalculation / 手动触发尺寸重新计算 */
|
|
55
201
|
resize: () => void;
|
|
56
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
|
+
*/
|
|
57
220
|
declare function useSize<T extends HTMLElement>(el: TemplateRef<T>, options: ToRefs<SizeOptions>, extraHeight?: MaybeRef<number>): SizeInfo;
|
|
58
221
|
//#endregion
|
|
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
|
+
*/
|
|
243
|
+
declare function useZoomAndDrag(parentEl: TemplateRef<HTMLDivElement>): {
|
|
244
|
+
actorStyle: import("vue").ComputedRef<{
|
|
245
|
+
left: string;
|
|
246
|
+
top: string;
|
|
247
|
+
width: string | undefined;
|
|
248
|
+
height: string;
|
|
249
|
+
}>;
|
|
250
|
+
zoom: import("vue").ComputedRef<string>;
|
|
251
|
+
reset: (isFullscreen?: boolean) => void;
|
|
252
|
+
zoomIn: () => void;
|
|
253
|
+
zoomOut: () => void;
|
|
254
|
+
resetZoom: () => void;
|
|
255
|
+
};
|
|
256
|
+
//#endregion
|
|
59
257
|
//#region src/client/utils/env.d.ts
|
|
258
|
+
/**
|
|
259
|
+
* User-Agent Client Hints data provided by modern browsers.
|
|
260
|
+
*
|
|
261
|
+
* 现代浏览器提供的 User-Agent 客户端提示数据。
|
|
262
|
+
*/
|
|
60
263
|
interface NavigatorUAData {
|
|
264
|
+
/** Operating system platform identifier / 操作系统平台标识符 */
|
|
61
265
|
platform?: string;
|
|
266
|
+
/** Whether the device is a mobile device / 设备是否为移动设备 */
|
|
62
267
|
mobile?: boolean;
|
|
63
268
|
}
|
|
64
269
|
declare global {
|
|
@@ -123,4 +328,4 @@ declare function isMobile(): boolean;
|
|
|
123
328
|
*/
|
|
124
329
|
declare function isSafari(): boolean;
|
|
125
330
|
//#endregion
|
|
126
|
-
export { EXTERNAL_URL_RE, SizeInfo, SizeOptions, URL_PROTOCOL_RE, _default as VPCopyButton, _default$1 as VPLoading, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize };
|
|
331
|
+
export { EXTERNAL_URL_RE, SizeInfo, SizeOptions, URL_PROTOCOL_RE, _default as VPCopyButton, _default$1 as VPLoading, _default$2 as VPTabSwitch, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize, useZoomAndDrag };
|