vitepress-plugin-toolkit 0.6.0 → 0.8.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.
@@ -123,13 +123,26 @@ interface SizeOptions {
123
123
  ratio?: number | string;
124
124
  }
125
125
  //#endregion
126
+ //#region src/client/components/FadeInExpandTransition.vue.d.ts
127
+ type __VLS_Props$2 = {
128
+ group?: boolean;
129
+ appear?: boolean;
130
+ width?: boolean;
131
+ mode?: 'default' | 'in-out' | 'out-in';
132
+ onLeave?: () => void;
133
+ onAfterLeave?: () => void;
134
+ onAfterEnter?: () => void;
135
+ };
136
+ declare const __VLS_export$3: import("vue").DefineComponent<__VLS_Props$2, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props$2> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
137
+ declare const _default: typeof __VLS_export$3;
138
+ //#endregion
126
139
  //#region src/client/components/VPCopyButton.vue.d.ts
127
140
  /** Text to copy to the clipboard / 要复制到剪贴板的文本 */
128
141
  type __VLS_Props$1 = {
129
142
  text: string;
130
143
  };
131
144
  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;
145
+ declare const _default$1: typeof __VLS_export$2;
133
146
  //#endregion
134
147
  //#region src/client/components/VPLoading.vue.d.ts
135
148
  /**
@@ -149,7 +162,7 @@ type __VLS_Props = {
149
162
  height?: string;
150
163
  };
151
164
  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;
165
+ declare const _default$2: typeof __VLS_export$1;
153
166
  //#endregion
154
167
  //#region src/client/components/VPTabSwitch.vue.d.ts
155
168
  /**
@@ -183,7 +196,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
183
196
  }>) => import("vue").VNode & {
184
197
  __ctx?: Awaited<typeof __VLS_setup>;
185
198
  };
186
- declare const _default$2: typeof __VLS_export;
199
+ declare const _default$3: typeof __VLS_export;
187
200
  type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
188
201
  //#endregion
189
202
  //#region src/client/composables/use-size.d.ts
@@ -328,4 +341,4 @@ declare function isMobile(): boolean;
328
341
  */
329
342
  declare function isSafari(): boolean;
330
343
  //#endregion
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 };
344
+ export { EXTERNAL_URL_RE, _default as FadeInExpandTransition, SizeInfo, SizeOptions, URL_PROTOCOL_RE, _default$1 as VPCopyButton, _default$2 as VPLoading, _default$3 as VPTabSwitch, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize, useZoomAndDrag };
@@ -1,4 +1,4 @@
1
- import { Fragment, computed, createElementBlock, createElementVNode, defineComponent, isRef, mergeModels, nextTick, normalizeClass, normalizeStyle, onMounted, openBlock, ref, renderList, shallowRef, toDisplayString, toValue, unref, useModel, watch } from "vue";
1
+ import { Fragment, Transition, TransitionGroup, computed, createBlock, createElementBlock, createElementVNode, defineComponent, h, isRef, mergeModels, nextTick, normalizeClass, normalizeStyle, onMounted, openBlock, ref, renderList, shallowRef, toDisplayString, toValue, unref, useModel, useSlots, watch } from "vue";
2
2
  import { useClipboard, useEventListener, useMediaQuery, useMutationObserver } from "@vueuse/core";
3
3
  //#region src/shared/link.ts
4
4
  /**
@@ -49,7 +49,7 @@ function isExternal(path) {
49
49
  * URL_PROTOCOL_RE.test('mailto:foo@example.com') // true
50
50
  * URL_PROTOCOL_RE.test('//cdn.example.com/lib.js') // false
51
51
  */
