@vuepress/client 2.0.0-beta.9 → 2.0.0-rc.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.
Files changed (72) hide show
  1. package/dist/app.js +333 -0
  2. package/dist/chunk-DHNSDB55.js +338 -0
  3. package/dist/index.d.ts +287 -0
  4. package/dist/index.js +64 -0
  5. package/dist/setupDevtools-X4YFRK4B.js +89 -0
  6. package/package.json +47 -15
  7. package/templates/build.html +16 -0
  8. package/templates/{index.dev.html → dev.html} +2 -0
  9. package/types.d.ts +6 -3
  10. package/CHANGELOG.md +0 -229
  11. package/lib/app.d.ts +0 -18
  12. package/lib/app.js +0 -139
  13. package/lib/client.d.ts +0 -1
  14. package/lib/client.js +0 -14
  15. package/lib/components/Content.d.ts +0 -7
  16. package/lib/components/Content.js +0 -34
  17. package/lib/components/OutboundLink.css +0 -7
  18. package/lib/components/OutboundLink.d.ts +0 -3
  19. package/lib/components/OutboundLink.js +0 -24
  20. package/lib/components/Vuepress.d.ts +0 -5
  21. package/lib/components/Vuepress.js +0 -33
  22. package/lib/components/index.d.ts +0 -3
  23. package/lib/components/index.js +0 -3
  24. package/lib/index.d.ts +0 -7
  25. package/lib/index.js +0 -5
  26. package/lib/injections/index.d.ts +0 -10
  27. package/lib/injections/index.js +0 -10
  28. package/lib/injections/pageData.d.ts +0 -7
  29. package/lib/injections/pageData.js +0 -32
  30. package/lib/injections/pageFrontmatter.d.ts +0 -7
  31. package/lib/injections/pageFrontmatter.js +0 -10
  32. package/lib/injections/pageHead.d.ts +0 -15
  33. package/lib/injections/pageHead.js +0 -33
  34. package/lib/injections/pageHeadTitle.d.ts +0 -11
  35. package/lib/injections/pageHeadTitle.js +0 -13
  36. package/lib/injections/pageLang.d.ts +0 -13
  37. package/lib/injections/pageLang.js +0 -16
  38. package/lib/injections/pagesData.d.ts +0 -6
  39. package/lib/injections/pagesData.js +0 -6
  40. package/lib/injections/routeLocale.d.ts +0 -10
  41. package/lib/injections/routeLocale.js +0 -14
  42. package/lib/injections/siteData.d.ts +0 -6
  43. package/lib/injections/siteData.js +0 -10
  44. package/lib/injections/siteLocaleData.d.ts +0 -12
  45. package/lib/injections/siteLocaleData.js +0 -17
  46. package/lib/injections/updateHead.d.ts +0 -15
  47. package/lib/injections/updateHead.js +0 -100
  48. package/lib/server.d.ts +0 -8
  49. package/lib/server.js +0 -10
  50. package/lib/types/clientAppEnhance.d.ts +0 -8
  51. package/lib/types/clientAppEnhance.js +0 -1
  52. package/lib/types/clientAppSetup.d.ts +0 -1
  53. package/lib/types/clientAppSetup.js +0 -1
  54. package/lib/types/index.d.ts +0 -7
  55. package/lib/types/index.js +0 -2
  56. package/lib/types/internal/clientAppEnhances.d.ts +0 -5
  57. package/lib/types/internal/clientAppRootComponents.d.ts +0 -5
  58. package/lib/types/internal/clientAppSetups.d.ts +0 -5
  59. package/lib/types/internal/layoutComponents.d.ts +0 -5
  60. package/lib/types/internal/pagesComponent.d.ts +0 -5
  61. package/lib/types/internal/pagesData.d.ts +0 -5
  62. package/lib/types/internal/pagesRoutes.d.ts +0 -5
  63. package/lib/types/internal/siteData.d.ts +0 -5
  64. package/lib/utils/defineClientAppEnhance.d.ts +0 -2
  65. package/lib/utils/defineClientAppEnhance.js +0 -1
  66. package/lib/utils/defineClientAppSetup.d.ts +0 -2
  67. package/lib/utils/defineClientAppSetup.js +0 -1
  68. package/lib/utils/index.d.ts +0 -3
  69. package/lib/utils/index.js +0 -3
  70. package/lib/utils/withBase.d.ts +0 -4
  71. package/lib/utils/withBase.js +0 -11
  72. package/templates/index.ssr.html +0 -12
