@vuepress/client
Advanced tools
Comparing version 2.0.0-beta.57 to 2.0.0-beta.58
147
dist/app.js
import { | ||
ClientOnly, | ||
Content, | ||
layoutsSymbol, | ||
pageData, | ||
@@ -9,2 +10,3 @@ pageFrontmatterSymbol, | ||
pageLangSymbol, | ||
pageLayoutSymbol, | ||
resolvers, | ||
@@ -15,9 +17,10 @@ routeLocaleSymbol, | ||
updateHeadSymbol, | ||
usePageData, | ||
usePageHead, | ||
usePageLang, | ||
usePageLayout, | ||
withBase | ||
} from "./chunk-5XHTLU25.js"; | ||
} from "./chunk-2OYZ7FSR.js"; | ||
// src/app.ts | ||
import { clientConfigs } from "@internal/clientConfigs"; | ||
import { createApp, createSSRApp, h as h2 } from "vue"; | ||
@@ -40,74 +43,43 @@ import { RouterView } from "vue-router"; | ||
// src/components/Vuepress.ts | ||
import { isString } from "@vuepress/shared"; | ||
import { computed, defineComponent, h } from "vue"; | ||
var LAYOUT_NAME_DEFAULT = "Layout"; | ||
var LAYOUT_NAME_NOT_FOUND = "NotFound"; | ||
var createVuepressComponent = async () => { | ||
const { clientConfigs } = await import("@internal/clientConfigs"); | ||
const layouts = clientConfigs.reduce( | ||
(prev, item) => ({ | ||
...prev, | ||
...item.layouts | ||
}), | ||
{} | ||
); | ||
const Vuepress = defineComponent({ | ||
name: "Vuepress", | ||
setup() { | ||
const page = usePageData(); | ||
const layoutComponent = computed(() => { | ||
let layoutName; | ||
if (page.value.path) { | ||
const frontmatterLayout = page.value.frontmatter.layout; | ||
if (isString(frontmatterLayout)) { | ||
layoutName = frontmatterLayout; | ||
} else { | ||
layoutName = LAYOUT_NAME_DEFAULT; | ||
} | ||
} else { | ||
layoutName = LAYOUT_NAME_NOT_FOUND; | ||
} | ||
return layouts[layoutName]; | ||
}); | ||
return () => h(layoutComponent.value); | ||
} | ||
}); | ||
return Vuepress; | ||
}; | ||
import { defineComponent, h } from "vue"; | ||
var Vuepress = defineComponent({ | ||
name: "Vuepress", | ||
setup() { | ||
const layout = usePageLayout(); | ||
return () => h(layout.value); | ||
} | ||
}); | ||
// src/routes.ts | ||
var createRoutes = async () => { | ||
const Vuepress = await createVuepressComponent(); | ||
return pagesRoutes.reduce( | ||
(result, [name, path, meta, redirects]) => { | ||
result.push( | ||
{ | ||
name, | ||
path, | ||
component: Vuepress, | ||
meta | ||
}, | ||
...redirects.map((item) => ({ | ||
path: item, | ||
redirect: path | ||
})) | ||
); | ||
return result; | ||
}, | ||
[ | ||
var createRoutes = () => pagesRoutes.reduce( | ||
(result, [name, path, meta, redirects]) => { | ||
result.push( | ||
{ | ||
name: "404", | ||
path: "/:catchAll(.*)", | ||
component: Vuepress | ||
} | ||
] | ||
); | ||
}; | ||
name, | ||
path, | ||
component: Vuepress, | ||
meta | ||
}, | ||
...redirects.map((item) => ({ | ||
path: item, | ||
redirect: path | ||
})) | ||
); | ||
return result; | ||
}, | ||
[ | ||
{ | ||
name: "404", | ||
path: "/:catchAll(.*)", | ||
component: Vuepress | ||
} | ||
] | ||
); | ||
// src/router.ts | ||
var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory; | ||
var createVueRouter = async () => { | ||
var createVueRouter = () => { | ||
const router = createRouter({ | ||
history: historyCreator(removeEndingSlash(__VUEPRESS_BASE__)), | ||
routes: await createRoutes(), | ||
routes: createRoutes(), | ||
scrollBehavior: (to, from, savedPosition) => { | ||
@@ -140,5 +112,6 @@ if (savedPosition) | ||
// src/setupGlobalComputed.ts | ||
import { computed as computed2 } from "vue"; | ||
var setupGlobalComputed = (app, router) => { | ||
const routeLocale = computed2( | ||
import { computed } from "vue"; | ||
var setupGlobalComputed = (app, router, clientConfigs2) => { | ||
const layouts = computed(() => resolvers.resolveLayouts(clientConfigs2)); | ||
const routeLocale = computed( | ||
() => resolvers.resolveRouteLocale( | ||
@@ -149,12 +122,12 @@ siteData.value.locales, | ||
); | ||
const siteLocaleData = computed2( | ||
const siteLocaleData = computed( | ||
() => resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value) | ||
); | ||
const pageFrontmatter = computed2( | ||
const pageFrontmatter = computed( | ||
() => resolvers.resolvePageFrontmatter(pageData.value) | ||
); | ||
const pageHeadTitle = computed2( | ||
const pageHeadTitle = computed( | ||
() => resolvers.resolvePageHeadTitle(pageData.value, siteLocaleData.value) | ||
); | ||
const pageHead = computed2( | ||
const pageHead = computed( | ||
() => resolvers.resolvePageHead( | ||
@@ -166,5 +139,7 @@ pageHeadTitle.value, | ||
); | ||
const pageLang = computed2(() => resolvers.resolvePageLang(pageData.value)); | ||
app.provide(routeLocaleSymbol, routeLocale); | ||
app.provide(siteLocaleDataSymbol, siteLocaleData); | ||
const pageLang = computed(() => resolvers.resolvePageLang(pageData.value)); | ||
const pageLayout = computed( | ||
() => resolvers.resolvePageLayout(pageData.value, layouts.value) | ||
); | ||
app.provide(layoutsSymbol, layouts); | ||
app.provide(pageFrontmatterSymbol, pageFrontmatter); | ||
@@ -174,2 +149,5 @@ app.provide(pageHeadTitleSymbol, pageHeadTitle); | ||
app.provide(pageLangSymbol, pageLang); | ||
app.provide(pageLayoutSymbol, pageLayout); | ||
app.provide(routeLocaleSymbol, routeLocale); | ||
app.provide(siteLocaleDataSymbol, siteLocaleData); | ||
Object.defineProperties(app.config.globalProperties, { | ||
@@ -187,2 +165,3 @@ $frontmatter: { get: () => pageFrontmatter.value }, | ||
return { | ||
layouts, | ||
pageData, | ||
@@ -193,2 +172,3 @@ pageFrontmatter, | ||
pageLang, | ||
pageLayout, | ||
routeLocale, | ||
@@ -201,3 +181,3 @@ siteData, | ||
// src/setupUpdateHead.ts | ||
import { isPlainObject, isString as isString2 } from "@vuepress/shared"; | ||
import { isPlainObject, isString } from "@vuepress/shared"; | ||
import { onMounted, provide, ref, useSSRContext, watch } from "vue"; | ||
@@ -258,3 +238,3 @@ import { useRoute } from "vue-router"; | ||
const attrsSelector = Object.entries(attrs).map(([key, value]) => { | ||
if (isString2(value)) { | ||
if (isString(value)) { | ||
return `[${key}=${JSON.stringify(value)}]`; | ||
@@ -277,3 +257,3 @@ } | ||
]) => { | ||
if (!isString2(tagName)) { | ||
if (!isString(tagName)) { | ||
return null; | ||
@@ -284,3 +264,3 @@ } | ||
Object.entries(attrs).forEach(([key, value]) => { | ||
if (isString2(value)) { | ||
if (isString(value)) { | ||
tag.setAttribute(key, value); | ||
@@ -292,3 +272,3 @@ } else if (value === true) { | ||
} | ||
if (isString2(content)) { | ||
if (isString(content)) { | ||
tag.appendChild(document.createTextNode(content)); | ||
@@ -302,3 +282,2 @@ } | ||
var createVueApp = async () => { | ||
const { clientConfigs } = await import("@internal/clientConfigs"); | ||
const app = appCreator({ | ||
@@ -319,5 +298,5 @@ name: "VuepressApp", | ||
}); | ||
const router = await createVueRouter(); | ||
const router = createVueRouter(); | ||
setupGlobalComponents(app); | ||
const globalComputed = setupGlobalComputed(app, router); | ||
const globalComputed = setupGlobalComputed(app, router, clientConfigs); | ||
if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) { | ||
@@ -324,0 +303,0 @@ const { setupDevtools } = await import("./setupDevtools-EXVHPMXB.js"); |
import { PageData, PageFrontmatter, HeadConfig, SiteData } from '@vuepress/shared'; | ||
export { PageData, PageFrontmatter, PageHeader, SiteData } from '@vuepress/shared'; | ||
import * as vue from 'vue'; | ||
import { Ref, ComputedRef, InjectionKey, App, Component } from 'vue'; | ||
import { Component, App, ComputedRef, InjectionKey, Ref } from 'vue'; | ||
import { Router, RouteMeta } from 'vue-router'; | ||
@@ -32,3 +32,57 @@ | ||
type Layouts = Record<string, Component>; | ||
/** | ||
* Configure vuepress client | ||
*/ | ||
interface ClientConfig { | ||
/** | ||
* An enhance function to be called after vue app instance and | ||
* vue-router instance has been created | ||
*/ | ||
enhance?: (context: { | ||
app: App; | ||
router: Router; | ||
siteData: SiteDataRef; | ||
}) => void | Promise<void>; | ||
/** | ||
* A function to be called inside the setup function of vue app | ||
*/ | ||
setup?: () => void; | ||
/** | ||
* Layout components | ||
*/ | ||
layouts?: Layouts; | ||
/** | ||
* Components to be placed directly into the root node of vue app | ||
*/ | ||
rootComponents?: Component[]; | ||
} | ||
type CreateVueAppFunction = () => Promise<{ | ||
app: App; | ||
router: Router; | ||
}>; | ||
type PageRouteItem = [ | ||
name: string, | ||
path: string, | ||
meta: RouteMeta, | ||
redirects: string[] | ||
]; | ||
/** | ||
* Ref wrapper of `Layouts` | ||
*/ | ||
type LayoutsRef = ComputedRef<Layouts>; | ||
/** | ||
* Injection key for layouts | ||
*/ | ||
declare const layoutsSymbol: InjectionKey<LayoutsRef>; | ||
/** | ||
* Returns layouts component map | ||
*/ | ||
declare const useLayouts: () => LayoutsRef; | ||
/** | ||
* Ref wrapper of `PageData` | ||
@@ -115,2 +169,15 @@ */ | ||
/** | ||
* Ref wrapper of `PageLayout` | ||
*/ | ||
type PageLayoutRef = ComputedRef<Component>; | ||
/** | ||
* Injection key for page layout | ||
*/ | ||
declare const pageLayoutSymbol: InjectionKey<PageLayoutRef>; | ||
/** | ||
* Returns layout component of current page | ||
*/ | ||
declare const usePageLayout: () => ComputedRef<Component>; | ||
/** | ||
* Data resolvers of all pages | ||
@@ -196,41 +263,2 @@ * | ||
/** | ||
* Configure vuepress client | ||
*/ | ||
interface ClientConfig { | ||
/** | ||
* An enhance function to be called after vue app instance and | ||
* vue-router instance has been created | ||
*/ | ||
enhance?: (context: { | ||
app: App; | ||
router: Router; | ||
siteData: SiteDataRef; | ||
}) => void | Promise<void>; | ||
/** | ||
* A function to be called inside the setup function of vue app | ||
*/ | ||
setup?: () => void; | ||
/** | ||
* Layout components | ||
*/ | ||
layouts?: Record<string, Component>; | ||
/** | ||
* Components to be placed directly into the root node of vue app | ||
*/ | ||
rootComponents?: Component[]; | ||
} | ||
type CreateVueAppFunction = () => Promise<{ | ||
app: App; | ||
router: Router; | ||
}>; | ||
type PageRouteItem = [ | ||
name: string, | ||
path: string, | ||
meta: RouteMeta, | ||
redirects: string[] | ||
]; | ||
/** | ||
* A helper function to help you define vuepress client config file | ||
@@ -251,2 +279,3 @@ */ | ||
declare const resolvers: { | ||
resolveLayouts: (clientConfigs: ClientConfig[]) => Layouts; | ||
resolvePageData: (pageKey: string) => Promise<PageData>; | ||
@@ -256,3 +285,4 @@ resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter; | ||
resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle; | ||
resolvePageLang: (pageData: PageData) => PageLang; | ||
resolvePageLang: (page: PageData) => PageLang; | ||
resolvePageLayout: (page: PageData, layouts: Layouts) => Component; | ||
resolveRouteLocale: (locales: SiteData['locales'], routePath: string) => RouteLocale; | ||
@@ -262,2 +292,2 @@ resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData; | ||
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 }; | ||
export { ClientConfig, ClientOnly, Content, CreateVueAppFunction, Layouts, LayoutsRef, PageDataRef, PageFrontmatterRef, PageHead, PageHeadRef, PageHeadTitle, PageHeadTitleRef, PageLang, PageLangRef, PageLayoutRef, PageRouteItem, PagesData, PagesDataRef, RouteLocale, RouteLocaleRef, SiteDataRef, SiteLocaleData, SiteLocaleDataRef, UpdateHead, defineClientConfig, layoutsSymbol, pageData, pageDataEmpty, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, pageLayoutSymbol, pagesData, resolvers, routeLocaleSymbol, siteData, siteLocaleDataSymbol, updateHeadSymbol, useLayouts, usePageData, usePageFrontmatter, usePageHead, usePageHeadTitle, usePageLang, usePageLayout, usePagesData, useRouteLocale, useSiteData, useSiteLocaleData, useUpdateHead, withBase }; |
@@ -5,2 +5,3 @@ import { | ||
defineClientConfig, | ||
layoutsSymbol, | ||
pageData, | ||
@@ -12,2 +13,3 @@ pageDataEmpty, | ||
pageLangSymbol, | ||
pageLayoutSymbol, | ||
pagesData, | ||
@@ -19,2 +21,3 @@ resolvers, | ||
updateHeadSymbol, | ||
useLayouts, | ||
usePageData, | ||
@@ -25,2 +28,3 @@ usePageFrontmatter, | ||
usePageLang, | ||
usePageLayout, | ||
usePagesData, | ||
@@ -32,3 +36,3 @@ useRouteLocale, | ||
withBase | ||
} from "./chunk-5XHTLU25.js"; | ||
} from "./chunk-2OYZ7FSR.js"; | ||
export { | ||
@@ -38,2 +42,3 @@ ClientOnly, | ||
defineClientConfig, | ||
layoutsSymbol, | ||
pageData, | ||
@@ -45,2 +50,3 @@ pageDataEmpty, | ||
pageLangSymbol, | ||
pageLayoutSymbol, | ||
pagesData, | ||
@@ -52,2 +58,3 @@ resolvers, | ||
updateHeadSymbol, | ||
useLayouts, | ||
usePageData, | ||
@@ -58,2 +65,3 @@ usePageFrontmatter, | ||
usePageLang, | ||
usePageLayout, | ||
usePagesData, | ||
@@ -60,0 +68,0 @@ useRouteLocale, |
{ | ||
"name": "@vuepress/client", | ||
"version": "2.0.0-beta.57", | ||
"version": "2.0.0-beta.58", | ||
"description": "Client package of VuePress", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
"vue-router": "^4.1.6", | ||
"@vuepress/shared": "2.0.0-beta.57" | ||
"@vuepress/shared": "2.0.0-beta.58" | ||
}, | ||
@@ -42,0 +42,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31666
1003
+ Added@vuepress/shared@2.0.0-beta.58(transitive)
- Removed@vuepress/shared@2.0.0-beta.57(transitive)