@vuepress/client 2.0.0-beta.52 → 2.0.0-beta.54

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/dist/app.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  ClientOnly,
3
3
  Content,
4
- Vuepress,
5
4
  pageData,
6
5
  pageFrontmatterSymbol,
7
6
  pageHeadSymbol,
@@ -12,14 +11,14 @@ import {
12
11
  siteData,
13
12
  siteLocaleDataSymbol,
14
13
  updateHeadSymbol,
14
+ usePageData,
15
15
  usePageHead,
16
16
  usePageLang,
17
17
  withBase
18
- } from "./chunk-X6HE2CCA.js";
18
+ } from "./chunk-YRWD2ESJ.js";
19
19
 
20
20
  // src/app.ts
21
- import { clientConfigs } from "@internal/clientConfigs";
22
- import { createApp, createSSRApp, h } from "vue";
21
+ import { createApp, createSSRApp, h as h2 } from "vue";
23
22
  import { RouterView } from "vue-router";
24
23
 
25
24
  // src/router.ts
@@ -34,37 +33,80 @@ import {
34
33
 
35
34
  // src/routes.ts
36
35
  import { pagesRoutes } from "@internal/pagesRoutes";
37
- var createRoutes = () => pagesRoutes.reduce(
38
- (result, [name, path, meta, redirects]) => {
39
- result.push(
40
- {
41
- name,
42
- path,
43
- component: Vuepress,
44
- meta
45
- },
46
- ...redirects.map((item) => ({
47
- path: item,
48
- redirect: path
49
- }))
50
- );
51
- return result;
52
- },
53
- [
54
- {
55
- name: "404",
56
- path: "/:catchAll(.*)",
57
- component: Vuepress
36
+
37
+ // src/components/Vuepress.ts
38
+ import { isString } from "@vuepress/shared";
39
+ import { computed, defineComponent, h } from "vue";
40
+ var LAYOUT_NAME_DEFAULT = "Layout";
41
+ var LAYOUT_NAME_NOT_FOUND = "NotFound";
42
+ var createVuepressComponent = async () => {
43
+ const { clientConfigs } = await import("@internal/clientConfigs");
44
+ const layouts = clientConfigs.reduce(
45
+ (prev, item) => ({
46
+ ...prev,
47
+ ...item.layouts
48
+ }),
49
+ {}
50
+ );
51
+ const Vuepress = defineComponent({
52
+ name: "Vuepress",
53
+ setup() {
54
+ const page = usePageData();
55
+ const layoutComponent = computed(() => {
56
+ let layoutName;
57
+ if (page.value.path) {
58
+ const frontmatterLayout = page.value.frontmatter.layout;
59
+ if (isString(frontmatterLayout)) {
60
+ layoutName = frontmatterLayout;
61
+ } else {
62
+ layoutName = LAYOUT_NAME_DEFAULT;
63
+ }
64
+ } else {
65
+ layoutName = LAYOUT_NAME_NOT_FOUND;
66
+ }
67
+ return layouts[layoutName];
68
+ });
69
+ return () => h(layoutComponent.value);
58
70
  }
59
- ]
60
- );
71
+ });
72
+ return Vuepress;
73
+ };
74
+
75
+ // src/routes.ts
76
+ var createRoutes = async () => {
77
+ const Vuepress = await createVuepressComponent();
78
+ return pagesRoutes.reduce(
79
+ (result, [name, path, meta, redirects]) => {
80
+ result.push(
81
+ {
82
+ name,
83
+ path,
84
+ component: Vuepress,
85
+ meta
86
+ },
87
+ ...redirects.map((item) => ({
88
+ path: item,
89
+ redirect: path
90
+ }))
91
+ );
92
+ return result;
93
+ },
94
+ [
95
+ {
96
+ name: "404",
97
+ path: "/:catchAll(.*)",
98
+ component: Vuepress
99
+ }
100
+ ]
101
+ );
102
+ };
61
103
 
62
104
  // src/router.ts
63
105
  var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
64
- var createVueRouter = () => {
106
+ var createVueRouter = async () => {
65
107
  const router = createRouter({
66
108
  history: historyCreator(removeEndingSlash(siteData.value.base)),
67
- routes: createRoutes(),
109
+ routes: await createRoutes(),
68
110
  scrollBehavior: (to, from, savedPosition) => {
69
111
  if (savedPosition)
70
112
  return savedPosition;
@@ -92,31 +134,31 @@ var setupGlobalComponents = (app) => {
92
134
  };
93
135
 
94
136
  // src/setupGlobalComputed.ts
95
- import { computed } from "vue";
137
+ import { computed as computed2 } from "vue";
96
138
  var setupGlobalComputed = (app, router) => {
97
- const routeLocale = computed(
139
+ const routeLocale = computed2(
98
140
  () => resolvers.resolveRouteLocale(
99
141
  siteData.value.locales,
100
142
  router.currentRoute.value.path
101
143
  )
102
144
  );
103
- const siteLocaleData = computed(
145
+ const siteLocaleData = computed2(
104
146
  () => resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value)
105
147
  );
106
- const pageFrontmatter = computed(
148
+ const pageFrontmatter = computed2(
107
149
  () => resolvers.resolvePageFrontmatter(pageData.value)
108
150
  );
109
- const pageHeadTitle = computed(
151
+ const pageHeadTitle = computed2(
110
152
  () => resolvers.resolvePageHeadTitle(pageData.value, siteLocaleData.value)
111
153
  );
112
- const pageHead = computed(
154
+ const pageHead = computed2(
113
155
  () => resolvers.resolvePageHead(
114
156
  pageHeadTitle.value,
115
157
  pageFrontmatter.value,
116
158
  siteLocaleData.value
117
159
  )
118
160
  );
119
- const pageLang = computed(() => resolvers.resolvePageLang(pageData.value));
161
+ const pageLang = computed2(() => resolvers.resolvePageLang(pageData.value));
120
162
  app.provide(routeLocaleSymbol, routeLocale);
121
163
  app.provide(siteLocaleDataSymbol, siteLocaleData);
122
164
  app.provide(pageFrontmatterSymbol, pageFrontmatter);
@@ -147,7 +189,7 @@ var setupGlobalComputed = (app, router) => {
147
189
  };
148
190
 
149
191
  // src/setupUpdateHead.ts
150
- import { isPlainObject, isString } from "@vuepress/shared";
192
+ import { isPlainObject, isString as isString2 } from "@vuepress/shared";
151
193
  import { onMounted, provide, ref, useSSRContext, watch } from "vue";
152
194
  import { useRoute } from "vue-router";
153
195
  var setupUpdateHead = () => {
@@ -203,8 +245,8 @@ var queryHeadTag = ([
203
245
  content = ""
204
246
  ]) => {
205
247
  const attrsSelector = Object.entries(attrs).map(([key, value]) => {
206
- if (isString(value)) {
207
- return `[${key}="${value}"]`;
248
+ if (isString2(value)) {
249
+ return `[${key}=${JSON.stringify(value)}]`;
208
250
  }
209
251
  if (value === true) {
210
252
  return `[${key}]`;
@@ -221,20 +263,20 @@ var createHeadTag = ([
221
263
  attrs,
222
264
  content
223
265
  ]) => {
224
- if (!isString(tagName)) {
266
+ if (!isString2(tagName)) {
225
267
  return null;
226
268
  }
227
269
  const tag = document.createElement(tagName);
228
270
  if (isPlainObject(attrs)) {
229
271
  Object.entries(attrs).forEach(([key, value]) => {
230
- if (isString(value)) {
272
+ if (isString2(value)) {
231
273
  tag.setAttribute(key, value);
232
274
  } else if (value === true) {
233
275
  tag.setAttribute(key, "");
234
276
  }
235
277
  });
236
278
  }
237
- if (isString(content)) {
279
+ if (isString2(content)) {
238
280
  tag.appendChild(document.createTextNode(content));
239
281
  }
240
282
  return tag;
@@ -243,6 +285,7 @@ var createHeadTag = ([
243
285
  // src/app.ts
244
286
  var appCreator = __VUEPRESS_DEV__ ? createApp : createSSRApp;
245
287
  var createVueApp = async () => {
288
+ const { clientConfigs } = await import("@internal/clientConfigs");
246
289
  const app = appCreator({
247
290
  name: "VuepressApp",
248
291
  setup() {
@@ -251,14 +294,14 @@ var createVueApp = async () => {
251
294
  clientConfig.setup?.();
252
295
  }
253
296
  return () => [
254
- h(RouterView),
297
+ h2(RouterView),
255
298
  ...clientConfigs.flatMap(
256
- ({ rootComponents = [] }) => rootComponents.map((component) => h(component))
299
+ ({ rootComponents = [] }) => rootComponents.map((component) => h2(component))
257
300
  )
258
301
  ];
259
302
  }
260
303
  });
261
- const router = createVueRouter();
304
+ const router = await createVueRouter();
262
305
  setupGlobalComponents(app);
263
306
  const globalComputed = setupGlobalComputed(app, router);
264
307
  if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
@@ -199,41 +199,6 @@ var Content = defineComponent2({
199
199
  }
200
200
  });
201
201
 
202
- // src/components/Vuepress.ts
203
- import { clientConfigs } from "@internal/clientConfigs";
204
- import { isString as isString2 } from "@vuepress/shared";
205
- import { computed as computed2, defineComponent as defineComponent3, h as h2 } from "vue";
206
- var LAYOUT_NAME_DEFAULT = "Layout";
207
- var LAYOUT_NAME_NOT_FOUND = "NotFound";
208
- var layouts = clientConfigs.reduce(
209
- (prev, item) => ({
210
- ...prev,
211
- ...item.layouts
212
- }),
213
- {}
214
- );
215
- var Vuepress = defineComponent3({
216
- name: "Vuepress",
217
- setup() {
218
- const page = usePageData();
219
- const layoutComponent = computed2(() => {
220
- let layoutName;
221
- if (page.value.path) {
222
- const frontmatterLayout = page.value.frontmatter.layout;
223
- if (isString2(frontmatterLayout)) {
224
- layoutName = frontmatterLayout;
225
- } else {
226
- layoutName = LAYOUT_NAME_DEFAULT;
227
- }
228
- } else {
229
- layoutName = LAYOUT_NAME_NOT_FOUND;
230
- }
231
- return layouts[layoutName];
232
- });
233
- return () => h2(layoutComponent.value);
234
- }
235
- });
236
-
237
202
  // src/withBase.ts
238
203
  import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
239
204
  var withBase = (url) => {
@@ -268,6 +233,5 @@ export {
268
233
  resolvers,
269
234
  ClientOnly,
270
235
  Content,
271
- Vuepress,
272
236
  withBase
273
237
  };
package/dist/index.d.ts CHANGED
@@ -29,17 +29,10 @@ declare const Content: vue.DefineComponent<{
29
29
  pageKey: string;
30
30
  }>;
31
31
 
32
- /**
33
- * Global Layout
34
- */
35
- declare const Vuepress: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
36
- [key: string]: any;
37
- }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{}>>, {}>;
38
-
39
32
  /**
40
33
  * Ref wrapper of `PageData`
41
34
  */
42
- declare type PageDataRef<T extends Record<any, any> = Record<never, never>> = Ref<PageData<T>>;
35
+ type PageDataRef<T extends Record<any, any> = Record<never, never>> = Ref<PageData<T>>;
43
36
  /**
44
37
  * Empty page data to be used as the fallback value
45
38
  */
@@ -56,7 +49,7 @@ declare const usePageData: <T extends Record<any, any> = Record<never, never>>()
56
49
  /**
57
50
  * Ref wrapper of `PageFrontmatter`
58
51
  */
59
- declare type PageFrontmatterRef<T extends Record<any, any> = Record<string, unknown>> = ComputedRef<PageFrontmatter<T>>;
52
+ type PageFrontmatterRef<T extends Record<any, any> = Record<string, unknown>> = ComputedRef<PageFrontmatter<T>>;
60
53
  /**
61
54
  * Injection key for page frontmatter
62
55
  */
@@ -69,11 +62,11 @@ declare const usePageFrontmatter: <T extends Record<any, any> = Record<string, u
69
62
  /**
70
63
  * Page head config, which would be used for generate html tags in `<head>`
71
64
  */
72
- declare type PageHead = HeadConfig[];
65
+ type PageHead = HeadConfig[];
73
66
  /**
74
67
  * Ref wrapper of `PageHead`
75
68
  */
76
- declare type PageHeadRef = ComputedRef<PageHead>;
69
+ type PageHeadRef = ComputedRef<PageHead>;
77
70
  /**
78
71
  * Injection key for page head
79
72
  */
@@ -86,11 +79,11 @@ declare const usePageHead: () => PageHeadRef;
86
79
  /**
87
80
  * Page head title, which would be used as the content of `head > title` tag
88
81
  */
89
- declare type PageHeadTitle = string;
82
+ type PageHeadTitle = string;
90
83
  /**
91
84
  * Ref wrapper of `PageHeadTitle`
92
85
  */
93
- declare type PageHeadTitleRef = ComputedRef<PageHeadTitle>;
86
+ type PageHeadTitleRef = ComputedRef<PageHeadTitle>;
94
87
  /**
95
88
  * Injection key for page head title
96
89
  */
@@ -103,11 +96,11 @@ declare const usePageHeadTitle: () => PageHeadTitleRef;
103
96
  /**
104
97
  * Page language
105
98
  */
106
- declare type PageLang = string;
99
+ type PageLang = string;
107
100
  /**
108
101
  * Ref wrapper of `PageLang`
109
102
  */
110
- declare type PageLangRef = ComputedRef<PageLang>;
103
+ type PageLangRef = ComputedRef<PageLang>;
111
104
  /**
112
105
  * Injection key for page language
113
106
  */
@@ -123,11 +116,11 @@ declare const usePageLang: () => PageLangRef;
123
116
  * The key is page key, and the value is an async function that
124
117
  * returns the page data
125
118
  */
126
- declare type PagesData = Record<string, (() => Promise<PageData>) | undefined>;
119
+ type PagesData = Record<string, (() => Promise<PageData>) | undefined>;
127
120
  /**
128
121
  * Ref wrapper of `PagesData`
129
122
  */
130
- declare type PagesDataRef = Ref<PagesData>;
123
+ type PagesDataRef = Ref<PagesData>;
131
124
  /**
132
125
  * Global pages data ref
133
126
  */
@@ -140,11 +133,11 @@ declare const usePagesData: () => PagesDataRef;
140
133
  /**
141
134
  * Route locale path
142
135
  */
143
- declare type RouteLocale = string;
136
+ type RouteLocale = string;
144
137
  /**
145
138
  * Ref wrapper of `RouteLocale`
146
139
  */
147
- declare type RouteLocaleRef = ComputedRef<RouteLocale>;
140
+ type RouteLocaleRef = ComputedRef<RouteLocale>;
148
141
  /**
149
142
  * Injection key for page route locale path
150
143
  */
@@ -157,7 +150,7 @@ declare const useRouteLocale: () => RouteLocaleRef;
157
150
  /**
158
151
  * Ref wrapper of `SiteData`
159
152
  */
160
- declare type SiteDataRef = Ref<SiteData>;
153
+ type SiteDataRef = Ref<SiteData>;
161
154
  /**
162
155
  * Global site data ref
163
156
  */
@@ -170,11 +163,11 @@ declare const useSiteData: () => SiteDataRef;
170
163
  /**
171
164
  * Site data of current locale
172
165
  */
173
- declare type SiteLocaleData = SiteData;
166
+ type SiteLocaleData = SiteData;
174
167
  /**
175
168
  * Ref wrapper of `SiteLocaleData`
176
169
  */
177
- declare type SiteLocaleDataRef = ComputedRef<SiteLocaleData>;
170
+ type SiteLocaleDataRef = ComputedRef<SiteLocaleData>;
178
171
  /**
179
172
  * Injection key for site locale data
180
173
  */
@@ -187,7 +180,7 @@ declare const useSiteLocaleData: () => SiteLocaleDataRef;
187
180
  /**
188
181
  * A util function to force update `<head>` of current page
189
182
  */
190
- declare type UpdateHead = () => void;
183
+ type UpdateHead = () => void;
191
184
  /**
192
185
  * Injection key for `updateHead` util
193
186
  */
@@ -224,12 +217,12 @@ interface ClientConfig {
224
217
  rootComponents?: Component[];
225
218
  }
226
219
 
227
- declare type CreateVueAppFunction = () => Promise<{
220
+ type CreateVueAppFunction = () => Promise<{
228
221
  app: App;
229
222
  router: Router;
230
223
  }>;
231
224
 
232
- declare type PageRouteItem = [
225
+ type PageRouteItem = [
233
226
  name: string,
234
227
  path: string,
235
228
  meta: RouteMeta,
@@ -261,4 +254,4 @@ declare const resolvers: {
261
254
  */
262
255
  declare const withBase: (url: string) => string;
263
256
 
264
- export { ClientConfig, ClientOnly, Content, CreateVueAppFunction, PageDataRef, PageFrontmatterRef, PageHead, PageHeadRef, PageHeadTitle, PageHeadTitleRef, PageLang, PageLangRef, PageRouteItem, PagesData, PagesDataRef, RouteLocale, RouteLocaleRef, SiteDataRef, SiteLocaleData, SiteLocaleDataRef, UpdateHead, Vuepress, defineClientConfig, pageData, pageDataEmpty, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, pagesData, resolvers, routeLocaleSymbol, siteData, siteLocaleDataSymbol, updateHeadSymbol, usePageData, usePageFrontmatter, usePageHead, usePageHeadTitle, usePageLang, usePagesData, useRouteLocale, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
257
+ export { ClientConfig, ClientOnly, Content, CreateVueAppFunction, PageDataRef, PageFrontmatterRef, PageHead, PageHeadRef, PageHeadTitle, PageHeadTitleRef, PageLang, PageLangRef, PageRouteItem, PagesData, PagesDataRef, RouteLocale, RouteLocaleRef, SiteDataRef, SiteLocaleData, SiteLocaleDataRef, UpdateHead, defineClientConfig, pageData, pageDataEmpty, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, pagesData, resolvers, routeLocaleSymbol, siteData, siteLocaleDataSymbol, updateHeadSymbol, usePageData, usePageFrontmatter, usePageHead, usePageHeadTitle, usePageLang, usePagesData, useRouteLocale, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  ClientOnly,
3
3
  Content,
4
- Vuepress,
5
4
  pageData,
6
5
  pageDataEmpty,
7
6
  pageFrontmatterSymbol,
@@ -25,14 +24,13 @@ import {
25
24
  useSiteLocaleData,
26
25
  useUpdateHead,
27
26
  withBase
28
- } from "./chunk-X6HE2CCA.js";
27
+ } from "./chunk-YRWD2ESJ.js";
29
28
 
30
29
  // src/helpers/defineClientConfig.ts
31
30
  var defineClientConfig = (clientConfig = {}) => clientConfig;
32
31
  export {
33
32
  ClientOnly,
34
33
  Content,
35
- Vuepress,
36
34
  defineClientConfig,
37
35
  pageData,
38
36
  pageDataEmpty,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/client",
3
- "version": "2.0.0-beta.52",
3
+ "version": "2.0.0-beta.54",
4
4
  "description": "Client package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -34,9 +34,9 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@vue/devtools-api": "^6.4.5",
37
- "@vuepress/shared": "2.0.0-beta.52",
38
- "vue": "^3.2.41",
39
- "vue-router": "^4.1.5"
37
+ "vue": "^3.2.45",
38
+ "vue-router": "^4.1.6",
39
+ "@vuepress/shared": "2.0.0-beta.54"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"