From 662a79395eb0e91619c14da394c9be54a7802549 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 1 Jul 2022 11:28:02 +0200 Subject: [PATCH 1/3] split @docusaurus/types --- .../docusaurus-types/src/clientModule.d.ts | 19 + packages/docusaurus-types/src/config.d.ts | 283 ++++++ packages/docusaurus-types/src/context.d.ts | 62 ++ packages/docusaurus-types/src/i18n.d.ts | 82 ++ packages/docusaurus-types/src/index.d.ts | 850 ++---------------- packages/docusaurus-types/src/plugin.d.ts | 194 ++++ packages/docusaurus-types/src/routing.d.ts | 138 +++ packages/docusaurus-types/src/swizzle.d.ts | 43 + packages/docusaurus-types/src/utils.d.ts | 14 + 9 files changed, 904 insertions(+), 781 deletions(-) create mode 100644 packages/docusaurus-types/src/clientModule.d.ts create mode 100644 packages/docusaurus-types/src/config.d.ts create mode 100644 packages/docusaurus-types/src/context.d.ts create mode 100644 packages/docusaurus-types/src/i18n.d.ts create mode 100644 packages/docusaurus-types/src/plugin.d.ts create mode 100644 packages/docusaurus-types/src/routing.d.ts create mode 100644 packages/docusaurus-types/src/swizzle.d.ts create mode 100644 packages/docusaurus-types/src/utils.d.ts diff --git a/packages/docusaurus-types/src/clientModule.d.ts b/packages/docusaurus-types/src/clientModule.d.ts new file mode 100644 index 000000000000..07c0ddf358e2 --- /dev/null +++ b/packages/docusaurus-types/src/clientModule.d.ts @@ -0,0 +1,19 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import type {Location} from 'history'; + +export type ClientModule = { + onRouteDidUpdate?: (args: { + previousLocation: Location | null; + location: Location; + }) => (() => void) | void; + onRouteUpdate?: (args: { + previousLocation: Location | null; + location: Location; + }) => (() => void) | void; +}; diff --git a/packages/docusaurus-types/src/config.d.ts b/packages/docusaurus-types/src/config.d.ts new file mode 100644 index 000000000000..77fd2126bed9 --- /dev/null +++ b/packages/docusaurus-types/src/config.d.ts @@ -0,0 +1,283 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import type {RuleSetRule} from 'webpack'; +import type {Required as RequireKeys, DeepPartial} from 'utility-types'; +import type {I18nConfig} from './i18n'; +import type {PluginConfig, PresetConfig} from './plugin'; + +export type ReportingSeverity = 'ignore' | 'log' | 'warn' | 'throw'; + +export type ThemeConfig = { + [key: string]: unknown; +}; + +/** + * Docusaurus config, after validation/normalization. + */ +export type DocusaurusConfig = { + /** + * Title for your website. Will be used in metadata and as browser tab title. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#title + */ + title: string; + /** + * URL for your website. This can also be considered the top-level hostname. + * For example, `https://facebook.github.io` is the URL of + * https://facebook.github.io/metro/, and `https://docusaurus.io` is the URL + * for https://docusaurus.io. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#url + */ + url: string; + /** + * Can be considered as the path after the host. For example, `/metro/` is the + * base URL of https://facebook.github.io/metro/. For URLs that have no path, + * it should be set to `/`. Always has both leading and trailing slash. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#baseUrl + */ + baseUrl: string; + /** + * Path to your site favicon; must be a URL that can be used in link's href. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#favicon + */ + favicon?: string; + /** + * Allow to customize the presence/absence of a trailing slash at the end of + * URLs/links, and how static HTML files are generated: + * + * - `undefined` (default): keeps URLs untouched, and emit + * `/docs/myDoc/index.html` for `/docs/myDoc.md` + * - `true`: add trailing slashes to URLs/links, and emit + * `/docs/myDoc/index.html` for `/docs/myDoc.md` + * - `false`: remove trailing slashes from URLs/links, and emit + * `/docs/myDoc.html` for `/docs/myDoc.md` + * + * @see https://github.com/slorber/trailing-slash-guide + * @see https://docusaurus.io/docs/api/docusaurus-config#trailingSlash + * @default undefined + */ + trailingSlash: boolean | undefined; + /** + * The i18n configuration object to [localize your + * site](https://docusaurus.io/docs/i18n/introduction). + * + * @see https://docusaurus.io/docs/api/docusaurus-config#i18n + */ + i18n: I18nConfig; + /** + * This option adds `` to + * every page to tell search engines to avoid indexing your site. + * + * @see https://moz.com/learn/seo/robots-meta-directives + * @see https://docusaurus.io/docs/api/docusaurus-config#noIndex + * @default false + */ + noIndex: boolean; + /** + * The behavior of Docusaurus when it detects any broken link. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenLinks + * @default "throw" + */ + onBrokenLinks: ReportingSeverity; + /** + * The behavior of Docusaurus when it detects any broken markdown link. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenMarkdownLinks + * @default "warn" + */ + onBrokenMarkdownLinks: ReportingSeverity; + /** + * The behavior of Docusaurus when it detects any [duplicate + * routes](https://docusaurus.io/docs/creating-pages#duplicate-routes). + * + * @see https://docusaurus.io/docs/api/docusaurus-config#onDuplicateRoutes + * @default "warn" + */ + onDuplicateRoutes: ReportingSeverity; + /** + * The tagline for your website. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#tagline + * @default "" + */ + tagline: string; + /** + * The GitHub user or organization that owns the repository. You don't need + * this if you are not using the `docusaurus deploy` command. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#organizationName + */ + organizationName?: string; + /** + * The name of the GitHub repository. You don't need this if you are not using + * the `docusaurus deploy` command. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#projectName + */ + projectName?: string; + /** + * The name of the branch to deploy the static files to. You don't need this + * if you are not using the `docusaurus deploy` command. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#deploymentBranch + */ + deploymentBranch?: string; + /** + * The hostname of your server. Useful if you are using GitHub Enterprise. You + * don't need this if you are not using the `docusaurus deploy` command. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#githubHost + */ + githubHost?: string; + /** + * The port of your server. Useful if you are using GitHub Enterprise. You + * don't need this if you are not using the `docusaurus deploy` command. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#githubPort + */ + githubPort?: string; + /** + * The [theme configuration](https://docusaurus.io/docs/api/themes/configuration) + * object to customize your site UI like navbar and footer. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#themeConfig + * @default {} + */ + themeConfig: ThemeConfig; + /** + * List of plugins. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#plugins + * @default [] + */ + plugins: PluginConfig[]; + /** + * List of themes. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#themes + * @default [] + */ + themes: PluginConfig[]; + /** + * List of presets. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#presets + * @default [] + */ + presets: PresetConfig[]; + /** + * Docusaurus guards `docusaurus.config.js` from unknown fields. To add a + * custom field, define it on `customFields`. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#customFields + * @default {} + */ + customFields?: { + [key: string]: unknown; + }; + /** + * An array of paths, relative to the site's directory or absolute. Files + * under these paths will be copied to the build output as-is. + * + * @see https://docusaurus.io/docs/api/docusaurus-config#staticDirectories + * @default ["static"] + */ + staticDirectories: string[]; + /** + * An array of scripts to load. The values can be either strings or plain + * objects of attribute-value maps. The `