@docusaurus/types 2.0.0-beta.8e9b829d9 → 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 CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/types",
3
- "version": "2.0.0-beta.8e9b829d9",
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"
@@ -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",
23
- "webpack": "^5.40.0",
22
+ "utility-types": "^3.10.0",
23
+ "webpack": "^5.61.0",
24
24
  "webpack-merge": "^5.8.0"
25
25
  },
26
- "gitHead": "cb79fda03ac12835068842a7e0a86f610974eae2"
26
+ "gitHead": "8a491fc29ad002f90e97f5b5fe4178ac8fa0c4d7"
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;
@@ -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
- isClient: boolean;
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 {
@@ -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: LoadedPlugin[];
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 {
@@ -246,11 +263,7 @@ export interface Plugin<Content = unknown> {
246
263
  getPathsToWatch?(): string[];
247
264
  getClientModules?(): string[];
248
265
  extendCli?(cli: Command): void;
249
- injectHtmlTags?({
250
- content,
251
- }: {
252
- content: Content;
253
- }): {
266
+ injectHtmlTags?({content}: {content: Content}): {
254
267
  headTags?: HtmlTags;
255
268
  preBodyTags?: HtmlTags;
256
269
  postBodyTags?: HtmlTags;
@@ -346,7 +359,7 @@ export interface RouteConfig {
346
359
  routes?: RouteConfig[];
347
360
  exact?: boolean;
348
361
  priority?: number;
349
- [propName: string]: any;
362
+ [propName: string]: unknown;
350
363
  }
351
364
 
352
365
  // Aliases used for Webpack resolution (when using docusaurus swizzle)
@@ -420,4 +433,5 @@ export interface TOCItem {
420
433
  readonly value: string;
421
434
  readonly id: string;
422
435
  readonly children: TOCItem[];
436
+ readonly level: number;
423
437
  }
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});