@docusaurus/types 2.0.0-beta.8bda3b2db → 2.0.0-beta.9
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 +9 -6
- package/src/index.d.ts +44 -13
- package/tsconfig.json +7 -0
- package/src/index.js +0 -10
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/types",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"description": "Common types for Docusaurus packages.",
|
|
5
|
-
"main": "./src/index.js",
|
|
6
5
|
"types": "./src/index.d.ts",
|
|
7
6
|
"publishConfig": {
|
|
8
7
|
"access": "public"
|
|
@@ -13,12 +12,16 @@
|
|
|
13
12
|
"directory": "packages/docusaurus-types"
|
|
14
13
|
},
|
|
15
14
|
"license": "MIT",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "tsc -p ."
|
|
17
|
+
},
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"commander": "^5.1.0",
|
|
18
|
-
"joi": "^17.4.
|
|
20
|
+
"joi": "^17.4.2",
|
|
19
21
|
"querystring": "0.2.0",
|
|
20
|
-
"
|
|
21
|
-
"webpack
|
|
22
|
+
"utility-types": "^3.10.0",
|
|
23
|
+
"webpack": "^5.61.0",
|
|
24
|
+
"webpack-merge": "^5.8.0"
|
|
22
25
|
},
|
|
23
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "8a491fc29ad002f90e97f5b5fe4178ac8fa0c4d7"
|
|
24
27
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -5,12 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
// ESLint doesn't understand types dependencies in d.ts
|
|
9
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
10
8
|
import type {RuleSetRule, Configuration} from 'webpack';
|
|
11
9
|
import type {Command} from 'commander';
|
|
12
10
|
import type {ParsedUrlQueryInput} from 'querystring';
|
|
13
11
|
import type Joi from 'joi';
|
|
12
|
+
import type {Overwrite, DeepPartial} from 'utility-types';
|
|
14
13
|
|
|
15
14
|
// Convert webpack-merge webpack-merge enum to union type
|
|
16
15
|
// For type retro-compatible webpack-merge upgrade: we used string literals before)
|
|
@@ -23,10 +22,11 @@ export type ThemeConfig = {
|
|
|
23
22
|
[key: string]: unknown;
|
|
24
23
|
};
|
|
25
24
|
|
|
25
|
+
// Docusaurus config, after validation/normalization
|
|
26
26
|
export interface DocusaurusConfig {
|
|
27
27
|
baseUrl: string;
|
|
28
28
|
baseUrlIssueBanner: boolean;
|
|
29
|
-
favicon
|
|
29
|
+
favicon?: string;
|
|
30
30
|
tagline?: string;
|
|
31
31
|
title: string;
|
|
32
32
|
url: string;
|
|
@@ -39,6 +39,7 @@ export interface DocusaurusConfig {
|
|
|
39
39
|
noIndex: boolean;
|
|
40
40
|
organizationName?: string;
|
|
41
41
|
projectName?: string;
|
|
42
|
+
deploymentBranch?: string;
|
|
42
43
|
githubHost?: string;
|
|
43
44
|
githubPort?: string;
|
|
44
45
|
plugins?: PluginConfig[];
|
|
@@ -70,6 +71,19 @@ export interface DocusaurusConfig {
|
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
// Docusaurus config, as provided by the user (partial/unnormalized)
|
|
75
|
+
// This type is used to provide type-safety / IDE auto-complete on the config file
|
|
76
|
+
// See https://docusaurus.io/docs/typescript-support
|
|
77
|
+
export type Config = Overwrite<
|
|
78
|
+
Partial<DocusaurusConfig>,
|
|
79
|
+
{
|
|
80
|
+
title: Required<DocusaurusConfig['title']>;
|
|
81
|
+
url: Required<DocusaurusConfig['url']>;
|
|
82
|
+
baseUrl: Required<DocusaurusConfig['baseUrl']>;
|
|
83
|
+
i18n?: DeepPartial<DocusaurusConfig['i18n']>;
|
|
84
|
+
}
|
|
85
|
+
>;
|
|
86
|
+
|
|
73
87
|
/**
|
|
74
88
|
* - `type: 'package'`, plugin is in a different package.
|
|
75
89
|
* - `type: 'project'`, plugin is in the same docusaurus project.
|
|
@@ -127,7 +141,10 @@ export interface DocusaurusContext {
|
|
|
127
141
|
globalData: Record<string, unknown>;
|
|
128
142
|
i18n: I18n;
|
|
129
143
|
codeTranslations: Record<string, string>;
|
|
130
|
-
|
|
144
|
+
|
|
145
|
+
// Don't put mutable values here, to avoid triggering re-renders
|
|
146
|
+
// We could reconsider that choice if context selectors are implemented
|
|
147
|
+
// isBrowser: boolean; // Not here on purpose!
|
|
131
148
|
}
|
|
132
149
|
|
|
133
150
|
export interface Preset {
|
|
@@ -180,7 +197,7 @@ export interface LoadContext {
|
|
|
180
197
|
siteConfig: DocusaurusConfig;
|
|
181
198
|
siteConfigPath: string;
|
|
182
199
|
outDir: string;
|
|
183
|
-
baseUrl: string;
|
|
200
|
+
baseUrl: string; // TODO to remove: useless, there's already siteConfig.baseUrl!
|
|
184
201
|
i18n: I18n;
|
|
185
202
|
ssrTemplate?: string;
|
|
186
203
|
codeTranslations: Record<string, string>;
|
|
@@ -195,10 +212,10 @@ export interface InjectedHtmlTags {
|
|
|
195
212
|
export type HtmlTags = string | HtmlTagObject | (string | HtmlTagObject)[];
|
|
196
213
|
|
|
197
214
|
export interface Props extends LoadContext, InjectedHtmlTags {
|
|
198
|
-
siteMetadata: DocusaurusSiteMetadata;
|
|
199
|
-
routes: RouteConfig[];
|
|
200
|
-
routesPaths: string[];
|
|
201
|
-
plugins:
|
|
215
|
+
readonly siteMetadata: DocusaurusSiteMetadata;
|
|
216
|
+
readonly routes: RouteConfig[];
|
|
217
|
+
readonly routesPaths: string[];
|
|
218
|
+
readonly plugins: LoadedPlugin[];
|
|
202
219
|
}
|
|
203
220
|
|
|
204
221
|
export interface PluginContentLoadedActions {
|
|
@@ -219,7 +236,7 @@ export type AllContent = Record<
|
|
|
219
236
|
// TODO improve type (not exposed by postcss-loader)
|
|
220
237
|
export type PostCssOptions = Record<string, unknown> & {plugins: unknown[]};
|
|
221
238
|
|
|
222
|
-
export interface Plugin<Content> {
|
|
239
|
+
export interface Plugin<Content = unknown> {
|
|
223
240
|
name: string;
|
|
224
241
|
loadContent?(): Promise<Content>;
|
|
225
242
|
contentLoaded?({
|
|
@@ -229,14 +246,16 @@ export interface Plugin<Content> {
|
|
|
229
246
|
content: Content; // the content loaded by this plugin instance
|
|
230
247
|
allContent: AllContent; // content loaded by ALL the plugins
|
|
231
248
|
actions: PluginContentLoadedActions;
|
|
232
|
-
}): void
|
|
249
|
+
}): Promise<void>;
|
|
233
250
|
routesLoaded?(routes: RouteConfig[]): void; // TODO remove soon, deprecated (alpha-60)
|
|
234
251
|
postBuild?(props: Props): void;
|
|
235
252
|
postStart?(props: Props): void;
|
|
253
|
+
// TODO refactor the configureWebpack API surface: use an object instead of multiple params (requires breaking change)
|
|
236
254
|
configureWebpack?(
|
|
237
255
|
config: Configuration,
|
|
238
256
|
isServer: boolean,
|
|
239
257
|
utils: ConfigureWebpackUtils,
|
|
258
|
+
content: Content,
|
|
240
259
|
): Configuration & {mergeStrategy?: ConfigureWebpackFnMergeStrategy};
|
|
241
260
|
configurePostCss?(options: PostCssOptions): PostCssOptions;
|
|
242
261
|
getThemePath?(): string;
|
|
@@ -244,7 +263,7 @@ export interface Plugin<Content> {
|
|
|
244
263
|
getPathsToWatch?(): string[];
|
|
245
264
|
getClientModules?(): string[];
|
|
246
265
|
extendCli?(cli: Command): void;
|
|
247
|
-
injectHtmlTags?(): {
|
|
266
|
+
injectHtmlTags?({content}: {content: Content}): {
|
|
248
267
|
headTags?: HtmlTags;
|
|
249
268
|
preBodyTags?: HtmlTags;
|
|
250
269
|
postBodyTags?: HtmlTags;
|
|
@@ -279,6 +298,15 @@ export interface Plugin<Content> {
|
|
|
279
298
|
}): ThemeConfig;
|
|
280
299
|
}
|
|
281
300
|
|
|
301
|
+
export type InitializedPlugin<Content = unknown> = Plugin<Content> & {
|
|
302
|
+
readonly options: PluginOptions;
|
|
303
|
+
readonly version: DocusaurusPluginVersionInformation;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export type LoadedPlugin<Content = unknown> = InitializedPlugin<Content> & {
|
|
307
|
+
readonly content: Content;
|
|
308
|
+
};
|
|
309
|
+
|
|
282
310
|
export type PluginModule = {
|
|
283
311
|
<T, X>(context: LoadContext, options: T): Plugin<X>;
|
|
284
312
|
validateOptions?<T>(data: OptionValidationContext<T>): T;
|
|
@@ -331,9 +359,11 @@ export interface RouteConfig {
|
|
|
331
359
|
routes?: RouteConfig[];
|
|
332
360
|
exact?: boolean;
|
|
333
361
|
priority?: number;
|
|
362
|
+
[propName: string]: unknown;
|
|
334
363
|
}
|
|
335
364
|
|
|
336
|
-
|
|
365
|
+
// Aliases used for Webpack resolution (when using docusaurus swizzle)
|
|
366
|
+
export interface ThemeAliases {
|
|
337
367
|
[alias: string]: string;
|
|
338
368
|
}
|
|
339
369
|
|
|
@@ -403,4 +433,5 @@ export interface TOCItem {
|
|
|
403
433
|
readonly value: string;
|
|
404
434
|
readonly id: string;
|
|
405
435
|
readonly children: TOCItem[];
|
|
436
|
+
readonly level: number;
|
|
406
437
|
}
|
package/tsconfig.json
ADDED
package/src/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/* eslint-disable */
|
|
9
|
-
'use strict';
|
|
10
|
-
Object.defineProperty(exports, '__esModule', {value: true});
|