@vuepress/client 2.0.0-beta.37 → 2.0.0-beta.40

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 (77) hide show
  1. package/dist/app.d.ts +7 -0
  2. package/dist/app.js +259 -0
  3. package/dist/chunk-RTLFYRTT.js +250 -0
  4. package/dist/createVueAppFunction-c8e67ca1.d.ts +9 -0
  5. package/dist/index.d.ts +220 -0
  6. package/dist/index.js +70 -0
  7. package/package.json +49 -18
  8. package/templates/{index.build.html → build.html} +0 -0
  9. package/templates/{index.dev.html → dev.html} +0 -0
  10. package/lib/app.d.ts +0 -7
  11. package/lib/app.js +0 -65
  12. package/lib/components/ClientOnly.d.ts +0 -3
  13. package/lib/components/ClientOnly.js +0 -10
  14. package/lib/components/Content.d.ts +0 -7
  15. package/lib/components/Content.js +0 -34
  16. package/lib/components/Vuepress.d.ts +0 -6
  17. package/lib/components/Vuepress.js +0 -38
  18. package/lib/components/index.d.ts +0 -3
  19. package/lib/components/index.js +0 -3
  20. package/lib/composables/index.d.ts +0 -10
  21. package/lib/composables/index.js +0 -10
  22. package/lib/composables/pageData.d.ts +0 -19
  23. package/lib/composables/pageData.js +0 -31
  24. package/lib/composables/pageFrontmatter.d.ts +0 -15
  25. package/lib/composables/pageFrontmatter.js +0 -15
  26. package/lib/composables/pageHead.d.ts +0 -18
  27. package/lib/composables/pageHead.js +0 -15
  28. package/lib/composables/pageHeadTitle.d.ts +0 -17
  29. package/lib/composables/pageHeadTitle.js +0 -15
  30. package/lib/composables/pageLang.d.ts +0 -17
  31. package/lib/composables/pageLang.js +0 -15
  32. package/lib/composables/pagesData.d.ts +0 -21
  33. package/lib/composables/pagesData.js +0 -10
  34. package/lib/composables/routeLocale.d.ts +0 -17
  35. package/lib/composables/routeLocale.js +0 -15
  36. package/lib/composables/siteData.d.ts +0 -15
  37. package/lib/composables/siteData.js +0 -16
  38. package/lib/composables/siteLocaleData.d.ts +0 -18
  39. package/lib/composables/siteLocaleData.js +0 -15
  40. package/lib/composables/updateHead.d.ts +0 -13
  41. package/lib/composables/updateHead.js +0 -15
  42. package/lib/helpers/defineClientAppEnhance.d.ts +0 -2
  43. package/lib/helpers/defineClientAppEnhance.js +0 -1
  44. package/lib/helpers/defineClientAppSetup.d.ts +0 -2
  45. package/lib/helpers/defineClientAppSetup.js +0 -1
  46. package/lib/helpers/index.d.ts +0 -3
  47. package/lib/helpers/index.js +0 -3
  48. package/lib/helpers/withBase.d.ts +0 -4
  49. package/lib/helpers/withBase.js +0 -11
  50. package/lib/index.d.ts +0 -8
  51. package/lib/index.js +0 -7
  52. package/lib/resolvers.d.ts +0 -15
  53. package/lib/resolvers.js +0 -64
  54. package/lib/router.d.ts +0 -5
  55. package/lib/router.js +0 -40
  56. package/lib/setupDevtools.d.ts +0 -3
  57. package/lib/setupDevtools.js +0 -22
  58. package/lib/setupGlobalComponents.d.ts +0 -5
  59. package/lib/setupGlobalComponents.js +0 -10
  60. package/lib/setupGlobalComputed.d.ts +0 -34
  61. package/lib/setupGlobalComputed.js +0 -45
  62. package/lib/setupUpdateHead.d.ts +0 -13
  63. package/lib/setupUpdateHead.js +0 -101
  64. package/lib/types/clientAppEnhance.d.ts +0 -8
  65. package/lib/types/clientAppEnhance.js +0 -1
  66. package/lib/types/clientAppSetup.d.ts +0 -1
  67. package/lib/types/clientAppSetup.js +0 -1
  68. package/lib/types/index.d.ts +0 -2
  69. package/lib/types/index.js +0 -2
  70. package/lib/types/internal/clientAppEnhances.d.ts +0 -5
  71. package/lib/types/internal/clientAppRootComponents.d.ts +0 -5
  72. package/lib/types/internal/clientAppSetups.d.ts +0 -5
  73. package/lib/types/internal/layoutComponents.d.ts +0 -5
  74. package/lib/types/internal/pagesComponents.d.ts +0 -5
  75. package/lib/types/internal/pagesData.d.ts +0 -5
  76. package/lib/types/internal/pagesRoutes.d.ts +0 -5
  77. package/lib/types/internal/siteData.d.ts +0 -5
