Skip to content

Commit c7594b8

Browse files
authored
breaking: Upgrade to Docusaurus v3. Drop Node.js v16 and TypeScript v4. (#115)
* Update deps. * Update ts. * Update routes. * Fix TS types. * Polish. * Update CI. * Fix ts.
1 parent a454145 commit c7594b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4027
-2898
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
node-version: [16, 18]
13+
node-version: [18, 20]
1414
fail-fast: true
1515
steps:
1616
- uses: actions/checkout@v3

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
},
1515
"devDependencies": {
1616
"@moonrepo/dev": "^2.0.1",
17-
"@types/marked": "^4.3.1",
18-
"@types/react": "^18.2.23",
19-
"eslint": "^8.50.0",
20-
"eslint-config-moon": "^2.0.10",
21-
"lerna": "^7.3.0",
22-
"packemon": "^3.2.1",
17+
"@types/marked": "^4.3.2",
18+
"@types/react": "^18.2.33",
19+
"eslint": "^8.52.0",
20+
"eslint-config-moon": "^2.0.11",
21+
"lerna": "^7.4.2",
22+
"packemon": "^3.2.2",
2323
"prettier": "^3.0.3",
2424
"prettier-config-moon": "^1.1.2",
2525
"react": "^18.2.0",

packages/plugin/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@
4040
]
4141
},
4242
"peerDependencies": {
43-
"@docusaurus/core": "^2.0.0",
44-
"react": ">=16.0.0",
45-
"typescript": "^4.0.0 || ^5.0.0"
43+
"@docusaurus/core": "^3.0.0",
44+
"react": ">=18.0.0",
45+
"typescript": "^5.0.0"
4646
},
4747
"dependencies": {
48-
"@docusaurus/plugin-content-docs": "^2.4.3",
49-
"@docusaurus/types": "^2.4.3",
50-
"@docusaurus/utils": "^2.4.3",
51-
"@vscode/codicons": "^0.0.33",
48+
"@docusaurus/plugin-content-docs": "^3.0.0",
49+
"@docusaurus/types": "^3.0.0",
50+
"@docusaurus/utils": "^3.0.0",
51+
"@vscode/codicons": "^0.0.35",
5252
"marked": "^4.3.0",
5353
"typedoc": "0.25.0"
5454
},
5555
"devDependencies": {
56-
"@docusaurus/module-type-aliases": "^2.4.3",
56+
"@docusaurus/module-type-aliases": "^3.0.0",
57+
"@docusaurus/tsconfig": "^3.0.0",
5758
"react": "^18.2.0",
5859
"react-dom": "^18.2.0",
5960
"typescript": "^5.2.2"

packages/plugin/src/components/AnchorLink.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
export interface AnchorLinkProps {
42
id: string;
53
}

packages/plugin/src/components/ApiChangelog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { PageMetadata } from '@docusaurus/theme-common';
32
import type { Props as DocItemProps } from '@theme/DocItem';
43
import type { TOCItem } from '../types';

packages/plugin/src/components/ApiDataContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { createContext } from 'react';
2-
import type { ApiOptions, DeclarationReflectionMap } from '../types';
2+
import type { ApiOptions, TSDDeclarationReflectionMap } from '../types';
33

44
export const ApiDataContext = createContext<{
55
options: ApiOptions;
6-
reflections: DeclarationReflectionMap;
6+
reflections: TSDDeclarationReflectionMap;
77
}>({
88
options: {
99
banner: '',

packages/plugin/src/components/ApiIndex.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import { useEffect } from 'react';
22
import Link from '@docusaurus/Link';
33
import type { PropVersionMetadata } from '@docusaurus/plugin-content-docs';
44
import type { GlobalVersion } from '@docusaurus/plugin-content-docs/client';

packages/plugin/src/components/ApiItem.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
import React, { useMemo } from 'react';
2-
import type { JSONOutput } from 'typedoc';
1+
import { useMemo } from 'react';
32
import { PageMetadata } from '@docusaurus/theme-common';
43
import type { Props as DocItemProps } from '@theme/DocItem';
54
import { useReflection } from '../hooks/useReflection';
65
import { useReflectionMap } from '../hooks/useReflectionMap';
7-
import type { DeclarationReflectionMap, TOCItem } from '../types';
6+
import type { TOCItem, TSDDeclarationReflection, TSDDeclarationReflectionMap } from '../types';
87
import { getKindIconHtml } from '../utils/icons';
98
import ApiItemLayout from './ApiItemLayout';
109
import { displayPartsToMarkdown } from './Comment';
1110
import { Flags } from './Flags';
1211
import { Reflection } from './Reflection';
1312
import { TypeParametersGeneric } from './TypeParametersGeneric';
1413

15-
function extractTOC(
16-
item: JSONOutput.DeclarationReflection,
17-
map: DeclarationReflectionMap,
18-
): TOCItem[] {
14+
function extractTOC(item: TSDDeclarationReflection, map: TSDDeclarationReflectionMap): TOCItem[] {
1915
const toc: TOCItem[] = [];
2016
const mapped = new Set<string>();
2117

packages/plugin/src/components/ApiItemLayout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// we had to duplicate it. Keep this file in sync as much as possible!
33
// https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/theme/DocItem/index.tsx
44

5-
import React from 'react';
65
import type { PropNavigation } from '@docusaurus/plugin-content-docs';
76
import { ThemeClassNames, useWindowSize } from '@docusaurus/theme-common';
87
import DocBreadcrumbs from '@theme/DocBreadcrumbs';

packages/plugin/src/components/ApiPage.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,33 @@
22

33
import '@vscode/codicons/dist/codicon.css';
44
import './styles.css';
5-
import React, { useMemo } from 'react';
6-
import type { JSONOutput } from 'typedoc';
7-
import DocPage, { type Props as DocPageProps } from '@theme/DocPage';
8-
import type { ApiOptions, DeclarationReflectionMap, PackageReflectionGroup } from '../types';
5+
import { useMemo } from 'react';
6+
import DocRoot, { type Props as DocRootProps } from '@theme/DocRoot';
7+
import type {
8+
ApiOptions,
9+
PackageReflectionGroup,
10+
TSDDeclarationReflection,
11+
TSDDeclarationReflectionMap,
12+
TSDReflection,
13+
} from '../types';
914
import { ApiDataContext } from './ApiDataContext';
1015

11-
function isObject(value: unknown): value is JSONOutput.Reflection {
16+
function isObject(value: unknown): value is TSDReflection {
1217
return typeof value === 'object' && value !== null && !Array.isArray(value);
1318
}
1419

1520
function deepMapReflections(
16-
data: JSONOutput.Reflection,
17-
map: DeclarationReflectionMap,
18-
parent?: JSONOutput.Reflection,
21+
data: TSDReflection,
22+
map: TSDDeclarationReflectionMap,
23+
parent?: TSDReflection,
1924
) {
2025
Object.entries(data).forEach(([key, value]) => {
2126
if (key === 'id') {
2227
const hasType = 'type' in data;
2328

2429
// Dont overwrite with reference nodes
2530
if (!hasType || (hasType && (data as unknown as { type: string }).type !== 'reference')) {
26-
map[Number(value)] = data as JSONOutput.DeclarationReflection;
31+
map[Number(value)] = data as TSDDeclarationReflection;
2732

2833
if (parent) {
2934
data.parentId = parent.id;
@@ -43,8 +48,8 @@ function deepMapReflections(
4348
return map;
4449
}
4550

46-
function mapPackagesToReflection(packages: PackageReflectionGroup[]): DeclarationReflectionMap {
47-
const map: DeclarationReflectionMap = {};
51+
function mapPackagesToReflection(packages: PackageReflectionGroup[]): TSDDeclarationReflectionMap {
52+
const map: TSDDeclarationReflectionMap = {};
4853

4954
packages.forEach((pkg) => {
5055
pkg.entryPoints.forEach((entry) => {
@@ -55,7 +60,7 @@ function mapPackagesToReflection(packages: PackageReflectionGroup[]): Declaratio
5560
return map;
5661
}
5762

58-
export interface ApiPageProps extends DocPageProps {
63+
export interface ApiPageProps extends DocRootProps {
5964
options: ApiOptions;
6065
packages: PackageReflectionGroup[];
6166
}
@@ -69,7 +74,7 @@ function ApiPage({ options, packages, ...props }: ApiPageProps) {
6974
return (
7075
<ApiDataContext.Provider value={value}>
7176
<div className="apiPage">
72-
<DocPage {...props} />
77+
<DocRoot {...props} />
7378
</div>
7479
</ApiDataContext.Provider>
7580
);

0 commit comments

Comments
 (0)