@vuepress/client 2.0.0-rc.0 → 2.0.0-rc.10

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.
@@ -6,9 +6,9 @@ var PLUGIN_LABEL = "VuePress";
6
6
  var PLUGIN_COMPONENT_STATE_TYPE = PLUGIN_LABEL;
7
7
  var INSPECTOR_ID = PLUGIN_ID;
8
8
  var INSPECTOR_LABEL = PLUGIN_LABEL;
9
- var INSPECTOR_GLOBAL_COMPUTED_ID = "global-computed";
10
- var INSPECTOR_GLOBAL_COMPUTED_LABEL = "Global Computed";
11
- var setupDevtools = (app, globalComputed) => {
9
+ var INSPECTOR_CLIENT_DATA_ID = "client-data";
10
+ var INSPECTOR_CLIENT_DATA_LABEL = "Client Data";
11
+ var setupDevtools = (app, clientData) => {
12
12
  setupDevtoolsPlugin(
13
13
  {
14
14
  // fix recursive reference
@@ -21,12 +21,12 @@ var setupDevtools = (app, globalComputed) => {
21
21
  componentStateTypes: [PLUGIN_COMPONENT_STATE_TYPE]
22
22
  },
23
23
  (api) => {
24
- const globalComputedEntries = Object.entries(globalComputed);
25
- const globalComputedKeys = Object.keys(globalComputed);
26
- const globalComputedValues = Object.values(globalComputed);
24
+ const clientDataEntries = Object.entries(clientData);
25
+ const clientDataKeys = Object.keys(clientData);
26
+ const clientDataValues = Object.values(clientData);
27
27
  api.on.inspectComponent((payload) => {
28
28
  payload.instanceData.state.push(
29
- ...globalComputedEntries.map(([name, item]) => ({
29
+ ...clientDataEntries.map(([name, item]) => ({
30
30
  type: PLUGIN_COMPONENT_STATE_TYPE,
31
31
  editable: false,
32
32
  key: name,
@@ -44,9 +44,9 @@ var setupDevtools = (app, globalComputed) => {
44
44
  return;
45
45
  payload.rootNodes = [
46
46
  {
47
- id: INSPECTOR_GLOBAL_COMPUTED_ID,
48
- label: INSPECTOR_GLOBAL_COMPUTED_LABEL,
49
- children: globalComputedKeys.map((name) => ({
47
+ id: INSPECTOR_CLIENT_DATA_ID,
48
+ label: INSPECTOR_CLIENT_DATA_LABEL,
49
+ children: clientDataKeys.map((name) => ({
50
50
  id: name,
51
51
  label: name
52
52
  }))
@@ -56,9 +56,9 @@ var setupDevtools = (app, globalComputed) => {
56
56
  api.on.getInspectorState((payload) => {
57
57
  if (payload.inspectorId !== INSPECTOR_ID)
58
58
  return;
59
- if (payload.nodeId === INSPECTOR_GLOBAL_COMPUTED_ID) {
59
+ if (payload.nodeId === INSPECTOR_CLIENT_DATA_ID) {
60
60
  payload.state = {
61
- [INSPECTOR_GLOBAL_COMPUTED_LABEL]: globalComputedEntries.map(
61
+ [INSPECTOR_CLIENT_DATA_LABEL]: clientDataEntries.map(
62
62
  ([name, item]) => ({
63
63
  key: name,
64
64
  value: item.value
@@ -66,18 +66,18 @@ var setupDevtools = (app, globalComputed) => {
66
66
  )
67
67
  };
68
68
  }
69
- if (globalComputedKeys.includes(payload.nodeId)) {
69
+ if (clientDataKeys.includes(payload.nodeId)) {
70
70
  payload.state = {
71
- [INSPECTOR_GLOBAL_COMPUTED_LABEL]: [
71
+ [INSPECTOR_CLIENT_DATA_LABEL]: [
72
72
  {
73
73
  key: payload.nodeId,
74
- value: globalComputed[payload.nodeId].value
74
+ value: clientData[payload.nodeId].value
75
75
  }
76
76
  ]
77
77
  };
78
78
  }
79
79
  });
80
- watch(globalComputedValues, () => {
80
+ watch(clientDataValues, () => {
81
81
  api.notifyComponentUpdate();
82
82
  api.sendInspectorState(INSPECTOR_ID);
83
83
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/client",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0-rc.10",
4
4
  "description": "Client package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -8,11 +8,11 @@
8
8
  ],
9
9
  "homepage": "https://github.com/vuepress",
10
10
  "bugs": {
11
- "url": "https://github.com/vuepress/vuepress-next/issues"
11
+ "url": "https://github.com/vuepress/core/issues"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "git+https://github.com/vuepress/vuepress-next.git"
15
+ "url": "git+https://github.com/vuepress/core.git"
16
16
  },
17
17
  "license": "MIT",
18
18
  "author": "meteorlxy",
@@ -33,28 +33,27 @@
33
33
  "types.d.ts"
34
34
  ],
35
35
  "dependencies": {
36
- "@vue/devtools-api": "^6.5.1",
37
- "@vueuse/core": "^10.6.1",
38
- "vue": "^3.3.8",
39
- "vue-router": "^4.2.5",
40
- "@vuepress/shared": "2.0.0-rc.0"
36
+ "@vue/devtools-api": "^6.6.1",
37
+ "vue": "^3.4.27",
38
+ "vue-router": "^4.3.2",
39
+ "@vuepress/shared": "2.0.0-rc.10"
41
40
  },
42
41
  "publishConfig": {
43
42
  "access": "public"
44
43
  },
45
44
  "tsup": {
46
45
  "clean": true,
47
- "dts": "./src/index.ts",
46
+ "dts": [
47
+ "./src/app.ts",
48
+ "./src/index.ts"
49
+ ],
48
50
  "entry": [
49
51
  "./src/app.ts",
50
52
  "./src/index.ts"
51
53
  ],
52
54
  "external": [
53
55
  "@internal/clientConfigs",
54
- "@internal/layoutComponents",
55
- "@internal/pagesComponents",
56
- "@internal/pagesData",
57
- "@internal/pagesRoutes",
56
+ "@internal/routes",
58
57
  "@internal/siteData"
59
58
  ],
60
59
  "format": [
@@ -1,338 +0,0 @@
1
- // src/composables/layouts.ts
2
- import { inject } from "vue";
3
- var layoutsSymbol = Symbol(
4
- __VUEPRESS_DEV__ ? "layouts" : ""
5
- );
6
- var useLayouts = () => {
7
- const layouts = inject(layoutsSymbol);
8
- if (!layouts) {
9
- throw new Error("useLayouts() is called without provider.");
10
- }
11
- return layouts;
12
- };
13
-
14
- // src/composables/pageData.ts
15
- import { inject as inject2, readonly } from "vue";
16
- var pageDataSymbol = Symbol(
17
- __VUEPRESS_DEV__ ? "pageData" : ""
18
- );
19
- var pageDataEmpty = readonly({
20
- key: "",
21
- path: "",
22
- title: "",
23
- lang: "",
24
- frontmatter: {},
25
- headers: []
26
- });
27
- var usePageData = () => {
28
- const pageData = inject2(pageDataSymbol);
29
- if (!pageData) {
30
- throw new Error("pageData() is called without provider.");
31
- }
32
- return pageData;
33
- };
34
-
35
- // src/composables/pageFrontmatter.ts
36
- import { inject as inject3 } from "vue";
37
- var pageFrontmatterSymbol = Symbol(
38
- __VUEPRESS_DEV__ ? "pageFrontmatter" : ""
39
- );
40
- var usePageFrontmatter = () => {
41
- const pageFrontmatter = inject3(pageFrontmatterSymbol);
42
- if (!pageFrontmatter) {
43
- throw new Error("usePageFrontmatter() is called without provider.");
44
- }
45
- return pageFrontmatter;
46
- };
47
-
48
- // src/composables/pageHead.ts
49
- import { inject as inject4 } from "vue";
50
- var pageHeadSymbol = Symbol(
51
- __VUEPRESS_DEV__ ? "pageHead" : ""
52
- );
53
- var usePageHead = () => {
54
- const pageHead = inject4(pageHeadSymbol);
55
- if (!pageHead) {
56
- throw new Error("usePageHead() is called without provider.");
57
- }
58
- return pageHead;
59
- };
60
-
61
- // src/composables/pageHeadTitle.ts
62
- import { inject as inject5 } from "vue";
63
- var pageHeadTitleSymbol = Symbol(
64
- __VUEPRESS_DEV__ ? "pageHeadTitle" : ""
65
- );
66
- var usePageHeadTitle = () => {
67
- const pageHeadTitle = inject5(pageHeadTitleSymbol);
68
- if (!pageHeadTitle) {
69
- throw new Error("usePageHeadTitle() is called without provider.");
70
- }
71
- return pageHeadTitle;
72
- };
73
-
74
- // src/composables/pageLang.ts
75
- import { inject as inject6 } from "vue";
76
- var pageLangSymbol = Symbol(
77
- __VUEPRESS_DEV__ ? "pageLang" : ""
78
- );
79
- var usePageLang = () => {
80
- const pageLang = inject6(pageLangSymbol);
81
- if (!pageLang) {
82
- throw new Error("usePageLang() is called without provider.");
83
- }
84
- return pageLang;
85
- };
86
-
87
- // src/composables/pageLayout.ts
88
- import { inject as inject7 } from "vue";
89
- var pageLayoutSymbol = Symbol(
90
- __VUEPRESS_DEV__ ? "pageLayout" : ""
91
- );
92
- var usePageLayout = () => {
93
- const pageLayout = inject7(pageLayoutSymbol);
94
- if (!pageLayout) {
95
- throw new Error("usePageLayout() is called without provider.");
96
- }
97
- return pageLayout;
98
- };
99
-
100
- // src/composables/pagesData.ts
101
- import { pagesData as pagesDataRaw } from "@internal/pagesData";
102
- import { ref } from "vue";
103
- var pagesData = ref(pagesDataRaw);
104
- var usePagesData = () => pagesData;
105
-
106
- // src/composables/routeLocale.ts
107
- import { inject as inject8 } from "vue";
108
- var routeLocaleSymbol = Symbol(
109
- __VUEPRESS_DEV__ ? "routeLocale" : ""
110
- );
111
- var useRouteLocale = () => {
112
- const routeLocale = inject8(routeLocaleSymbol);
113
- if (!routeLocale) {
114
- throw new Error("useRouteLocale() is called without provider.");
115
- }
116
- return routeLocale;
117
- };
118
-
119
- // src/composables/siteData.ts
120
- import { siteData as siteDataRaw } from "@internal/siteData";
121
- import { ref as ref2 } from "vue";
122
- var siteData = ref2(siteDataRaw);
123
- var useSiteData = () => siteData;
124
- if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
125
- __VUE_HMR_RUNTIME__.updateSiteData = (data) => {
126
- siteData.value = data;
127
- };
128
- }
129
-
130
- // src/composables/siteLocaleData.ts
131
- import { inject as inject9 } from "vue";
132
- var siteLocaleDataSymbol = Symbol(
133
- __VUEPRESS_DEV__ ? "siteLocaleData" : ""
134
- );
135
- var useSiteLocaleData = () => {
136
- const siteLocaleData = inject9(siteLocaleDataSymbol);
137
- if (!siteLocaleData) {
138
- throw new Error("useSiteLocaleData() is called without provider.");
139
- }
140
- return siteLocaleData;
141
- };
142
-
143
- // src/composables/updateHead.ts
144
- import { inject as inject10 } from "vue";
145
- var updateHeadSymbol = Symbol(
146
- __VUEPRESS_DEV__ ? "updateHead" : ""
147
- );
148
- var useUpdateHead = () => {
149
- const updateHead = inject10(updateHeadSymbol);
150
- if (!updateHead) {
151
- throw new Error("useUpdateHead() is called without provider.");
152
- }
153
- return updateHead;
154
- };
155
-
156
- // src/resolvers.ts
157
- import {
158
- dedupeHead,
159
- isArray,
160
- isString,
161
- resolveLocalePath
162
- } from "@vuepress/shared";
163
- import { reactive } from "vue";
164
-
165
- // src/constants.ts
166
- var LAYOUT_NAME_DEFAULT = "Layout";
167
- var LAYOUT_NAME_NOT_FOUND = "NotFound";
168
-
169
- // src/resolvers.ts
170
- var resolvers = reactive({
171
- /**
172
- * Resolve layouts component map
173
- */
174
- resolveLayouts: (clientConfigs) => clientConfigs.reduce(
175
- (prev, item) => ({
176
- ...prev,
177
- ...item.layouts
178
- }),
179
- {}
180
- ),
181
- /**
182
- * Resolve page data according to page key
183
- */
184
- resolvePageData: async (pageKey) => {
185
- const pageDataResolver = pagesData.value[pageKey];
186
- const pageData = await pageDataResolver?.();
187
- return pageData ?? pageDataEmpty;
188
- },
189
- /**
190
- * Resolve page frontmatter from page data
191
- */
192
- resolvePageFrontmatter: (pageData) => pageData.frontmatter,
193
- /**
194
- * Merge the head config in frontmatter and site locale
195
- *
196
- * Frontmatter should take priority over site locale
197
- */
198
- resolvePageHead: (headTitle, frontmatter, siteLocale) => {
199
- const description = isString(frontmatter.description) ? frontmatter.description : siteLocale.description;
200
- const head = [
201
- ...isArray(frontmatter.head) ? frontmatter.head : [],
202
- ...siteLocale.head,
203
- ["title", {}, headTitle],
204
- ["meta", { name: "description", content: description }]
205
- ];
206
- return dedupeHead(head);
207
- },
208
- /**
209
- * Resolve the content of page head title
210
- *
211
- * It would be used as the content of the `<title>` tag
212
- */
213
- resolvePageHeadTitle: (page, siteLocale) => [page.title, siteLocale.title].filter((item) => !!item).join(" | "),
214
- /**
215
- * Resolve page language from page data
216
- *
217
- * It would be used as the `lang` attribute of `<html>` tag
218
- */
219
- resolvePageLang: (page, siteLocale) => page.lang || siteLocale.lang || "en-US",
220
- /**
221
- * Resolve layout component of current page
222
- */
223
- resolvePageLayout: (page, layouts) => {
224
- let layoutName;
225
- if (page.path) {
226
- const frontmatterLayout = page.frontmatter.layout;
227
- if (isString(frontmatterLayout)) {
228
- layoutName = frontmatterLayout;
229
- } else {
230
- layoutName = LAYOUT_NAME_DEFAULT;
231
- }
232
- } else {
233
- layoutName = LAYOUT_NAME_NOT_FOUND;
234
- }
235
- return layouts[layoutName];
236
- },
237
- /**
238
- * Resolve locale path according to route path and locales config
239
- */
240
- resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
241
- /**
242
- * Resolve site data for specific locale
243
- *
244
- * It would merge the locales fields to the root fields
245
- */
246
- resolveSiteLocaleData: (site, routeLocale) => ({
247
- ...site,
248
- ...site.locales[routeLocale]
249
- })
250
- });
251
-
252
- // src/components/ClientOnly.ts
253
- import { defineComponent, onMounted, ref as ref3 } from "vue";
254
- var ClientOnly = defineComponent({
255
- name: "ClientOnly",
256
- setup(_, ctx) {
257
- const isMounted = ref3(false);
258
- onMounted(() => {
259
- isMounted.value = true;
260
- });
261
- return () => isMounted.value ? ctx.slots.default?.() : null;
262
- }
263
- });
264
-
265
- // src/components/Content.ts
266
- import { pagesComponents } from "@internal/pagesComponents";
267
- import { computed, defineComponent as defineComponent2, h } from "vue";
268
- var Content = defineComponent2({
269
- // eslint-disable-next-line vue/no-reserved-component-names
270
- name: "Content",
271
- props: {
272
- pageKey: {
273
- type: String,
274
- required: false,
275
- default: ""
276
- }
277
- },
278
- setup(props) {
279
- const page = usePageData();
280
- const pageComponent = computed(
281
- () => pagesComponents[props.pageKey || page.value.key]
282
- );
283
- return () => pageComponent.value ? (
284
- // use page component
285
- h(pageComponent.value)
286
- ) : (
287
- // fallback content
288
- h(
289
- "div",
290
- __VUEPRESS_DEV__ ? "Page does not exist. This is a fallback content." : "404 Not Found"
291
- )
292
- );
293
- }
294
- });
295
-
296
- // src/helpers/defineClientConfig.ts
297
- var defineClientConfig = (clientConfig = {}) => clientConfig;
298
-
299
- // src/helpers/withBase.ts
300
- import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
301
- var withBase = (url) => {
302
- if (isLinkHttp(url))
303
- return url;
304
- return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
305
- };
306
-
307
- export {
308
- layoutsSymbol,
309
- useLayouts,
310
- pageDataSymbol,
311
- pageDataEmpty,
312
- usePageData,
313
- pageFrontmatterSymbol,
314
- usePageFrontmatter,
315
- pageHeadSymbol,
316
- usePageHead,
317
- pageHeadTitleSymbol,
318
- usePageHeadTitle,
319
- pageLangSymbol,
320
- usePageLang,
321
- pageLayoutSymbol,
322
- usePageLayout,
323
- pagesData,
324
- usePagesData,
325
- routeLocaleSymbol,
326
- useRouteLocale,
327
- siteData,
328
- useSiteData,
329
- siteLocaleDataSymbol,
330
- useSiteLocaleData,
331
- updateHeadSymbol,
332
- useUpdateHead,
333
- resolvers,
334
- ClientOnly,
335
- Content,
336
- defineClientConfig,
337
- withBase
338
- };