Skip to content

Commit

Permalink
Merge branch 'main' into markdown-links
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed May 15, 2024
2 parents eabcadb + 9003521 commit 8607e2d
Show file tree
Hide file tree
Showing 9 changed files with 299 additions and 216 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- name: Build
run: pnpm build

- name: Check Types
run: pnpm check-types

- name: Lint
run: pnpm lint

Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"type": "module",
"scripts": {
"build": "pnpm -r --workspace-concurrency=1 --stream build",
"check-types": "vue-tsc --noEmit",
"clean": "pnpm --parallel --stream clean",
"format": "prettier --write .",
"lint": "eslint --ext .cjs,.js,.ts,.vue . && prettier --check .",
"lint:fix": "eslint --fix --ext .cjs,.js,.ts,.vue . && prettier --write .",
"prepare": "husky",
"release": "pnpm release:check && pnpm release:version && pnpm release:publish",
"release:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"release:check": "pnpm lint && pnpm clean && pnpm build && pnpm test",
"release:check": "pnpm lint && pnpm clean && pnpm build && pnpm check-types && pnpm test",
"release:publish": "pnpm -r publish --tag next",
"release:version": "bumpp -r --execute=\"pnpm release:changelog\" --commit \"build: publish v%s\" --all",
"test": "pnpm test:unit && pnpm test:e2e",
Expand All @@ -33,7 +34,7 @@
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@commitlint/types": "^19.0.3",
"@types/node": "^20.12.11",
"@types/node": "^20.12.12",
"@types/webpack-env": "^1.18.5",
"@vitest/coverage-istanbul": "^1.6.0",
"bumpp": "^9.4.1",
Expand All @@ -51,7 +52,8 @@
"tsup": "^8.0.2",
"typescript": "^5.4.5",
"vite": "~5.2.11",
"vitest": "^1.6.0"
"vitest": "^1.6.0",
"vue-tsc": "^2.0.17"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
10 changes: 6 additions & 4 deletions packages/client/src/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const resolvers = reactive({
resolvePageHead: (
pageHeadTitle: PageHeadTitle,
pageFrontmatter: PageFrontmatter,
siteLocaleDate: SiteData,
siteLocaleDate: SiteLocaleData,
): PageHead => {
const description = isString(pageFrontmatter.description)
? pageFrontmatter.description
Expand All @@ -64,7 +64,7 @@ export const resolvers = reactive({
*/
resolvePageHeadTitle: (
pageData: PageData,
siteLocaleDate: SiteData,
siteLocaleDate: SiteLocaleData,
): PageHeadTitle =>
[pageData.title, siteLocaleDate.title].filter((item) => !!item).join(' | '),

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

/**
* Resolve layout component of current page
Expand Down
37 changes: 17 additions & 20 deletions packages/client/src/setupDevtools.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { setupDevtoolsPlugin } from '@vue/devtools-api'
import { watch } from 'vue'
import type { App } from 'vue'
import type { GlobalComputed } from './setupGlobalComputed.js'
import type { ClientData } from './types/index.js'

const PLUGIN_ID = 'org.vuejs.vuepress'
const PLUGIN_LABEL = 'VuePress'
const PLUGIN_COMPONENT_STATE_TYPE = PLUGIN_LABEL

const INSPECTOR_ID = PLUGIN_ID
const INSPECTOR_LABEL = PLUGIN_LABEL
const INSPECTOR_GLOBAL_COMPUTED_ID = 'global-computed'
const INSPECTOR_GLOBAL_COMPUTED_LABEL = 'Global Computed'
const INSPECTOR_CLIENT_DATA_ID = 'client-data'
const INSPECTOR_CLIENT_DATA_LABEL = 'Client Data'

export const setupDevtools = (
app: App,
globalComputed: GlobalComputed,
): void => {
export const setupDevtools = (app: App, clientData: ClientData): void => {
setupDevtoolsPlugin(
{
// fix recursive reference
Expand All @@ -28,14 +25,14 @@ export const setupDevtools = (
componentStateTypes: [PLUGIN_COMPONENT_STATE_TYPE],
},
(api) => {
const globalComputedEntries = Object.entries(globalComputed)
const globalComputedKeys = Object.keys(globalComputed)
const globalComputedValues = Object.values(globalComputed)
const clientDataEntries = Object.entries(clientData)
const clientDataKeys = Object.keys(clientData)
const clientDataValues = Object.values(clientData)

// setup component state
api.on.inspectComponent((payload) => {
payload.instanceData.state.push(
...globalComputedEntries.map(([name, item]) => ({
...clientDataEntries.map(([name, item]) => ({
type: PLUGIN_COMPONENT_STATE_TYPE,
editable: false,
key: name,
Expand All @@ -54,9 +51,9 @@ export const setupDevtools = (
if (payload.inspectorId !== INSPECTOR_ID) return
payload.rootNodes = [
{
id: INSPECTOR_GLOBAL_COMPUTED_ID,
label: INSPECTOR_GLOBAL_COMPUTED_LABEL,
children: globalComputedKeys.map((name) => ({
id: INSPECTOR_CLIENT_DATA_ID,
label: INSPECTOR_CLIENT_DATA_LABEL,
children: clientDataKeys.map((name) => ({
id: name,
label: name,
})),
Expand All @@ -65,30 +62,30 @@ export const setupDevtools = (
})
api.on.getInspectorState((payload) => {
if (payload.inspectorId !== INSPECTOR_ID) return
if (payload.nodeId === INSPECTOR_GLOBAL_COMPUTED_ID) {
if (payload.nodeId === INSPECTOR_CLIENT_DATA_ID) {
payload.state = {
[INSPECTOR_GLOBAL_COMPUTED_LABEL]: globalComputedEntries.map(
[INSPECTOR_CLIENT_DATA_LABEL]: clientDataEntries.map(
([name, item]) => ({
key: name,
value: item.value,
}),
),
}
}
if (globalComputedKeys.includes(payload.nodeId)) {
if (clientDataKeys.includes(payload.nodeId)) {
payload.state = {
[INSPECTOR_GLOBAL_COMPUTED_LABEL]: [
[INSPECTOR_CLIENT_DATA_LABEL]: [
{
key: payload.nodeId,
value: globalComputed[payload.nodeId].value,
value: clientData[payload.nodeId].value,
},
],
}
}
})

// refresh the component state and inspector state
watch(globalComputedValues, () => {
watch(clientDataValues, () => {
api.notifyComponentUpdate()
api.sendInspectorState(INSPECTOR_ID)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/core/tests/pluginApi/createHookQueue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ describe('core > pluginApi > createHookQueue', () => {
pluginName: 'test2',
hook: func2,
})
const result = await hook.process(app)
const result = await hook.process(app, true)

expect(func1).toHaveBeenCalledTimes(1)
expect(func1).toHaveBeenCalledWith(app)
expect(func1).toHaveBeenCalledWith(app, true)
expect(func2).toHaveBeenCalledTimes(1)
expect(func2).toHaveBeenCalledWith(app)
expect(func2).toHaveBeenCalledWith(app, true)
expect(result).toEqual([{ foo: 'foo' }, { bar: 'bar' }])
}),
)
Expand Down
14 changes: 7 additions & 7 deletions packages/markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
"clean": "rimraf dist"
},
"dependencies": {
"@mdit-vue/plugin-component": "^2.1.2",
"@mdit-vue/plugin-frontmatter": "^2.1.2",
"@mdit-vue/plugin-headers": "^2.1.2",
"@mdit-vue/plugin-sfc": "^2.1.2",
"@mdit-vue/plugin-title": "^2.1.2",
"@mdit-vue/plugin-toc": "^2.1.2",
"@mdit-vue/shared": "^2.1.2",
"@mdit-vue/plugin-component": "^2.1.3",
"@mdit-vue/plugin-frontmatter": "^2.1.3",
"@mdit-vue/plugin-headers": "^2.1.3",
"@mdit-vue/plugin-sfc": "^2.1.3",
"@mdit-vue/plugin-title": "^2.1.3",
"@mdit-vue/plugin-toc": "^2.1.3",
"@mdit-vue/shared": "^2.1.3",
"@mdit-vue/types": "^2.1.0",
"@types/markdown-it": "^14.1.1",
"@types/markdown-it-emoji": "^3.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { path } from '@vuepress/utils'
import type ParserBlock from 'markdown-it/lib/parser_block.mjs'
import type { RuleBlock } from 'markdown-it/lib/parser_block.mjs'
import type { ImportCodePluginOptions } from './importCodePlugin.js'
import type { ImportCodeTokenMeta } from './types.js'

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

export const createImportCodeBlockRule =
({
handleImportPath = (str) => str,
}: ImportCodePluginOptions): ParserBlock.RuleBlock =>
({ handleImportPath = (str) => str }: ImportCodePluginOptions): RuleBlock =>
(state, startLine, endLine, silent): boolean => {
// if it's indented more than 3 spaces, it should be a code block
/* istanbul ignore if */
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"globby": "^14.0.1",
"hash-sum": "^2.0.0",
"ora": "^8.0.1",
"picocolors": "^1.0.0",
"picocolors": "^1.0.1",
"upath": "^2.0.1"
},
"publishConfig": {
Expand Down
Loading

0 comments on commit 8607e2d

Please sign in to comment.