Skip to content

Commit 611a292

Browse files
committed
refactor: fix types issue
1 parent 4637470 commit 611a292

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

packages/client/src/resolvers.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const resolvers = reactive({
4343
resolvePageHead: (
4444
pageHeadTitle: PageHeadTitle,
4545
pageFrontmatter: PageFrontmatter,
46-
siteLocaleDate: SiteData,
46+
siteLocaleDate: SiteLocaleData,
4747
): PageHead => {
4848
const description = isString(pageFrontmatter.description)
4949
? pageFrontmatter.description
@@ -64,7 +64,7 @@ export const resolvers = reactive({
6464
*/
6565
resolvePageHeadTitle: (
6666
pageData: PageData,
67-
siteLocaleDate: SiteData,
67+
siteLocaleDate: SiteLocaleData,
6868
): PageHeadTitle =>
6969
[pageData.title, siteLocaleDate.title].filter((item) => !!item).join(' | '),
7070

@@ -73,8 +73,10 @@ export const resolvers = reactive({
7373
*
7474
* It would be used as the `lang` attribute of `<html>` tag
7575
*/
76-
resolvePageLang: (pageData: PageData, siteLocaleData: SiteData): PageLang =>
77-
pageData.lang || siteLocaleData.lang || LANG_DEFAULT,
76+
resolvePageLang: (
77+
pageData: PageData,
78+
siteLocaleData: SiteLocaleData,
79+
): PageLang => pageData.lang || siteLocaleData.lang || LANG_DEFAULT,
7880

7981
/**
8082
* Resolve layout component of current page

packages/client/src/setupDevtools.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import { setupDevtoolsPlugin } from '@vue/devtools-api'
22
import { watch } from 'vue'
33
import type { App } from 'vue'
4-
import type { GlobalComputed } from './setupGlobalComputed.js'
4+
import type { ClientData } from './types/index.js'
55

66
const PLUGIN_ID = 'org.vuejs.vuepress'
77
const PLUGIN_LABEL = 'VuePress'
88
const PLUGIN_COMPONENT_STATE_TYPE = PLUGIN_LABEL
99

1010
const INSPECTOR_ID = PLUGIN_ID
1111
const INSPECTOR_LABEL = PLUGIN_LABEL
12-
const INSPECTOR_GLOBAL_COMPUTED_ID = 'global-computed'
13-
const INSPECTOR_GLOBAL_COMPUTED_LABEL = 'Global Computed'
12+
const INSPECTOR_CLIENT_DATA_ID = 'client-data'
13+
const INSPECTOR_CLIENT_DATA_LABEL = 'Client Data'
1414

15-
export const setupDevtools = (
16-
app: App,
17-
globalComputed: GlobalComputed,
18-
): void => {
15+
export const setupDevtools = (app: App, clientData: ClientData): void => {
1916
setupDevtoolsPlugin(
2017
{
2118
// fix recursive reference
@@ -28,14 +25,14 @@ export const setupDevtools = (
2825
componentStateTypes: [PLUGIN_COMPONENT_STATE_TYPE],
2926
},
3027
(api) => {
31-
const globalComputedEntries = Object.entries(globalComputed)
32-
const globalComputedKeys = Object.keys(globalComputed)
33-
const globalComputedValues = Object.values(globalComputed)
28+
const clientDataEntries = Object.entries(clientData)
29+
const clientDataKeys = Object.keys(clientData)
30+
const clientDataValues = Object.values(clientData)
3431

3532
// setup component state
3633
api.on.inspectComponent((payload) => {
3734
payload.instanceData.state.push(
38-
...globalComputedEntries.map(([name, item]) => ({
35+
...clientDataEntries.map(([name, item]) => ({
3936
type: PLUGIN_COMPONENT_STATE_TYPE,
4037
editable: false,
4138
key: name,
@@ -54,9 +51,9 @@ export const setupDevtools = (
5451
if (payload.inspectorId !== INSPECTOR_ID) return
5552
payload.rootNodes = [
5653
{
57-
id: INSPECTOR_GLOBAL_COMPUTED_ID,
58-
label: INSPECTOR_GLOBAL_COMPUTED_LABEL,
59-
children: globalComputedKeys.map((name) => ({
54+
id: INSPECTOR_CLIENT_DATA_ID,
55+
label: INSPECTOR_CLIENT_DATA_LABEL,
56+
children: clientDataKeys.map((name) => ({
6057
id: name,
6158
label: name,
6259
})),
@@ -65,30 +62,30 @@ export const setupDevtools = (
6562
})
6663
api.on.getInspectorState((payload) => {
6764
if (payload.inspectorId !== INSPECTOR_ID) return
68-
if (payload.nodeId === INSPECTOR_GLOBAL_COMPUTED_ID) {
65+
if (payload.nodeId === INSPECTOR_CLIENT_DATA_ID) {
6966
payload.state = {
70-
[INSPECTOR_GLOBAL_COMPUTED_LABEL]: globalComputedEntries.map(
67+
[INSPECTOR_CLIENT_DATA_LABEL]: clientDataEntries.map(
7168
([name, item]) => ({
7269
key: name,
7370
value: item.value,
7471
}),
7572
),
7673
}
7774
}
78-
if (globalComputedKeys.includes(payload.nodeId)) {
75+
if (clientDataKeys.includes(payload.nodeId)) {
7976
payload.state = {
80-
[INSPECTOR_GLOBAL_COMPUTED_LABEL]: [
77+
[INSPECTOR_CLIENT_DATA_LABEL]: [
8178
{
8279
key: payload.nodeId,
83-
value: globalComputed[payload.nodeId].value,
80+
value: clientData[payload.nodeId].value,
8481
},
8582
],
8683
}
8784
}
8885
})
8986

9087
// refresh the component state and inspector state
91-
watch(globalComputedValues, () => {
88+
watch(clientDataValues, () => {
9289
api.notifyComponentUpdate()
9390
api.sendInspectorState(INSPECTOR_ID)
9491
})

packages/core/tests/pluginApi/createHookQueue.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ describe('core > pluginApi > createHookQueue', () => {
299299
pluginName: 'test2',
300300
hook: func2,
301301
})
302-
const result = await hook.process(app)
302+
const result = await hook.process(app, true)
303303

304304
expect(func1).toHaveBeenCalledTimes(1)
305-
expect(func1).toHaveBeenCalledWith(app)
305+
expect(func1).toHaveBeenCalledWith(app, true)
306306
expect(func2).toHaveBeenCalledTimes(1)
307-
expect(func2).toHaveBeenCalledWith(app)
307+
expect(func2).toHaveBeenCalledWith(app, true)
308308
expect(result).toEqual([{ foo: 'foo' }, { bar: 'bar' }])
309309
}),
310310
)

packages/markdown/src/plugins/importCodePlugin/createImportCodeBlockRule.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { path } from '@vuepress/utils'
2-
import type ParserBlock from 'markdown-it/lib/parser_block.mjs'
2+
import type { RuleBlock } from 'markdown-it/lib/parser_block.mjs'
33
import type { ImportCodePluginOptions } from './importCodePlugin.js'
44
import type { ImportCodeTokenMeta } from './types.js'
55

@@ -13,9 +13,7 @@ const START_CODES = [64, 91, 99, 111, 100, 101]
1313
const SYNTAX_RE = /^@\[code(?:{(?:(\d+)?-(\d+)?)})?(?: ([^\]]+))?\]\(([^)]*)\)/
1414

1515
export const createImportCodeBlockRule =
16-
({
17-
handleImportPath = (str) => str,
18-
}: ImportCodePluginOptions): ParserBlock.RuleBlock =>
16+
({ handleImportPath = (str) => str }: ImportCodePluginOptions): RuleBlock =>
1917
(state, startLine, endLine, silent): boolean => {
2018
// if it's indented more than 3 spaces, it should be a code block
2119
/* istanbul ignore if */

0 commit comments

Comments
 (0)