@docusaurus/types 3.5.2 → 3.6.0
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 +3 -3
- package/src/bundler.d.ts +17 -0
- package/src/config.d.ts +29 -4
- package/src/context.d.ts +6 -0
- package/src/index.d.ts +3 -0
- package/src/plugin.d.ts +10 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/types",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Common types for Docusaurus packages.",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"joi": "^17.9.2",
|
|
21
21
|
"react-helmet-async": "^1.3.0",
|
|
22
22
|
"utility-types": "^3.10.0",
|
|
23
|
-
"webpack": "^5.
|
|
23
|
+
"webpack": "^5.95.0",
|
|
24
24
|
"webpack-merge": "^5.9.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": "^18.0.0",
|
|
28
28
|
"react-dom": "^18.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "05bba6d4f495ef6b0bec5d41453932bb97981830"
|
|
31
31
|
}
|
package/src/bundler.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
import type webpack from 'webpack';
|
|
9
|
+
|
|
10
|
+
// We use Webpack and Rspack interchangeably because most Rspack APIs are
|
|
11
|
+
// compatible with Webpack. So it's ok to use Webpack types for Rspack too.
|
|
12
|
+
// When compatibility doesn't work, use "CurrentBundler.name"
|
|
13
|
+
// See https://github.com/facebook/docusaurus/pull/10402
|
|
14
|
+
export type CurrentBundler = {
|
|
15
|
+
name: 'webpack' | 'rspack';
|
|
16
|
+
instance: typeof webpack;
|
|
17
|
+
};
|
package/src/config.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type {SiteStorage} from './context';
|
|
9
9
|
import type {RuleSetRule} from 'webpack';
|
|
10
|
-
import type {
|
|
10
|
+
import type {DeepPartial, Overwrite} from 'utility-types';
|
|
11
11
|
import type {I18nConfig} from './i18n';
|
|
12
12
|
import type {PluginConfig, PresetConfig, HtmlTagObject} from './plugin';
|
|
13
13
|
|
|
@@ -123,7 +123,18 @@ export type StorageConfig = {
|
|
|
123
123
|
namespace: boolean | string;
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
export type FasterConfig = {
|
|
127
|
+
swcJsLoader: boolean;
|
|
128
|
+
swcJsMinimizer: boolean;
|
|
129
|
+
swcHtmlMinimizer: boolean;
|
|
130
|
+
lightningCssMinimizer: boolean;
|
|
131
|
+
mdxCrossCompilerCache: boolean;
|
|
132
|
+
rspackBundler: boolean;
|
|
133
|
+
};
|
|
134
|
+
|
|
126
135
|
export type FutureConfig = {
|
|
136
|
+
experimental_faster: FasterConfig;
|
|
137
|
+
|
|
127
138
|
experimental_storage: StorageConfig;
|
|
128
139
|
|
|
129
140
|
/**
|
|
@@ -392,6 +403,7 @@ export type DocusaurusConfig = {
|
|
|
392
403
|
*
|
|
393
404
|
* @see https://docusaurus.io/docs/api/docusaurus-config#ssrTemplate
|
|
394
405
|
*/
|
|
406
|
+
// TODO Docusaurus v4 - rename to ssgTemplate?
|
|
395
407
|
ssrTemplate?: string;
|
|
396
408
|
/**
|
|
397
409
|
* Will be used as title delimiter in the generated `<title>` tag.
|
|
@@ -416,6 +428,9 @@ export type DocusaurusConfig = {
|
|
|
416
428
|
* Babel loader and preset; otherwise, you can provide your custom Webpack
|
|
417
429
|
* rule set.
|
|
418
430
|
*/
|
|
431
|
+
// TODO Docusaurus v4
|
|
432
|
+
// Use an object type ({isServer}) so that it conforms to jsLoaderFactory
|
|
433
|
+
// Eventually deprecate this if swc loader becomes stable?
|
|
419
434
|
jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule);
|
|
420
435
|
};
|
|
421
436
|
/** Markdown-related options. */
|
|
@@ -423,11 +438,21 @@ export type DocusaurusConfig = {
|
|
|
423
438
|
};
|
|
424
439
|
|
|
425
440
|
/**
|
|
426
|
-
* Docusaurus config, as provided by the user (partial/
|
|
441
|
+
* Docusaurus config, as provided by the user (partial/un-normalized). This type
|
|
427
442
|
* is used to provide type-safety / IDE auto-complete on the config file.
|
|
428
443
|
* @see https://docusaurus.io/docs/typescript-support
|
|
429
444
|
*/
|
|
430
|
-
export type Config =
|
|
445
|
+
export type Config = Overwrite<
|
|
431
446
|
DeepPartial<DocusaurusConfig>,
|
|
432
|
-
|
|
447
|
+
{
|
|
448
|
+
title: DocusaurusConfig['title'];
|
|
449
|
+
url: DocusaurusConfig['url'];
|
|
450
|
+
baseUrl: DocusaurusConfig['baseUrl'];
|
|
451
|
+
future?: Overwrite<
|
|
452
|
+
DeepPartial<FutureConfig>,
|
|
453
|
+
{
|
|
454
|
+
experimental_faster?: boolean | FasterConfig;
|
|
455
|
+
}
|
|
456
|
+
>;
|
|
457
|
+
}
|
|
433
458
|
>;
|
package/src/context.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {DocusaurusConfig} from './config';
|
|
|
8
8
|
import type {CodeTranslations, I18n} from './i18n';
|
|
9
9
|
import type {LoadedPlugin, PluginVersionInformation} from './plugin';
|
|
10
10
|
import type {PluginRouteConfig} from './routing';
|
|
11
|
+
import type {CurrentBundler} from './bundler';
|
|
11
12
|
|
|
12
13
|
export type DocusaurusContext = {
|
|
13
14
|
siteConfig: DocusaurusConfig;
|
|
@@ -74,6 +75,11 @@ export type LoadContext = {
|
|
|
74
75
|
* Defines the default browser storage behavior for a site
|
|
75
76
|
*/
|
|
76
77
|
siteStorage: SiteStorage;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The bundler used to build the site (Webpack or Rspack)
|
|
81
|
+
*/
|
|
82
|
+
currentBundler: CurrentBundler;
|
|
77
83
|
};
|
|
78
84
|
|
|
79
85
|
export type Props = LoadContext & {
|
package/src/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export {
|
|
|
14
14
|
ParseFrontMatter,
|
|
15
15
|
DocusaurusConfig,
|
|
16
16
|
FutureConfig,
|
|
17
|
+
FasterConfig,
|
|
17
18
|
StorageConfig,
|
|
18
19
|
Config,
|
|
19
20
|
} from './config';
|
|
@@ -72,6 +73,8 @@ export {
|
|
|
72
73
|
HtmlTags,
|
|
73
74
|
} from './plugin';
|
|
74
75
|
|
|
76
|
+
export {CurrentBundler} from './bundler';
|
|
77
|
+
|
|
75
78
|
export {
|
|
76
79
|
RouteConfig,
|
|
77
80
|
PluginRouteConfig,
|
package/src/plugin.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import type {ThemeConfig} from './config';
|
|
|
15
15
|
import type {LoadContext, Props} from './context';
|
|
16
16
|
import type {SwizzleConfig} from './swizzle';
|
|
17
17
|
import type {RouteConfig} from './routing';
|
|
18
|
+
import type {CurrentBundler} from './bundler';
|
|
18
19
|
|
|
19
20
|
export type PluginOptions = {id?: string} & {[key: string]: unknown};
|
|
20
21
|
|
|
@@ -54,13 +55,16 @@ export type PluginContentLoadedActions = {
|
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
export type ConfigureWebpackUtils = {
|
|
58
|
+
currentBundler: CurrentBundler;
|
|
57
59
|
getStyleLoaders: (
|
|
58
60
|
isServer: boolean,
|
|
59
61
|
cssOptions: {[key: string]: unknown},
|
|
60
62
|
) => RuleSetRule[];
|
|
61
63
|
getJSLoader: (options: {
|
|
62
64
|
isServer: boolean;
|
|
63
|
-
|
|
65
|
+
// TODO Docusaurus v4 remove?
|
|
66
|
+
// not ideal because JS Loader might not use Babel...
|
|
67
|
+
babelOptions?: string | {[key: string]: unknown};
|
|
64
68
|
}) => RuleSetRule;
|
|
65
69
|
};
|
|
66
70
|
|
|
@@ -122,12 +126,13 @@ export type Plugin<Content = unknown> = {
|
|
|
122
126
|
head: {[location: string]: HelmetServerState};
|
|
123
127
|
},
|
|
124
128
|
) => Promise<void> | void;
|
|
125
|
-
// TODO
|
|
126
|
-
//
|
|
129
|
+
// TODO Docusaurus v4 ?
|
|
130
|
+
// refactor the configureWebpack API surface: use an object instead of
|
|
131
|
+
// multiple params (requires breaking change)
|
|
127
132
|
configureWebpack?: (
|
|
128
133
|
config: WebpackConfiguration,
|
|
129
134
|
isServer: boolean,
|
|
130
|
-
|
|
135
|
+
configureWebpackUtils: ConfigureWebpackUtils,
|
|
131
136
|
content: Content,
|
|
132
137
|
) => WebpackConfiguration & {
|
|
133
138
|
mergeStrategy?: {
|
|
@@ -191,9 +196,8 @@ export type LoadedPlugin = InitializedPlugin & {
|
|
|
191
196
|
export type PluginModule<Content = unknown> = {
|
|
192
197
|
(context: LoadContext, options: unknown):
|
|
193
198
|
| Plugin<Content>
|
|
194
|
-
| Promise<Plugin<Content>>
|
|
195
199
|
| null
|
|
196
|
-
| Promise<null>;
|
|
200
|
+
| Promise<Plugin<Content> | null>;
|
|
197
201
|
|
|
198
202
|
validateOptions?: <T, U>(data: OptionValidationContext<T, U>) => U;
|
|
199
203
|
validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
|