@@ -1,101 +0,0 @@
1
- import { isPlainObject, isString } from '@vuepress/shared';
2
- import { onMounted, provide, ref, useSSRContext, watch } from 'vue';
3
- import { useRoute } from 'vue-router';
4
- import { updateHeadSymbol, usePageHead, usePageLang } from './composables';
5
- /**
6
- * Auto update head and provide as global util
7
- */
8
- export const setupUpdateHead = () => {
9
- const route = useRoute();
10
- const head = usePageHead();
11
- const lang = usePageLang();
12
- // ssr-only, extract page meta info to ssrContext
13
- if (__VUEPRESS_SSR__) {
14
- const ssrContext = useSSRContext();
15
- if (ssrContext) {
16
- ssrContext.head = head.value;
17
- ssrContext.lang = lang.value;
18
- }
19
- return;
20
- }
21
- const headTags = ref([]);
22
- // load current head tags from DOM
23
- const loadHead = () => {
24
- head.value.forEach((item) => {
25
- const tag = queryHeadTag(item);
26
- if (tag) {
27
- headTags.value.push(tag);
28
- }
29
- });
30
- };
31
- // update html lang attribute and head tags to DOM
32
- const updateHead = () => {
33
- document.documentElement.lang = lang.value;
34
- headTags.value.forEach((item) => {
35
- if (item.parentNode === document.head) {
36
- document.head.removeChild(item);
37
- }
38
- });
39
- headTags.value.splice(0, headTags.value.length);
40
- head.value.forEach((item) => {
41
- const tag = createHeadTag(item);
42
- if (tag !== null) {
43
- document.head.appendChild(tag);
44
- headTags.value.push(tag);
45
- }
46
- });
47
- };
48
- provide(updateHeadSymbol, updateHead);
49
- onMounted(() => {
50
- loadHead();
51
- updateHead();
52
- // only update head on route change
53
- watch(() => route.path, () => updateHead());
54
- });
55
- };
56
- /**
57
- * Query the matched head tag of head config
58
- */
59
- export const queryHeadTag = ([tagName, attrs, content = '',]) => {
60
- const attrsSelector = Object.entries(attrs)
61
- .map(([key, value]) => {
62
- if (isString(value)) {
63
- return `[${key}="${value}"]`;
64
- }
65
- if (value === true) {
66
- return `[${key}]`;
67
- }
68
- return '';
69
- })
70
- .join('');
71
- const selector = `head > ${tagName}${attrsSelector}`;
72
- const tags = Array.from(document.querySelectorAll(selector));
73
- const matchedTag = tags.find((item) => item.innerText === content);
74
- return matchedTag || null;
75
- };
76
- /**
77
- * Create head tag from head config
78
- */
79
- export const createHeadTag = ([tagName, attrs, content,]) => {
80
- if (!isString(tagName)) {
81
- return null;
82
- }
83
- // create element
84
- const tag = document.createElement(tagName);
85
- // set attributes
86
- if (isPlainObject(attrs)) {
87
- Object.entries(attrs).forEach(([key, value]) => {
88
- if (isString(value)) {
89
- tag.setAttribute(key, value);
90
- }
91
- else if (value === true) {
92
- tag.setAttribute(key, '');
93
- }
94
- });
95
- }
96
- // set content
97
- if (isString(content)) {
98
- tag.appendChild(document.createTextNode(content));
99
- }
100
- return tag;
101
- };
@@ -1,8 +0,0 @@
1
- import type { App } from 'vue';
2
- import type { Router } from 'vue-router';
3
- import type { SiteDataRef } from '../composables';
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,2 +0,0 @@
1
- export * from './clientAppEnhance';
2
- export * from './clientAppSetup';
@@ -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/pagesComponents' {
4
- export const pagesComponents: 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
- }