1
1
import { Application } from "express" ;
2
2
import WebpackDevServer from "webpack-dev-server" ;
3
3
import { UserPlugins , PluginOptions } from "./plugin" ;
4
- import { ChainWebpack , Hook , AsyncHook } from "./shared" ;
4
+ import { ChainWebpack , Hook , AsyncHook , PluginObject } from "./shared" ;
5
5
import { Page , Context } from "./context" ;
6
6
import { ExtendMarkdown } from "./markdown" ;
7
7
@@ -14,6 +14,8 @@ export type LifeCycleHook$Ready = AsyncHook<[], unknown>;
14
14
export type LifeCycleHook$Updated = Hook < [ ] , unknown > ;
15
15
export type LifeCycleHook$Generated = Hook < [ ] , unknown > ;
16
16
17
+ export type FileDescriptor = { name : string ; content : string } ;
18
+
17
19
/**
18
20
* Plugin Options API
19
21
*/
@@ -22,6 +24,10 @@ export type PluginEntryOptions = {
22
24
* Current name
23
25
*/
24
26
name : string ;
27
+ /**
28
+ * Specify whether current plugin can be applied multiple times.
29
+ */
30
+ multiple ?: boolean ;
25
31
/**
26
32
* Sub plugins
27
33
*/
@@ -76,19 +82,19 @@ export type PluginEntryOptions = {
76
82
enhanceAppFiles ?:
77
83
| string
78
84
| string [ ]
79
- | AsyncHook < [ ] , { name : string ; content : string } > ;
85
+ | AsyncHook < [ ] , FileDescriptor | FileDescriptor [ ] > ;
80
86
/**
81
87
* Generate some client modules at compile time.
82
88
*
83
89
* @see https://vuepress.vuejs.org/plugin/option-api.html#clientdynamicmodules
84
90
*/
85
- clientDynamicModules ?: AsyncHook < [ ] , { name : string ; content : string } > ;
91
+ clientDynamicModules ?: AsyncHook < [ ] , FileDescriptor | FileDescriptor [ ] > ;
86
92
/**
87
93
* A function used to extend or edit the $page object
88
94
*
89
95
* @see https://vuepress.vuejs.org/plugin/option-api.html#extendpagedata
90
96
*/
91
- extendPageData : Hook < [ Page ] , unknown > ;
97
+ extendPageData : < T extends PluginObject = PluginObject > ( page : Page & T ) => void ;
92
98
/**
93
99
* A path to the mixin file which allows you to control the lifecycle of root component.
94
100
*
@@ -155,6 +161,6 @@ export type PluginEntry = PluginEntryOptions & {
155
161
*
156
162
* @see https://vuepress.vuejs.org/plugin/writing-a-plugin.html
157
163
*/
158
- export type UserPluginEntry < T extends PluginOptions = PluginOptions > =
164
+ export type Plugin < T extends PluginOptions = PluginOptions > =
159
165
| PluginEntry
160
166
| ( ( options : T , ctx : Context ) => PluginEntry ) ;
0 commit comments