Upgrade to React 19, Next 15.1 and enable React Compiler (#6996)

Co-authored-by: Sebastian Markbåge <sebastian@calyptus.eu>
Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>
Co-authored-by: eps1lon <sebastian.silbermann@vercel.com>
This commit is contained in:
Matt Carroll
2025-01-13 08:48:01 -08:00
committed by GitHub
parent 517c0fa442
commit 855ce2373d
40 changed files with 1714 additions and 512 deletions

View File

@@ -6,7 +6,8 @@
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "^_" }],
"react-hooks/exhaustive-deps": "error"
"react-hooks/exhaustive-deps": "error",
"react/no-unknown-property": ["error", { "ignore": ["meta"] }]
},
"env": {
"node": true,

2
next-env.d.ts vendored
View File

@@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

View File

@@ -9,10 +9,8 @@ const nextConfig = {
pageExtensions: ['jsx', 'js', 'ts', 'tsx', 'mdx', 'md'],
reactStrictMode: true,
experimental: {
// TODO: Remove after https://github.com/vercel/next.js/issues/49355 is fixed
appDir: false,
scrollRestoration: true,
legacyBrowsers: false,
reactCompiler: true,
},
env: {},
webpack: (config, {dev, isServer, ...options}) => {

View File

@@ -18,7 +18,7 @@
"ci-check": "npm-run-all prettier:diff --parallel lint tsc lint-heading-ids rss",
"tsc": "tsc --noEmit",
"start": "next start",
"postinstall": "patch-package && (is-ci || husky install .husky)",
"postinstall": "is-ci || husky install .husky",
"check-all": "npm-run-all prettier lint:fix tsc rss",
"rss": "node scripts/generateRss.js"
},
@@ -28,17 +28,18 @@
"@docsearch/react": "^3.6.1",
"@headlessui/react": "^1.7.0",
"@radix-ui/react-context-menu": "^2.1.5",
"babel-plugin-react-compiler": "0.0.0-experimental-696af53-20240625",
"body-scroll-lock": "^3.1.3",
"classnames": "^2.2.6",
"date-fns": "^2.16.1",
"debounce": "^1.2.1",
"github-slugger": "^1.3.0",
"next": "^13.4.1",
"next": "15.1.0",
"next-remote-watch": "^1.0.0",
"parse-numeric-range": "^1.2.0",
"react": "^0.0.0-experimental-16d053d59-20230506",
"react": "^19.0.0",
"react-collapsed": "4.0.4",
"react-dom": "^0.0.0-experimental-16d053d59-20230506",
"react-dom": "^19.0.0",
"remark-frontmatter": "^4.0.1",
"remark-gfm": "^3.0.1"
},
@@ -54,8 +55,8 @@
"@types/mdx-js__react": "^1.5.2",
"@types/node": "^14.6.4",
"@types/parse-numeric-range": "^0.0.1",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.5",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"asyncro": "^3.0.0",
@@ -78,7 +79,6 @@
"mdast-util-to-string": "^1.1.0",
"metro-cache": "0.72.2",
"npm-run-all": "^4.1.5",
"patch-package": "^6.2.2",
"postcss": "^8.4.5",
"postcss-flexbugs-fixes": "4.2.1",
"postcss-preset-env": "^6.7.0",
@@ -94,7 +94,7 @@
"retext-smartypants": "^4.0.0",
"rss": "^1.2.2",
"tailwindcss": "^3.4.1",
"typescript": "^4.0.2",
"typescript": "^5.7.2",
"unist-util-visit": "^2.0.3",
"webpack-bundle-analyzer": "^4.5.0"
},

View File