@@ -1,33 +0,0 @@
1
- import { inject } from 'vue';
2
- import { dedupeHead, isArray, isString } from '@vuepress/shared';
3
- export const pageHeadSymbol = Symbol(__DEV__ ? 'pageHead' : '');
4
- export const usePageHead = () => {
5
- const pageHead = inject(pageHeadSymbol);
6
- if (!pageHead) {
7
- throw new Error('usePageHead() is called without provider.');
8
- }
9
- return pageHead;
10
- };
11
- /**
12
- * Merge the head config in frontmatter and site locale
13
- *
14
- * Frontmatter should take priority over site locale
15
- */
16
- export const resolvePageHead = (headTitle, frontmatter, siteLocale) => {
17
- const description = isString(frontmatter.description)
18
- ? frontmatter.description
19
- : siteLocale.description;
20
- const head = [
21
- ...(isArray(frontmatter.head) ? frontmatter.head : []),
22
- ...siteLocale.head,
23
- ['title', {}, headTitle],
24
- ['meta', { name: 'description', content: description }],
25
- ['meta', { charset: 'utf-8' }],
26
- [
27
- 'meta',
28
- { name: 'viewport', content: 'width=device-width,initial-scale=1' },
29
- ],
30
- ['meta', { name: 'generator', content: `VuePress ${__VERSION__}` }],
31
- ];
32
- return dedupeHead(head);
33
- };
@@ -1,11 +0,0 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { PageData } from './pageData';
3
- import type { SiteLocaleData } from './siteLocaleData';
4
- export declare type PageHeadTitle = string;
5
- export declare type PageHeadTitleRef = ComputedRef<PageHeadTitle>;
6
- export declare const pageHeadTitleSymbol: InjectionKey<PageHeadTitleRef>;
7
- export declare const usePageHeadTitle: () => PageHeadTitleRef;
8
- /**
9
- * Title to displayed in `<head>` tag
10
- */
11
- export declare const resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle;
@@ -1,13 +0,0 @@
1
- import { inject } from 'vue';
2
- export const pageHeadTitleSymbol = Symbol(__DEV__ ? 'pageHeadTitle' : '');
3
- export const usePageHeadTitle = () => {
4
- const pageHeadTitle = inject(pageHeadTitleSymbol);
5
- if (!pageHeadTitle) {
6
- throw new Error('usePageHeadTitle() is called without provider.');
7
- }
8
- return pageHeadTitle;
9
- };
10
- /**
11
- * Title to displayed in `<head>` tag
12
- */
13
- export const resolvePageHeadTitle = (page, siteLocale) => `${page.title ? `${page.title} | ` : ``}${siteLocale.title}`;
@@ -1,13 +0,0 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { PageData } from '@vuepress/shared';
3
- export declare type PageLang = string;
4
- export declare type PageLangRef = ComputedRef<PageLang>;
5
- export declare const pageLangSymbol: InjectionKey<PageLangRef>;
6
- export declare const usePageLang: () => PageLangRef;
7
- /**
8
- * Resolve language of current page
9
- *
10
- * It's mainly used for the `lang` attribute of `<html>` tag,
11
- * which should not be empty
12
- */
13
- export declare const resolvePageLang: (pageData: PageData) => PageLang;
@@ -1,16 +0,0 @@
1
- import { inject } from 'vue';
2
- export const pageLangSymbol = Symbol(__DEV__ ? 'pageLang' : '');
3
- export const usePageLang = () => {
4
- const pageLang = inject(pageLangSymbol);
5
- if (!pageLang) {
6
- throw new Error('usePageLang() is called without provider.');
7
- }
8
- return pageLang;
9
- };
10
- /**
11
- * Resolve language of current page
12
- *
13
- * It's mainly used for the `lang` attribute of `<html>` tag,
14
- * which should not be empty
15
- */
16
- export const resolvePageLang = (pageData) => pageData.lang || 'en';
@@ -1,6 +0,0 @@
1
- import type { Ref } from 'vue';
2
- import type { PageData } from '@vuepress/shared';
3
- export declare type PagesData = Record<string, () => Promise<PageData>>;
4
- export declare type PagesDataRef = Ref<PagesData>;
5
- export declare const pagesData: PagesDataRef;
6
- export declare const usePagesData: () => PagesDataRef;
@@ -1,6 +0,0 @@
1
- import { ref } from 'vue';
2
- import { pagesData as pagesDataRaw } from '@internal/pagesData';
3
- export const pagesData = ref(pagesDataRaw);
4
- export const usePagesData = () => {
5
- return pagesData;
6
- };
@@ -1,10 +0,0 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { SiteData } from '@vuepress/shared';
3
- export declare type RouteLocale = string;
4
- export declare type RouteLocaleRef = ComputedRef<RouteLocale>;
5
- export declare const routeLocaleSymbol: InjectionKey<RouteLocaleRef>;
6
- export declare const useRouteLocale: () => RouteLocaleRef;
7
- /**
8
- * Resolve locale path of the route path
9
- */
10
- export declare const resolveRouteLocale: (locales: SiteData['locales'], routePath: string) => RouteLocale;
@@ -1,14 +0,0 @@
1
- import { inject } from 'vue';
2
- import { resolveLocalePath } from '@vuepress/shared';
3
- export const routeLocaleSymbol = Symbol(__DEV__ ? 'routeLocale' : '');
4
- export const useRouteLocale = () => {
5
- const routeLocale = inject(routeLocaleSymbol);
6
- if (!routeLocale) {
7
- throw new Error('useRouteLocale() is called without provider.');
8
- }
9
- return routeLocale;
10
- };
11
- /**
12
- * Resolve locale path of the route path
13
- */
14
- export const resolveRouteLocale = (locales, routePath) => resolveLocalePath(locales, routePath);
@@ -1,6 +0,0 @@
1
- import type { Ref } from 'vue';
2
- import type { SiteData } from '@vuepress/shared';
3
- export type { SiteData };
4
- export declare type SiteDataRef = Ref<SiteData>;
5
- export declare const siteData: SiteDataRef;
6
- export declare const useSiteData: () => SiteDataRef;
@@ -1,10 +0,0 @@
1
- import { ref } from 'vue';
2
- import { siteData as siteDataRaw } from '@internal/siteData';
3
- export const siteData = ref(siteDataRaw);
4
- export const useSiteData = () => siteData;
5
- if (import.meta.webpackHot || import.meta.hot) {
6
- // reuse vue HMR runtime
7
- __VUE_HMR_RUNTIME__.updateSiteData = (data) => {
8
- siteData.value = data;
9
- };
10
- }
@@ -1,12 +0,0 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { SiteData } from '@vuepress/shared';
3
- import type { RouteLocale } from './routeLocale';
4
- export declare type SiteLocaleData = SiteData;
5
- export declare type SiteLocaleDataRef = ComputedRef<SiteLocaleData>;
6
- export declare const siteLocaleDataSymbol: InjectionKey<SiteLocaleDataRef>;
7
- export declare const useSiteLocaleData: () => SiteLocaleDataRef;
8
- /**
9
- * Merge the locales fields to the root fields
10
- * according to the route path
11
- */
12
- export declare const resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
@@ -1,17 +0,0 @@
1
- import { inject } from 'vue';
2
- export const siteLocaleDataSymbol = Symbol(__DEV__ ? 'siteLocaleData' : '');
3
- export const useSiteLocaleData = () => {
4
- const siteLocaleData = inject(siteLocaleDataSymbol);
5
- if (!siteLocaleData) {
6
- throw new Error('useSiteLocaleData() is called without provider.');
7
- }
8
- return siteLocaleData;
9
- };
10
- /**
11
- * Merge the locales fields to the root fields
12
- * according to the route path
13
- */
14
- export const resolveSiteLocaleData = (site, routeLocale) => ({
15
- ...site,
16
- ...site.locales[routeLocale],
17
- });
@@ -1,15 +0,0 @@
1
- import type { HeadConfig } from '@vuepress/shared';
2
- /**
3
- * Query the matched head tag of head config
4
- */
5
- export declare const queryHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;
6
- /**
7
- * Create head tag from head config
8
- */
9
- export declare const createHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;
10
- /**
11
- * Auto update head
12
- *
13
- * This composable function should be used only once in the root app
14
- */
15
- export declare const useUpdateHead: () => void;
@@ -1,100 +0,0 @@
1
- import { onMounted, ref, useSSRContext, watch } from 'vue';
2
- import { useRoute } from 'vue-router';
3
- import { isPlainObject, isString } from '@vuepress/shared';
4
- import { usePageHead } from './pageHead';
5
- import { usePageLang } from './pageLang';
6
- /**
7
- * Query the matched head tag of head config
8
- */
9
- export const queryHeadTag = ([tagName, attrs, content = '',]) => {
10
- const attrsSelector = Object.entries(attrs).map(([key, value]) => {
11
- if (isString(value)) {
12
- return `[${key}="${value}"]`;
13
- }
14
- if (value === true) {
15
- return `[${key}]`;
16
- }
17
- return '';
18
- });
19
- const selector = `head > ${tagName}${attrsSelector}`;
20
- const tags = Array.from(document.querySelectorAll(selector));
21
- const matchedTag = tags.find((item) => item.innerText === content);
22
- return matchedTag || null;
23
- };
24
- /**
25
- * Create head tag from head config
26
- */
27
- export const createHeadTag = ([tagName, attrs, content,]) => {
28
- if (!isString(tagName)) {
29
- return null;
30
- }
31
- // create element
32
- const tag = document.createElement(tagName);
33
- // set attributes
34
- if (isPlainObject(attrs)) {
35
- Object.entries(attrs).forEach(([key, value]) => {
36
- if (isString(value)) {
37
- tag.setAttribute(key, value);
38
- }
39
- else if (value === true) {
40
- tag.setAttribute(key, '');
41
- }
42
- });
43
- }
44
- // set content
45
- if (isString(content)) {
46
- tag.appendChild(document.createTextNode(content));
47
- }
48
- return tag;
49
- };
50
- /**
51
- * Auto update head
52
- *
53
- * This composable function should be used only once in the root app
54
- */
55
- export const useUpdateHead = () => {
56
- const route = useRoute();
57
- const head = usePageHead();
58
- const lang = usePageLang();
59
- // ssr-only, extract page meta info to ssrContext
60
- if (__SSR__) {
61
- const ssrContext = useSSRContext();
62
- if (ssrContext) {
63
- ssrContext.head = head.value;
64
- ssrContext.lang = lang.value;
65
- }
66
- return;
67
- }
68
- const headTags = ref([]);
69
- // load current head tags from DOM
70
- const loadHead = () => {
71
- head.value.forEach((item) => {
72
- const tag = queryHeadTag(item);
73
- if (tag) {
74
- headTags.value.push(tag);
75
- }
76
- });
77
- };
78
- // update html lang attribute and head tags to DOM
79
- const updateHead = () => {
80
- document.documentElement.lang = lang.value;
81
- headTags.value.forEach((item) => {
82
- if (item.parentNode === document.head) {
83
- document.head.removeChild(item);
84
- }
85
- });
86
- headTags.value.splice(0, headTags.value.length);
87
- head.value.forEach((item) => {
88
- const tag = createHeadTag(item);
89
- if (tag !== null) {
90
- document.head.appendChild(tag);
91
- headTags.value.push(tag);
92
- }
93
- });
94
- };
95
- onMounted(() => {
96
- loadHead();
97
- updateHead();
98
- watch(() => route.path, () => updateHead());
99
- });
100
- };
package/lib/server.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { CreateVueAppResult } from './app';
2
- export interface ServerEntry {
3
- createServerApp: () => Promise<CreateVueAppResult>;
4
- }
5
- /**
6
- * Server entry point, used for SSR
7
- */
8
- export declare const createServerApp: () => Promise<CreateVueAppResult>;
package/lib/server.js DELETED
@@ -1,10 +0,0 @@
1
- import { createSSRApp } from 'vue';
2
- import { createMemoryHistory } from 'vue-router';
3
- import { createVueApp } from './app';
4
- /**
5
- * Server entry point, used for SSR
6
- */
7
- export const createServerApp = async () => createVueApp({
8
- appCreator: createSSRApp,
9
- historyCreator: createMemoryHistory,
10
- });
@@ -1,8 +0,0 @@
1
- import type { App } from 'vue';
2
- import type { Router } from 'vue-router';
3
- import type { SiteDataRef } from '../injections';
4
- export declare type ClientAppEnhance = (context: {
5
- app: App;
6
- router: Router;
7
- siteData: SiteDataRef;
8
- }) => void | Promise<void>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare type ClientAppSetup = () => void;
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export * from './clientAppEnhance';
2
- export * from './clientAppSetup';
3
- declare module 'vue-router' {
4
- interface RouteMeta {
5
- title?: string;
6
- }
7
- }
@@ -1,2 +0,0 @@
1
- export * from './clientAppEnhance';
2
- export * from './clientAppSetup';
@@ -1,5 +0,0 @@
1
- import type { ClientAppEnhance } from '../clientAppEnhance'
2
-
3
- declare module '@internal/clientAppEnhances' {
4
- export const clientAppEnhances: ClientAppEnhance[]
5
- }
@@ -1,5 +0,0 @@
1
- import type { ComponentOptions } from 'vue'
2
-
3
- declare module '@internal/clientAppRootComponents' {
4
- export const clientAppRootComponents: ComponentOptions[]
5
- }
@@ -1,5 +0,0 @@
1
- import type { ClientAppSetup } from '../clientAppSetup'
2
-
3
- declare module '@internal/clientAppSetups' {
4
- export const clientAppSetups: ClientAppSetup[]
5
- }
@@ -1,5 +0,0 @@
1
- import type { AsyncComponentLoader } from 'vue'
2
-
3
- declare module '@internal/layoutComponents' {
4
- export const layoutComponents: Record<string, AsyncComponentLoader>
5
- }
@@ -1,5 +0,0 @@
1
- import type { ComponentOptions } from 'vue'
2
-
3
- declare module '@internal/pagesComponent' {
4
- export const pagesComponent: Record<string, ComponentOptions>
5
- }
@@ -1,5 +0,0 @@
1
- import type { PageData } from '@vuepress/shared'
2
-
3
- declare module '@internal/pagesData' {
4
- export const pagesData: Record<string, () => Promise<PageData>>
5
- }
@@ -1,5 +0,0 @@
1
- import type { RouteRecordRaw } from 'vue-router'
2
-
3
- declare module '@internal/pagesRoutes' {
4
- export const pagesRoutes: RouteRecordRaw[]
5
- }
@@ -1,5 +0,0 @@
1
- import type { SiteData } from '@vuepress/shared'
2
-
3
- declare module '@internal/siteData' {
4
- export const siteData: SiteData
5
- }
@@ -1,2 +0,0 @@
1
- import type { ClientAppEnhance } from '../types';
2
- export declare const defineClientAppEnhance: (clientAppEnhance: ClientAppEnhance) => ClientAppEnhance;
@@ -1 +0,0 @@
1
- export const defineClientAppEnhance = (clientAppEnhance) => clientAppEnhance;
@@ -1,2 +0,0 @@
1
- import type { ClientAppSetup } from '../types';
2
- export declare const defineClientAppSetup: (clientAppSetup: ClientAppSetup) => ClientAppSetup;
@@ -1 +0,0 @@
1
- export const defineClientAppSetup = (clientAppSetup) => clientAppSetup;
@@ -1,3 +0,0 @@
1
- export * from './defineClientAppEnhance';
2
- export * from './defineClientAppSetup';
3
- export * from './withBase';
@@ -1,3 +0,0 @@
1
- export * from './defineClientAppEnhance';
2
- export * from './defineClientAppSetup';
3
- export * from './withBase';
@@ -1,4 +0,0 @@
1
- /**
2
- * Prefix url with site base
3
- */
4
- export declare const withBase: (url: string) => string;
@@ -1,11 +0,0 @@
1
- import { isLinkHttp } from '@vuepress/shared';
2
- import { useSiteData } from '../injections';
3
- /**
4
- * Prefix url with site base
5
- */
6
- export const withBase = (url) => {
7
- if (isLinkHttp(url))
8
- return url;
9
- const base = useSiteData().value.base;
10
- return `${base}${url}`.replace(/\/+/, '/');
11
- };
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="{{ lang }}">
3
- <head>
4
- <!--vuepress-ssr-head-->
5
- <!--vuepress-ssr-resources-->
6
- <!--vuepress-ssr-styles-->
7
- </head>
8
- <body>
9
- <div id="app"><!--vuepress-ssr-app--></div>
10
- <!--vuepress-ssr-scripts-->
11
- </body>
12
- </html>