vitepress-plugin-toolkit 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pengzhanbo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,126 @@
1
+ import { MaybeRef, Ref, TemplateRef, ToRefs } from "vue";
2
+
3
+ //#region src/shared/link.d.ts
4
+ declare const EXTERNAL_URL_RE: RegExp;
5
+ declare function isExternal(path: string): boolean;
6
+ declare const URL_PROTOCOL_RE: RegExp;
7
+ declare function isLinkWithProtocol(link: string): boolean;
8
+ //#endregion
9
+ //#region src/shared/size.d.ts
10
+ /**
11
+ * Size Options
12
+ *
13
+ * 尺寸选项
14
+ */
15
+ interface SizeOptions {
16
+ /**
17
+ * Width
18
+ *
19
+ * 宽度
20
+ */
21
+ width?: string;
22
+ /**
23
+ * Height
24
+ *
25
+ * 高度
26
+ */
27
+ height?: string;
28
+ /**
29
+ * Aspect ratio
30
+ *
31
+ * 宽高比
32
+ */
33
+ ratio?: number | string;
34
+ }
35
+ //#endregion
36
+ //#region src/client/components/VPCopyButton.vue.d.ts
37
+ type __VLS_Props$1 = {
38
+ text: string;
39
+ };
40
+ declare const __VLS_export$1: 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>;
41
+ declare const _default: typeof __VLS_export$1;
42
+ //#endregion
43
+ //#region src/client/components/VPLoading.vue.d.ts
44
+ type __VLS_Props = {
45
+ absolute?: boolean;
46
+ height?: string;
47
+ };
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;
50
+ //#endregion
51
+ //#region src/client/composables/use-size.d.ts
52
+ interface SizeInfo {
53
+ width: Ref<string>;
54
+ height: Ref<string>;
55
+ resize: () => void;
56
+ }
57
+ declare function useSize<T extends HTMLElement>(el: TemplateRef<T>, options: ToRefs<SizeOptions>, extraHeight?: MaybeRef<number>): SizeInfo;
58
+ //#endregion
59
+ //#region src/client/utils/env.d.ts
60
+ interface NavigatorUAData {
61
+ platform?: string;
62
+ mobile?: boolean;
63
+ }
64
+ declare global {
65
+ interface Navigator {
66
+ userAgentData?: NavigatorUAData;
67
+ }
68
+ }
69
+ /**
70
+ * Check if the user device is iPhone or iPod.
71
+ *
72
+ * 检查用户设备是否为 iPhone 或 iPod。
73
+ *
74
+ * @returns Whether it's iPhone or iPod / 是否为 iPhone 或 iPod
75
+ */
76
+ declare const isiPhone: () => boolean;
77
+ /**
78
+ * Check if the user device is Windows.
79
+ *
80
+ * 检查用户设备是否为 Windows。
81
+ *
82
+ * @returns Whether it's Windows / 是否为 Windows
83
+ */
84
+ declare function isWindows(): boolean;
85
+ /**
86
+ * Check if the user device is iPad.
87
+ *
88
+ * 检查用户设备是否为 iPad。
89
+ *
90
+ * @returns Whether it's iPad / 是否为 iPad
91
+ */
92
+ declare const isiPad: () => boolean;
93
+ /**
94
+ * Check if the user device is iOS (iPhone, iPad, or iPod).
95
+ *
96
+ * 检查用户设备是否为 iOS (iPhone, iPad, iPod)。
97
+ *
98
+ * @returns Whether it's iOS / 是否为 iOS
99
+ */
100
+ declare function isIOS(): boolean;
101
+ /**
102
+ * Check if the user device is macOS.
103
+ *
104
+ * 检查用户设备是否为 macOS。
105
+ *
106
+ * @returns Whether it's macOS / 是否为 macOS
107
+ */
108
+ declare function isMacOS(): boolean;
109
+ /**
110
+ * Check if the user device is a mobile device.
111
+ *
112
+ * 检查用户设备是否为移动设备。
113
+ *
114
+ * @returns Whether it's a mobile device / 是否为移动设备
115
+ */
116
+ declare function isMobile(): boolean;
117
+ /**
118
+ * Check if the user device is Safari.
119
+ *
120
+ * 检查用户设备是否为 Safari。
121
+ *
122
+ * @returns Whether it's Safari / 是否为 Safari
123
+ */
124
+ declare function isSafari(): boolean;
125
+ //#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 };
@@ -0,0 +1,181 @@
1
+ import { computed, createElementBlock, createElementVNode, defineComponent, isRef, normalizeClass, normalizeStyle, onMounted, openBlock, ref, toValue, unref, watch } from "vue";
2
+ import { useClipboard, useEventListener } from "@vueuse/core";
3
+ //#region src/shared/link.ts
4
+ const EXTERNAL_URL_RE = /^(?:[a-z]+:|\/\/)/i;
5
+ function isExternal(path) {
6
+ return EXTERNAL_URL_RE.test(path);
7
+ }
8
+ const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:/;
9
+ function isLinkWithProtocol(link) {
10
+ return URL_PROTOCOL_RE.test(link) || link.startsWith("//");
11
+ }
12
+ //#endregion
13
+ //#region src/client/components/VPCopyButton.vue
14
+ const _sfc_main = /* @__PURE__ */ defineComponent({
15
+ __name: "VPCopyButton",
16
+ props: { text: {} },
17
+ setup(__props) {
18
+ const { copied, copy } = useClipboard();
19
+ return (_ctx, _cache) => {
20
+ return openBlock(), createElementBlock("button", {
21
+ class: normalizeClass(["vp-copy", { copied: unref(copied) }]),
22
+ "aria-label": "Copy",
23
+ type: "button",
24
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(copy)(__props.text))
25
+ }, null, 2);
26
+ };
27
+ }
28
+ });
29
+ //#endregion
30
+ //#region src/client/components/VPLoading.vue
31
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
32
+ __name: "VPLoading",
33
+ props: {
34
+ absolute: { type: Boolean },
35
+ height: {}
36
+ },
37
+ setup(__props) {
38
+ return (_ctx, _cache) => {
39
+ return openBlock(), createElementBlock("div", {
40
+ class: normalizeClass(["vp-loading", { absolute: __props.absolute }]),
41
+ style: normalizeStyle({ height: __props.height })
42
+ }, [..._cache[0] || (_cache[0] = [createElementVNode("svg", {
43
+ xmlns: "http://www.w3.org/2000/svg",
44
+ width: "1em",
45
+ height: "1em",
46
+ viewBox: "0 0 24 24"
47
+ }, [createElementVNode("path", {
48
+ fill: "none",
49
+ stroke: "currentColor",
50
+ "stroke-dasharray": "15",
51
+ "stroke-dashoffset": "15",
52
+ "stroke-linecap": "round",
53
+ "stroke-width": "2",
54
+ d: "M12 3C16.9706 3 21 7.02944 21 12"
55
+ }, [createElementVNode("animate", {
56
+ fill: "freeze",
57
+ attributeName: "stroke-dashoffset",
58
+ dur: "0.3s",
59
+ values: "15;0"
60
+ }), createElementVNode("animateTransform", {
61
+ attributeName: "transform",
62
+ dur: "1.5s",
63
+ repeatCount: "indefinite",
64
+ type: "rotate",
65
+ values: "0 12 12;360 12 12"
66
+ })])], -1)])], 6);
67
+ };
68
+ }
69
+ });
70
+ //#endregion
71
+ //#region src/client/composables/use-size.ts
72
+ function useSize(el, options, extraHeight = 0) {
73
+ const width = computed(() => toValue(options.width) || "100%");
74
+ const height = ref("auto");
75
+ const getHeight = (width) => {
76
+ const height = toValue(options.height);
77
+ const ratio = getRadio(toValue(options.ratio));
78
+ return height || `${Number(width) / ratio + toValue(extraHeight)}px`;
79
+ };
80
+ const resize = () => {
81
+ if (el.value) height.value = getHeight(el.value.offsetWidth);
82
+ };
83
+ onMounted(() => {
84
+ resize();
85
+ if (isRef(extraHeight)) watch(extraHeight, resize);
86
+ useEventListener("orientationchange", resize);
87
+ useEventListener("resize", resize);
88
+ });
89
+ return {
90
+ width,
91
+ height,
92
+ resize
93
+ };
94
+ }
95
+ function getRadio(ratio) {
96
+ if (typeof ratio === "string") {
97
+ const [width, height] = ratio.split(":");
98
+ const parsedRadio = Number(width) / Number(height);
99
+ if (!Number.isNaN(parsedRadio)) return parsedRadio;
100
+ }
101
+ return typeof ratio === "number" ? ratio : 16 / 9;
102
+ }
103
+ //#endregion
104
+ //#region src/client/utils/env.ts
105
+ function getPlatform() {
106
+ return navigator.userAgentData?.platform ?? navigator.platform;
107
+ }
108
+ const getUA = () => navigator.userAgent;
109
+ /**
110
+ * Check if the user device is iPhone or iPod.
111
+ *
112
+ * 检查用户设备是否为 iPhone 或 iPod。
113
+ *
114
+ * @returns Whether it's iPhone or iPod / 是否为 iPhone 或 iPod
115
+ */
116
+ const isiPhone = () => /\biPhone\b/iu.test(getPlatform());
117
+ /**
118
+ * Check if the user device is Windows.
119
+ *
120
+ * 检查用户设备是否为 Windows。
121
+ *
122
+ * @returns Whether it's Windows / 是否为 Windows
123
+ */
124
+ function isWindows() {
125
+ return /\b(?:Windows|Win32)\b/iu.test(getPlatform());
126
+ }
127
+ /**
128
+ * Check if the user device is iPad.
129
+ *
130
+ * 检查用户设备是否为 iPad。
131
+ *
132
+ * @returns Whether it's iPad / 是否为 iPad
133
+ */
134
+ const isiPad = () => /\biPad\b/iu.test(getPlatform());
135
+ /**
136
+ * Check if the user device is iOS (iPhone, iPad, or iPod).
137
+ *
138
+ * 检查用户设备是否为 iOS (iPhone, iPad, iPod)。
139
+ *
140
+ * @returns Whether it's iOS / 是否为 iOS
141
+ */
142
+ function isIOS() {
143
+ return /ios/iu.test(getPlatform()) || isiPhone() || isiPad();
144
+ }
145
+ /**
146
+ * Check if the user device is macOS.
147
+ *
148
+ * 检查用户设备是否为 macOS。
149
+ *
150
+ * @returns Whether it's macOS / 是否为 macOS
151
+ */
152
+ function isMacOS() {
153
+ const platform = getPlatform();
154
+ if (platform) return /mac/iu.test(platform);
155
+ return /macintosh|mac os x/iu.test(getUA()) && !isIOS();
156
+ }
157
+ /**
158
+ * Check if the user device is a mobile device.
159
+ *
160
+ * 检查用户设备是否为移动设备。
161
+ *
162
+ * @returns Whether it's a mobile device / 是否为移动设备
163
+ */
164
+ function isMobile() {
165
+ const uaDataMobile = navigator.userAgentData?.mobile;
166
+ if (typeof uaDataMobile === "boolean") return uaDataMobile;
167
+ return /\b(?:Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|CriOS|FxiOS)\b/iu.test(getUA());
168
+ }
169
+ /**
170
+ * Check if the user device is Safari.
171
+ *
172
+ * 检查用户设备是否为 Safari。
173
+ *
174
+ * @returns Whether it's Safari / 是否为 Safari
175
+ */
176
+ function isSafari() {
177
+ const ua = getUA();
178
+ return /safari/iu.test(ua) && !/chrome|crios|fxios|edgios|edg|opr|opera|ucbrowser|qqbrowser|baidubrowser/iu.test(ua);
179
+ }
180
+ //#endregion
181
+ export { EXTERNAL_URL_RE, URL_PROTOCOL_RE, _sfc_main as VPCopyButton, _sfc_main$1 as VPLoading, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize };
@@ -0,0 +1,126 @@
1
+ import { MaybeRef, Ref, TemplateRef, ToRefs } from "vue";
2
+
3
+ //#region src/shared/link.d.ts
4
+ declare const EXTERNAL_URL_RE: RegExp;
5
+ declare function isExternal(path: string): boolean;
6
+ declare const URL_PROTOCOL_RE: RegExp;
7
+ declare function isLinkWithProtocol(link: string): boolean;
8
+ //#endregion
9
+ //#region src/shared/size.d.ts
10
+ /**
11
+ * Size Options
12
+ *
13
+ * 尺寸选项
14
+ */
15
+ interface SizeOptions {
16
+ /**
17
+ * Width
18
+ *
19
+ * 宽度
20
+ */
21
+ width?: string;
22
+ /**
23
+ * Height
24
+ *
25
+ * 高度
26
+ */
27
+ height?: string;
28
+ /**
29
+ * Aspect ratio
30
+ *
31
+ * 宽高比
32
+ */
33
+ ratio?: number | string;
34
+ }
35
+ //#endregion
36
+ //#region src/client/components/VPCopyButton.vue.d.ts
37
+ type __VLS_Props$1 = {
38
+ text: string;
39
+ };
40
+ declare const __VLS_export$1: 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>;
41
+ declare const _default: typeof __VLS_export$1;
42
+ //#endregion
43
+ //#region src/client/components/VPLoading.vue.d.ts
44
+ type __VLS_Props = {
45
+ absolute?: boolean;
46
+ height?: string;
47
+ };
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;
50
+ //#endregion
51
+ //#region src/client/composables/use-size.d.ts
52
+ interface SizeInfo {
53
+ width: Ref<string>;
54
+ height: Ref<string>;
55
+ resize: () => void;
56
+ }
57
+ declare function useSize<T extends HTMLElement>(el: TemplateRef<T>, options: ToRefs<SizeOptions>, extraHeight?: MaybeRef<number>): SizeInfo;
58
+ //#endregion
59
+ //#region src/client/utils/env.d.ts
60
+ interface NavigatorUAData {
61
+ platform?: string;
62
+ mobile?: boolean;
63
+ }
64
+ declare global {
65
+ interface Navigator {
66
+ userAgentData?: NavigatorUAData;
67
+ }
68
+ }
69
+ /**
70
+ * Check if the user device is iPhone or iPod.
71
+ *
72
+ * 检查用户设备是否为 iPhone 或 iPod。
73
+ *
74
+ * @returns Whether it's iPhone or iPod / 是否为 iPhone 或 iPod
75
+ */
76
+ declare const isiPhone: () => boolean;
77
+ /**
78
+ * Check if the user device is Windows.
79
+ *
80
+ * 检查用户设备是否为 Windows。
81
+ *
82
+ * @returns Whether it's Windows / 是否为 Windows
83
+ */
84
+ declare function isWindows(): boolean;
85
+ /**
86
+ * Check if the user device is iPad.
87
+ *
88
+ * 检查用户设备是否为 iPad。
89
+ *
90
+ * @returns Whether it's iPad / 是否为 iPad
91
+ */
92
+ declare const isiPad: () => boolean;
93
+ /**
94
+ * Check if the user device is iOS (iPhone, iPad, or iPod).
95
+ *
96
+ * 检查用户设备是否为 iOS (iPhone, iPad, iPod)。
97
+ *
98
+ * @returns Whether it's iOS / 是否为 iOS
99
+ */
100
+ declare function isIOS(): boolean;
101
+ /**
102
+ * Check if the user device is macOS.
103
+ *
104
+ * 检查用户设备是否为 macOS。
105
+ *
106
+ * @returns Whether it's macOS / 是否为 macOS
107
+ */
108
+ declare function isMacOS(): boolean;
109
+ /**
110
+ * Check if the user device is a mobile device.
111
+ *
112
+ * 检查用户设备是否为移动设备。
113
+ *
114
+ * @returns Whether it's a mobile device / 是否为移动设备
115
+ */
116
+ declare function isMobile(): boolean;
117
+ /**
118
+ * Check if the user device is Safari.
119
+ *
120
+ * 检查用户设备是否为 Safari。
121
+ *
122
+ * @returns Whether it's Safari / 是否为 Safari
123
+ */
124
+ declare function isSafari(): boolean;
125
+ //#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 };
@@ -0,0 +1,171 @@
1
+ import { computed, defineComponent, isRef, mergeProps, onMounted, ref, toValue, unref, useSSRContext, watch } from "vue";
2
+ import { ssrRenderAttrs } from "vue/server-renderer";
3
+ import { useClipboard, useEventListener } from "@vueuse/core";
4
+ //#region src/shared/link.ts
5
+ const EXTERNAL_URL_RE = /^(?:[a-z]+:|\/\/)/i;
6
+ function isExternal(path) {
7
+ return EXTERNAL_URL_RE.test(path);
8
+ }
9
+ const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:/;
10
+ function isLinkWithProtocol(link) {
11
+ return URL_PROTOCOL_RE.test(link) || link.startsWith("//");
12
+ }
13
+ //#endregion
14
+ //#region src/client/components/VPCopyButton.vue
15
+ const _sfc_main = /* @__PURE__ */ defineComponent({
16
+ __name: "VPCopyButton",
17
+ __ssrInlineRender: true,
18
+ props: { text: {} },
19
+ setup(__props) {
20
+ const { copied, copy } = useClipboard();
21
+ return (_ctx, _push, _parent, _attrs) => {
22
+ _push(`<button${ssrRenderAttrs(mergeProps({
23
+ class: ["vp-copy", { copied: unref(copied) }],
24
+ "aria-label": "Copy",
25
+ type: "button"
26
+ }, _attrs))}></button>`);
27
+ };
28
+ }
29
+ });
30
+ const _sfc_setup$1 = _sfc_main.setup;
31
+ _sfc_main.setup = (props, ctx) => {
32
+ const ssrContext = useSSRContext();
33
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/client/components/VPCopyButton.vue");
34
+ return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
35
+ };
36
+ //#endregion
37
+ //#region src/client/components/VPLoading.vue
38
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
39
+ __name: "VPLoading",
40
+ __ssrInlineRender: true,
41
+ props: {
42
+ absolute: { type: Boolean },
43
+ height: {}
44
+ },
45
+ setup(__props) {
46
+ return (_ctx, _push, _parent, _attrs) => {
47
+ _push(`<div${ssrRenderAttrs(mergeProps({
48
+ class: ["vp-loading", { absolute: __props.absolute }],
49
+ style: { height: __props.height }
50
+ }, _attrs))}><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-dasharray="15" stroke-dashoffset="15" stroke-linecap="round" stroke-width="2" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"></animate><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"></animateTransform></path></svg></div>`);
51
+ };
52
+ }
53
+ });
54
+ const _sfc_setup = _sfc_main$1.setup;
55
+ _sfc_main$1.setup = (props, ctx) => {
56
+ const ssrContext = useSSRContext();
57
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/client/components/VPLoading.vue");
58
+ return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
59
+ };
60
+ //#endregion
61
+ //#region src/client/composables/use-size.ts
62
+ function useSize(el, options, extraHeight = 0) {
63
+ const width = computed(() => toValue(options.width) || "100%");
64
+ const height = ref("auto");
65
+ const getHeight = (width) => {
66
+ const height = toValue(options.height);
67
+ const ratio = getRadio(toValue(options.ratio));
68
+ return height || `${Number(width) / ratio + toValue(extraHeight)}px`;
69
+ };
70
+ const resize = () => {
71
+ if (el.value) height.value = getHeight(el.value.offsetWidth);
72
+ };
73
+ onMounted(() => {
74
+ resize();
75
+ if (isRef(extraHeight)) watch(extraHeight, resize);
76
+ useEventListener("orientationchange", resize);
77
+ useEventListener("resize", resize);
78
+ });
79
+ return {
80
+ width,
81
+ height,
82
+ resize
83
+ };
84
+ }
85
+ function getRadio(ratio) {
86
+ if (typeof ratio === "string") {
87
+ const [width, height] = ratio.split(":");
88
+ const parsedRadio = Number(width) / Number(height);
89
+ if (!Number.isNaN(parsedRadio)) return parsedRadio;
90
+ }
91
+ return typeof ratio === "number" ? ratio : 16 / 9;
92
+ }
93
+ //#endregion
94
+ //#region src/client/utils/env.ts
95
+ function getPlatform() {
96
+ return navigator.userAgentData?.platform ?? navigator.platform;
97
+ }
98
+ const getUA = () => navigator.userAgent;
99
+ /**
100
+ * Check if the user device is iPhone or iPod.
101
+ *
102
+ * 检查用户设备是否为 iPhone 或 iPod。
103
+ *
104
+ * @returns Whether it's iPhone or iPod / 是否为 iPhone 或 iPod
105
+ */
106
+ const isiPhone = () => /\biPhone\b/iu.test(getPlatform());
107
+ /**
108
+ * Check if the user device is Windows.
109
+ *
110
+ * 检查用户设备是否为 Windows。
111
+ *
112
+ * @returns Whether it's Windows / 是否为 Windows
113
+ */
114
+ function isWindows() {
115
+ return /\b(?:Windows|Win32)\b/iu.test(getPlatform());
116
+ }
117
+ /**
118
+ * Check if the user device is iPad.
119
+ *
120
+ * 检查用户设备是否为 iPad。
121
+ *
122
+ * @returns Whether it's iPad / 是否为 iPad
123
+ */
124
+ const isiPad = () => /\biPad\b/iu.test(getPlatform());
125
+ /**
126
+ * Check if the user device is iOS (iPhone, iPad, or iPod).
127
+ *
128
+ * 检查用户设备是否为 iOS (iPhone, iPad, iPod)。
129
+ *
130
+ * @returns Whether it's iOS / 是否为 iOS
131
+ */
132
+ function isIOS() {
133
+ return /ios/iu.test(getPlatform()) || isiPhone() || isiPad();
134
+ }
135
+ /**
136
+ * Check if the user device is macOS.
137
+ *
138
+ * 检查用户设备是否为 macOS。
139
+ *
140
+ * @returns Whether it's macOS / 是否为 macOS
141
+ */
142
+ function isMacOS() {
143
+ const platform = getPlatform();
144
+ if (platform) return /mac/iu.test(platform);
145
+ return /macintosh|mac os x/iu.test(getUA()) && !isIOS();
146
+ }
147
+ /**
148
+ * Check if the user device is a mobile device.
149
+ *
150
+ * 检查用户设备是否为移动设备。
151
+ *
152
+ * @returns Whether it's a mobile device / 是否为移动设备
153
+ */
154
+ function isMobile() {
155
+ const uaDataMobile = navigator.userAgentData?.mobile;
156
+ if (typeof uaDataMobile === "boolean") return uaDataMobile;
157
+ return /\b(?:Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|CriOS|FxiOS)\b/iu.test(getUA());
158
+ }
159
+ /**
160
+ * Check if the user device is Safari.
161
+ *
162
+ * 检查用户设备是否为 Safari。
163
+ *
164
+ * @returns Whether it's Safari / 是否为 Safari
165
+ */
166
+ function isSafari() {
167
+ const ua = getUA();
168
+ return /safari/iu.test(ua) && !/chrome|crios|fxios|edgios|edg|opr|opera|ucbrowser|qqbrowser|baidubrowser/iu.test(ua);
169
+ }
170
+ //#endregion
171
+ export { EXTERNAL_URL_RE, URL_PROTOCOL_RE, _sfc_main as VPCopyButton, _sfc_main$1 as VPLoading, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize };
@@ -0,0 +1,75 @@
1
+ .vp-doc .has-copy > button.vp-copy {
2
+ position: absolute;
3
+ top: 12px;
4
+
5
+ /* rtl:ignore */
6
+ right: 12px;
7
+ z-index: 3;
8
+ width: 40px;
9
+ height: 40px;
10
+ cursor: pointer;
11
+ background-color: var(--vp-code-copy-code-bg);
12
+ background-image: var(--vp-icon-copy);
13
+ background-repeat: no-repeat;
14
+ background-position: 50%;
15
+ background-size: 20px;
16
+ border: 1px solid var(--vp-code-copy-code-border-color);
17
+ border-radius: 4px;
18
+ opacity: 0;
19
+ transition:
20
+ border-color 0.25s,
21
+ background-color 0.25s,
22
+ opacity 0.25s;
23
+
24
+ /* rtl:ignore */
25
+ direction: ltr;
26
+ }
27
+
28
+ .vp-doc .has-copy:hover > button.vp-copy,
29
+ .vp-doc .has-copy > button.vp-copy:focus {
30
+ opacity: 1;
31
+ }
32
+
33
+ .vp-doc .has-copy > button.vp-copy:hover,
34
+ .vp-doc .has-copy > button.vp-copy.copied {
35
+ background-color: var(--vp-code-copy-code-hover-bg);
36
+ border-color: var(--vp-code-copy-code-hover-border-color);
37
+ }
38
+
39
+ .vp-doc .has-copy > button.vp-copy.copied,
40
+ .vp-doc .has-copy > button.vp-copy:hover.copied {
41
+ background-color: var(--vp-code-copy-code-hover-bg);
42
+ background-image: var(--vp-icon-copied);
43
+
44
+ /* rtl:ignore */
45
+ border-radius: 0 4px 4px 0;
46
+ }
47
+
48
+ .vp-doc .has-copy > button.vp-copy.copied::before,
49
+ .vp-doc .has-copy > button.vp-copy:hover.copied::before {
50
+ position: relative;
51
+ top: -1px;
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: center;
55
+ width: fit-content;
56
+ height: 40px;
57
+ padding: 0 10px;
58
+ font-size: 12px;
59
+ font-weight: 500;
60
+ color: var(--vp-code-copy-code-active-text);
61
+ text-align: center;
62
+ white-space: nowrap;
63
+ content: var(--vp-code-copy-copied-text-content);
64
+ background-color: var(--vp-code-copy-code-hover-bg);
65
+ border: 1px solid var(--vp-code-copy-code-hover-border-color);
66
+
67
+ /* rtl:ignore */
68
+ border-right: 0;
69
+
70
+ /* rtl:ignore */
71
+ border-radius: 4px 0 0 4px;
72
+
73
+ /* rtl:ignore */
74
+ transform: translateX(calc(-100% - 1px));
75
+ }