@@ -1,22 +0,0 @@
diff --git a/node_modules/next/dist/server/render.js b/node_modules/next/dist/server/render.js
index a1f8648..1b3d608 100644
--- a/node_modules/next/dist/server/render.js
+++ b/node_modules/next/dist/server/render.js
@@ -758,9 +758,14 @@ async function renderToHTML(req, res, pathname, query, renderOpts) {
// Always using react concurrent rendering mode with required react version 18.x
const renderShell = async (EnhancedApp, EnhancedComponent)=>{
const content = renderContent(EnhancedApp, EnhancedComponent);
- return await (0, _nodewebstreamshelper.renderToInitialStream)({
- ReactDOMServer: _serverbrowser.default,
- element: content
+ return new Promise((resolve, reject) => {
+ (0, _nodewebstreamshelper.renderToInitialStream)({
+ ReactDOMServer: _serverbrowser.default,
+ element: content,
+ streamOptions: {
+ onError: reject
+ }
+ }).then(resolve, reject);
});
};
const createBodyResult = (0, _tracer.getTracer)().wrap(_constants2.RenderSpan.createBodyResult, (initialStream, suffix)=>{

View File

@@ -1,16 +0,0 @@
diff --git a/node_modules/next-remote-watch/bin/next-remote-watch b/node_modules/next-remote-watch/bin/next-remote-watch
index c055b66..a2f749c 100755
--- a/node_modules/next-remote-watch/bin/next-remote-watch
+++ b/node_modules/next-remote-watch/bin/next-remote-watch
@@ -66,7 +66,10 @@ app.prepare().then(() => {
}
}
- app.server.hotReloader.send('reloadPage')
+ app.server.hotReloader.send({
+ event: 'serverOnlyChanges',
+ pages: ['/[[...markdownPath]]']
+ });
}
)
}

View File

@@ -1,13 +1,17 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
import type {DetailedHTMLProps, AnchorHTMLAttributes} from 'react';
export function ExternalLink({
href,
target,
children,
...props
}: JSX.IntrinsicElements['a']) {
}: DetailedHTMLProps<
AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>) {
return (
<a href={href} target={target ?? '_blank'} rel="noopener" {...props}>
{children}

View File

@@ -4,9 +4,10 @@
import {memo} from 'react';
import cn from 'classnames';
import type {SVGProps} from 'react';
export const IconArrow = memo<
JSX.IntrinsicElements['svg'] & {
SVGProps<SVGSVGElement> & {
/**
* The direction the arrow should point.
* `start` and `end` are relative to the current locale.

View File

@@ -4,9 +4,10 @@
import {memo} from 'react';
import cn from 'classnames';
import type {SVGProps} from 'react';
export const IconArrowSmall = memo<
JSX.IntrinsicElements['svg'] & {
SVGProps<SVGSVGElement> & {
/**
* The direction the arrow should point.
* `start` and `end` are relative to the current locale.

View File

@@ -3,10 +3,9 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconBsky = memo<JSX.IntrinsicElements['svg']>(function IconBsky(
props
) {
export const IconBsky = memo<SVGProps<SVGSVGElement>>(function IconBsky(props) {
return (
<svg
aria-label="Bluesky"

View File

@@ -3,8 +3,9 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconClose = memo<JSX.IntrinsicElements['svg']>(function IconClose(
export const IconClose = memo<SVGProps<SVGSVGElement>>(function IconClose(
props
) {
return (

View File

@@ -3,8 +3,9 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconFacebookCircle = memo<JSX.IntrinsicElements['svg']>(
export const IconFacebookCircle = memo<SVGProps<SVGSVGElement>>(
function IconFacebookCircle(props) {
return (
<svg

View File

@@ -3,19 +3,20 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconGitHub = memo<JSX.IntrinsicElements['svg']>(
function IconGitHub(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1.5em"
height="1.5em"
viewBox="0 -2 24 24"
fill="currentColor"
{...props}>
<path d="M10 0a10 10 0 0 0-3.16 19.49c.5.1.68-.22.68-.48l-.01-1.7c-2.78.6-3.37-1.34-3.37-1.34-.46-1.16-1.11-1.47-1.11-1.47-.9-.62.07-.6.07-.6 1 .07 1.53 1.03 1.53 1.03.9 1.52 2.34 1.08 2.91.83.1-.65.35-1.09.63-1.34-2.22-.25-4.55-1.11-4.55-4.94 0-1.1.39-1.99 1.03-2.69a3.6 3.6 0 0 1 .1-2.64s.84-.27 2.75 1.02a9.58 9.58 0 0 1 5 0c1.91-1.3 2.75-1.02 2.75-1.02.55 1.37.2 2.4.1 2.64.64.7 1.03 1.6 1.03 2.69 0 3.84-2.34 4.68-4.57 4.93.36.31.68.92.68 1.85l-.01 2.75c0 .26.18.58.69.48A10 10 0 0 0 10 0"></path>
</svg>
);
}
);
export const IconGitHub = memo<SVGProps<SVGSVGElement>>(function IconGitHub(
props
) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="1.5em"
height="1.5em"
viewBox="0 -2 24 24"
fill="currentColor"
{...props}>
<path d="M10 0a10 10 0 0 0-3.16 19.49c.5.1.68-.22.68-.48l-.01-1.7c-2.78.6-3.37-1.34-3.37-1.34-.46-1.16-1.11-1.47-1.11-1.47-.9-.62.07-.6.07-.6 1 .07 1.53 1.03 1.53 1.03.9 1.52 2.34 1.08 2.91.83.1-.65.35-1.09.63-1.34-2.22-.25-4.55-1.11-4.55-4.94 0-1.1.39-1.99 1.03-2.69a3.6 3.6 0 0 1 .1-2.64s.84-.27 2.75 1.02a9.58 9.58 0 0 1 5 0c1.91-1.3 2.75-1.02 2.75-1.02.55 1.37.2 2.4.1 2.64.64.7 1.03 1.6 1.03 2.69 0 3.84-2.34 4.68-4.57 4.93.36.31.68.92.68 1.85l-.01 2.75c0 .26.18.58.69.48A10 10 0 0 0 10 0"></path>
</svg>
);
});

View File

@@ -3,8 +3,9 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconHamburger = memo<JSX.IntrinsicElements['svg']>(
export const IconHamburger = memo<SVGProps<SVGSVGElement>>(
function IconHamburger(props) {
return (
<svg

View File

@@ -3,8 +3,9 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconInstagram = memo<JSX.IntrinsicElements['svg']>(
export const IconInstagram = memo<SVGProps<SVGSVGElement>>(
function IconInstagram(props) {
return (
<svg

View File

@@ -3,10 +3,9 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconLink = memo<JSX.IntrinsicElements['svg']>(function IconLink(
props
) {
export const IconLink = memo<SVGProps<SVGSVGElement>>(function IconLink(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"

View File

@@ -3,26 +3,27 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconNewPage = memo<JSX.IntrinsicElements['svg']>(
function IconNewPage(props) {
return (
<svg
width="1em"
height="1em"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}>
<path
d="M20.5001 2H15.5001C15.3675 2 15.2403 2.05268 15.1465 2.14645C15.0528 2.24021 15.0001 2.36739 15.0001 2.5V3.5C15.0001 3.63261 15.0528 3.75979 15.1465 3.85355C15.2403 3.94732 15.3675 4 15.5001 4H18.5901L7.6501 14.94C7.60323 14.9865 7.56604 15.0418 7.54065 15.1027C7.51527 15.1636 7.5022 15.229 7.5022 15.295C7.5022 15.361 7.51527 15.4264 7.54065 15.4873C7.56604 15.5482 7.60323 15.6035 7.6501 15.65L8.3501 16.35C8.39658 16.3969 8.45188 16.4341 8.51281 16.4594C8.57374 16.4848 8.63909 16.4979 8.7051 16.4979C8.7711 16.4979 8.83646 16.4848 8.89738 16.4594C8.95831 16.4341 9.01362 16.3969 9.0601 16.35L20.0001 5.41V8.5C20.0001 8.63261 20.0528 8.75979 20.1465 8.85355C20.2403 8.94732 20.3675 9 20.5001 9H21.5001C21.6327 9 21.7599 8.94732 21.8537 8.85355C21.9474 8.75979 22.0001 8.63261 22.0001 8.5V3.5C22.0001 3.10218 21.8421 2.72064 21.5608 2.43934C21.2795 2.15804 20.8979 2 20.5001 2V2Z"
fill="currentColor"
/>
<path
d="M21.5 13H20.5C20.3674 13 20.2402 13.0527 20.1464 13.1464C20.0527 13.2402 20 13.3674 20 13.5V20H4V4H10.5C10.6326 4 10.7598 3.94732 10.8536 3.85355C10.9473 3.75979 11 3.63261 11 3.5V2.5C11 2.36739 10.9473 2.24021 10.8536 2.14645C10.7598 2.05268 10.6326 2 10.5 2H3.5C3.10218 2 2.72064 2.15804 2.43934 2.43934C2.15804 2.72064 2 3.10218 2 3.5V20.5C2 20.8978 2.15804 21.2794 2.43934 21.5607C2.72064 21.842 3.10218 22 3.5 22H20.5C20.8978 22 21.2794 21.842 21.5607 21.5607C21.842 21.2794 22 20.8978 22 20.5V13.5C22 13.3674 21.9473 13.2402 21.8536 13.1464C21.7598 13.0527 21.6326 13 21.5 13Z"
fill="currentColor"
/>
</svg>
);
}
);
export const IconNewPage = memo<SVGProps<SVGSVGElement>>(function IconNewPage(
props
) {
return (
<svg
width="1em"
height="1em"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}>
<path
d="M20.5001 2H15.5001C15.3675 2 15.2403 2.05268 15.1465 2.14645C15.0528 2.24021 15.0001 2.36739 15.0001 2.5V3.5C15.0001 3.63261 15.0528 3.75979 15.1465 3.85355C15.2403 3.94732 15.3675 4 15.5001 4H18.5901L7.6501 14.94C7.60323 14.9865 7.56604 15.0418 7.54065 15.1027C7.51527 15.1636 7.5022 15.229 7.5022 15.295C7.5022 15.361 7.51527 15.4264 7.54065 15.4873C7.56604 15.5482 7.60323 15.6035 7.6501 15.65L8.3501 16.35C8.39658 16.3969 8.45188 16.4341 8.51281 16.4594C8.57374 16.4848 8.63909 16.4979 8.7051 16.4979C8.7711 16.4979 8.83646 16.4848 8.89738 16.4594C8.95831 16.4341 9.01362 16.3969 9.0601 16.35L20.0001 5.41V8.5C20.0001 8.63261 20.0528 8.75979 20.1465 8.85355C20.2403 8.94732 20.3675 9 20.5001 9H21.5001C21.6327 9 21.7599 8.94732 21.8537 8.85355C21.9474 8.75979 22.0001 8.63261 22.0001 8.5V3.5C22.0001 3.10218 21.8421 2.72064 21.5608 2.43934C21.2795 2.15804 20.8979 2 20.5001 2V2Z"
fill="currentColor"
/>
<path
d="M21.5 13H20.5C20.3674 13 20.2402 13.0527 20.1464 13.1464C20.0527 13.2402 20 13.3674 20 13.5V20H4V4H10.5C10.6326 4 10.7598 3.94732 10.8536 3.85355C10.9473 3.75979 11 3.63261 11 3.5V2.5C11 2.36739 10.9473 2.24021 10.8536 2.14645C10.7598 2.05268 10.6326 2 10.5 2H3.5C3.10218 2 2.72064 2.15804 2.43934 2.43934C2.15804 2.72064 2 3.10218 2 3.5V20.5C2 20.8978 2.15804 21.2794 2.43934 21.5607C2.72064 21.842 3.10218 22 3.5 22H20.5C20.8978 22 21.2794 21.842 21.5607 21.5607C21.842 21.2794 22 20.8978 22 20.5V13.5C22 13.3674 21.9473 13.2402 21.8536 13.1464C21.7598 13.0527 21.6326 13 21.5 13Z"
fill="currentColor"
/>
</svg>
);
});

View File

@@ -3,10 +3,9 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconRss = memo<JSX.IntrinsicElements['svg']>(function IconRss(
props
) {
export const IconRss = memo<SVGProps<SVGSVGElement>>(function IconRss(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"

View File

@@ -3,20 +3,21 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconSearch = memo<JSX.IntrinsicElements['svg']>(
function IconSearch(props) {
return (
<svg width="1em" height="1em" viewBox="0 0 20 20" {...props}>
<path
d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
stroke="currentColor"
fill="none"
strokeWidth="2"
fillRule="evenodd"
strokeLinecap="round"
strokeLinejoin="round"></path>
</svg>
);
}
);
export const IconSearch = memo<SVGProps<SVGSVGElement>>(function IconSearch(
props
) {
return (
<svg width="1em" height="1em" viewBox="0 0 20 20" {...props}>
<path
d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
stroke="currentColor"
fill="none"
strokeWidth="2"
fillRule="evenodd"
strokeLinecap="round"
strokeLinejoin="round"></path>
</svg>
);
});

View File

@@ -3,22 +3,23 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconThreads = memo<JSX.IntrinsicElements['svg']>(
function IconThreads(props) {
return (
<svg
aria-label="Threads"
viewBox="0 0 192 192"
height="1.40em"
width="1.40em"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
{...props}>
<path
className="x19hqcy"
d="M141.537 88.9883C140.71 88.5919 139.87 88.2104 139.019 87.8451C137.537 60.5382 122.616 44.905 97.5619 44.745C97.4484 44.7443 97.3355 44.7443 97.222 44.7443C82.2364 44.7443 69.7731 51.1409 62.102 62.7807L75.881 72.2328C81.6116 63.5383 90.6052 61.6848 97.2286 61.6848C97.3051 61.6848 97.3819 61.6848 97.4576 61.6855C105.707 61.7381 111.932 64.1366 115.961 68.814C118.893 72.2193 120.854 76.925 121.825 82.8638C114.511 81.6207 106.601 81.2385 98.145 81.7233C74.3247 83.0954 59.0111 96.9879 60.0396 116.292C60.5615 126.084 65.4397 134.508 73.775 140.011C80.8224 144.663 89.899 146.938 99.3323 146.423C111.79 145.74 121.563 140.987 128.381 132.296C133.559 125.696 136.834 117.143 138.28 106.366C144.217 109.949 148.617 114.664 151.047 120.332C155.179 129.967 155.42 145.8 142.501 158.708C131.182 170.016 117.576 174.908 97.0135 175.059C74.2042 174.89 56.9538 167.575 45.7381 153.317C35.2355 139.966 29.8077 120.682 29.6052 96C29.8077 71.3178 35.2355 52.0336 45.7381 38.6827C56.9538 24.4249 74.2039 17.11 97.0132 16.9405C119.988 17.1113 137.539 24.4614 149.184 38.788C154.894 45.8136 159.199 54.6488 162.037 64.9503L178.184 60.6422C174.744 47.9622 169.331 37.0357 161.965 27.974C147.036 9.60668 125.202 0.195148 97.0695 0H96.9569C68.8816 0.19447 47.2921 9.6418 32.7883 28.0793C19.8819 44.4864 13.2244 67.3157 13.0007 95.9325L13 96L13.0007 96.0675C13.2244 124.684 19.8819 147.514 32.7883 163.921C47.2921 182.358 68.8816 191.806 96.9569 192H97.0695C122.03 191.827 139.624 185.292 154.118 170.811C173.081 151.866 172.51 128.119 166.26 113.541C161.776 103.087 153.227 94.5962 141.537 88.9883ZM98.4405 129.507C88.0005 130.095 77.1544 125.409 76.6196 115.372C76.2232 107.93 81.9158 99.626 99.0812 98.6368C101.047 98.5234 102.976 98.468 104.871 98.468C111.106 98.468 116.939 99.0737 122.242 100.233C120.264 124.935 108.662 128.946 98.4405 129.507Z"></path>
</svg>
);
}
);
export const IconThreads = memo<SVGProps<SVGSVGElement>>(function IconThreads(
props
) {
return (
<svg
aria-label="Threads"
viewBox="0 0 192 192"
height="1.40em"
width="1.40em"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
{...props}>
<path
className="x19hqcy"
d="M141.537 88.9883C140.71 88.5919 139.87 88.2104 139.019 87.8451C137.537 60.5382 122.616 44.905 97.5619 44.745C97.4484 44.7443 97.3355 44.7443 97.222 44.7443C82.2364 44.7443 69.7731 51.1409 62.102 62.7807L75.881 72.2328C81.6116 63.5383 90.6052 61.6848 97.2286 61.6848C97.3051 61.6848 97.3819 61.6848 97.4576 61.6855C105.707 61.7381 111.932 64.1366 115.961 68.814C118.893 72.2193 120.854 76.925 121.825 82.8638C114.511 81.6207 106.601 81.2385 98.145 81.7233C74.3247 83.0954 59.0111 96.9879 60.0396 116.292C60.5615 126.084 65.4397 134.508 73.775 140.011C80.8224 144.663 89.899 146.938 99.3323 146.423C111.79 145.74 121.563 140.987 128.381 132.296C133.559 125.696 136.834 117.143 138.28 106.366C144.217 109.949 148.617 114.664 151.047 120.332C155.179 129.967 155.42 145.8 142.501 158.708C131.182 170.016 117.576 174.908 97.0135 175.059C74.2042 174.89 56.9538 167.575 45.7381 153.317C35.2355 139.966 29.8077 120.682 29.6052 96C29.8077 71.3178 35.2355 52.0336 45.7381 38.6827C56.9538 24.4249 74.2039 17.11 97.0132 16.9405C119.988 17.1113 137.539 24.4614 149.184 38.788C154.894 45.8136 159.199 54.6488 162.037 64.9503L178.184 60.6422C174.744 47.9622 169.331 37.0357 161.965 27.974C147.036 9.60668 125.202 0.195148 97.0695 0H96.9569C68.8816 0.19447 47.2921 9.6418 32.7883 28.0793C19.8819 44.4864 13.2244 67.3157 13.0007 95.9325L13 96L13.0007 96.0675C13.2244 124.684 19.8819 147.514 32.7883 163.921C47.2921 182.358 68.8816 191.806 96.9569 192H97.0695C122.03 191.827 139.624 185.292 154.118 170.811C173.081 151.866 172.51 128.119 166.26 113.541C161.776 103.087 153.227 94.5962 141.537 88.9883ZM98.4405 129.507C88.0005 130.095 77.1544 125.409 76.6196 115.372C76.2232 107.93 81.9158 99.626 99.0812 98.6368C101.047 98.5234 102.976 98.468 104.871 98.468C111.106 98.468 116.939 99.0737 122.242 100.233C120.264 124.935 108.662 128.946 98.4405 129.507Z"></path>
</svg>
);
});

View File

@@ -3,20 +3,21 @@
*/
import {memo} from 'react';
import type {SVGProps} from 'react';
export const IconTwitter = memo<JSX.IntrinsicElements['svg']>(
function IconTwitter(props) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
height="1.30em"
width="1.30em"
fill="currentColor"
{...props}>
<path fill="none" d="M0 0h24v24H0z" />
<path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z" />
</svg>
);
}
);
export const IconTwitter = memo<SVGProps<SVGSVGElement>>(function IconTwitter(
props
) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
height="1.30em"
width="1.30em"
fill="currentColor"
{...props}>
<path fill="none" d="M0 0h24v24H0z" />
<path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z" />
</svg>
);
});

View File

@@ -1,8 +1,9 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
import type {SVGProps} from 'react';
export function Logo(props: JSX.IntrinsicElements['svg']) {
export function Logo(props: SVGProps<SVGSVGElement>) {
return (
<svg
width="100%"

View File

@@ -40,7 +40,10 @@ const parseChallengeContents = (
let challenge: Partial<ChallengeContents> = {};
let content: React.ReactElement[] = [];
Children.forEach(children, (child) => {
const {props, type} = child;
const {props, type} = child as React.ReactElement<{
children?: string;
id?: string;
}>;
switch ((type as any).mdxName) {
case 'Solution': {
challenge.solution = child;

View File

@@ -289,7 +289,7 @@ function getSyntaxHighlight(theme: any): HighlightStyle {
function getLineDecorators(
code: string,
meta: string
meta?: string
): Array<{
line: number;
className: string;
@@ -309,7 +309,7 @@ function getLineDecorators(
function getInlineDecorators(
code: string,
meta: string
meta?: string
): Array<{
step: number;
line: number;

View File

@@ -17,7 +17,14 @@ export function CodeDiagram({children, flip = false}: CodeDiagramProps) {
});
const content = Children.toArray(children).map((child: any) => {
if (child.type?.mdxName === 'pre') {
return <CodeBlock {...child.props} noMargin={true} noMarkers={true} />;
return (
<CodeBlock
key={child.key}
{...child.props}
noMargin={true}
noMarkers={true}
/>
);
} else if (child.type === 'img') {
return null;
} else {

View File

@@ -38,7 +38,8 @@ export function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
if (typeof children === 'string') {
message = children;
} else if (isValidElement(children)) {
message = children.props.children;
message = (children as React.ReactElement<{children?: React.ReactNode}>)
.props.children;
}
return (
@@ -113,7 +114,8 @@ export function ConsoleLogLine({children, level}: ConsoleBlockProps) {
if (typeof children === 'string') {
message = children;
} else if (isValidElement(children)) {
message = children.props.children;
message = (children as React.ReactElement<{children?: React.ReactNode}>)
.props.children;
} else if (Array.isArray(children)) {
message = children.reduce((result, child) => {
if (typeof child === 'string') {

View File

@@ -3,6 +3,7 @@
*/
import cn from 'classnames';
import type {HTMLAttributes} from 'react';
interface InlineCodeProps {
isLink?: boolean;
@@ -11,7 +12,7 @@ interface InlineCodeProps {
function InlineCode({
isLink,
...props
}: JSX.IntrinsicElements['code'] & InlineCodeProps) {
}: HTMLAttributes<HTMLElement> & InlineCodeProps) {
return (
<code
dir="ltr" // This is needed to prevent the code from inheriting the RTL direction of <html> in case of RTL languages to avoid like `()console.log` to be rendered as `console.log()`

View File

@@ -5,6 +5,7 @@
import {Children, useContext, useMemo} from 'react';
import * as React from 'react';
import cn from 'classnames';
import type {HTMLAttributes} from 'react';
import CodeBlock from './CodeBlock';
import {CodeDiagram} from './CodeDiagram';
@@ -59,21 +60,21 @@ function CodeStep({children, step}: {children: any; step: number}) {
);
}
const P = (p: JSX.IntrinsicElements['p']) => (
const P = (p: HTMLAttributes<HTMLParagraphElement>) => (
<p className="whitespace-pre-wrap my-4" {...p} />
);
const Strong = (strong: JSX.IntrinsicElements['strong']) => (
const Strong = (strong: HTMLAttributes<HTMLElement>) => (
<strong className="font-bold" {...strong} />
);
const OL = (p: JSX.IntrinsicElements['ol']) => (
const OL = (p: HTMLAttributes<HTMLOListElement>) => (
<ol className="ms-6 my-3 list-decimal" {...p} />
);
const LI = (p: JSX.IntrinsicElements['li']) => (
const LI = (p: HTMLAttributes<HTMLLIElement>) => (
<li className="leading-relaxed mb-1" {...p} />
);
const UL = (p: JSX.IntrinsicElements['ul']) => (
const UL = (p: HTMLAttributes<HTMLUListElement>) => (
<ul className="ms-6 my-3 list-disc" {...p} />
);
@@ -139,10 +140,7 @@ const RSCBadge = ({title}: {title: string}) => (
</span>
);
const Blockquote = ({
children,
...props
}: JSX.IntrinsicElements['blockquote']) => {
const Blockquote = ({children, ...props}: HTMLAttributes<HTMLQuoteElement>) => {
return (
<blockquote
className="mdx-blockquote py-4 px-8 my-8 shadow-inner-border dark:shadow-inner-border-dark bg-highlight dark:bg-highlight-dark bg-opacity-50 rounded-2xl leading-6 flex relative"

View File

@@ -17,7 +17,7 @@ export const LoadingOverlay = ({
clientId: string;
dependenciesLoading: boolean;
forceLoading: boolean;
} & React.HTMLAttributes<HTMLDivElement>): JSX.Element | null => {
} & React.HTMLAttributes<HTMLDivElement>): React.ReactNode | null => {
const loadingOverlayState = useLoadingOverlayState(
clientId,
dependenciesLoading,
@@ -64,6 +64,7 @@ export const LoadingOverlay = ({
transition: `opacity ${FADE_ANIMATION_DURATION}ms ease-out`,
}}>
<div className="sp-cube-wrapper" title="Open in CodeSandbox">
{/* @ts-ignore: the OpenInCodeSandboxButton type from '@codesandbox/sandpack-react/unstyled' is incompatible with JSX in React 19 */}
<OpenInCodeSandboxButton />
<div className="sp-cube">
<div className="sp-sides">

View File

@@ -115,7 +115,10 @@ export function NavigationBar({providedFiles}: {providedFiles: Array<string>}) {
return (
<div className="bg-wash dark:bg-card-dark flex justify-between items-center relative z-10 border-b border-border dark:border-border-dark rounded-t-lg text-lg">
{/* If Prettier reformats this block, the two @ts-ignore directives will no longer be adjacent to the problematic lines, causing TypeScript errors */}
{/* prettier-ignore */}
<div className="flex-1 grow min-w-0 px-4 lg:px-6">
{/* @ts-ignore: the Listbox type from '@headlessui/react' is incompatible with JSX in React 19 */}
<Listbox value={activeFile} onChange={setActiveFile}>
<div ref={containerRef}>
<div className="relative overflow-hidden">
@@ -129,8 +132,10 @@ export function NavigationBar({providedFiles}: {providedFiles: Array<string>}) {
'w-[fit-content]',
showDropdown ? 'invisible' : ''
)}>
{/* @ts-ignore: the FileTabs type from '@codesandbox/sandpack-react/unstyled' is incompatible with JSX in React 19 */}
<FileTabs />
</div>
{/* @ts-ignore: the Listbox type from '@headlessui/react' is incompatible with JSX in React 19 */}
<Listbox.Button as={Fragment}>
{({open}) => (
// If tabs don't fit, display the dropdown instead.
@@ -160,10 +165,10 @@ export function NavigationBar({providedFiles}: {providedFiles: Array<string>}) {
</Listbox.Button>
</div>
</div>
{isMultiFile && showDropdown && (
<Listbox.Options className="absolute mt-0.5 bg-card dark:bg-card-dark px-2 inset-x-0 mx-0 rounded-b-lg border-1 border-border dark:border-border-dark rounded-sm shadow-md">
{visibleFiles.map((filePath: string) => (
<Listbox.Option key={filePath} value={filePath} as={Fragment}>
{/* @ts-ignore: the Listbox type from '@headlessui/react' is incompatible with JSX in React 19 */}
{isMultiFile && showDropdown && (<Listbox.Options className="absolute mt-0.5 bg-card dark:bg-card-dark px-2 inset-x-0 mx-0 rounded-b-lg border-1 border-border dark:border-border-dark rounded-sm shadow-md">
{/* @ts-ignore: the Listbox type from '@headlessui/react' is incompatible with JSX in React 19 */}
{visibleFiles.map((filePath: string) => (<Listbox.Option key={filePath} value={filePath} as={Fragment}>
{({active}) => (
<li
className={cn(

View File

@@ -3,6 +3,7 @@
*/
import type {SandpackFile} from '@codesandbox/sandpack-react/unstyled';
import type {PropsWithChildren, ReactElement, HTMLAttributes} from 'react';
export const AppJSPath = `/src/App.js`;
export const StylesCSSPath = `/src/styles.css`;
@@ -17,7 +18,13 @@ export const createFileMap = (codeSnippets: any) => {
) {
return result;
}
const {props} = codeSnippet.props.children;
const {props} = (
codeSnippet.props as PropsWithChildren<{
children: ReactElement<
HTMLAttributes<HTMLDivElement> & {meta?: string}
>;
}>
).children;
let filePath; // path in the folder structure
let fileHidden = false; // if the file is available as a tab
let fileActive = false; // if the file tab is shown by default

View File

@@ -39,11 +39,9 @@ export function TeamMember({
personal,
}: TeamMemberProps) {
if (name == null || title == null || permalink == null || children == null) {
const identifier = name ?? title ?? permalink ?? 'unknown';
throw new Error(
'Expected name, title, permalink, and children for ' + name ??
title ??
permalink ??
'unknown'
`Expected name, title, permalink, and children for ${identifier}`
);
}
return (

View File

@@ -31,9 +31,11 @@ function TerminalBlock({level = 'info', children}: TerminalBlockProps) {
message = children;
} else if (
isValidElement(children) &&
typeof children.props.children === 'string'
typeof (children as React.ReactElement<{children: string}>).props
.children === 'string'
) {
message = children.props.children;
message = (children as React.ReactElement<{children: string}>).props
.children;
} else {
throw Error('Expected TerminalBlock children to be a plain string.');
}

View File

@@ -9,6 +9,8 @@ import {lazy, useEffect} from 'react';
import * as React from 'react';
import {createPortal} from 'react-dom';
import {siteConfig} from 'siteConfig';
import type {ComponentType, PropsWithChildren} from 'react';
import type {DocSearchModalProps} from '@docsearch/react/modal';
export interface SearchProps {
appId?: string;
@@ -83,9 +85,10 @@ const options = {
};
const DocSearchModal: any = lazy(() =>
// @ts-ignore
import('@docsearch/react/modal').then((mod) => ({
default: mod.DocSearchModal,
default: mod.DocSearchModal as ComponentType<
PropsWithChildren<DocSearchModalProps>
>,
}))
);

View File

@@ -71,31 +71,27 @@ function useActiveSection() {
}
// Deserialize a client React tree from JSON.
function reviveNodeOnClient(key, val) {
function reviveNodeOnClient(parentPropertyName, val) {
if (Array.isArray(val) && val[0] == '$r') {
// Assume it's a React element.
let type = val[1];
let Type = val[1];
let key = val[2];
if (key == null) {
key = parentPropertyName; // Index within a parent.
}
let props = val[3];
if (type === 'wrapper') {
type = Fragment;
if (Type === 'wrapper') {
Type = Fragment;
props = {children: props.children};
}
if (MDXComponents[type]) {
type = MDXComponents[type];
if (Type in MDXComponents) {
Type = MDXComponents[Type];
}
if (!type) {
console.error('Unknown type: ' + type);
type = Fragment;
if (!Type) {
console.error('Unknown type: ' + Type);
Type = Fragment;
}
return {
$$typeof: Symbol.for('react.element'),
type: type,
key: key,
ref: null,
props: props,
_owner: null,
};
return <Type key={key} {...props} />;
} else {
return val;
}

View File

@@ -53,31 +53,27 @@ export default function ErrorDecoderPage({
}
// Deserialize a client React tree from JSON.
function reviveNodeOnClient(key: unknown, val: any) {
function reviveNodeOnClient(parentPropertyName: unknown, val: any) {
if (Array.isArray(val) && val[0] == '$r') {
// Assume it's a React element.
let type = val[1];
let Type = val[1];
let key = val[2];
if (key == null) {
key = parentPropertyName; // Index within a parent.
}
let props = val[3];
if (type === 'wrapper') {
type = Fragment;
if (Type === 'wrapper') {
Type = Fragment;
props = {children: props.children};
}
if (type in MDXComponents) {
type = MDXComponents[type as keyof typeof MDXComponents];
if (Type in MDXComponents) {
Type = MDXComponents[Type as keyof typeof MDXComponents];
}
if (!type) {
console.error('Unknown type: ' + type);
type = Fragment;
if (!Type) {
console.error('Unknown type: ' + Type);
Type = Fragment;
}
return {
$$typeof: Symbol.for('react.element'),
type: type,
key: key,
ref: null,
props: props,
_owner: null,
};
return <Type key={key} {...props} />;
} else {
return val;
}

11
src/types/docsearch-react-modal.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*/
// This module must be declared and because the dynamic import in
// "src/components/Search.tsx" is not able to resolve the types from
// the package.
declare module '@docsearch/react/modal' {
// re-exports the types from @docsearch/react/dist/esm/index.d.ts
export * from '@docsearch/react/dist/esm/index';
}

View File

@@ -3,7 +3,7 @@ import {MDXComponents} from 'components/MDX/MDXComponents';
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~ IMPORTANT: BUMP THIS IF YOU CHANGE ANY CODE BELOW ~~~
const DISK_CACHE_BREAKER = 9;
const DISK_CACHE_BREAKER = 10;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default async function compileMDX(
@@ -144,7 +144,10 @@ export default async function compileMDX(
// Serialize a server React tree node to JSON.
function stringifyNodeOnServer(key: unknown, val: any) {
if (val != null && val.$$typeof === Symbol.for('react.element')) {
if (
val != null &&
val.$$typeof === Symbol.for('react.transitional.element')
) {
// Remove fake MDX props.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {mdxType, originalType, parentName, ...cleanProps} = val.props;

View File

@@ -9,6 +9,7 @@
*/
import * as React from 'react';
import {ValidationMap} from 'prop-types';
/**
* React.Ref uses the readonly type `React.RefObject` instead of
@@ -69,10 +70,8 @@ export interface ComponentWithAs<ComponentType extends As, ComponentProps> {
): React.ReactElement | null;
displayName?: string;
propTypes?: React.WeakValidationMap<
PropsWithAs<ComponentType, ComponentProps>
>;
contextTypes?: React.ValidationMap<any>;
propTypes?: ValidationMap<React.ReactNode>;
contextTypes?: ValidationMap<React.ReactNode>;
defaultProps?: Partial<PropsWithAs<ComponentType, ComponentProps>>;
}

1770
yarn.lock

File diff suppressed because it is too large Load Diff