@docusaurus/types 2.0.0-beta.15 → 2.0.0-beta.16

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.d.ts +45 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/types",
3
- "version": "2.0.0-beta.15",
3
+ "version": "2.0.0-beta.16",
4
4
  "description": "Common types for Docusaurus packages.",
5
5
  "types": "./src/index.d.ts",
6
6
  "publishConfig": {
@@ -17,11 +17,11 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "commander": "^5.1.0",
20
- "joi": "^17.4.2",
20
+ "joi": "^17.6.0",
21
21
  "querystring": "0.2.1",
22
22
  "utility-types": "^3.10.0",
23
- "webpack": "^5.61.0",
23
+ "webpack": "^5.69.1",
24
24
  "webpack-merge": "^5.8.0"
25
25
  },
26
- "gitHead": "32ec84ef3c0a238436e913b2026ab809e5750fa8"
26
+ "gitHead": "eb43c4d4f95a4fb97dc9bb9dc615413e0dc2e1e7"
27
27
  }
package/src/index.d.ts CHANGED
@@ -6,15 +6,12 @@
6
6
  */
7
7
 
8
8
  import type {RuleSetRule, Configuration} from 'webpack';
9
- import type {Command} from 'commander';
9
+ import type {CustomizeRuleString} from 'webpack-merge/dist/types';
10
+ import type {CommanderStatic} from 'commander';
10
11
  import type {ParsedUrlQueryInput} from 'querystring';
11
12
  import type Joi from 'joi';
12
13
  import type {Overwrite, DeepPartial} from 'utility-types';
13
-
14
- // Convert webpack-merge webpack-merge enum to union type
15
- // For type retro-compatible webpack-merge upgrade: we used string literals before)
16
- // see https://github.com/survivejs/webpack-merge/issues/179
17
- type MergeStrategy = 'match' | 'merge' | 'append' | 'prepend' | 'replace';
14
+ import type {Location} from 'history';
18
15
 
19
16
  export type ReportingSeverity = 'ignore' | 'log' | 'warn' | 'error' | 'throw';
20
17
 
@@ -27,10 +24,11 @@ export interface DocusaurusConfig {
27
24
  baseUrl: string;
28
25
  baseUrlIssueBanner: boolean;
29
26
  favicon?: string;
30
- tagline?: string;
27
+ tagline: string;
31
28
  title: string;
32
29
  url: string;
33
- // trailingSlash undefined = legacy retrocompatible behavior => /file => /file/index.html
30
+ // trailingSlash undefined = legacy retrocompatible behavior
31
+ // /file => /file/index.html
34
32
  trailingSlash: boolean | undefined;
35
33
  i18n: I18nConfig;
36
34
  onBrokenLinks: ReportingSeverity;
@@ -73,8 +71,8 @@ export interface DocusaurusConfig {
73
71
  }
74
72
 
75
73
  // Docusaurus config, as provided by the user (partial/unnormalized)
76
- // This type is used to provide type-safety / IDE auto-complete on the config file
77
- // See https://docusaurus.io/docs/typescript-support
74
+ // This type is used to provide type-safety / IDE auto-complete on the config
75
+ // file. See https://docusaurus.io/docs/typescript-support
78
76
  export type Config = Overwrite<
79
77
  Partial<DocusaurusConfig>,
80
78
  {
@@ -88,7 +86,8 @@ export type Config = Overwrite<
88
86
  /**
89
87
  * - `type: 'package'`, plugin is in a different package.
90
88
  * - `type: 'project'`, plugin is in the same docusaurus project.
91
- * - `type: 'local'`, none of plugin's ancestor directory contains any package.json.
89
+ * - `type: 'local'`, none of the plugin's ancestor directories contains a
90
+ * package.json.
92
91
  * - `type: 'synthetic'`, docusaurus generated internal plugin.
93
92
  */
94
93
  export type DocusaurusPluginVersionInformation =
@@ -259,8 +258,8 @@ export interface Plugin<Content = unknown> {
259
258
  }) => Promise<void>;
260
259
  routesLoaded?: (routes: RouteConfig[]) => void; // TODO remove soon, deprecated (alpha-60)
261
260
  postBuild?: (props: Props & {content: Content}) => Promise<void>;
262
- postStart?: (props: Props) => void;
263
- // TODO refactor the configureWebpack API surface: use an object instead of multiple params (requires breaking change)
261
+ // TODO refactor the configureWebpack API surface: use an object instead of
262
+ // multiple params (requires breaking change)
264
263
  configureWebpack?: (
265
264
  config: Configuration,
266
265
  isServer: boolean,
@@ -272,7 +271,7 @@ export interface Plugin<Content = unknown> {
272
271
  getTypeScriptThemePath?: () => string;
273
272
  getPathsToWatch?: () => string[];
274
273
  getClientModules?: () => string[];
275
- extendCli?: (cli: Command) => void;
274
+ extendCli?: (cli: CommanderStatic) => void;
276
275
  injectHtmlTags?: ({content}: {content: Content}) => {
277
276
  headTags?: HtmlTags;
278
277
  preBodyTags?: HtmlTags;
@@ -317,13 +316,30 @@ export type LoadedPlugin<Content = unknown> = InitializedPlugin<Content> & {
317
316
  readonly content: Content;
318
317
  };
319
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
+
320
334
  export type PluginModule = {
321
335
  <Options, Content>(context: LoadContext, options: Options):
322
336
  | Plugin<Content>
323
337
  | Promise<Plugin<Content>>;
324
338
  validateOptions?: <T>(data: OptionValidationContext<T>) => T;
325
339
  validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
326
- getSwizzleComponentList?: () => string[];
340
+
341
+ getSwizzleComponentList?: () => string[] | undefined; // TODO deprecate this one later
342
+ getSwizzleConfig?: () => SwizzleConfig | undefined;
327
343
  };
328
344
 
329
345
  export type ImportedPluginModule = PluginModule & {
@@ -331,7 +347,10 @@ export type ImportedPluginModule = PluginModule & {
331
347
  };
332
348
 
333
349
  export type ConfigureWebpackFn = Plugin<unknown>['configureWebpack'];
334
- export type ConfigureWebpackFnMergeStrategy = Record<string, MergeStrategy>;
350
+ export type ConfigureWebpackFnMergeStrategy = Record<
351
+ string,
352
+ CustomizeRuleString
353
+ >;
335
354
  export type ConfigurePostCssFn = Plugin<unknown>['configurePostCss'];
336
355
 
337
356
  export type PluginOptions = {id?: string} & Record<string, unknown>;
@@ -390,18 +409,6 @@ export interface ConfigureWebpackUtils {
390
409
  isServer: boolean;
391
410
  babelOptions?: Record<string, unknown>;
392
411
  }) => RuleSetRule;
393
-
394
- // TODO deprecated: remove before end of 2021?
395
- getCacheLoader: (
396
- isServer: boolean,
397
- cacheOptions?: Record<string, unknown>,
398
- ) => RuleSetRule | null;
399
-
400
- // TODO deprecated: remove before end of 2021?
401
- getBabelLoader: (
402
- isServer: boolean,
403
- options?: Record<string, unknown>,
404
- ) => RuleSetRule;
405
412
  }
406
413
 
407
414
  interface HtmlTagObject {
@@ -439,11 +446,18 @@ export interface ThemeConfigValidationContext<T> {
439
446
  themeConfig: Partial<T>;
440
447
  }
441
448
 
442
- export interface TOCItem {
449
+ export type TOCItem = {
443
450
  readonly value: string;
444
451
  readonly id: string;
445
- readonly children: TOCItem[];
446
452
  readonly level: number;
447
- }
453
+ };
448
454
 
449
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
+ };