Skip to content

Commit

Permalink
refactor(core): add type comments for internal plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Dec 25, 2021
1 parent 17c8fe4 commit c926aff
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = () => ({
name: '@vuepress/internal-data-block',

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const { path } = require('@vuepress/shared-utils')

module.exports = (options, context) => ({
/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx) => ({
name: '@vuepress/internal-enhance-app',

enhanceAppFiles () {
const { sourceDir, themeAPI } = context
const { sourceDir, themeAPI } = ctx
const enhanceAppPath = path.resolve(sourceDir, '.vuepress/enhanceApp.js')
const files = [enhanceAppPath]
if (themeAPI.existsParentTheme) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = () => ({
name: '@vuepress/internal-frontmatter-block',

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx) => {
return {
name: '@vuepress/internal-layout-components',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx) => {
const { pages } = ctx
// const componentNames = Object.keys(layoutComponentMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const {
datatypes: { isPlainObject }
} = require('@vuepress/shared-utils')

/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx) => ({
name: '@vuepress/internal-palette',

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const { codegen: { pathsToModuleCode }} = require('@vuepress/shared-utils')

module.exports = (options, context, api) => ({
/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx, api) => ({
name: '@vuepress/internal-root-mixins',

// @internal/root-mixins
async clientDynamicModules () {
const builtInRootMixins = [
context.getLibFilePath('client/root-mixins/updateMeta.js')
ctx.getLibFilePath('client/root-mixins/updateMeta.js')
]

const rootMixins = [
Expand Down
3 changes: 3 additions & 0 deletions packages/@vuepress/core/lib/node/internal-plugins/routes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx) => ({
name: '@vuepress/internal-routes',

Expand Down
7 changes: 5 additions & 2 deletions packages/@vuepress/core/lib/node/internal-plugins/siteData.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module.exports = (options, context) => ({
/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx) => ({
name: '@vuepress/internal-site-data',

// @internal/siteData
async clientDynamicModules () {
const code = `export const siteData = ${JSON.stringify(context.getSiteData(), null, 2)}`
const code = `export const siteData = ${JSON.stringify(ctx.getSiteData(), null, 2)}`
return { name: 'siteData.js', content: code, dirname: 'internal' }
}
})
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const { fs, path, logger, chalk } = require('@vuepress/shared-utils')

/**
* @param options
* @param {AppContext} ctx
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx) => ({
name: '@vuepress/internal-style',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const { fs, path } = require('@vuepress/shared-utils')

const DIR = 'transform'

/**
* @type {import('@vuepress/types').Plugin<{}, import('@vuepress/types').DefaultThemeConfig>}
*/
module.exports = (options, ctx) => ({
name: '@vuepress/internal-transform-modules',

Expand Down
1 change: 1 addition & 0 deletions packages/@vuepress/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@vuepress/plugin-last-updated": "1.9.4",
"@vuepress/plugin-register-components": "1.9.4",
"@vuepress/shared-utils": "1.9.4",
"@vuepress/types": "1.9.4",
"autoprefixer": "^9.5.1",
"babel-loader": "^8.0.4",
"bundle-require": "2.1.8",
Expand Down

0 comments on commit c926aff

Please sign in to comment.