52
- const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:/;
52
+ const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:/i;
53
53
  /**
54
54
  * Checks whether the given link contains a URL protocol scheme or is a
55
55
  * protocol-relative URL.
@@ -75,9 +75,75 @@ function isLinkWithProtocol(link) {
75
75
  return URL_PROTOCOL_RE.test(link) || link.startsWith("//");
76
76
  }
77
77
  //#endregion
78
+ //#region src/client/components/FadeInExpandTransition.vue
79
+ const _sfc_main = /*@__PURE__*/ defineComponent({
80
+ __name: "FadeInExpandTransition",
81
+ props: {
82
+ group: { type: Boolean },
83
+ appear: { type: Boolean },
84
+ width: { type: Boolean },
85
+ mode: { default: "default" },
86
+ onLeave: { type: Function },
87
+ onAfterLeave: { type: Function },
88
+ onAfterEnter: { type: Function }
89
+ },
90
+ setup(__props) {
91
+ function handleBeforeLeave(el) {
92
+ el.style[__props.width ? "maxWidth" : "maxHeight"] = `${__props.width ? el.offsetWidth : el.offsetHeight}px`;
93
+ el.offsetWidth;
94
+ }
95
+ function handleLeave(el) {
96
+ el.style[__props.width ? "maxWidth" : "maxHeight"] = "0";
97
+ el.offsetWidth;
98
+ __props.onLeave?.();
99
+ }
100
+ function handleAfterLeave(el) {
101
+ el.style[__props.width ? "maxWidth" : "maxHeight"] = "";
102
+ __props.onAfterLeave?.();
103
+ }
104
+ function handleEnter(el) {
105
+ el.style.transition = "none";
106
+ if (__props.width) {
107
+ const memorizedWidth = el.offsetWidth;
108
+ el.style.maxWidth = "0";
109
+ el.offsetWidth;
110
+ el.style.transition = "";
111
+ el.style.maxWidth = `${memorizedWidth}px`;
112
+ } else {
113
+ const memorizedHeight = el.offsetHeight;
114
+ el.style.maxHeight = "0";
115
+ el.offsetWidth;
116
+ el.style.transition = "";
117
+ el.style.maxHeight = `${memorizedHeight}px`;
118
+ }
119
+ el.offsetWidth;
120
+ }
121
+ function handleAfterEnter(el) {
122
+ el.style[__props.width ? "maxWidth" : "maxHeight"] = "";
123
+ __props.onAfterEnter?.();
124
+ }
125
+ const slots = useSlots();
126
+ function FadeTransition() {
127
+ return h(__props.group ? TransitionGroup : Transition, {
128
+ name: __props.width ? "fade-in-width-expand" : "fade-in-height-expand",
129
+ appear: __props.appear,
130
+ onEnter: handleEnter,
131
+ onAfterEnter: handleAfterEnter,
132
+ onBeforeLeave: handleBeforeLeave,
133
+ onLeave: handleLeave,
134
+ onAfterLeave: handleAfterLeave,
135
+ ...__props.group ? void 0 : { mode: __props.mode }
136
+ }, slots);
137
+ }
138
+ return (_ctx, _cache) => {
139
+ return openBlock(), createBlock(FadeTransition);
140
+ };
141
+ }
142
+ });
143
+ //#endregion
78
144
  //#region src/client/components/VPCopyButton.vue
79
145
  /** Text to copy to the clipboard / 要复制到剪贴板的文本 */
