@vuepress/client 2.0.0-rc.15 → 2.0.0-rc.17
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
CHANGED
package/dist/app.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
usePageLang,
|
|
13
13
|
usePageLayout,
|
|
14
14
|
withBase
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-LVRERRCW.js";
|
|
16
16
|
|
|
17
17
|
// src/app.ts
|
|
18
18
|
import { clientConfigs } from "@internal/clientConfigs";
|
|
@@ -31,10 +31,10 @@ if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
|
|
|
31
31
|
// src/router/createVueRouter.ts
|
|
32
32
|
import { removeEndingSlash } from "@vuepress/shared";
|
|
33
33
|
import {
|
|
34
|
+
START_LOCATION,
|
|
34
35
|
createMemoryHistory,
|
|
35
36
|
createRouter,
|
|
36
|
-
createWebHistory
|
|
37
|
-
START_LOCATION
|
|
37
|
+
createWebHistory
|
|
38
38
|
} from "vue-router";
|
|
39
39
|
var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
|
|
40
40
|
var createVueRouter = () => {
|
|
@@ -99,7 +99,7 @@ var setupGlobalComputed = (app, router, clientConfigs2) => {
|
|
|
99
99
|
__VUE_HMR_RUNTIME__.updatePageData = async (newPageData) => {
|
|
100
100
|
const oldPageChunk = await routes.value[newPageData.path].loader();
|
|
101
101
|
const newPageChunk = { comp: oldPageChunk.comp, data: newPageData };
|
|
102
|
-
routes.value[newPageData.path].loader = () => Promise.resolve(newPageChunk);
|
|
102
|
+
routes.value[newPageData.path].loader = async () => Promise.resolve(newPageChunk);
|
|
103
103
|
if (newPageData.path === router.currentRoute.value.meta._pageChunk?.data.path) {
|
|
104
104
|
pageChunk.value = newPageChunk;
|
|
105
105
|
}
|
|
@@ -165,6 +165,52 @@ var setupGlobalComputed = (app, router, clientConfigs2) => {
|
|
|
165
165
|
// src/setupUpdateHead.ts
|
|
166
166
|
import { isPlainObject, isString } from "@vuepress/shared";
|
|
167
167
|
import { onMounted, provide, useSSRContext, watch } from "vue";
|
|
168
|
+
var queryHeadElement = ([
|
|
169
|
+
tagName,
|
|
170
|
+
attrs,
|
|
171
|
+
content = ""
|
|
172
|
+
]) => {
|
|
173
|
+
const attrsSelector = Object.entries(attrs).map(([key, value]) => {
|
|
174
|
+
if (isString(value)) {
|
|
175
|
+
return `[${key}=${JSON.stringify(value)}]`;
|
|
176
|
+
}
|
|
177
|
+
if (value) {
|
|
178
|
+
return `[${key}]`;
|
|
179
|
+
}
|
|
180
|
+
return "";
|
|
181
|
+
}).join("");
|
|
182
|
+
const selector = `head > ${tagName}${attrsSelector}`;
|
|
183
|
+
const headElements = Array.from(
|
|
184
|
+
document.querySelectorAll(selector)
|
|
185
|
+
);
|
|
186
|
+
const matchedHeadElement = headElements.find(
|
|
187
|
+
(item) => item.innerText === content
|
|
188
|
+
);
|
|
189
|
+
return matchedHeadElement ?? null;
|
|
190
|
+
};
|
|
191
|
+
var createHeadElement = ([
|
|
192
|
+
tagName,
|
|
193
|
+
attrs,
|
|
194
|
+
content
|
|
195
|
+
]) => {
|
|
196
|
+
if (!isString(tagName)) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
const headElement = document.createElement(tagName);
|
|
200
|
+
if (isPlainObject(attrs)) {
|
|
201
|
+
Object.entries(attrs).forEach(([key, value]) => {
|
|
202
|
+
if (isString(value)) {
|
|
203
|
+
headElement.setAttribute(key, value);
|
|
204
|
+
} else if (value) {
|
|
205
|
+
headElement.setAttribute(key, "");
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (isString(content)) {
|
|
210
|
+
headElement.appendChild(document.createTextNode(content));
|
|
211
|
+
}
|
|
212
|
+
return headElement;
|
|
213
|
+
};
|
|
168
214
|
var setupUpdateHead = () => {
|
|
169
215
|
const head = usePageHead();
|
|
170
216
|
const lang = usePageLang();
|
|
@@ -224,52 +270,6 @@ var setupUpdateHead = () => {
|
|
|
224
270
|
watch(head, updateHead, { immediate: __VUEPRESS_DEV__ });
|
|
225
271
|
});
|
|
226
272
|
};
|
|
227
|
-
var queryHeadElement = ([
|
|
228
|
-
tagName,
|
|
229
|
-
attrs,
|
|
230
|
-
content = ""
|
|
231
|
-
]) => {
|
|
232
|
-
const attrsSelector = Object.entries(attrs).map(([key, value]) => {
|
|
233
|
-
if (isString(value)) {
|
|
234
|
-
return `[${key}=${JSON.stringify(value)}]`;
|
|
235
|
-
}
|
|
236
|
-
if (value === true) {
|
|
237
|
-
return `[${key}]`;
|
|
238
|
-
}
|
|
239
|
-
return "";
|
|
240
|
-
}).join("");
|
|
241
|
-
const selector = `head > ${tagName}${attrsSelector}`;
|
|
242
|
-
const headElements = Array.from(
|
|
243
|
-
document.querySelectorAll(selector)
|
|
244
|
-
);
|
|
245
|
-
const matchedHeadElement = headElements.find(
|
|
246
|
-
(item) => item.innerText === content
|
|
247
|
-
);
|
|
248
|
-
return matchedHeadElement || null;
|
|
249
|
-
};
|
|
250
|
-
var createHeadElement = ([
|
|
251
|
-
tagName,
|
|
252
|
-
attrs,
|
|
253
|
-
content
|
|
254
|
-
]) => {
|
|
255
|
-
if (!isString(tagName)) {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
const headElement = document.createElement(tagName);
|
|
259
|
-
if (isPlainObject(attrs)) {
|
|
260
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
261
|
-
if (isString(value)) {
|
|
262
|
-
headElement.setAttribute(key, value);
|
|
263
|
-
} else if (value === true) {
|
|
264
|
-
headElement.setAttribute(key, "");
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
if (isString(content)) {
|
|
269
|
-
headElement.appendChild(document.createTextNode(content));
|
|
270
|
-
}
|
|
271
|
-
return headElement;
|
|
272
|
-
};
|
|
273
273
|
|
|
274
274
|
// src/app.ts
|
|
275
275
|
var appCreator = __VUEPRESS_DEV__ ? createApp : createSSRApp;
|
|
@@ -281,18 +281,18 @@ var createVueApp = async () => {
|
|
|
281
281
|
for (const clientConfig of clientConfigs) {
|
|
282
282
|
clientConfig.setup?.();
|
|
283
283
|
}
|
|
284
|
-
const
|
|
285
|
-
({ rootComponents
|
|
284
|
+
const clientRootComponents = clientConfigs.flatMap(
|
|
285
|
+
({ rootComponents = [] }) => rootComponents.map((component) => h(component))
|
|
286
286
|
);
|
|
287
287
|
const pageLayout = usePageLayout();
|
|
288
|
-
return () => [h(pageLayout.value),
|
|
288
|
+
return () => [h(pageLayout.value), clientRootComponents];
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
291
|
const router = createVueRouter();
|
|
292
292
|
setupGlobalComponents(app);
|
|
293
293
|
const globalComputed = setupGlobalComputed(app, router, clientConfigs);
|
|
294
294
|
if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
|
|
295
|
-
const { setupDevtools } = await import("./setupDevtools-
|
|
295
|
+
const { setupDevtools } = await import("./setupDevtools-7MC2TMWH.js");
|
|
296
296
|
setupDevtools(app, globalComputed);
|
|
297
297
|
}
|
|
298
298
|
for (const clientConfig of clientConfigs) {
|
|
@@ -305,8 +305,8 @@ var createVueApp = async () => {
|
|
|
305
305
|
};
|
|
306
306
|
};
|
|
307
307
|
if (!__VUEPRESS_SSR__) {
|
|
308
|
-
createVueApp().then(({ app, router }) => {
|
|
309
|
-
router.isReady().then(() => {
|
|
308
|
+
void createVueApp().then(({ app, router }) => {
|
|
309
|
+
void router.isReady().then(() => {
|
|
310
310
|
app.mount("#app");
|
|
311
311
|
});
|
|
312
312
|
});
|
|
@@ -156,11 +156,11 @@ var RouteLink = defineComponent({
|
|
|
156
156
|
href: path.value,
|
|
157
157
|
onClick: (event = {}) => {
|
|
158
158
|
if (guardEvent(event)) {
|
|
159
|
-
router.push(props.to).catch();
|
|
159
|
+
void router.push(props.to).catch();
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
|
-
slots.default
|
|
163
|
+
slots.default()
|
|
164
164
|
);
|
|
165
165
|
}
|
|
166
166
|
});
|
|
@@ -219,7 +219,7 @@ var AutoLink = defineComponent2({
|
|
|
219
219
|
});
|
|
220
220
|
return () => {
|
|
221
221
|
const { before, after, default: defaultSlot } = slots;
|
|
222
|
-
const content = defaultSlot?.(config.value)
|
|
222
|
+
const content = defaultSlot?.(config.value) ?? [
|
|
223
223
|
before?.(config.value),
|
|
224
224
|
config.value.text,
|
|
225
225
|
after?.(config.value)
|
|
@@ -264,7 +264,6 @@ var ClientOnly = defineComponent3({
|
|
|
264
264
|
// src/components/Content.ts
|
|
265
265
|
import { computed as computed3, defineAsyncComponent, defineComponent as defineComponent4, h as h3 } from "vue";
|
|
266
266
|
var Content = defineComponent4({
|
|
267
|
-
// eslint-disable-next-line vue/no-reserved-component-names
|
|
268
267
|
name: "Content",
|
|
269
268
|
props: {
|
|
270
269
|
path: {
|
|
@@ -278,7 +277,9 @@ var Content = defineComponent4({
|
|
|
278
277
|
const ContentComponent = computed3(() => {
|
|
279
278
|
if (!props.path) return pageComponent.value;
|
|
280
279
|
const route = resolveRoute(props.path);
|
|
281
|
-
return defineAsyncComponent(
|
|
280
|
+
return defineAsyncComponent(
|
|
281
|
+
async () => route.loader().then(({ comp }) => comp)
|
|
282
|
+
);
|
|
282
283
|
});
|
|
283
284
|
return () => h3(ContentComponent.value);
|
|
284
285
|
}
|
|
@@ -356,8 +357,9 @@ var resolvers = reactive({
|
|
|
356
357
|
head: [
|
|
357
358
|
// when merging head, the locales head should be placed before root head
|
|
358
359
|
// to get higher priority
|
|
360
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- unsafe indexed access
|
|
359
361
|
...locales[routeLocale]?.head ?? [],
|
|
360
|
-
...siteData.head
|
|
362
|
+
...siteData.head
|
|
361
363
|
]
|
|
362
364
|
})
|
|
363
365
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -41,8 +41,8 @@ type RoutePath = string;
|
|
|
41
41
|
type RouteLocale = string;
|
|
42
42
|
type LayoutsRef = ComputedRef<Layouts>;
|
|
43
43
|
type PageComponentRef = ComputedRef<PageComponent>;
|
|
44
|
-
type PageDataRef<T extends Record<
|
|
45
|
-
type PageFrontmatterRef<T extends Record<
|
|
44
|
+
type PageDataRef<T extends Record<string, unknown> = Record<string, unknown>> = ComputedRef<PageData<T>>;
|
|
45
|
+
type PageFrontmatterRef<T extends Record<string, unknown> = Record<string, unknown>> = ComputedRef<PageFrontmatter<T>>;
|
|
46
46
|
type PageHeadRef = ComputedRef<PageHead>;
|
|
47
47
|
type PageHeadTitleRef = ComputedRef<PageHeadTitle>;
|
|
48
48
|
type PageLangRef = ComputedRef<PageLang>;
|
|
@@ -82,7 +82,7 @@ interface ClientConfig {
|
|
|
82
82
|
app: App;
|
|
83
83
|
router: Router;
|
|
84
84
|
siteData: SiteDataRef;
|
|
85
|
-
}) => void |
|
|
85
|
+
}) => Promise<void> | void;
|
|
86
86
|
/**
|
|
87
87
|
* A function to be called inside the setup function of vue app
|
|
88
88
|
*/
|
|
@@ -101,7 +101,7 @@ interface AutoLinkConfig {
|
|
|
101
101
|
/**
|
|
102
102
|
* Pattern to determine if the link should be active, which has higher priority than `exact`
|
|
103
103
|
*/
|
|
104
|
-
activeMatch?:
|
|
104
|
+
activeMatch?: RegExp | string;
|
|
105
105
|
/**
|
|
106
106
|
* The `aria-label` attribute
|
|
107
107
|
*/
|
|
@@ -133,51 +133,55 @@ interface AutoLinkConfig {
|
|
|
133
133
|
* - If the link is internal, it will be rendered as a `<RouteLink>`
|
|
134
134
|
* - If the link is external, it will be rendered as a normal `<a>` tag
|
|
135
135
|
*/
|
|
136
|
-
declare const AutoLink: vue.DefineComponent<{
|
|
136
|
+
declare const AutoLink: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
137
137
|
config: {
|
|
138
138
|
type: PropType<AutoLinkConfig>;
|
|
139
139
|
required: true;
|
|
140
140
|
};
|
|
141
|
-
}
|
|
141
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
142
142
|
[key: string]: any;
|
|
143
|
-
}>,
|
|
143
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
144
144
|
config: {
|
|
145
145
|
type: PropType<AutoLinkConfig>;
|
|
146
146
|
required: true;
|
|
147
147
|
};
|
|
148
|
-
}
|
|
149
|
-
default?: (config: AutoLinkConfig) => VNode
|
|
150
|
-
before?: (config: AutoLinkConfig) => VNode
|
|
151
|
-
after?: (config: AutoLinkConfig) => VNode
|
|
152
|
-
}
|
|
148
|
+
}>> & Readonly<{}>, {}, SlotsType<{
|
|
149
|
+
default?: (config: AutoLinkConfig) => VNode | VNode[];
|
|
150
|
+
before?: (config: AutoLinkConfig) => VNode | VNode[] | null;
|
|
151
|
+
after?: (config: AutoLinkConfig) => VNode | VNode[] | null;
|
|
152
|
+
}>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* Wrapper component that only renders its content on the client side and skips server side rendering
|
|
156
|
+
*
|
|
157
|
+
* Since vue 3.5, you can try the new `data-allow-mismatch` attribute instead of `<ClientOnly>` component in some cases to avoid hydration mismatch.
|
|
158
|
+
*
|
|
159
|
+
* @see https://blog.vuejs.org/posts/vue-3-5#data-allow-mismatch
|
|
156
160
|
*/
|
|
157
161
|
declare const ClientOnly: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
158
162
|
[key: string]: any;
|
|
159
|
-
}>[] | null | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<
|
|
163
|
+
}>[] | null | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
160
164
|
|
|
161
165
|
/**
|
|
162
166
|
* Markdown rendered content
|
|
163
167
|
*/
|
|
164
|
-
declare const Content: vue.DefineComponent<{
|
|
168
|
+
declare const Content: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
165
169
|
path: {
|
|
166
170
|
type: StringConstructor;
|
|
167
171
|
required: false;
|
|
168
172
|
default: string;
|
|
169
173
|
};
|
|
170
|
-
}
|
|
174
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
171
175
|
[key: string]: any;
|
|
172
|
-
}>,
|
|
176
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
173
177
|
path: {
|
|
174
178
|
type: StringConstructor;
|
|
175
179
|
required: false;
|
|
176
180
|
default: string;
|
|
177
181
|
};
|
|
178
|
-
}
|
|
182
|
+
}>> & Readonly<{}>, {
|
|
179
183
|
path: string;
|
|
180
|
-
}, {}>;
|
|
184
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
181
185
|
|
|
182
186
|
interface RouteLinkProps {
|
|
183
187
|
/**
|
|
@@ -206,7 +210,7 @@ interface RouteLinkProps {
|
|
|
206
210
|
*
|
|
207
211
|
* It's recommended to use `RouteLink` in VuePress.
|
|
208
212
|
*/
|
|
209
|
-
declare const RouteLink: vue.DefineComponent<{
|
|
213
|
+
declare const RouteLink: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
210
214
|
/**
|
|
211
215
|
* The route path to link to
|
|
212
216
|
*/
|
|
@@ -227,9 +231,9 @@ declare const RouteLink: vue.DefineComponent<{
|
|
|
227
231
|
type: StringConstructor;
|
|
228
232
|
default: string;
|
|
229
233
|
};
|
|
230
|
-
}
|
|
234
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
231
235
|
[key: string]: any;
|
|
232
|
-
}>,
|
|
236
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
233
237
|
/**
|
|
234
238
|
* The route path to link to
|
|
235
239
|
*/
|
|
@@ -250,12 +254,12 @@ declare const RouteLink: vue.DefineComponent<{
|
|
|
250
254
|
type: StringConstructor;
|
|
251
255
|
default: string;
|
|
252
256
|
};
|
|
253
|
-
}
|
|
257
|
+
}>> & Readonly<{}>, {
|
|
254
258
|
active: boolean;
|
|
255
259
|
activeClass: string;
|
|
256
260
|
}, SlotsType<{
|
|
257
|
-
default: () => string | VNode |
|
|
258
|
-
}
|
|
261
|
+
default: () => (VNode | string)[] | VNode | string;
|
|
262
|
+
}>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
259
263
|
|
|
260
264
|
/**
|
|
261
265
|
* Injection key for client data
|
|
@@ -268,8 +272,8 @@ declare const useClientData: () => ClientData;
|
|
|
268
272
|
|
|
269
273
|
declare const useLayouts: () => LayoutsRef;
|
|
270
274
|
declare const usePageComponent: () => PageComponentRef;
|
|
271
|
-
declare const usePageData: <T extends Record<
|
|
272
|
-
declare const usePageFrontmatter: <T extends Record<
|
|
275
|
+
declare const usePageData: <T extends Record<string, unknown> = Record<string, unknown>>() => PageDataRef<T>;
|
|
276
|
+
declare const usePageFrontmatter: <T extends Record<string, unknown> = Record<string, unknown>>() => PageFrontmatterRef<T>;
|
|
273
277
|
declare const usePageHead: () => PageHeadRef;
|
|
274
278
|
declare const usePageLang: () => PageLangRef;
|
|
275
279
|
declare const usePageLayout: () => PageLayoutRef;
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,8 @@ var setupDevtools = (app, clientData) => {
|
|
|
16
16
|
id: PLUGIN_ID,
|
|
17
17
|
label: PLUGIN_LABEL,
|
|
18
18
|
packageName: "@vuepress/client",
|
|
19
|
-
homepage: "https://
|
|
20
|
-
logo: "https://
|
|
19
|
+
homepage: "https://vuepress.vuejs.org",
|
|
20
|
+
logo: "https://vuepress.vuejs.org/images/hero.png",
|
|
21
21
|
componentStateTypes: [PLUGIN_COMPONENT_STATE_TYPE]
|
|
22
22
|
},
|
|
23
23
|
(api) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/client",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.17",
|
|
4
4
|
"description": "Client package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"types.d.ts"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@vue/devtools-api": "^
|
|
37
|
-
"vue": "^3.
|
|
38
|
-
"vue-router": "^4.4.
|
|
39
|
-
"@vuepress/shared": "2.0.0-rc.
|
|
36
|
+
"@vue/devtools-api": "^7.4.6",
|
|
37
|
+
"vue": "^3.5.10",
|
|
38
|
+
"vue-router": "^4.4.5",
|
|
39
|
+
"@vuepress/shared": "2.0.0-rc.17"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention, no-underscore-dangle */
|
|
1
2
|
declare const __VUEPRESS_VERSION__: string
|
|
2
3
|
declare const __VUEPRESS_BASE__: string
|
|
3
4
|
declare const __VUEPRESS_DEV__: boolean
|
|
4
5
|
declare const __VUEPRESS_SSR__: boolean
|
|
5
|
-
declare const __VUE_HMR_RUNTIME__: Record<string,
|
|
6
|
-
declare const __VUE_OPTIONS_API__: boolean
|
|
6
|
+
declare const __VUE_HMR_RUNTIME__: Record<string, unknown>
|
|
7
7
|
declare const __VUE_PROD_DEVTOOLS__: boolean
|