@docusaurus/types 2.0.0-beta.15a2b59f9 → 2.0.0-beta.17
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 +6 -6
- package/src/index.d.ts +111 -68
- package/src/index.js +0 -10
- package/tsconfig.json +0 -7
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.17",
|
|
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"
|
|
@@ -18,10 +17,11 @@
|
|
|
18
17
|
},
|
|
19
18
|
"dependencies": {
|
|
20
19
|
"commander": "^5.1.0",
|
|
21
|
-
"joi": "^17.
|
|
22
|
-
"querystring": "0.2.
|
|
23
|
-
"
|
|
20
|
+
"joi": "^17.6.0",
|
|
21
|
+
"querystring": "0.2.1",
|
|
22
|
+
"utility-types": "^3.10.0",
|
|
23
|
+
"webpack": "^5.69.1",
|
|
24
24
|
"webpack-merge": "^5.8.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "0032c0b0480083227af2e1b4da2d3ee6ce992403"
|
|
27
27
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -5,17 +5,13 @@
|
|
|
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
|
-
import type {
|
|
9
|
+
import type {CustomizeRuleString} from 'webpack-merge/dist/types';
|
|
10
|
+
import type {CommanderStatic} from 'commander';
|
|
12
11
|
import type {ParsedUrlQueryInput} from 'querystring';
|
|
13
12
|
import type Joi from 'joi';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// For type retro-compatible webpack-merge upgrade: we used string literals before)
|
|
17
|
-
// see https://github.com/survivejs/webpack-merge/issues/179
|
|
18
|
-
type MergeStrategy = 'match' | 'merge' | 'append' | 'prepend' | 'replace';
|
|
13
|
+
import type {Overwrite, DeepPartial} from 'utility-types';
|
|
14
|
+
import type {Location} from 'history';
|
|
19
15
|
|
|
20
16
|
export type ReportingSeverity = 'ignore' | 'log' | 'warn' | 'error' | 'throw';
|
|
21
17
|
|
|
@@ -23,14 +19,16 @@ export type ThemeConfig = {
|
|
|
23
19
|
[key: string]: unknown;
|
|
24
20
|
};
|
|
25
21
|
|
|
22
|
+
// Docusaurus config, after validation/normalization
|
|
26
23
|
export interface DocusaurusConfig {
|
|
27
24
|
baseUrl: string;
|
|
28
25
|
baseUrlIssueBanner: boolean;
|
|
29
26
|
favicon?: string;
|
|
30
|
-
tagline
|
|
27
|
+
tagline: string;
|
|
31
28
|
title: string;
|
|
32
29
|
url: string;
|
|
33
|
-
// trailingSlash undefined = legacy retrocompatible behavior
|
|
30
|
+
// trailingSlash undefined = legacy retrocompatible behavior
|
|
31
|
+
// /file => /file/index.html
|
|
34
32
|
trailingSlash: boolean | undefined;
|
|
35
33
|
i18n: I18nConfig;
|
|
36
34
|
onBrokenLinks: ReportingSeverity;
|
|
@@ -39,6 +37,7 @@ export interface DocusaurusConfig {
|
|
|
39
37
|
noIndex: boolean;
|
|
40
38
|
organizationName?: string;
|
|
41
39
|
projectName?: string;
|
|
40
|
+
deploymentBranch?: string;
|
|
42
41
|
githubHost?: string;
|
|
43
42
|
githubPort?: string;
|
|
44
43
|
plugins?: PluginConfig[];
|
|
@@ -57,6 +56,7 @@ export interface DocusaurusConfig {
|
|
|
57
56
|
)[];
|
|
58
57
|
clientModules?: string[];
|
|
59
58
|
ssrTemplate?: string;
|
|
59
|
+
staticDirectories: string[];
|
|
60
60
|
stylesheets?: (
|
|
61
61
|
| string
|
|
62
62
|
| {
|
|
@@ -70,10 +70,24 @@ export interface DocusaurusConfig {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
// Docusaurus config, as provided by the user (partial/unnormalized)
|
|
74
|
+
// This type is used to provide type-safety / IDE auto-complete on the config
|
|
75
|
+
// file. See https://docusaurus.io/docs/typescript-support
|
|
76
|
+
export type Config = Overwrite<
|
|
77
|
+
Partial<DocusaurusConfig>,
|
|
78
|
+
{
|
|
79
|
+
title: Required<DocusaurusConfig['title']>;
|
|
80
|
+
url: Required<DocusaurusConfig['url']>;
|
|
81
|
+
baseUrl: Required<DocusaurusConfig['baseUrl']>;
|
|
82
|
+
i18n?: DeepPartial<DocusaurusConfig['i18n']>;
|
|
83
|
+
}
|
|
84
|
+
>;
|
|
85
|
+
|
|
73
86
|
/**
|
|
74
87
|
* - `type: 'package'`, plugin is in a different package.
|
|
75
88
|
* - `type: 'project'`, plugin is in the same docusaurus project.
|
|
76
|
-
* - `type: 'local'`, none of plugin's ancestor
|
|
89
|
+
* - `type: 'local'`, none of the plugin's ancestor directories contains a
|
|
90
|
+
* package.json.
|
|
77
91
|
* - `type: 'synthetic'`, docusaurus generated internal plugin.
|
|
78
92
|
*/
|
|
79
93
|
export type DocusaurusPluginVersionInformation =
|
|
@@ -105,6 +119,7 @@ export type TranslationFiles = TranslationFile[];
|
|
|
105
119
|
|
|
106
120
|
export type I18nLocaleConfig = {
|
|
107
121
|
label: string;
|
|
122
|
+
htmlLang: string;
|
|
108
123
|
direction: string;
|
|
109
124
|
};
|
|
110
125
|
|
|
@@ -127,7 +142,10 @@ export interface DocusaurusContext {
|
|
|
127
142
|
globalData: Record<string, unknown>;
|
|
128
143
|
i18n: I18n;
|
|
129
144
|
codeTranslations: Record<string, string>;
|
|
130
|
-
|
|
145
|
+
|
|
146
|
+
// Don't put mutable values here, to avoid triggering re-renders
|
|
147
|
+
// We could reconsider that choice if context selectors are implemented
|
|
148
|
+
// isBrowser: boolean; // Not here on purpose!
|
|
131
149
|
}
|
|
132
150
|
|
|
133
151
|
export interface Preset {
|
|
@@ -135,6 +153,14 @@ export interface Preset {
|
|
|
135
153
|
themes?: PluginConfig[];
|
|
136
154
|
}
|
|
137
155
|
|
|
156
|
+
export type PresetModule = {
|
|
157
|
+
<T>(context: LoadContext, presetOptions: T): Preset;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type ImportedPresetModule = PresetModule & {
|
|
161
|
+
default?: PresetModule;
|
|
162
|
+
};
|
|
163
|
+
|
|
138
164
|
export type PresetConfig =
|
|
139
165
|
| [string, Record<string, unknown>]
|
|
140
166
|
| [string]
|
|
@@ -182,7 +208,7 @@ export interface LoadContext {
|
|
|
182
208
|
outDir: string;
|
|
183
209
|
baseUrl: string; // TODO to remove: useless, there's already siteConfig.baseUrl!
|
|
184
210
|
i18n: I18n;
|
|
185
|
-
ssrTemplate
|
|
211
|
+
ssrTemplate: string;
|
|
186
212
|
codeTranslations: Record<string, string>;
|
|
187
213
|
}
|
|
188
214
|
|
|
@@ -195,17 +221,17 @@ export interface InjectedHtmlTags {
|
|
|
195
221
|
export type HtmlTags = string | HtmlTagObject | (string | HtmlTagObject)[];
|
|
196
222
|
|
|
197
223
|
export interface Props extends LoadContext, InjectedHtmlTags {
|
|
198
|
-
siteMetadata: DocusaurusSiteMetadata;
|
|
199
|
-
routes: RouteConfig[];
|
|
200
|
-
routesPaths: string[];
|
|
201
|
-
plugins: LoadedPlugin[];
|
|
224
|
+
readonly siteMetadata: DocusaurusSiteMetadata;
|
|
225
|
+
readonly routes: RouteConfig[];
|
|
226
|
+
readonly routesPaths: string[];
|
|
227
|
+
readonly plugins: LoadedPlugin[];
|
|
202
228
|
}
|
|
203
229
|
|
|
204
230
|
export interface PluginContentLoadedActions {
|
|
205
|
-
addRoute(config: RouteConfig)
|
|
231
|
+
addRoute: (config: RouteConfig) => void;
|
|
206
232
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
|
-
createData(name: string, data: any)
|
|
208
|
-
setGlobalData<T = unknown>(data: T)
|
|
233
|
+
createData: (name: string, data: any) => Promise<string>;
|
|
234
|
+
setGlobalData: <T = unknown>(data: T) => void;
|
|
209
235
|
}
|
|
210
236
|
|
|
211
237
|
export type AllContent = Record<
|
|
@@ -221,34 +247,32 @@ export type PostCssOptions = Record<string, unknown> & {plugins: unknown[]};
|
|
|
221
247
|
|
|
222
248
|
export interface Plugin<Content = unknown> {
|
|
223
249
|
name: string;
|
|
224
|
-
loadContent
|
|
225
|
-
contentLoaded
|
|
250
|
+
loadContent?: () => Promise<Content>;
|
|
251
|
+
contentLoaded?: ({
|
|
226
252
|
content,
|
|
227
253
|
actions,
|
|
228
254
|
}: {
|
|
229
255
|
content: Content; // the content loaded by this plugin instance
|
|
230
256
|
allContent: AllContent; // content loaded by ALL the plugins
|
|
231
257
|
actions: PluginContentLoadedActions;
|
|
232
|
-
})
|
|
233
|
-
routesLoaded
|
|
234
|
-
postBuild
|
|
235
|
-
|
|
236
|
-
//
|
|
237
|
-
configureWebpack
|
|
258
|
+
}) => Promise<void>;
|
|
259
|
+
routesLoaded?: (routes: RouteConfig[]) => void; // TODO remove soon, deprecated (alpha-60)
|
|
260
|
+
postBuild?: (props: Props & {content: Content}) => Promise<void>;
|
|
261
|
+
// TODO refactor the configureWebpack API surface: use an object instead of
|
|
262
|
+
// multiple params (requires breaking change)
|
|
263
|
+
configureWebpack?: (
|
|
238
264
|
config: Configuration,
|
|
239
265
|
isServer: boolean,
|
|
240
266
|
utils: ConfigureWebpackUtils,
|
|
241
267
|
content: Content,
|
|
242
|
-
)
|
|
243
|
-
configurePostCss
|
|
244
|
-
getThemePath
|
|
245
|
-
getTypeScriptThemePath
|
|
246
|
-
getPathsToWatch
|
|
247
|
-
getClientModules
|
|
248
|
-
extendCli
|
|
249
|
-
injectHtmlTags
|
|
250
|
-
content: Content,
|
|
251
|
-
}): {
|
|
268
|
+
) => Configuration & {mergeStrategy?: ConfigureWebpackFnMergeStrategy};
|
|
269
|
+
configurePostCss?: (options: PostCssOptions) => PostCssOptions;
|
|
270
|
+
getThemePath?: () => string;
|
|
271
|
+
getTypeScriptThemePath?: () => string;
|
|
272
|
+
getPathsToWatch?: () => string[];
|
|
273
|
+
getClientModules?: () => string[];
|
|
274
|
+
extendCli?: (cli: CommanderStatic) => void;
|
|
275
|
+
injectHtmlTags?: ({content}: {content: Content}) => {
|
|
252
276
|
headTags?: HtmlTags;
|
|
253
277
|
preBodyTags?: HtmlTags;
|
|
254
278
|
postBodyTags?: HtmlTags;
|
|
@@ -256,31 +280,31 @@ export interface Plugin<Content = unknown> {
|
|
|
256
280
|
// TODO before/afterDevServer implementation
|
|
257
281
|
|
|
258
282
|
// translations
|
|
259
|
-
getTranslationFiles
|
|
283
|
+
getTranslationFiles?: ({
|
|
260
284
|
content,
|
|
261
285
|
}: {
|
|
262
286
|
content: Content;
|
|
263
|
-
})
|
|
264
|
-
getDefaultCodeTranslationMessages
|
|
287
|
+
}) => Promise<TranslationFiles>;
|
|
288
|
+
getDefaultCodeTranslationMessages?: () => Promise<
|
|
265
289
|
Record<
|
|
266
290
|
string, // id
|
|
267
291
|
string // message
|
|
268
292
|
>
|
|
269
293
|
>;
|
|
270
|
-
translateContent
|
|
294
|
+
translateContent?: ({
|
|
271
295
|
content,
|
|
272
296
|
translationFiles,
|
|
273
297
|
}: {
|
|
274
298
|
content: Content; // the content loaded by this plugin instance
|
|
275
299
|
translationFiles: TranslationFiles;
|
|
276
|
-
})
|
|
277
|
-
translateThemeConfig
|
|
300
|
+
}) => Content;
|
|
301
|
+
translateThemeConfig?: ({
|
|
278
302
|
themeConfig,
|
|
279
303
|
translationFiles,
|
|
280
304
|
}: {
|
|
281
305
|
themeConfig: ThemeConfig;
|
|
282
306
|
translationFiles: TranslationFiles;
|
|
283
|
-
})
|
|
307
|
+
}) => ThemeConfig;
|
|
284
308
|
}
|
|
285
309
|
|
|
286
310
|
export type InitializedPlugin<Content = unknown> = Plugin<Content> & {
|
|
@@ -292,11 +316,30 @@ export type LoadedPlugin<Content = unknown> = InitializedPlugin<Content> & {
|
|
|
292
316
|
readonly content: Content;
|
|
293
317
|
};
|
|
294
318
|
|
|
319
|
+
export type SwizzleAction = 'eject' | 'wrap';
|
|
320
|
+
export type SwizzleActionStatus = 'safe' | 'unsafe' | 'forbidden';
|
|
321
|
+
|
|
322
|
+
export type SwizzleComponentConfig = {
|
|
323
|
+
actions: Record<SwizzleAction, SwizzleActionStatus>;
|
|
324
|
+
description?: string;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export type SwizzleConfig = {
|
|
328
|
+
components: Record<string, SwizzleComponentConfig>;
|
|
329
|
+
// Other settings could be added here,
|
|
330
|
+
// For example: the ability to declare the config as exhaustive
|
|
331
|
+
// so that we can emit errors
|
|
332
|
+
};
|
|
333
|
+
|
|
295
334
|
export type PluginModule = {
|
|
296
|
-
<
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
335
|
+
<Options, Content>(context: LoadContext, options: Options):
|
|
336
|
+
| Plugin<Content>
|
|
337
|
+
| Promise<Plugin<Content>>;
|
|
338
|
+
validateOptions?: <T>(data: OptionValidationContext<T>) => T;
|
|
339
|
+
validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
|
|
340
|
+
|
|
341
|
+
getSwizzleComponentList?: () => string[] | undefined; // TODO deprecate this one later
|
|
342
|
+
getSwizzleConfig?: () => SwizzleConfig | undefined;
|
|
300
343
|
};
|
|
301
344
|
|
|
302
345
|
export type ImportedPluginModule = PluginModule & {
|
|
@@ -304,7 +347,10 @@ export type ImportedPluginModule = PluginModule & {
|
|
|
304
347
|
};
|
|
305
348
|
|
|
306
349
|
export type ConfigureWebpackFn = Plugin<unknown>['configureWebpack'];
|
|
307
|
-
export type ConfigureWebpackFnMergeStrategy = Record<
|
|
350
|
+
export type ConfigureWebpackFnMergeStrategy = Record<
|
|
351
|
+
string,
|
|
352
|
+
CustomizeRuleString
|
|
353
|
+
>;
|
|
308
354
|
export type ConfigurePostCssFn = Plugin<unknown>['configurePostCss'];
|
|
309
355
|
|
|
310
356
|
export type PluginOptions = {id?: string} & Record<string, unknown>;
|
|
@@ -344,6 +390,7 @@ export interface RouteConfig {
|
|
|
344
390
|
routes?: RouteConfig[];
|
|
345
391
|
exact?: boolean;
|
|
346
392
|
priority?: number;
|
|
393
|
+
[propName: string]: unknown;
|
|
347
394
|
}
|
|
348
395
|
|
|
349
396
|
// Aliases used for Webpack resolution (when using docusaurus swizzle)
|
|
@@ -362,18 +409,6 @@ export interface ConfigureWebpackUtils {
|
|
|
362
409
|
isServer: boolean;
|
|
363
410
|
babelOptions?: Record<string, unknown>;
|
|
364
411
|
}) => RuleSetRule;
|
|
365
|
-
|
|
366
|
-
// TODO deprecated: remove before end of 2021?
|
|
367
|
-
getCacheLoader: (
|
|
368
|
-
isServer: boolean,
|
|
369
|
-
cacheOptions?: Record<string, unknown>,
|
|
370
|
-
) => RuleSetRule | null;
|
|
371
|
-
|
|
372
|
-
// TODO deprecated: remove before end of 2021?
|
|
373
|
-
getBabelLoader: (
|
|
374
|
-
isServer: boolean,
|
|
375
|
-
options?: Record<string, unknown>,
|
|
376
|
-
) => RuleSetRule;
|
|
377
412
|
}
|
|
378
413
|
|
|
379
414
|
interface HtmlTagObject {
|
|
@@ -381,9 +416,7 @@ interface HtmlTagObject {
|
|
|
381
416
|
* Attributes of the html tag
|
|
382
417
|
* E.g. `{'disabled': true, 'value': 'demo', 'rel': 'preconnect'}`
|
|
383
418
|
*/
|
|
384
|
-
attributes?:
|
|
385
|
-
[attributeName: string]: string | boolean;
|
|
386
|
-
};
|
|
419
|
+
attributes?: Partial<Record<string, string | boolean>>;
|
|
387
420
|
/**
|
|
388
421
|
* The tag name e.g. `div`, `script`, `link`, `meta`
|
|
389
422
|
*/
|
|
@@ -413,8 +446,18 @@ export interface ThemeConfigValidationContext<T> {
|
|
|
413
446
|
themeConfig: Partial<T>;
|
|
414
447
|
}
|
|
415
448
|
|
|
416
|
-
export
|
|
449
|
+
export type TOCItem = {
|
|
417
450
|
readonly value: string;
|
|
418
451
|
readonly id: string;
|
|
419
|
-
readonly
|
|
420
|
-
}
|
|
452
|
+
readonly level: number;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
export type RouteChunksTree = {[x: string | number]: string | RouteChunksTree};
|
|
456
|
+
|
|
457
|
+
export type ClientModule = {
|
|
458
|
+
onRouteUpdate?: (args: {
|
|
459
|
+
previousLocation: Location | null;
|
|
460
|
+
location: Location;
|
|
461
|
+
}) => void;
|
|
462
|
+
onRouteUpdateDelayed?: (args: {location: Location}) => void;
|
|
463
|
+
};
|
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});
|