mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 02:37:59 +02:00
chore: upgrade to TS 4.7, compile with NodeNext (#7586)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
b503523f66
commit
b4d93b9bd0
62 changed files with 225 additions and 195 deletions
6
.eslintrc.js
vendored
6
.eslintrc.js
vendored
|
@ -211,10 +211,12 @@ module.exports = {
|
||||||
],
|
],
|
||||||
|
|
||||||
'import/extensions': OFF,
|
'import/extensions': OFF,
|
||||||
// Ignore certain webpack aliases because they can't be resolved
|
// This rule doesn't yet support resolving .js imports when the actual file
|
||||||
|
// is .ts. Plus it's not all that useful when our code is fully TS-covered.
|
||||||
'import/no-unresolved': [
|
'import/no-unresolved': [
|
||||||
ERROR,
|
OFF,
|
||||||
{
|
{
|
||||||
|
// Ignore certain webpack aliases because they can't be resolved
|
||||||
ignore: [
|
ignore: [
|
||||||
'^@theme',
|
'^@theme',
|
||||||
'^@docusaurus',
|
'^@docusaurus',
|
||||||
|
|
|
@ -40,14 +40,12 @@ const tsconfigSchema = Joi.object({
|
||||||
incremental: Joi.forbidden(),
|
incremental: Joi.forbidden(),
|
||||||
tsBuildInfoFile: Joi.forbidden(),
|
tsBuildInfoFile: Joi.forbidden(),
|
||||||
outDir: Joi.forbidden(),
|
outDir: Joi.forbidden(),
|
||||||
module: Joi.valid('commonjs', 'es2020', 'esnext').required(),
|
|
||||||
}).unknown(),
|
}).unknown(),
|
||||||
otherwise: Joi.object({
|
otherwise: Joi.object({
|
||||||
noEmit: Joi.valid(false).required(),
|
noEmit: Joi.valid(false).required(),
|
||||||
incremental: Joi.valid(true).required(),
|
incremental: Joi.valid(true).required(),
|
||||||
rootDir: Joi.valid('src').required(),
|
rootDir: Joi.valid('src').required(),
|
||||||
outDir: Joi.valid('lib').required(),
|
outDir: Joi.valid('lib').required(),
|
||||||
module: Joi.valid('commonjs', 'es2020', 'esnext').required(),
|
|
||||||
}).unknown(),
|
}).unknown(),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -111,6 +111,6 @@
|
||||||
"stylelint": "^14.9.1",
|
"stylelint": "^14.9.1",
|
||||||
"stylelint-config-prettier": "^9.0.3",
|
"stylelint-config-prettier": "^9.0.3",
|
||||||
"stylelint-config-standard": "^26.0.0",
|
"stylelint-config-standard": "^26.0.0",
|
||||||
"typescript": "~4.6.4"
|
"typescript": "~4.7.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@docusaurus/module-type-aliases": "2.0.0-beta.21",
|
"@docusaurus/module-type-aliases": "2.0.0-beta.21",
|
||||||
"@tsconfig/docusaurus": "^1.0.5",
|
"@tsconfig/docusaurus": "^1.0.5",
|
||||||
"typescript": "^4.6.4"
|
"typescript": "^4.7.3"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"module": "es2020",
|
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
"references": [{"path": "./tsconfig.build.json"}],
|
"references": [{"path": "./tsconfig.build.json"}],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"module": "esnext",
|
|
||||||
"rootDir": "."
|
"rootDir": "."
|
||||||
},
|
},
|
||||||
"include": ["bin"],
|
"include": ["bin"],
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"types": []
|
"types": []
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
"references": [{"path": "./tsconfig.build.json"}],
|
"references": [{"path": "./tsconfig.build.json"}],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"module": "esnext",
|
|
||||||
"rootDir": "."
|
"rootDir": "."
|
||||||
},
|
},
|
||||||
"include": ["bin"],
|
"include": ["bin"],
|
||||||
|
|
16
packages/docusaurus-plugin-client-redirects/src/deps.d.ts
vendored
Normal file
16
packages/docusaurus-plugin-client-redirects/src/deps.d.ts
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO incompatible declaration file
|
||||||
|
declare module 'eta' {
|
||||||
|
export const defaultConfig: object;
|
||||||
|
|
||||||
|
export function compile(
|
||||||
|
template: string,
|
||||||
|
options?: object,
|
||||||
|
): (data: object, config: object) => string;
|
||||||
|
}
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,9 +6,18 @@
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"exports": {
|
"exports": {
|
||||||
"./src/*": "./src/*",
|
"./src/*": "./src/*",
|
||||||
"./client": "./lib/client/index.js",
|
"./client": {
|
||||||
"./server": "./lib/server-export.js",
|
"type": "./lib/client/index.d.ts",
|
||||||
".": "./lib/index.js"
|
"default": "./lib/client/index.js"
|
||||||
|
},
|
||||||
|
"./server": {
|
||||||
|
"type": "./lib/server-export.d.ts",
|
||||||
|
"default": "./lib/server-export.js"
|
||||||
|
},
|
||||||
|
".": {
|
||||||
|
"types": "./src/plugin-content-docs.d.ts",
|
||||||
|
"default": "./lib/index.js"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"types": "src/plugin-content-docs.d.ts",
|
"types": "src/plugin-content-docs.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -18,15 +18,60 @@ import {
|
||||||
getActiveDocContext,
|
getActiveDocContext,
|
||||||
getDocVersionSuggestions,
|
getDocVersionSuggestions,
|
||||||
} from './docsClientUtils';
|
} from './docsClientUtils';
|
||||||
import type {
|
|
||||||
GlobalPluginData,
|
|
||||||
GlobalVersion,
|
|
||||||
ActivePlugin,
|
|
||||||
ActiveDocContext,
|
|
||||||
DocVersionSuggestions,
|
|
||||||
} from '@docusaurus/plugin-content-docs/client';
|
|
||||||
import type {UseDataOptions} from '@docusaurus/types';
|
import type {UseDataOptions} from '@docusaurus/types';
|
||||||
|
|
||||||
|
export type ActivePlugin = {
|
||||||
|
pluginId: string;
|
||||||
|
pluginData: GlobalPluginData;
|
||||||
|
};
|
||||||
|
export type ActiveDocContext = {
|
||||||
|
activeVersion?: GlobalVersion;
|
||||||
|
activeDoc?: GlobalDoc;
|
||||||
|
alternateDocVersions: {[versionName: string]: GlobalDoc};
|
||||||
|
};
|
||||||
|
export type GlobalDoc = {
|
||||||
|
/**
|
||||||
|
* For generated index pages, this is the `slug`, **not** `permalink`
|
||||||
|
* (without base URL). Because slugs have leading slashes but IDs don't,
|
||||||
|
* there won't be clashes.
|
||||||
|
*/
|
||||||
|
id: string;
|
||||||
|
path: string;
|
||||||
|
sidebar: string | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GlobalVersion = {
|
||||||
|
name: string;
|
||||||
|
label: string;
|
||||||
|
isLast: boolean;
|
||||||
|
path: string;
|
||||||
|
/** The doc with `slug: /`, or first doc in first sidebar */
|
||||||
|
mainDocId: string;
|
||||||
|
docs: GlobalDoc[];
|
||||||
|
/** Unversioned IDs. In development, this list is empty. */
|
||||||
|
draftIds: string[];
|
||||||
|
sidebars?: {[sidebarId: string]: GlobalSidebar};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type GlobalSidebar = {
|
||||||
|
link?: {
|
||||||
|
label: string;
|
||||||
|
path: string;
|
||||||
|
};
|
||||||
|
// ... we may add other things here later
|
||||||
|
};
|
||||||
|
export type GlobalPluginData = {
|
||||||
|
path: string;
|
||||||
|
versions: GlobalVersion[];
|
||||||
|
breadcrumbs: boolean;
|
||||||
|
};
|
||||||
|
export type DocVersionSuggestions = {
|
||||||
|
/** Suggest the latest version */
|
||||||
|
latestVersionSuggestion: GlobalVersion;
|
||||||
|
/** Suggest the same doc, in latest version (if one exists) */
|
||||||
|
latestDocSuggestion?: GlobalDoc;
|
||||||
|
};
|
||||||
|
|
||||||
// Important to use a constant object to avoid React useEffect executions etc.
|
// Important to use a constant object to avoid React useEffect executions etc.
|
||||||
// see https://github.com/facebook/docusaurus/issues/5089
|
// see https://github.com/facebook/docusaurus/issues/5089
|
||||||
const StableEmptyObject = {};
|
const StableEmptyObject = {};
|
||||||
|
@ -71,6 +116,7 @@ export function useActivePluginAndVersion(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Versions are returned ordered (most recent first). */
|
||||||
export function useVersions(pluginId: string | undefined): GlobalVersion[] {
|
export function useVersions(pluginId: string | undefined): GlobalVersion[] {
|
||||||
const data = useDocsData(pluginId);
|
const data = useDocsData(pluginId);
|
||||||
return data.versions;
|
return data.versions;
|
||||||
|
@ -81,6 +127,10 @@ export function useLatestVersion(pluginId: string | undefined): GlobalVersion {
|
||||||
return getLatestVersion(data);
|
return getLatestVersion(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns `undefined` on doc-unrelated pages, because there's no version
|
||||||
|
* currently considered as active.
|
||||||
|
*/
|
||||||
export function useActiveVersion(
|
export function useActiveVersion(
|
||||||
pluginId: string | undefined,
|
pluginId: string | undefined,
|
||||||
): GlobalVersion | undefined {
|
): GlobalVersion | undefined {
|
||||||
|
@ -96,7 +146,9 @@ export function useActiveDocContext(
|
||||||
const {pathname} = useLocation();
|
const {pathname} = useLocation();
|
||||||
return getActiveDocContext(data, pathname);
|
return getActiveDocContext(data, pathname);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Useful to say "hey, you are not on the latest docs version, please switch"
|
||||||
|
*/
|
||||||
export function useDocVersionSuggestions(
|
export function useDocVersionSuggestions(
|
||||||
pluginId: string | undefined,
|
pluginId: string | undefined,
|
||||||
): DocVersionSuggestions {
|
): DocVersionSuggestions {
|
||||||
|
|
|
@ -616,89 +616,3 @@ declare module '@theme/DocPage' {
|
||||||
|
|
||||||
export default function DocPage(props: Props): JSX.Element;
|
export default function DocPage(props: Props): JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO TS only supports reading `exports` in 4.7. We will need to merge the
|
|
||||||
// type defs (and JSDoc) here with the implementation after that
|
|
||||||
declare module '@docusaurus/plugin-content-docs/client' {
|
|
||||||
import type {UseDataOptions} from '@docusaurus/types';
|
|
||||||
|
|
||||||
export type ActivePlugin = {
|
|
||||||
pluginId: string;
|
|
||||||
pluginData: GlobalPluginData;
|
|
||||||
};
|
|
||||||
export type ActiveDocContext = {
|
|
||||||
activeVersion?: GlobalVersion;
|
|
||||||
activeDoc?: GlobalDoc;
|
|
||||||
alternateDocVersions: {[versionName: string]: GlobalDoc};
|
|
||||||
};
|
|
||||||
export type GlobalDoc = {
|
|
||||||
/**
|
|
||||||
* For generated index pages, this is the `slug`, **not** `permalink`
|
|
||||||
* (without base URL). Because slugs have leading slashes but IDs don't,
|
|
||||||
* there won't be clashes.
|
|
||||||
*/
|
|
||||||
id: string;
|
|
||||||
path: string;
|
|
||||||
sidebar: string | undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GlobalVersion = {
|
|
||||||
name: string;
|
|
||||||
label: string;
|
|
||||||
isLast: boolean;
|
|
||||||
path: string;
|
|
||||||
/** The doc with `slug: /`, or first doc in first sidebar */
|
|
||||||
mainDocId: string;
|
|
||||||
docs: GlobalDoc[];
|
|
||||||
/** Unversioned IDs. In development, this list is empty. */
|
|
||||||
draftIds: string[];
|
|
||||||
sidebars?: {[sidebarId: string]: GlobalSidebar};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GlobalSidebar = {
|
|
||||||
link?: {
|
|
||||||
label: string;
|
|
||||||
path: string;
|
|
||||||
};
|
|
||||||
// ... we may add other things here later
|
|
||||||
};
|
|
||||||
export type GlobalPluginData = {
|
|
||||||
path: string;
|
|
||||||
versions: GlobalVersion[];
|
|
||||||
breadcrumbs: boolean;
|
|
||||||
};
|
|
||||||
export type DocVersionSuggestions = {
|
|
||||||
/** Suggest the latest version */
|
|
||||||
latestVersionSuggestion: GlobalVersion;
|
|
||||||
/** Suggest the same doc, in latest version (if one exists) */
|
|
||||||
latestDocSuggestion?: GlobalDoc;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
|
|
||||||
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
|
||||||
export const useActivePlugin: (
|
|
||||||
options?: UseDataOptions,
|
|
||||||
) => ActivePlugin | undefined;
|
|
||||||
export const useActivePluginAndVersion: (
|
|
||||||
options?: UseDataOptions,
|
|
||||||
) =>
|
|
||||||
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
||||||
| undefined;
|
|
||||||
/** Versions are returned ordered (most recent first). */
|
|
||||||
export const useVersions: (pluginId?: string) => GlobalVersion[];
|
|
||||||
export const useLatestVersion: (pluginId?: string) => GlobalVersion;
|
|
||||||
/**
|
|
||||||
* Returns `undefined` on doc-unrelated pages, because there's no version
|
|
||||||
* currently considered as active.
|
|
||||||
*/
|
|
||||||
export const useActiveVersion: (
|
|
||||||
pluginId?: string,
|
|
||||||
) => GlobalVersion | undefined;
|
|
||||||
export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
|
|
||||||
/**
|
|
||||||
* Useful to say "hey, you are not on the latest docs version, please switch"
|
|
||||||
*/
|
|
||||||
export const useDocVersionSuggestions: (
|
|
||||||
pluginId?: string,
|
|
||||||
) => DocVersionSuggestions;
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
15
packages/docusaurus-plugin-pwa/src/deps.d.ts
vendored
Normal file
15
packages/docusaurus-plugin-pwa/src/deps.d.ts
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO incompatible declaration file: https://github.com/unjs/webpackbar/pull/108
|
||||||
|
declare module 'webpackbar' {
|
||||||
|
import webpack from 'webpack';
|
||||||
|
|
||||||
|
export default class WebpackBarPlugin extends webpack.ProgressPlugin {
|
||||||
|
constructor(options: {name: string; color?: string});
|
||||||
|
}
|
||||||
|
}
|
|
@ -139,7 +139,7 @@ async function registerSW() {
|
||||||
if (!offlineMode) {
|
if (!offlineMode) {
|
||||||
return sendSkipWaiting();
|
return sendSkipWaiting();
|
||||||
}
|
}
|
||||||
return import('./renderReloadPopup').then(({default: renderReloadPopup}) =>
|
return import('./renderReloadPopup.js').then(({renderReloadPopup}) =>
|
||||||
renderReloadPopup({
|
renderReloadPopup({
|
||||||
onReload() {
|
onReload() {
|
||||||
wb.addEventListener('controlling', () => {
|
wb.addEventListener('controlling', () => {
|
||||||
|
|
|
@ -20,7 +20,7 @@ const createContainer = () => {
|
||||||
return container;
|
return container;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function renderReloadPopup(props: Props): Promise<void> {
|
export function renderReloadPopup(props: Props): Promise<void> {
|
||||||
const container = getContainer() ?? createContainer();
|
const container = getContainer() ?? createContainer();
|
||||||
return import('@theme/PwaReloadPopup').then(({default: ReloadPopup}) => {
|
return import('@theme/PwaReloadPopup').then(({default: ReloadPopup}) => {
|
||||||
ReactDOM.render(<ReloadPopup {...props} />, container);
|
ReactDOM.render(<ReloadPopup {...props} />, container);
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default function CodeBlockContainer<T extends 'div' | 'pre'>({
|
||||||
return (
|
return (
|
||||||
<As
|
<As
|
||||||
// Polymorphic components are hard to type, without `oneOf` generics
|
// Polymorphic components are hard to type, without `oneOf` generics
|
||||||
{...(props as never)}
|
{...(props as any)}
|
||||||
style={prismCssVariables}
|
style={prismCssVariables}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
import React, {useCallback, useState, useRef, useEffect} from 'react';
|
import React, {useCallback, useState, useRef, useEffect} from 'react';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
|
// @ts-expect-error: TODO, we need to make theme-classic have type: module
|
||||||
import copy from 'copy-text-to-clipboard';
|
import copy from 'copy-text-to-clipboard';
|
||||||
import {translate} from '@docusaurus/Translate';
|
import {translate} from '@docusaurus/Translate';
|
||||||
import type {Props} from '@theme/CodeBlock/CopyButton';
|
import type {Props} from '@theme/CodeBlock/CopyButton';
|
||||||
|
|
|
@ -24,5 +24,5 @@ export default function NavbarItem({type, ...props}: Props): JSX.Element {
|
||||||
if (!NavbarItemComponent) {
|
if (!NavbarItemComponent) {
|
||||||
throw new Error(`No NavbarItem component found for type "${type}".`);
|
throw new Error(`No NavbarItem component found for type "${type}".`);
|
||||||
}
|
}
|
||||||
return <NavbarItemComponent {...(props as never)} />;
|
return <NavbarItemComponent {...(props as any)} />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
14
packages/docusaurus-theme-common/Details.d.ts
vendored
14
packages/docusaurus-theme-common/Details.d.ts
vendored
|
@ -1,14 +0,0 @@
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// `Details` is a separate export entry because of side-effects messing with CSS
|
|
||||||
// insertion order. See https://github.com/facebook/docusaurus/pull/7085.
|
|
||||||
// However, because TS doesn't recognize `exports` (also a problem in
|
|
||||||
// `content-docs`), we have to manually create a stub.
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/named
|
|
||||||
export {Details, type DetailsProps} from './lib/components/Details';
|
|
|
@ -5,7 +5,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,8 +7,14 @@
|
||||||
"*.css"
|
"*.css"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
"./client": "./lib/client/index.js",
|
"./client": {
|
||||||
".": "./lib/index.js"
|
"types": "./lib/client/index.d.ts",
|
||||||
|
"default": "./lib/client/index.js"
|
||||||
|
},
|
||||||
|
".": {
|
||||||
|
"types": "./src/theme-search-algolia.d.ts",
|
||||||
|
"default": "./lib/index.js"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"types": "src/theme-search-algolia.d.ts",
|
"types": "src/theme-search-algolia.d.ts",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|
|
@ -8,3 +8,13 @@
|
||||||
declare module '@docsearch/react/modal';
|
declare module '@docsearch/react/modal';
|
||||||
|
|
||||||
declare module '@docsearch/react/style';
|
declare module '@docsearch/react/style';
|
||||||
|
|
||||||
|
// TODO incompatible declaration file
|
||||||
|
declare module 'eta' {
|
||||||
|
export const defaultConfig: object;
|
||||||
|
|
||||||
|
export function compile(
|
||||||
|
template: string,
|
||||||
|
options?: object,
|
||||||
|
): (data: object, config: object) => string;
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
"extends": "../../tsconfig.json",
|
"extends": "../../tsconfig.json",
|
||||||
"references": [{"path": "./tsconfig.build.json"}],
|
"references": [{"path": "./tsconfig.build.json"}],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "esnext",
|
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"checkJs": true
|
"checkJs": true
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/history": "^4.7.11",
|
"@types/history": "^4.7.11",
|
||||||
|
"@types/react": "*",
|
||||||
"commander": "^5.1.0",
|
"commander": "^5.1.0",
|
||||||
"joi": "^17.6.0",
|
"joi": "^17.6.0",
|
||||||
"react-helmet-async": "^1.3.0",
|
"react-helmet-async": "^1.3.0",
|
||||||
|
|
22
packages/docusaurus-types/src/index.d.ts
vendored
22
packages/docusaurus-types/src/index.d.ts
vendored
|
@ -5,6 +5,7 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import type {JSXElementConstructor} from 'react';
|
||||||
import type {RuleSetRule, Configuration as WebpackConfiguration} from 'webpack';
|
import type {RuleSetRule, Configuration as WebpackConfiguration} from 'webpack';
|
||||||
import type {CustomizeRuleString} from 'webpack-merge/dist/types';
|
import type {CustomizeRuleString} from 'webpack-merge/dist/types';
|
||||||
import type {CommanderStatic} from 'commander';
|
import type {CommanderStatic} from 'commander';
|
||||||
|
@ -758,3 +759,24 @@ export type UseDataOptions = {
|
||||||
*/
|
*/
|
||||||
failfast?: boolean;
|
failfast?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This type is almost the same as `React.ComponentProps`, but with one minor
|
||||||
|
* fix: when the component is a function with no parameters, it produces `{}`
|
||||||
|
* instead of `unknown`, allowing us to spread the props derived from another
|
||||||
|
* component. This is useful for wrap swizzling.
|
||||||
|
*
|
||||||
|
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
|
||||||
|
*/
|
||||||
|
export type WrapperProps<
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
|
||||||
|
> = T extends JSXElementConstructor<infer P>
|
||||||
|
? unknown extends P
|
||||||
|
? // eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
{}
|
||||||
|
: P
|
||||||
|
: T extends keyof JSX.IntrinsicElements
|
||||||
|
? JSX.IntrinsicElements[T]
|
||||||
|
: // eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
{};
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"noEmitHelpers": false
|
"noEmitHelpers": false
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -132,7 +132,7 @@ export default function ComponentCreator(
|
||||||
// Is there any way to put this RouteContextProvider upper in the tree?
|
// Is there any way to put this RouteContextProvider upper in the tree?
|
||||||
return (
|
return (
|
||||||
<RouteContextProvider value={routeContext}>
|
<RouteContextProvider value={routeContext}>
|
||||||
<Component {...loadedModules} {...props} />
|
<Component {...loadedModules} {...(props as object)} />
|
||||||
</RouteContextProvider>
|
</RouteContextProvider>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -43,11 +43,12 @@ export default function FirstLevelComponentWrapper(props) {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`wrap TypeScript wrap ComponentInFolder 2`] = `
|
exports[`wrap TypeScript wrap ComponentInFolder 2`] = `
|
||||||
"import React, {ComponentProps} from 'react';
|
"import React from 'react';
|
||||||
import ComponentInFolder from '@theme-original/ComponentInFolder';
|
import ComponentInFolder from '@theme-original/ComponentInFolder';
|
||||||
import type ComponentInFolderType from '@theme/ComponentInFolder';
|
import type ComponentInFolderType from '@theme/ComponentInFolder';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ComponentInFolderType>;
|
type Props = WrapperProps<typeof ComponentInFolderType>;
|
||||||
|
|
||||||
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -60,11 +61,12 @@ export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`wrap TypeScript wrap ComponentInFolder/ComponentInSubFolder 2`] = `
|
exports[`wrap TypeScript wrap ComponentInFolder/ComponentInSubFolder 2`] = `
|
||||||
"import React, {ComponentProps} from 'react';
|
"import React from 'react';
|
||||||
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
|
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
|
||||||
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
|
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ComponentInSubFolderType>;
|
type Props = WrapperProps<typeof ComponentInSubFolderType>;
|
||||||
|
|
||||||
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -77,11 +79,12 @@ export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`wrap TypeScript wrap FirstLevelComponent 2`] = `
|
exports[`wrap TypeScript wrap FirstLevelComponent 2`] = `
|
||||||
"import React, {ComponentProps} from 'react';
|
"import React from 'react';
|
||||||
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
|
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
|
||||||
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
|
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof FirstLevelComponentType>;
|
type Props = WrapperProps<typeof FirstLevelComponentType>;
|
||||||
|
|
||||||
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
|
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -273,11 +273,12 @@ exports[`swizzle wrap ComponentInFolder JS: theme dir tree 1`] = `
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`swizzle wrap ComponentInFolder TS: ComponentInFolder/index.tsx 1`] = `
|
exports[`swizzle wrap ComponentInFolder TS: ComponentInFolder/index.tsx 1`] = `
|
||||||
"import React, {ComponentProps} from 'react';
|
"import React from 'react';
|
||||||
import ComponentInFolder from '@theme-original/ComponentInFolder';
|
import ComponentInFolder from '@theme-original/ComponentInFolder';
|
||||||
import type ComponentInFolderType from '@theme/ComponentInFolder';
|
import type ComponentInFolderType from '@theme/ComponentInFolder';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ComponentInFolderType>;
|
type Props = WrapperProps<typeof ComponentInFolderType>;
|
||||||
|
|
||||||
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
export default function ComponentInFolderWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -317,11 +318,12 @@ exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder JS: theme dir tree
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder TS: ComponentInFolder/ComponentInSubFolder/index.tsx 1`] = `
|
exports[`swizzle wrap ComponentInFolder/ComponentInSubFolder TS: ComponentInFolder/ComponentInSubFolder/index.tsx 1`] = `
|
||||||
"import React, {ComponentProps} from 'react';
|
"import React from 'react';
|
||||||
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
|
import ComponentInSubFolder from '@theme-original/ComponentInFolder/ComponentInSubFolder';
|
||||||
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
|
import type ComponentInSubFolderType from '@theme/ComponentInFolder/ComponentInSubFolder';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ComponentInSubFolderType>;
|
type Props = WrapperProps<typeof ComponentInSubFolderType>;
|
||||||
|
|
||||||
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
export default function ComponentInSubFolderWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -361,11 +363,12 @@ exports[`swizzle wrap ComponentInFolder/Sibling JS: theme dir tree 1`] = `
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`swizzle wrap ComponentInFolder/Sibling TS: ComponentInFolder/Sibling.tsx 1`] = `
|
exports[`swizzle wrap ComponentInFolder/Sibling TS: ComponentInFolder/Sibling.tsx 1`] = `
|
||||||
"import React, {ComponentProps} from 'react';
|
"import React from 'react';
|
||||||
import Sibling from '@theme-original/ComponentInFolder/Sibling';
|
import Sibling from '@theme-original/ComponentInFolder/Sibling';
|
||||||
import type SiblingType from '@theme/ComponentInFolder/Sibling';
|
import type SiblingType from '@theme/ComponentInFolder/Sibling';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof SiblingType>;
|
type Props = WrapperProps<typeof SiblingType>;
|
||||||
|
|
||||||
export default function SiblingWrapper(props: Props): JSX.Element {
|
export default function SiblingWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
@ -403,11 +406,12 @@ exports[`swizzle wrap FirstLevelComponent JS: theme dir tree 1`] = `
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`swizzle wrap FirstLevelComponent TS: FirstLevelComponent.tsx 1`] = `
|
exports[`swizzle wrap FirstLevelComponent TS: FirstLevelComponent.tsx 1`] = `
|
||||||
"import React, {ComponentProps} from 'react';
|
"import React from 'react';
|
||||||
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
|
import FirstLevelComponent from '@theme-original/FirstLevelComponent';
|
||||||
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
|
import type FirstLevelComponentType from '@theme/FirstLevelComponent';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof FirstLevelComponentType>;
|
type Props = WrapperProps<typeof FirstLevelComponentType>;
|
||||||
|
|
||||||
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
|
export default function FirstLevelComponentWrapper(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -121,11 +121,12 @@ export async function wrap({
|
||||||
const toPath = path.resolve(siteDir, THEME_PATH, wrapperFileName);
|
const toPath = path.resolve(siteDir, THEME_PATH, wrapperFileName);
|
||||||
|
|
||||||
const content = typescript
|
const content = typescript
|
||||||
? `import React, {ComponentProps} from 'react';
|
? `import React from 'react';
|
||||||
import ${componentName} from '@theme-${importType}/${themeComponentName}';
|
import ${componentName} from '@theme-${importType}/${themeComponentName}';
|
||||||
import type ${componentName}Type from '@theme/${themeComponentName}';
|
import type ${componentName}Type from '@theme/${themeComponentName}';
|
||||||
|
import type {WrapperProps} from '@docusaurus/types';
|
||||||
|
|
||||||
type Props = ComponentProps<typeof ${componentName}Type>;
|
type Props = WrapperProps<typeof ${componentName}Type>;
|
||||||
|
|
||||||
export default function ${wrapperComponentName}(props: Props): JSX.Element {
|
export default function ${wrapperComponentName}(props: Props): JSX.Element {
|
||||||
return (
|
return (
|
||||||
|
|
19
packages/docusaurus/src/deps.d.ts
vendored
19
packages/docusaurus/src/deps.d.ts
vendored
|
@ -73,3 +73,22 @@ declare module 'webpack/lib/HotModuleReplacementPlugin' {
|
||||||
|
|
||||||
export default HotModuleReplacementPlugin;
|
export default HotModuleReplacementPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO incompatible declaration file: https://github.com/unjs/webpackbar/pull/108
|
||||||
|
declare module 'webpackbar' {
|
||||||
|
import webpack from 'webpack';
|
||||||
|
|
||||||
|
export default class WebpackBarPlugin extends webpack.ProgressPlugin {
|
||||||
|
constructor(options: {name: string; color?: string});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO incompatible declaration file
|
||||||
|
declare module 'eta' {
|
||||||
|
export const defaultConfig: object;
|
||||||
|
|
||||||
|
export function compile(
|
||||||
|
template: string,
|
||||||
|
options?: object,
|
||||||
|
): (data: object, config: object) => string;
|
||||||
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
"rootDir": ".",
|
"rootDir": "."
|
||||||
"module": "esnext"
|
|
||||||
},
|
},
|
||||||
"include": ["bin"],
|
"include": ["bin"],
|
||||||
"exclude": ["**/__tests__/**"]
|
"exclude": ["**/__tests__/**"]
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"composite": true,
|
"composite": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||||
"module": "commonjs",
|
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "lib"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
"jsx": "react-native",
|
"jsx": "react-native",
|
||||||
"importHelpers": true,
|
"importHelpers": true,
|
||||||
"noEmitHelpers": true,
|
"noEmitHelpers": true,
|
||||||
// Will be overridden in every project
|
// Will be overridden in client projects
|
||||||
"module": "esnext",
|
"module": "NodeNext",
|
||||||
// Avoid accidentally using this config to build
|
// Avoid accidentally using this config to build
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
"importsNotUsedAsValues": "remove",
|
"importsNotUsedAsValues": "remove",
|
||||||
|
|
||||||
/* Module Resolution */
|
/* Module Resolution */
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "NodeNext",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
|
|
@ -19,12 +19,14 @@ type Props = {
|
||||||
presetOptionName: string;
|
presetOptionName: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const docsPluginId = undefined; // Default docs plugin instance
|
||||||
|
|
||||||
export default function ConfigTabs({
|
export default function ConfigTabs({
|
||||||
code,
|
code,
|
||||||
pluginName,
|
pluginName,
|
||||||
presetOptionName,
|
presetOptionName,
|
||||||
}: Props): JSX.Element {
|
}: Props): JSX.Element {
|
||||||
const versionPath = useActiveVersion()!.path;
|
const versionPath = useActiveVersion(docsPluginId)!.path;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs groupId="api-config-ex">
|
<Tabs groupId="api-config-ex">
|
||||||
|
|
|
@ -17,9 +17,11 @@ import Translate from '@docusaurus/Translate';
|
||||||
import Admonition from '@theme/Admonition';
|
import Admonition from '@theme/Admonition';
|
||||||
import CodeBlock from '@theme/CodeBlock';
|
import CodeBlock from '@theme/CodeBlock';
|
||||||
|
|
||||||
|
const docsPluginId = undefined; // Default docs plugin instance
|
||||||
|
|
||||||
function PackageJson() {
|
function PackageJson() {
|
||||||
const latestVersion = useLatestVersion();
|
const latestVersion = useLatestVersion(docsPluginId);
|
||||||
const allVersions = useVersions();
|
const allVersions = useVersions(docsPluginId);
|
||||||
// Only happens in deploy preview / local dev, but still nice
|
// Only happens in deploy preview / local dev, but still nice
|
||||||
const versionName =
|
const versionName =
|
||||||
latestVersion.name === 'current' && allVersions.length > 1
|
latestVersion.name === 'current' && allVersions.length > 1
|
||||||
|
@ -37,8 +39,8 @@ function PackageJson() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function VersionNotice() {
|
function VersionNotice() {
|
||||||
const latestVersion = useLatestVersion();
|
const latestVersion = useLatestVersion(docsPluginId);
|
||||||
const activeVersion = useActiveDocContext().activeVersion!;
|
const activeVersion = useActiveDocContext(docsPluginId).activeVersion!;
|
||||||
const isBrowser = useIsBrowser();
|
const isBrowser = useIsBrowser();
|
||||||
// It's possible that the user is browsing a snapshot version
|
// It's possible that the user is browsing a snapshot version
|
||||||
// which is only detectable once we are in the browser
|
// which is only detectable once we are in the browser
|
||||||
|
|
|
@ -17,6 +17,8 @@ import Layout from '@theme/Layout';
|
||||||
import Heading from '@theme/Heading';
|
import Heading from '@theme/Heading';
|
||||||
import VersionsArchived from '@site/versionsArchived.json';
|
import VersionsArchived from '@site/versionsArchived.json';
|
||||||
|
|
||||||
|
const docsPluginId = undefined; // Default docs plugin instance
|
||||||
|
|
||||||
const VersionsArchivedList = Object.entries(VersionsArchived);
|
const VersionsArchivedList = Object.entries(VersionsArchived);
|
||||||
|
|
||||||
function DocumentationLabel() {
|
function DocumentationLabel() {
|
||||||
|
@ -37,8 +39,8 @@ export default function Version(): JSX.Element {
|
||||||
const {
|
const {
|
||||||
siteConfig: {organizationName, projectName},
|
siteConfig: {organizationName, projectName},
|
||||||
} = useDocusaurusContext();
|
} = useDocusaurusContext();
|
||||||
const versions = useVersions();
|
const versions = useVersions(docsPluginId);
|
||||||
const latestVersion = useLatestVersion();
|
const latestVersion = useLatestVersion(docsPluginId);
|
||||||
const currentVersion = versions.find(
|
const currentVersion = versions.find(
|
||||||
(version) => version.name === 'current',
|
(version) => version.name === 'current',
|
||||||
)!;
|
)!;
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"importsNotUsedAsValues": "remove",
|
"importsNotUsedAsValues": "remove",
|
||||||
|
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
|
||||||
// This is important. We run `yarn tsc` in website so we can catch issues
|
// This is important. We run `yarn tsc` in website so we can catch issues
|
||||||
// with our declaration files (mostly names that are forgotten to be
|
// with our declaration files (mostly names that are forgotten to be
|
||||||
// imported, invalid semantics...). Because we don't have end-to-end type
|
// imported, invalid semantics...). Because we don't have end-to-end type
|
||||||
|
|
19
yarn.lock
19
yarn.lock
|
@ -3259,9 +3259,9 @@
|
||||||
integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==
|
integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==
|
||||||
|
|
||||||
"@tsconfig/docusaurus@^1.0.5":
|
"@tsconfig/docusaurus@^1.0.5":
|
||||||
version "1.0.5"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.5.tgz#5298c5b0333c6263f06c3149b38ebccc9f169a4e"
|
resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.6.tgz#7305a7fa590decc0d5968500234e95fd68788978"
|
||||||
integrity sha512-KM/TuJa9fugo67dTGx+ktIqf3fVc077J6jwHu845Hex4EQf7LABlNonP/mohDKT0cmncdtlYVHHF74xR/YpThg==
|
integrity sha512-1QxDaP54hpzM6bq9E+yFEo4F9WbWHhsDe4vktZXF/iDlc9FqGr9qlg+3X/nuKQXx8QxHV7ue8NXFazzajsxFBA==
|
||||||
|
|
||||||
"@types/babel__core@^7.1.14":
|
"@types/babel__core@^7.1.14":
|
||||||
version "7.1.19"
|
version "7.1.19"
|
||||||
|
@ -14884,16 +14884,11 @@ typedarray@^0.0.6:
|
||||||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||||
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==
|
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==
|
||||||
|
|
||||||
typescript@^4.6.4:
|
typescript@^4.7.3, typescript@~4.7.3:
|
||||||
version "4.7.3"
|
version "4.7.3"
|
||||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.3.tgz#8364b502d5257b540f9de4c40be84c98e23a129d"
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.3.tgz#8364b502d5257b540f9de4c40be84c98e23a129d"
|
||||||
integrity sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==
|
integrity sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==
|
||||||
|
|
||||||
typescript@~4.6.4:
|
|
||||||
version "4.6.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9"
|
|
||||||
integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==
|
|
||||||
|
|
||||||
ua-parser-js@^0.7.30:
|
ua-parser-js@^0.7.30:
|
||||||
version "0.7.31"
|
version "0.7.31"
|
||||||
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6"
|
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6"
|
||||||
|
@ -15365,9 +15360,9 @@ vfile@^4.0.0:
|
||||||
vfile-message "^2.0.0"
|
vfile-message "^2.0.0"
|
||||||
|
|
||||||
vfile@^5.0.0:
|
vfile@^5.0.0:
|
||||||
version "5.3.2"
|
version "5.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/vfile/-/vfile-5.3.2.tgz#b499fbc50197ea50ad3749e9b60beb16ca5b7c54"
|
resolved "https://registry.yarnpkg.com/vfile/-/vfile-5.3.3.tgz#70b75779d99e0698a8cb6536a09361ac37f800a0"
|
||||||
integrity sha512-w0PLIugRY3Crkgw89TeMvHCzqCs/zpreR31hl4D92y6SOE07+bfJe+dK5Q2akwS+i/c801kzjoOr9gMcTe6IAA==
|
integrity sha512-xwALvwUKmXzHOri5dGXqXNN8JDEvxPhf8avC+E+pJEl32e4/grLdRdsgx23HpK7QI0cwgR4+QfaM8D5KUnki3g==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/unist" "^2.0.0"
|
"@types/unist" "^2.0.0"
|
||||||
is-buffer "^2.0.0"
|
is-buffer "^2.0.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue