@docusaurus/types 0.0.0-4240 → 0.0.0-4244
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/package.json +2 -2
- package/src/index.d.ts +36 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/types",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4244",
|
|
4
4
|
"description": "Common types for Docusaurus packages.",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"publishConfig": {
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"webpack": "^5.61.0",
|
|
24
24
|
"webpack-merge": "^5.8.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "92169a27a03dacb747edc8d13166daed2a3efd25"
|
|
27
27
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -153,6 +153,14 @@ export interface Preset {
|
|
|
153
153
|
themes?: PluginConfig[];
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
export type PresetModule = {
|
|
157
|
+
<T>(context: LoadContext, presetOptions: T): Preset;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type ImportedPresetModule = PresetModule & {
|
|
161
|
+
default?: PresetModule;
|
|
162
|
+
};
|
|
163
|
+
|
|
156
164
|
export type PresetConfig =
|
|
157
165
|
| [string, Record<string, unknown>]
|
|
158
166
|
| [string]
|
|
@@ -220,10 +228,10 @@ export interface Props extends LoadContext, InjectedHtmlTags {
|
|
|
220
228
|
}
|
|
221
229
|
|
|
222
230
|
export interface PluginContentLoadedActions {
|
|
223
|
-
addRoute(config: RouteConfig)
|
|
231
|
+
addRoute: (config: RouteConfig) => void;
|
|
224
232
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
|
-
createData(name: string, data: any)
|
|
226
|
-
setGlobalData<T = unknown>(data: T)
|
|
233
|
+
createData: (name: string, data: any) => Promise<string>;
|
|
234
|
+
setGlobalData: <T = unknown>(data: T) => void;
|
|
227
235
|
}
|
|
228
236
|
|
|
229
237
|
export type AllContent = Record<
|
|
@@ -239,32 +247,32 @@ export type PostCssOptions = Record<string, unknown> & {plugins: unknown[]};
|
|
|
239
247
|
|
|
240
248
|
export interface Plugin<Content = unknown> {
|
|
241
249
|
name: string;
|
|
242
|
-
loadContent
|
|
243
|
-
contentLoaded
|
|
250
|
+
loadContent?: () => Promise<Content>;
|
|
251
|
+
contentLoaded?: ({
|
|
244
252
|
content,
|
|
245
253
|
actions,
|
|
246
254
|
}: {
|
|
247
255
|
content: Content; // the content loaded by this plugin instance
|
|
248
256
|
allContent: AllContent; // content loaded by ALL the plugins
|
|
249
257
|
actions: PluginContentLoadedActions;
|
|
250
|
-
})
|
|
251
|
-
routesLoaded
|
|
252
|
-
postBuild
|
|
253
|
-
postStart
|
|
258
|
+
}) => Promise<void>;
|
|
259
|
+
routesLoaded?: (routes: RouteConfig[]) => void; // TODO remove soon, deprecated (alpha-60)
|
|
260
|
+
postBuild?: (props: Props) => void;
|
|
261
|
+
postStart?: (props: Props) => void;
|
|
254
262
|
// TODO refactor the configureWebpack API surface: use an object instead of multiple params (requires breaking change)
|
|
255
|
-
configureWebpack
|
|
263
|
+
configureWebpack?: (
|
|
256
264
|
config: Configuration,
|
|
257
265
|
isServer: boolean,
|
|
258
266
|
utils: ConfigureWebpackUtils,
|
|
259
267
|
content: Content,
|
|
260
|
-
)
|
|
261
|
-
configurePostCss
|
|
262
|
-
getThemePath
|
|
263
|
-
getTypeScriptThemePath
|
|
264
|
-
getPathsToWatch
|
|
265
|
-
getClientModules
|
|
266
|
-
extendCli
|
|
267
|
-
injectHtmlTags
|
|
268
|
+
) => Configuration & {mergeStrategy?: ConfigureWebpackFnMergeStrategy};
|
|
269
|
+
configurePostCss?: (options: PostCssOptions) => PostCssOptions;
|
|
270
|
+
getThemePath?: () => string;
|
|
271
|
+
getTypeScriptThemePath?: () => string;
|
|
272
|
+
getPathsToWatch?: () => string[];
|
|
273
|
+
getClientModules?: () => string[];
|
|
274
|
+
extendCli?: (cli: Command) => void;
|
|
275
|
+
injectHtmlTags?: ({content}: {content: Content}) => {
|
|
268
276
|
headTags?: HtmlTags;
|
|
269
277
|
preBodyTags?: HtmlTags;
|
|
270
278
|
postBodyTags?: HtmlTags;
|
|
@@ -272,31 +280,31 @@ export interface Plugin<Content = unknown> {
|
|
|
272
280
|
// TODO before/afterDevServer implementation
|
|
273
281
|
|
|
274
282
|
// translations
|
|
275
|
-
getTranslationFiles
|
|
283
|
+
getTranslationFiles?: ({
|
|
276
284
|
content,
|
|
277
285
|
}: {
|
|
278
286
|
content: Content;
|
|
279
|
-
})
|
|
280
|
-
getDefaultCodeTranslationMessages
|
|
287
|
+
}) => Promise<TranslationFiles>;
|
|
288
|
+
getDefaultCodeTranslationMessages?: () => Promise<
|
|
281
289
|
Record<
|
|
282
290
|
string, // id
|
|
283
291
|
string // message
|
|
284
292
|
>
|
|
285
293
|
>;
|
|
286
|
-
translateContent
|
|
294
|
+
translateContent?: ({
|
|
287
295
|
content,
|
|
288
296
|
translationFiles,
|
|
289
297
|
}: {
|
|
290
298
|
content: Content; // the content loaded by this plugin instance
|
|
291
299
|
translationFiles: TranslationFiles;
|
|
292
|
-
})
|
|
293
|
-
translateThemeConfig
|
|
300
|
+
}) => Content;
|
|
301
|
+
translateThemeConfig?: ({
|
|
294
302
|
themeConfig,
|
|
295
303
|
translationFiles,
|
|
296
304
|
}: {
|
|
297
305
|
themeConfig: ThemeConfig;
|
|
298
306
|
translationFiles: TranslationFiles;
|
|
299
|
-
})
|
|
307
|
+
}) => ThemeConfig;
|
|
300
308
|
}
|
|
301
309
|
|
|
302
310
|
export type InitializedPlugin<Content = unknown> = Plugin<Content> & {
|
|
@@ -310,9 +318,9 @@ export type LoadedPlugin<Content = unknown> = InitializedPlugin<Content> & {
|
|
|
310
318
|
|
|
311
319
|
export type PluginModule = {
|
|
312
320
|
<T, X>(context: LoadContext, options: T): Plugin<X>;
|
|
313
|
-
validateOptions
|
|
314
|
-
validateThemeConfig
|
|
315
|
-
getSwizzleComponentList
|
|
321
|
+
validateOptions?: <T>(data: OptionValidationContext<T>) => T;
|
|
322
|
+
validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
|
|
323
|
+
getSwizzleComponentList?: () => string[];
|
|
316
324
|
};
|
|
317
325
|
|
|
318
326
|
export type ImportedPluginModule = PluginModule & {
|