@docusaurus/types 2.0.0-beta.7babfe036 → 2.0.0-beta.8

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 CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/types",
3
- "version": "2.0.0-beta.7babfe036",
3
+ "version": "2.0.0-beta.8",
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.4.0",
20
+ "joi": "^17.4.2",
22
21
  "querystring": "0.2.0",
22
+ "utility-types": "^3.10.0",
23
23
  "webpack": "^5.40.0",
24
24
  "webpack-merge": "^5.8.0"
25
25
  },
26
- "gitHead": "3f4ee03e60c4343e3fe7fa29d0200efda0d66bd5"
26
+ "gitHead": "4f9b8d76d1eab9f20ddfad9865a1388ea2ce1c9c"
27
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,6 +22,7 @@ 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;
@@ -70,6 +70,19 @@ 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 file
75
+ // 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.
@@ -127,7 +140,10 @@ export interface DocusaurusContext {
127
140
  globalData: Record<string, unknown>;
128
141
  i18n: I18n;
129
142
  codeTranslations: Record<string, string>;
130
- isClient: boolean;
143
+
144
+ // Don't put mutable values here, to avoid triggering re-renders
145
+ // We could reconsider that choice if context selectors are implemented
146
+ // isBrowser: boolean; // Not here on purpose!
131
147
  }
132
148
 
133
149
  export interface Preset {
@@ -195,10 +211,10 @@ export interface InjectedHtmlTags {
195
211
  export type HtmlTags = string | HtmlTagObject | (string | HtmlTagObject)[];
196
212
 
197
213
  export interface Props extends LoadContext, InjectedHtmlTags {
198
- siteMetadata: DocusaurusSiteMetadata;
199
- routes: RouteConfig[];
200
- routesPaths: string[];
201
- plugins: LoadedPlugin[];
214
+ readonly siteMetadata: DocusaurusSiteMetadata;
215
+ readonly routes: RouteConfig[];
216
+ readonly routesPaths: string[];
217
+ readonly plugins: LoadedPlugin[];
202
218
  }
203
219
 
204
220
  export interface PluginContentLoadedActions {
@@ -229,7 +245,7 @@ export interface Plugin<Content = unknown> {
229
245
  content: Content; // the content loaded by this plugin instance
230
246
  allContent: AllContent; // content loaded by ALL the plugins
231
247
  actions: PluginContentLoadedActions;
232
- }): void;
248
+ }): Promise<void>;
233
249
  routesLoaded?(routes: RouteConfig[]): void; // TODO remove soon, deprecated (alpha-60)
234
250
  postBuild?(props: Props): void;
235
251
  postStart?(props: Props): void;
@@ -246,11 +262,7 @@ export interface Plugin<Content = unknown> {
246
262
  getPathsToWatch?(): string[];
247
263
  getClientModules?(): string[];
248
264
  extendCli?(cli: Command): void;
249
- injectHtmlTags?({
250
- content,
251
- }: {
252
- content: Content;
253
- }): {
265
+ injectHtmlTags?({content}: {content: Content}): {
254
266
  headTags?: HtmlTags;
255
267
  preBodyTags?: HtmlTags;
256
268
  postBodyTags?: HtmlTags;
@@ -346,7 +358,7 @@ export interface RouteConfig {
346
358
  routes?: RouteConfig[];
347
359
  exact?: boolean;
348
360
  priority?: number;
349
- [propName: string]: any;
361
+ [propName: string]: unknown;
350
362
  }
351
363
 
352
364
  // Aliases used for Webpack resolution (when using docusaurus swizzle)
@@ -420,4 +432,5 @@ export interface TOCItem {
420
432
  readonly value: string;
421
433
  readonly id: string;
422
434
  readonly children: TOCItem[];
435
+ readonly level: number;
423
436
  }
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});