80
- const _sfc_main = /*@__PURE__*/ defineComponent({
146
+ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
81
147
  __name: "VPCopyButton",
82
148
  props: { text: {} },
83
149
  setup(__props) {
@@ -104,7 +170,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
104
170
  });
105
171
  //#endregion
106
172
  //#region src/client/components/VPLoading.vue
107
- const _sfc_main$1 = /*@__PURE__*/ defineComponent({
173
+ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
108
174
  __name: "VPLoading",
109
175
  props: {
110
176
  absolute: { type: Boolean },
@@ -160,7 +226,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
160
226
  const _hoisted_1 = { class: "vp-tab-switch-list" };
161
227
  const _hoisted_2 = ["onClick"];
162
228
  /** List of tab items to render / 要渲染的标签项列表 */
163
- const _sfc_main$2 = /*@__PURE__*/ defineComponent({
229
+ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
164
230
  __name: "VPTabSwitch",
165
231
  props: /*@__PURE__*/ mergeModels({ items: {} }, {
166
232
  "modelValue": {},
@@ -573,4 +639,4 @@ function isSafari() {
573
639
  return /safari/iu.test(ua) && !/chrome|crios|fxios|edgios|edg|opr|opera|ucbrowser|qqbrowser|baidubrowser/iu.test(ua);
574
640
  }
575
641
  //#endregion
576
- export { EXTERNAL_URL_RE, URL_PROTOCOL_RE, _sfc_main as VPCopyButton, _sfc_main$1 as VPLoading, _sfc_main$2 as VPTabSwitch, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize, useZoomAndDrag };
642
+ export { EXTERNAL_URL_RE, _sfc_main as FadeInExpandTransition, URL_PROTOCOL_RE, _sfc_main$1 as VPCopyButton, _sfc_main$2 as VPLoading, _sfc_main$3 as VPTabSwitch, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize, useZoomAndDrag };
@@ -123,13 +123,26 @@ interface SizeOptions {
123
123
  ratio?: number | string;
124
124
  }
125
125
  //#endregion
126
+ //#region src/client/components/FadeInExpandTransition.vue.d.ts
127
+ type __VLS_Props$2 = {
128
+ group?: boolean;
129
+ appear?: boolean;
130
+ width?: boolean;
131
+ mode?: 'default' | 'in-out' | 'out-in';
132
+ onLeave?: () => void;
133
+ onAfterLeave?: () => void;
134
+ onAfterEnter?: () => void;
135
+ };
136
+ declare const __VLS_export$3: import("vue").DefineComponent<__VLS_Props$2, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props$2> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
137
+ declare const _default: typeof __VLS_export$3;
138
+ //#endregion
126
139
  //#region src/client/components/VPCopyButton.vue.d.ts
127
140
  /** Text to copy to the clipboard / 要复制到剪贴板的文本 */
128
141
  type __VLS_Props$1 = {
129
142
  text: string;
130
143
  };
131
144
  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;
145
+ declare const _default$1: typeof __VLS_export$2;
133
146
  //#endregion
134
147
  //#region src/client/components/VPLoading.vue.d.ts
135
148
  /**
@@ -149,7 +162,7 @@ type __VLS_Props = {
149
162
  height?: string;
150
163
  };
151
164
  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;
165
+ declare const _default$2: typeof __VLS_export$1;
153
166
  //#endregion
154
167
  //#region src/client/components/VPTabSwitch.vue.d.ts
155
168
  /**
@@ -183,7 +196,7 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
183
196
  }>) => import("vue").VNode & {
184
197
  __ctx?: Awaited<typeof __VLS_setup>;
185
198
  };
186
- declare const _default$2: typeof __VLS_export;
199
+ declare const _default$3: typeof __VLS_export;
187
200
  type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
188
201
  //#endregion
189
202
  //#region src/client/composables/use-size.d.ts
@@ -328,4 +341,4 @@ declare function isMobile(): boolean;
328
341
  */
329
342
  declare function isSafari(): boolean;
330
343
  //#endregion
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 };
344
+ export { EXTERNAL_URL_RE, _default as FadeInExpandTransition, SizeInfo, SizeOptions, URL_PROTOCOL_RE, _default$1 as VPCopyButton, _default$2 as VPLoading, _default$3 as VPTabSwitch, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize, useZoomAndDrag };
@@ -1,5 +1,5 @@
1
- import { computed, defineComponent, isRef, mergeModels, mergeProps, nextTick, onMounted, ref, shallowRef, toValue, unref, useModel, useSSRContext, watch } from "vue";
2
- import { ssrInterpolate, ssrRenderAttrs, ssrRenderClass, ssrRenderList } from "vue/server-renderer";
1
+ import { Transition, TransitionGroup, computed, defineComponent, h, isRef, mergeModels, mergeProps, nextTick, onMounted, ref, shallowRef, toValue, unref, useModel, useSSRContext, useSlots, watch } from "vue";
2
+ import { ssrInterpolate, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderList } from "vue/server-renderer";
3
3
  import { useClipboard, useEventListener, useMediaQuery, useMutationObserver } from "@vueuse/core";
4
4
  //#region src/shared/link.ts
5
5
  /**
@@ -50,7 +50,7 @@ function isExternal(path) {
50
50
  * URL_PROTOCOL_RE.test('mailto:foo@example.com') // true
51
51
  * URL_PROTOCOL_RE.test('//cdn.example.com/lib.js') // false
52
52
  */
53
- const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:/;
53
+ const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:/i;
54
54
  /**
55
55
  * Checks whether the given link contains a URL protocol scheme or is a
56
56
  * protocol-relative URL.
@@ -76,9 +76,82 @@ function isLinkWithProtocol(link) {
76
76
  return URL_PROTOCOL_RE.test(link) || link.startsWith("//");
77
77
  }
78
78
  //#endregion
79
+ //#region src/client/components/FadeInExpandTransition.vue
80
+ const _sfc_main = /*@__PURE__*/ defineComponent({
81
+ __name: "FadeInExpandTransition",
82
+ __ssrInlineRender: true,
83
+ props: {
84
+ group: { type: Boolean },
85
+ appear: { type: Boolean },
86
+ width: { type: Boolean },
87
+ mode: { default: "default" },
88
+ onLeave: { type: Function },
89
+ onAfterLeave: { type: Function },
90
+ onAfterEnter: { type: Function }
91
+ },
92
+ setup(__props) {
93
+ function handleBeforeLeave(el) {
94
+ el.style[__props.width ? "maxWidth" : "maxHeight"] = `${__props.width ? el.offsetWidth : el.offsetHeight}px`;
95
+ el.offsetWidth;
96
+ }
97
+ function handleLeave(el) {
98
+ el.style[__props.width ? "maxWidth" : "maxHeight"] = "0";
99
+ el.offsetWidth;
100
+ __props.onLeave?.();
101
+ }
102
+ function handleAfterLeave(el) {
103
+ el.style[__props.width ? "maxWidth" : "maxHeight"] = "";
104
+ __props.onAfterLeave?.();
105
+ }
106
+ function handleEnter(el) {
107
+ el.style.transition = "none";
108
+ if (__props.width) {
109
+ const memorizedWidth = el.offsetWidth;
110
+ el.style.maxWidth = "0";
111
+ el.offsetWidth;
112
+ el.style.transition = "";
113
+ el.style.maxWidth = `${memorizedWidth}px`;
114
+ } else {
115
+ const memorizedHeight = el.offsetHeight;
116
+ el.style.maxHeight = "0";
117
+ el.offsetWidth;
118
+ el.style.transition = "";
119
+ el.style.maxHeight = `${memorizedHeight}px`;
120
+ }
121
+ el.offsetWidth;
122
+ }
123
+ function handleAfterEnter(el) {
124
+ el.style[__props.width ? "maxWidth" : "maxHeight"] = "";
125
+ __props.onAfterEnter?.();
126
+ }
127
+ const slots = useSlots();
128
+ function FadeTransition() {
129
+ return h(__props.group ? TransitionGroup : Transition, {
130
+ name: __props.width ? "fade-in-width-expand" : "fade-in-height-expand",
131
+ appear: __props.appear,
132
+ onEnter: handleEnter,
133
+ onAfterEnter: handleAfterEnter,
134
+ onBeforeLeave: handleBeforeLeave,
135
+ onLeave: handleLeave,
136
+ onAfterLeave: handleAfterLeave,
137
+ ...__props.group ? void 0 : { mode: __props.mode }
138
+ }, slots);
139
+ }
140
+ return (_ctx, _push, _parent, _attrs) => {
141
+ _push(ssrRenderComponent(FadeTransition, _attrs, null, _parent));
142
+ };
143
+ }
144
+ });
145
+ const _sfc_setup$3 = _sfc_main.setup;
146
+ _sfc_main.setup = (props, ctx) => {
147
+ const ssrContext = useSSRContext();
148
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/client/components/FadeInExpandTransition.vue");
149
+ return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
150
+ };
151
+ //#endregion
79
152
  //#region src/client/components/VPCopyButton.vue
80
153
  /** Text to copy to the clipboard / 要复制到剪贴板的文本 */
81
- const _sfc_main = /*@__PURE__*/ defineComponent({
154
+ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
82
155
  __name: "VPCopyButton",
83
156
  __ssrInlineRender: true,
84
157
  props: { text: {} },
@@ -103,15 +176,15 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
103
176
  };
104
177
  }
105
178
  });
106
- const _sfc_setup$2 = _sfc_main.setup;
107
- _sfc_main.setup = (props, ctx) => {
179
+ const _sfc_setup$2 = _sfc_main$1.setup;
180
+ _sfc_main$1.setup = (props, ctx) => {
108
181
  const ssrContext = useSSRContext();
109
182
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/client/components/VPCopyButton.vue");
110
183
  return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
111
184
  };
112
185
  //#endregion
113
186
  //#region src/client/components/VPLoading.vue
114
- const _sfc_main$1 = /*@__PURE__*/ defineComponent({
187
+ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
115
188
  __name: "VPLoading",
116
189
  __ssrInlineRender: true,
117
190
  props: {
@@ -139,8 +212,8 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
139
212
  };
140
213
  }
141
214
  });
142
- const _sfc_setup$1 = _sfc_main$1.setup;
143
- _sfc_main$1.setup = (props, ctx) => {
215
+ const _sfc_setup$1 = _sfc_main$2.setup;
216
+ _sfc_main$2.setup = (props, ctx) => {
144
217
  const ssrContext = useSSRContext();
145
218
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/client/components/VPLoading.vue");
146
219
  return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
@@ -148,7 +221,7 @@ _sfc_main$1.setup = (props, ctx) => {
148
221
  //#endregion
149
222
  //#region src/client/components/VPTabSwitch.vue
150
223
  /** List of tab items to render / 要渲染的标签项列表 */
151
- const _sfc_main$2 = /*@__PURE__*/ defineComponent({
224
+ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
152
225
  __name: "VPTabSwitch",
153
226
  __ssrInlineRender: true,
154
227
  props: /*@__PURE__*/ mergeModels({ items: {} }, {
@@ -171,8 +244,8 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
171
244
  };
172
245
  }
173
246
  });
174
- const _sfc_setup = _sfc_main$2.setup;
175
- _sfc_main$2.setup = (props, ctx) => {
247
+ const _sfc_setup = _sfc_main$3.setup;
248
+ _sfc_main$3.setup = (props, ctx) => {
176
249
  const ssrContext = useSSRContext();
177
250
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/client/components/VPTabSwitch.vue");
178
251
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
@@ -539,4 +612,4 @@ function isSafari() {
539
612
  return /safari/iu.test(ua) && !/chrome|crios|fxios|edgios|edg|opr|opera|ucbrowser|qqbrowser|baidubrowser/iu.test(ua);
540
613
  }
541
614
  //#endregion
542
- export { EXTERNAL_URL_RE, URL_PROTOCOL_RE, _sfc_main as VPCopyButton, _sfc_main$1 as VPLoading, _sfc_main$2 as VPTabSwitch, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize, useZoomAndDrag };
615
+ export { EXTERNAL_URL_RE, _sfc_main as FadeInExpandTransition, URL_PROTOCOL_RE, _sfc_main$1 as VPCopyButton, _sfc_main$2 as VPLoading, _sfc_main$3 as VPTabSwitch, isExternal, isIOS, isLinkWithProtocol, isMacOS, isMobile, isSafari, isWindows, isiPad, isiPhone, useSize, useZoomAndDrag };
@@ -1,5 +1,5 @@
1
1
  import container from "markdown-it-container";
2
- import { LRUCache, camelCase, deepMerge, isArray, isBoolean, isNull, isNumber, isPrimitive, isString, isUndefined, kebabCase, objectEntries, objectKeys, omit, removeTrailingSlash, slash, toArray, uniq } from "@pengzhanbo/utils";
2
+ import { LRUCache, attempt, camelCase, deepMerge, isArray, isBoolean, isNull, isNumber, isPrimitive, isString, isUndefined, kebabCase, objectEntries, objectKeys, omit, removeTrailingSlash, slash, toArray, uniq } from "@pengzhanbo/utils";
3
3
  import ansis from "ansis";
4
4
  import process from "node:process";
5
5
  import picomatch from "picomatch";
@@ -53,7 +53,7 @@ function isExternal(path) {
53
53
  * URL_PROTOCOL_RE.test('mailto:foo@example.com') // true
54
54
  * URL_PROTOCOL_RE.test('//cdn.example.com/lib.js') // false
55
55
  */
56
- const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:/;
56
+ const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:/i;
57
57
  /**
58
58
  * Checks whether the given link contains a URL protocol scheme or is a
59
59
  * protocol-relative URL.
@@ -495,7 +495,7 @@ function resolveMatcherPattern(include, exclude) {
495
495
  };
496
496
  }
497
497
  function normalize(arr) {
498
- return isArray(arr) ? arr.sort((a, b) => a.localeCompare(b)) : arr;
498
+ return isArray(arr) ? [...arr].sort((a, b) => a.localeCompare(b)) : arr;
499
499
  }
500
500
  //#endregion
501
501
  //#region src/node/utils/logger.ts
@@ -576,6 +576,7 @@ function createLogger(prefix, defaultLevel = "info") {
576
576
  * ```
577
577
  */
578
578
  function parseRect(str, unit = "px") {
579
+ str = str.trim();
579
580
  if (Number.parseFloat(str) === Number(str)) return `${str}${unit}`;
580
581
  return str;
581
582
  }
@@ -830,7 +831,7 @@ function createLocales(builtinLocales, userLocales = {}) {
830
831
  locales[key] = localeData;
831
832
  break;
832
833
  }
833
- if (!locales.root) locales.root = builtinLocales[0][1];
834
+ if (!locales.root) locales.root = builtinLocales[0]?.[1] || {};
834
835
  deepMerge(locales, userLocales);
835
836
  return locales;
836
837
  }
@@ -859,7 +860,7 @@ function createLocales(builtinLocales, userLocales = {}) {
859
860
  */
860
861
  function getLocaleWithPath(path) {
861
862
  const locales = getVitepressConfig().userConfig?.locales || {};
862
- const keys = objectKeys(locales);
863
+ const keys = objectKeys(locales).sort((a, b) => b.length - a.length);
863
864
  const key = keys.find((locale) => path.startsWith(locale)) || keys[0] || "";
864
865
  if (!key || !locales[key]) return {
865
866
  lang: "",
@@ -907,9 +908,11 @@ function resolveRouteLink(url, env) {
907
908
  if (isExternal(url)) return url;
908
909
  const config = getVitepressConfig();
909
910
  if (url.startsWith("/")) return slash(removeTrailingSlash(config.site.base) + url);
910
- if (url.startsWith("#")) return decodeURI(normalizeHash(url));
911
- const { pathname, protocol } = new URL(url, "http://a.com");
912
- if (!url.startsWith("#") && protocol.startsWith("http") && treatAsHtml(pathname)) {
911
+ if (url.startsWith("#")) return normalizeHash(url);
912
+ const [error, data] = attempt(() => new URL(url, "http://a.com"));
913
+ if (error) return url;
914
+ const { pathname, protocol } = data;
915
+ if (protocol.startsWith("http") && treatAsHtml(pathname)) {
913
916
  const indexMatch = url.match(indexRE);
914
917
  if (indexMatch) {
915
918
  const [, path, hash] = indexMatch;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitepress-plugin-toolkit",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.8.0",
5
5
  "description": "Development toolkit for vitepress plugins",
6
6
  "author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo/)",
7
7
  "license": "MIT",