@vuepress/core 2.0.0-beta.4 → 2.0.0-beta.42
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.
- package/lib/app/appInit.js +6 -16
- package/lib/app/appPrepare.js +12 -15
- package/lib/app/appUse.d.ts +2 -2
- package/lib/app/appUse.js +17 -15
- package/lib/app/createBaseApp.d.ts +5 -0
- package/lib/app/createBaseApp.js +46 -0
- package/lib/app/createBuildApp.d.ts +5 -0
- package/lib/app/createBuildApp.js +13 -0
- package/lib/app/createDevApp.d.ts +5 -0
- package/lib/app/createDevApp.js +13 -0
- package/lib/app/index.d.ts +13 -12
- package/lib/app/index.js +18 -13
- package/lib/app/prepare/index.d.ts +1 -3
- package/lib/app/prepare/index.js +6 -4
- package/lib/app/prepare/prepareLayoutComponents.js +2 -2
- package/lib/app/prepare/preparePageComponent.js +6 -1
- package/lib/app/prepare/preparePageData.js +7 -11
- package/lib/app/prepare/{preparePagesComponent.d.ts → preparePagesComponents.d.ts} +1 -1
- package/lib/app/prepare/preparePagesComponents.js +24 -0
- package/lib/app/prepare/preparePagesData.js +5 -4
- package/lib/app/prepare/preparePagesRoutes.js +61 -11
- package/lib/app/prepare/prepareSiteData.js +19 -1
- package/lib/app/{createAppDir.d.ts → resolveAppDir.d.ts} +2 -2
- package/lib/app/resolveAppDir.js +32 -0
- package/lib/app/resolveAppEnv.d.ts +5 -0
- package/lib/app/resolveAppEnv.js +12 -0
- package/lib/app/resolveAppMarkdown.d.ts +6 -0
- package/lib/app/resolveAppMarkdown.js +16 -0
- package/lib/app/resolveAppOptions.d.ts +5 -0
- package/lib/app/{createAppOptions.js → resolveAppOptions.js} +16 -20
- package/lib/app/resolveAppPages.d.ts +5 -0
- package/lib/app/resolveAppPages.js +31 -0
- package/lib/app/resolveAppSiteData.d.ts +7 -0
- package/lib/app/resolveAppSiteData.js +17 -0
- package/lib/app/resolveAppVersion.d.ts +4 -0
- package/lib/app/resolveAppVersion.js +10 -0
- package/lib/app/resolveAppWriteTemp.d.ts +5 -0
- package/lib/app/{createAppWriteTemp.js → resolveAppWriteTemp.js} +5 -5
- package/lib/app/resolvePluginObject.d.ts +5 -0
- package/lib/app/resolvePluginObject.js +9 -0
- package/lib/app/resolveThemeInfo.d.ts +5 -0
- package/lib/app/resolveThemeInfo.js +31 -0
- package/lib/app/resolveThemeLayouts.d.ts +5 -0
- package/lib/app/resolveThemeLayouts.js +25 -0
- package/lib/app/setupAppThemeAndPlugins.d.ts +5 -0
- package/lib/app/setupAppThemeAndPlugins.js +21 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +5 -2
- package/lib/page/createPage.js +75 -39
- package/lib/page/index.d.ts +4 -3
- package/lib/page/index.js +9 -4
- package/lib/page/inferPagePath.js +2 -2
- package/lib/page/renderPageContent.d.ts +19 -0
- package/lib/page/renderPageContent.js +26 -0
- package/lib/page/renderPageExcerpt.d.ts +11 -0
- package/lib/page/renderPageExcerpt.js +17 -0
- package/lib/page/resolvePageComponentInfo.d.ts +2 -9
- package/lib/page/resolvePageComponentInfo.js +2 -24
- package/lib/page/resolvePageContent.js +1 -2
- package/lib/page/resolvePageDataInfo.d.ts +2 -1
- package/lib/page/resolvePageDataInfo.js +2 -2
- package/lib/page/resolvePageDate.d.ts +1 -1
- package/lib/page/resolvePageDate.js +6 -7
- package/lib/page/resolvePageFileContent.js +3 -4
- package/lib/page/resolvePageFilePath.d.ts +1 -1
- package/lib/page/resolvePageFilePath.js +6 -11
- package/lib/page/resolvePageHtmlInfo.d.ts +11 -0
- package/lib/page/resolvePageHtmlInfo.js +18 -0
- package/lib/page/resolvePageKey.js +1 -1
- package/lib/page/resolvePageLang.js +2 -3
- package/lib/page/resolvePagePath.js +12 -1
- package/lib/page/resolvePagePermalink.js +4 -5
- package/lib/page/resolvePageRouteMeta.d.ts +7 -0
- package/lib/page/resolvePageRouteMeta.js +8 -0
- package/lib/pluginApi/createHookQueue.d.ts +1 -1
- package/lib/pluginApi/createHookQueue.js +7 -46
- package/lib/pluginApi/createPluginApi.js +2 -2
- package/lib/pluginApi/createPluginApiHooks.js +15 -14
- package/lib/pluginApi/createPluginApiRegisterHooks.js +6 -6
- package/lib/pluginApi/index.js +5 -1
- package/lib/pluginApi/normalizeClientFilesHook.js +5 -2
- package/lib/pluginApi/normalizeReturnObjectHook.js +1 -1
- package/lib/types/app/app.d.ts +82 -14
- package/lib/types/app/index.js +5 -1
- package/lib/types/app/options.d.ts +78 -27
- package/lib/types/app/utils.d.ts +10 -3
- package/lib/types/bundler.d.ts +3 -24
- package/lib/types/index.d.ts +2 -3
- package/lib/types/index.js +6 -3
- package/lib/types/page.d.ts +78 -32
- package/lib/types/plugin.d.ts +5 -24
- package/lib/types/{plugin-api → pluginApi}/hooks.d.ts +8 -9
- package/lib/types/{plugin-api → pluginApi}/hooks.js +0 -0
- package/lib/types/{plugin-api → pluginApi}/index.d.ts +0 -0
- package/lib/types/{plugin-api → pluginApi}/index.js +5 -1
- package/lib/types/{plugin-api → pluginApi}/pluginApi.d.ts +0 -0
- package/lib/types/{plugin-api → pluginApi}/pluginApi.js +0 -0
- package/lib/types/theme.d.ts +42 -14
- package/package.json +14 -14
- package/CHANGELOG.md +0 -260
- package/lib/app/appUseByConfig.d.ts +0 -2
- package/lib/app/appUseByConfig.js +0 -14
- package/lib/app/createApp.d.ts +0 -5
- package/lib/app/createApp.js +0 -44
- package/lib/app/createAppDir.js +0 -32
- package/lib/app/createAppEnv.d.ts +0 -5
- package/lib/app/createAppEnv.js +0 -14
- package/lib/app/createAppOptions.d.ts +0 -5
- package/lib/app/createAppPages.d.ts +0 -5
- package/lib/app/createAppPages.js +0 -33
- package/lib/app/createAppSiteData.d.ts +0 -7
- package/lib/app/createAppSiteData.js +0 -19
- package/lib/app/createAppVersion.d.ts +0 -4
- package/lib/app/createAppVersion.js +0 -11
- package/lib/app/createAppWriteTemp.d.ts +0 -5
- package/lib/app/normalizePlugin.d.ts +0 -2
- package/lib/app/normalizePlugin.js +0 -19
- package/lib/app/normalizePluginConfig.d.ts +0 -2
- package/lib/app/normalizePluginConfig.js +0 -18
- package/lib/app/prepare/preparePageRoutes.d.ts +0 -5
- package/lib/app/prepare/preparePageRoutes.js +0 -57
- package/lib/app/prepare/preparePagesComponent.js +0 -23
- package/lib/app/prepare/resolvePageData.d.ts +0 -5
- package/lib/app/prepare/resolvePageData.js +0 -18
- package/lib/app/resolveBundler.d.ts +0 -2
- package/lib/app/resolveBundler.js +0 -10
- package/lib/app/resolvePlugin.d.ts +0 -5
- package/lib/app/resolvePlugin.js +0 -20
- package/lib/page/resolvePageExcerpt.d.ts +0 -9
- package/lib/page/resolvePageExcerpt.js +0 -15
- package/lib/page/resolvePageRoutesInfo.d.ts +0 -11
- package/lib/page/resolvePageRoutesInfo.js +0 -16
- package/lib/page/resolvePageTitle.d.ts +0 -9
- package/lib/page/resolvePageTitle.js +0 -26
- package/lib/themeApi/createThemeApi.d.ts +0 -7
- package/lib/themeApi/createThemeApi.js +0 -30
- package/lib/themeApi/index.d.ts +0 -1
- package/lib/themeApi/index.js +0 -13
- package/lib/themeApi/resolveThemeInfo.d.ts +0 -2
- package/lib/themeApi/resolveThemeInfo.js +0 -34
- package/lib/themeApi/resolveThemeLayouts.d.ts +0 -5
- package/lib/themeApi/resolveThemeLayouts.js +0 -33
- package/lib/types/theme-api/index.d.ts +0 -1
- package/lib/types/theme-api/index.js +0 -13
- package/lib/types/theme-api/themeApi.d.ts +0 -44
- package/lib/types/theme-api/themeApi.js +0 -2
package/lib/types/app/app.d.ts
CHANGED
|
@@ -1,30 +1,98 @@
|
|
|
1
1
|
import type { Markdown } from '@vuepress/markdown';
|
|
2
2
|
import type { SiteData } from '@vuepress/shared';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Bundler } from '../bundler';
|
|
4
4
|
import type { Page } from '../page';
|
|
5
|
-
import type { Plugin
|
|
6
|
-
import type { PluginApi } from '../
|
|
7
|
-
import type { ThemeApi } from '../theme-api';
|
|
5
|
+
import type { Plugin } from '../plugin';
|
|
6
|
+
import type { PluginApi } from '../pluginApi';
|
|
8
7
|
import type { AppOptions } from './options';
|
|
9
8
|
import type { AppDir, AppEnv, AppWriteTemp } from './utils';
|
|
10
9
|
/**
|
|
11
10
|
* Vuepress app
|
|
12
11
|
*/
|
|
13
12
|
export interface App {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Directory utils
|
|
15
|
+
*/
|
|
16
16
|
dir: AppDir;
|
|
17
|
+
/**
|
|
18
|
+
* Environment flags
|
|
19
|
+
*/
|
|
17
20
|
env: AppEnv;
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Options that filled all optional fields with a default value
|
|
23
|
+
*/
|
|
24
|
+
options: AppOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Plugin system
|
|
27
|
+
*/
|
|
20
28
|
pluginApi: PluginApi;
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Site data, which will be used in client side
|
|
31
|
+
*/
|
|
32
|
+
siteData: SiteData;
|
|
33
|
+
/**
|
|
34
|
+
* Version of vuepress core
|
|
35
|
+
*/
|
|
36
|
+
version: string;
|
|
37
|
+
/**
|
|
38
|
+
* Write temp file
|
|
39
|
+
*/
|
|
40
|
+
writeTemp: AppWriteTemp;
|
|
41
|
+
/**
|
|
42
|
+
* Use a plugin
|
|
43
|
+
*/
|
|
44
|
+
use: (plugin: Plugin) => this;
|
|
45
|
+
/**
|
|
46
|
+
* Initialize app.
|
|
47
|
+
*
|
|
48
|
+
* - Theme and plugin will be loaded.
|
|
49
|
+
* - Layouts and pages will be resolved.
|
|
50
|
+
*/
|
|
23
51
|
init: () => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Prepare data for client and write temp files.
|
|
54
|
+
*
|
|
55
|
+
* Should be called after `app.init()`.
|
|
56
|
+
*/
|
|
24
57
|
prepare: () => Promise<void>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Layout components.
|
|
60
|
+
*
|
|
61
|
+
* Only available after initialization
|
|
62
|
+
*/
|
|
63
|
+
layouts: Record<string, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Markdown-it instance.
|
|
66
|
+
*
|
|
67
|
+
* Only available after initialization
|
|
68
|
+
*/
|
|
69
|
+
markdown: Markdown;
|
|
70
|
+
/**
|
|
71
|
+
* Page objects.
|
|
72
|
+
*
|
|
73
|
+
* Only available after initialization
|
|
74
|
+
*/
|
|
29
75
|
pages: Page[];
|
|
30
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Vuepress dev app
|
|
79
|
+
*/
|
|
80
|
+
export interface DevApp extends App {
|
|
81
|
+
/**
|
|
82
|
+
* Start dev server
|
|
83
|
+
*
|
|
84
|
+
* Should be called after `app.prepare()`.
|
|
85
|
+
*/
|
|
86
|
+
dev: () => ReturnType<Bundler['dev']>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Vuepress build app
|
|
90
|
+
*/
|
|
91
|
+
export interface BuildApp extends App {
|
|
92
|
+
/**
|
|
93
|
+
* Build static files
|
|
94
|
+
*
|
|
95
|
+
* Should be called after `app.prepare()`.
|
|
96
|
+
*/
|
|
97
|
+
build: () => ReturnType<Bundler['build']>;
|
|
98
|
+
}
|
package/lib/types/app/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,32 +1,83 @@
|
|
|
1
1
|
import type { MarkdownOptions } from '@vuepress/markdown';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
2
|
+
import type { SiteData } from '@vuepress/shared';
|
|
3
|
+
import type { Bundler } from '../bundler';
|
|
4
|
+
import type { PluginConfig } from '../plugin';
|
|
5
|
+
import type { Theme } from '../theme';
|
|
5
6
|
/**
|
|
6
|
-
* Vuepress app
|
|
7
|
+
* Vuepress app common config that shared between dev and build
|
|
7
8
|
*/
|
|
8
|
-
export interface
|
|
9
|
-
base: string;
|
|
10
|
-
locales: SiteLocaleConfig;
|
|
11
|
-
theme: string;
|
|
12
|
-
themeConfig: Partial<T>;
|
|
13
|
-
bundler: string;
|
|
14
|
-
bundlerConfig: Partial<U>;
|
|
9
|
+
export interface AppConfigCommon extends Partial<SiteData> {
|
|
15
10
|
source: string;
|
|
16
|
-
dest
|
|
17
|
-
temp
|
|
18
|
-
cache
|
|
19
|
-
public
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
dest?: string;
|
|
12
|
+
temp?: string;
|
|
13
|
+
cache?: string;
|
|
14
|
+
public?: string;
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
markdown?: MarkdownOptions;
|
|
17
|
+
pagePatterns?: string[];
|
|
18
|
+
bundler: Bundler;
|
|
19
|
+
theme: Theme;
|
|
20
|
+
plugins?: PluginConfig;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Vuepress app config for dev
|
|
24
|
+
*/
|
|
25
|
+
export interface AppConfigDev {
|
|
26
|
+
/**
|
|
27
|
+
* Specify the host to use for the dev server
|
|
28
|
+
*
|
|
29
|
+
* @default '0.0.0.0'
|
|
30
|
+
*/
|
|
31
|
+
host?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Specify the port to use for the dev server
|
|
34
|
+
*
|
|
35
|
+
* @default 8080
|
|
36
|
+
*/
|
|
37
|
+
port?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to open the browser after dev-server had been started
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
open?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Specify the path of the HTML template to be used for dev
|
|
46
|
+
*
|
|
47
|
+
* @default '@vuepress/client/templates/dev.html'
|
|
48
|
+
*/
|
|
49
|
+
templateDev?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Vuepress app config for build
|
|
53
|
+
*/
|
|
54
|
+
export interface AppConfigBuild {
|
|
55
|
+
/**
|
|
56
|
+
* Determine what resource files should be preloaded. Use boolean value to
|
|
57
|
+
* totally enable / disable.
|
|
58
|
+
*
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
shouldPreload?: ((file: string, type: string) => boolean) | boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Determine what resource files should be prefetched. Use boolean value to
|
|
64
|
+
* totally enable / disable.
|
|
65
|
+
*
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
shouldPrefetch?: ((file: string, type: string) => boolean) | boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Specify the path of the HTML template to be used for build
|
|
71
|
+
*
|
|
72
|
+
* @default '@vuepress/client/templates/build.html'
|
|
73
|
+
*/
|
|
74
|
+
templateBuild?: string;
|
|
31
75
|
}
|
|
32
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Vuepress app config
|
|
78
|
+
*/
|
|
79
|
+
export declare type AppConfig = AppConfigCommon & AppConfigDev & AppConfigBuild;
|
|
80
|
+
/**
|
|
81
|
+
* Vuepress app options
|
|
82
|
+
*/
|
|
83
|
+
export declare type AppOptions = Required<AppConfig>;
|
package/lib/types/app/utils.d.ts
CHANGED
|
@@ -17,11 +17,18 @@ export interface AppDir {
|
|
|
17
17
|
* Environment flags
|
|
18
18
|
*/
|
|
19
19
|
export interface AppEnv {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Is running in build mode or not
|
|
22
|
+
*/
|
|
23
|
+
isBuild: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Is running in dev mode or not
|
|
26
|
+
*/
|
|
22
27
|
isDev: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Is debug mode enabled or not
|
|
30
|
+
*/
|
|
23
31
|
isDebug: boolean;
|
|
24
|
-
nodeEnv: string | undefined;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Write temp file util
|
package/lib/types/bundler.d.ts
CHANGED
|
@@ -7,28 +7,7 @@ import type { App } from './app';
|
|
|
7
7
|
* - build: bundle assets for deployment
|
|
8
8
|
*/
|
|
9
9
|
export interface Bundler {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare type BundlerDev = (app: App) => Promise<() => Promise<void>>;
|
|
14
|
-
export declare type BundlerBuild = (app: App) => Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* A function that returns a bundler instance
|
|
17
|
-
*
|
|
18
|
-
* A bundler package should have a `CreateBundlerFunction` as the default export
|
|
19
|
-
*/
|
|
20
|
-
export declare type CreateBundlerFunction<BundlerOptions extends BundlerConfig = Partial<BundlerConfig>> = (options: BundlerOptions) => Bundler;
|
|
21
|
-
/**
|
|
22
|
-
* Bundler entry type
|
|
23
|
-
*/
|
|
24
|
-
export interface BundlerEntry {
|
|
25
|
-
createBundler: CreateBundlerFunction;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* User config type of bundler
|
|
29
|
-
*
|
|
30
|
-
* @remark suffix `Config` means this is for user config
|
|
31
|
-
*/
|
|
32
|
-
export interface BundlerConfig {
|
|
33
|
-
[key: string]: any;
|
|
10
|
+
name: string;
|
|
11
|
+
dev: (app: App) => Promise<() => Promise<void>>;
|
|
12
|
+
build: (app: App) => Promise<void>;
|
|
34
13
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty,
|
|
1
|
+
import type { HeadAttrsConfig, HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig } from '@vuepress/shared';
|
|
2
2
|
export type { HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, HeadAttrsConfig, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig, };
|
|
3
3
|
export * from './app';
|
|
4
4
|
export * from './bundler';
|
|
5
5
|
export * from './page';
|
|
6
6
|
export * from './plugin';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './pluginApi';
|
|
8
8
|
export * from './theme';
|
|
9
|
-
export * from './theme-api';
|
package/lib/types/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,6 +18,5 @@ __exportStar(require("./app"), exports);
|
|
|
14
18
|
__exportStar(require("./bundler"), exports);
|
|
15
19
|
__exportStar(require("./page"), exports);
|
|
16
20
|
__exportStar(require("./plugin"), exports);
|
|
17
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./pluginApi"), exports);
|
|
18
22
|
__exportStar(require("./theme"), exports);
|
|
19
|
-
__exportStar(require("./theme-api"), exports);
|
package/lib/types/page.d.ts
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
import type { MarkdownLink } from '@vuepress/markdown';
|
|
2
|
-
import type { PageData, PageFrontmatter } from '@vuepress/shared';
|
|
2
|
+
import type { PageBase, PageData, PageFrontmatter } from '@vuepress/shared';
|
|
3
3
|
/**
|
|
4
4
|
* Vuepress Page
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export declare type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPageFrontmatter extends Record<any, any> = Record<string, unknown>, ExtraPageFields extends Record<any, any> = Record<never, never>> = PageBase<ExtraPageFrontmatter> & ExtraPageFields & {
|
|
7
|
+
/**
|
|
8
|
+
* Data of the page, which will be available in client code
|
|
9
|
+
*/
|
|
10
|
+
data: PageData<ExtraPageData, ExtraPageFrontmatter>;
|
|
11
|
+
/**
|
|
12
|
+
* Raw Content of the page
|
|
13
|
+
*/
|
|
14
|
+
content: string;
|
|
15
|
+
/**
|
|
16
|
+
* Rendered content of the page
|
|
17
|
+
*/
|
|
18
|
+
contentRendered: string;
|
|
19
|
+
/**
|
|
20
|
+
* Date of the page, in 'yyyy-MM-dd' format
|
|
21
|
+
*
|
|
22
|
+
* @example '2020-09-09'
|
|
23
|
+
*/
|
|
24
|
+
date: string;
|
|
25
|
+
/**
|
|
26
|
+
* Dependencies of the page
|
|
27
|
+
*/
|
|
28
|
+
deps: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Hoisted tags of the page
|
|
31
|
+
*/
|
|
32
|
+
hoistedTags: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Links of the page
|
|
35
|
+
*/
|
|
36
|
+
links: MarkdownLink[];
|
|
7
37
|
/**
|
|
8
38
|
* Path of the page that inferred from file path
|
|
9
39
|
*
|
|
@@ -21,13 +51,29 @@ export interface Page extends PageData {
|
|
|
21
51
|
*/
|
|
22
52
|
pathLocale: string;
|
|
23
53
|
/**
|
|
24
|
-
*
|
|
54
|
+
* Permalink of the page
|
|
55
|
+
*
|
|
56
|
+
* If the page does not have a permalink, it would be `null`
|
|
57
|
+
*/
|
|
58
|
+
permalink: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Custom data to be attached to the page route record of vue-router
|
|
61
|
+
*
|
|
62
|
+
* @see https://router.vuejs.org/api/#meta
|
|
63
|
+
*/
|
|
64
|
+
routeMeta: Record<string, unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* Slug of the page
|
|
67
|
+
*/
|
|
68
|
+
slug: string;
|
|
69
|
+
/**
|
|
70
|
+
* Source file path
|
|
25
71
|
*
|
|
26
72
|
* If the page does not come from a file, it would be `null`
|
|
27
73
|
*/
|
|
28
74
|
filePath: string | null;
|
|
29
75
|
/**
|
|
30
|
-
*
|
|
76
|
+
* Source file path relative to source directory
|
|
31
77
|
*
|
|
32
78
|
* If the page does not come from a file, it would be `null`
|
|
33
79
|
*/
|
|
@@ -37,15 +83,13 @@ export interface Page extends PageData {
|
|
|
37
83
|
*/
|
|
38
84
|
componentFilePath: string;
|
|
39
85
|
/**
|
|
40
|
-
* Component relative
|
|
86
|
+
* Component file path relative to temp directory
|
|
41
87
|
*/
|
|
42
88
|
componentFilePathRelative: string;
|
|
43
|
-
/**
|
|
44
|
-
* Component file content that generated from the source file
|
|
45
|
-
*/
|
|
46
|
-
componentFileContent: string;
|
|
47
89
|
/**
|
|
48
90
|
* Component file chunk name
|
|
91
|
+
*
|
|
92
|
+
* Only take effect in webpack
|
|
49
93
|
*/
|
|
50
94
|
componentFileChunkName: string;
|
|
51
95
|
/**
|
|
@@ -53,46 +97,48 @@ export interface Page extends PageData {
|
|
|
53
97
|
*/
|
|
54
98
|
dataFilePath: string;
|
|
55
99
|
/**
|
|
56
|
-
* Page data relative
|
|
100
|
+
* Page data file path relative to temp directory
|
|
57
101
|
*/
|
|
58
102
|
dataFilePathRelative: string;
|
|
59
103
|
/**
|
|
60
104
|
* Page data file chunk name
|
|
105
|
+
*
|
|
106
|
+
* Only take effect in webpack
|
|
61
107
|
*/
|
|
62
108
|
dataFileChunkName: string;
|
|
63
109
|
/**
|
|
64
|
-
*
|
|
110
|
+
* Rendered html file path
|
|
65
111
|
*/
|
|
66
|
-
|
|
112
|
+
htmlFilePath: string;
|
|
67
113
|
/**
|
|
68
|
-
*
|
|
114
|
+
* Rendered html file path relative to dest directory
|
|
69
115
|
*/
|
|
70
|
-
|
|
116
|
+
htmlFilePathRelative: string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Options to create vuepress page
|
|
120
|
+
*/
|
|
121
|
+
export interface PageOptions {
|
|
71
122
|
/**
|
|
72
|
-
*
|
|
123
|
+
* If `filePath` is not set, this option will be used as the raw
|
|
124
|
+
* markdown content of the page.
|
|
125
|
+
*
|
|
126
|
+
* If `filePath` is set, this option will be ignored, while the
|
|
127
|
+
* content of the file will be used.
|
|
73
128
|
*/
|
|
74
|
-
content
|
|
129
|
+
content?: string;
|
|
75
130
|
/**
|
|
76
|
-
*
|
|
131
|
+
* Absolute file path of the markdown source file.
|
|
77
132
|
*/
|
|
78
|
-
|
|
133
|
+
filePath?: string;
|
|
79
134
|
/**
|
|
80
|
-
*
|
|
135
|
+
* Default frontmatter of the page, which could be overridden by
|
|
136
|
+
* the frontmatter of the markdown content.
|
|
81
137
|
*/
|
|
82
|
-
|
|
138
|
+
frontmatter?: PageFrontmatter;
|
|
83
139
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* @example '2020-09-09'
|
|
140
|
+
* If this option is set, it will be used as the final route path
|
|
141
|
+
* of the page, ignoring the relative path and permalink.
|
|
87
142
|
*/
|
|
88
|
-
date: string;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Options to create vuepress page
|
|
92
|
-
*/
|
|
93
|
-
export interface PageOptions {
|
|
94
143
|
path?: string;
|
|
95
|
-
filePath?: string;
|
|
96
|
-
frontmatter?: PageFrontmatter;
|
|
97
|
-
content?: string;
|
|
98
144
|
}
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { App } from './app';
|
|
2
|
-
import type { HooksExposed } from './
|
|
2
|
+
import type { HooksExposed } from './pluginApi';
|
|
3
3
|
/**
|
|
4
4
|
* Vuepress plugin
|
|
5
5
|
*
|
|
@@ -9,40 +9,21 @@ import type { HooksExposed } from './plugin-api';
|
|
|
9
9
|
*
|
|
10
10
|
* A plugin package should have a `Plugin` as the default export
|
|
11
11
|
*/
|
|
12
|
-
export declare type Plugin<T extends
|
|
12
|
+
export declare type Plugin<T extends PluginObject = PluginObject> = T | PluginFunction<T>;
|
|
13
13
|
/**
|
|
14
14
|
* Vuepress plugin function
|
|
15
15
|
*
|
|
16
16
|
* It accepts plugin options and vuepress app, returns plugin object
|
|
17
17
|
*/
|
|
18
|
-
export declare type PluginFunction<T extends
|
|
18
|
+
export declare type PluginFunction<T extends PluginObject = PluginObject> = (app: App) => T;
|
|
19
19
|
/**
|
|
20
20
|
* Vuepress plugin object
|
|
21
21
|
*/
|
|
22
22
|
export interface PluginObject extends Partial<HooksExposed> {
|
|
23
23
|
name: string;
|
|
24
24
|
multiple?: boolean;
|
|
25
|
-
plugins?: PluginConfig[];
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* It can be set by user in user config, and will be passed to plugin function
|
|
31
|
-
*/
|
|
32
|
-
export declare type PluginOptions = Record<string, any>;
|
|
33
|
-
/**
|
|
34
|
-
* Plugin config to be used in user config file
|
|
35
|
-
*
|
|
36
|
-
* Users can use this config to control which plugins to be used,
|
|
37
|
-
* and set the plugin options
|
|
38
|
-
*
|
|
39
|
-
* @remark suffix `Config` means this is for user config
|
|
40
|
-
*/
|
|
41
|
-
export declare type PluginConfig<T extends PluginOptions = PluginOptions> = string | Plugin<T> | [string | Plugin<T>] | [string | Plugin<T>, Partial<T> | boolean];
|
|
42
|
-
/**
|
|
43
|
-
* Normalized plugin config
|
|
27
|
+
* Config field for plugins
|
|
44
28
|
*/
|
|
45
|
-
export declare type
|
|
46
|
-
Plugin<T> | string,
|
|
47
|
-
Partial<T> | boolean
|
|
48
|
-
];
|
|
29
|
+
export declare type PluginConfig = (Plugin | Plugin[])[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Markdown } from '@vuepress/markdown';
|
|
1
|
+
import type { Markdown, MarkdownOptions } from '@vuepress/markdown';
|
|
2
2
|
import type { App } from '../app';
|
|
3
3
|
import type { Page, PageOptions } from '../page';
|
|
4
4
|
declare type PromiseOrNot<T> = Promise<T> | T;
|
|
@@ -11,11 +11,9 @@ export declare type Hook<Exposed, Normalized = Exposed, Result = Normalized exte
|
|
|
11
11
|
result: Result;
|
|
12
12
|
};
|
|
13
13
|
export declare type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
|
|
14
|
+
export declare type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
|
|
14
15
|
export declare type ClientFilesHook = Hook<string | string[] | ((app: App) => PromiseOrNot<string | string[]>), (app: App) => Promise<string[]>>;
|
|
15
|
-
export declare type ReturnObjectHook = Hook<Record<string, any> | ((app: App) => Record<string, any
|
|
16
|
-
export declare type ExtendsMarkdownHook = Hook<(md: Markdown, app: App) => void>;
|
|
17
|
-
export declare type ExtendsPageOptionsHook = Hook<(filePath: string, app: App) => PromiseOrNot<PageOptions>>;
|
|
18
|
-
export declare type ExtendsPageDataHook = Hook<(page: Page, app: App) => PromiseOrNot<Record<string, any>>>;
|
|
16
|
+
export declare type ReturnObjectHook = Hook<Record<string, any> | ((app: App) => PromiseOrNot<Record<string, any>>), (app: App) => Promise<Record<string, any>>>;
|
|
19
17
|
/**
|
|
20
18
|
* List of hooks
|
|
21
19
|
*/
|
|
@@ -24,9 +22,11 @@ export interface Hooks {
|
|
|
24
22
|
onPrepared: LifeCycleHook;
|
|
25
23
|
onWatched: LifeCycleHook<[watchers: Closable[], restart: () => Promise<void>]>;
|
|
26
24
|
onGenerated: LifeCycleHook;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
extendsMarkdownOptions: ExtendsHook<MarkdownOptions>;
|
|
26
|
+
extendsMarkdown: ExtendsHook<Markdown>;
|
|
27
|
+
extendsPageOptions: ExtendsHook<PageOptions>;
|
|
28
|
+
extendsPage: ExtendsHook<Page>;
|
|
29
|
+
extendsBundlerOptions: ExtendsHook<any>;
|
|
30
30
|
clientAppEnhanceFiles: ClientFilesHook;
|
|
31
31
|
clientAppRootComponentFiles: ClientFilesHook;
|
|
32
32
|
clientAppSetupFiles: ClientFilesHook;
|
|
@@ -70,6 +70,5 @@ export interface HookQueue<T extends HooksName> {
|
|
|
70
70
|
items: HookItem<T>[];
|
|
71
71
|
add: (item: HookItem<T>) => void;
|
|
72
72
|
process: (...args: Parameters<HooksNormalized[T]>) => Promise<HooksResult[T][]>;
|
|
73
|
-
processSync: (...args: Parameters<HooksNormalized[T]>) => HooksResult[T][];
|
|
74
73
|
}
|
|
75
74
|
export {};
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
File without changes
|
|
File without changes
|