From 8dbe151e2a94547062dfb37ee75612ea1ad66659 Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Sat, 25 Jan 2025 15:25:02 -0500 Subject: [PATCH] downgrade --- package.json | 6 +- packages/commons/react-commons/package.json | 4 +- .../react-commons/src/useResizeObserver.ts | 2 +- .../versions/latest/NavigationNodeParent.ts | 8 +- packages/fern-docs/bundle/package.json | 12 +- packages/fern-docs/components/package.json | 14 +- packages/fern-docs/icons-cdn/package.json | 10 +- .../local-preview-bundle/package.json | 12 +- packages/fern-docs/search-ui/package.json | 16 +- packages/fern-docs/seo/package.json | 6 +- .../src/__test__/getBreadcrumbList.test.ts | 7 +- packages/fern-docs/seo/src/with-seo.ts | 9 +- .../fern-docs/syntax-highlighter/package.json | 12 +- packages/fern-docs/ui/package.json | 10 +- .../components/accordion/AccordionGroup.tsx | 99 +- .../src/mdx/components/html-table/Table.tsx | 7 +- .../ui/src/mdx/components/html/image.tsx | 11 +- .../ui/src/mdx/components/html/index.tsx | 24 +- .../ui/src/mdx/components/iframe/IFrame.tsx | 83 +- .../fern-docs/ui/src/mdx/components/index.tsx | 85 +- .../fern-docs/ui/src/util/getSlugFromText.ts | 4 +- packages/fern-docs/utils/package.json | 2 +- .../forward-proxy/nextjs-proxy/package.json | 10 +- pnpm-lock.yaml | 2456 +++++++++-------- 24 files changed, 1592 insertions(+), 1317 deletions(-) diff --git a/package.json b/package.json index e7644c26e4..17021ef388 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "elliptic": "6.6.0", "esbuild": "0.24.2", "eslint": "9.17.0", - "eslint-config-next": "15.1.2", + "eslint-config-next": "14.2.23", "instantsearch.js": "4.75.4", "jsonpath-plus": "10.0.7", "markdown-to-jsx": "7.4.0", @@ -82,7 +82,7 @@ "depcheck": "^1.4.7", "dotenv": "^16.4.5", "eslint": "^9", - "eslint-config-next": "15.1.2", + "eslint-config-next": "14.2.23", "eslint-config-prettier": "^9.1.0", "eslint-config-turbo": "^2.3.3", "eslint-plugin-deprecation": "^3.0.0", @@ -105,7 +105,7 @@ "prettier": "^3.4.2", "prettier-plugin-organize-imports": "^4.1.0", "prettier-plugin-tailwindcss": "^0.6.9", - "react": "^19", + "react": "^18", "rollup": "^4.22.4", "styled-jsx": "^5.1.2", "stylelint": "^16.1.0", diff --git a/packages/commons/react-commons/package.json b/packages/commons/react-commons/package.json index 6f862754b2..d02d1135ca 100644 --- a/packages/commons/react-commons/package.json +++ b/packages/commons/react-commons/package.json @@ -33,13 +33,13 @@ "es-toolkit": "^1.27.0", "fastdom": "^1.0.12", "immer": "^9.0.15", - "react": "^19", + "react": "^18", "ts-essentials": "^10.0.1" }, "devDependencies": { "@fern-platform/configs": "workspace:*", "@types/node": "^18.19.74", - "@types/react": "^19", + "@types/react": "^18", "depcheck": "^1.4.7", "eslint": "^9", "prettier": "^3.4.2", diff --git a/packages/commons/react-commons/src/useResizeObserver.ts b/packages/commons/react-commons/src/useResizeObserver.ts index 7be2398760..bed629daa1 100644 --- a/packages/commons/react-commons/src/useResizeObserver.ts +++ b/packages/commons/react-commons/src/useResizeObserver.ts @@ -5,7 +5,7 @@ import { noop } from "ts-essentials"; import { useEventCallback } from "./useEventCallback"; export function useResizeObserver( - ref: RefObject, + ref: RefObject, measure: (entries: ResizeObserverEntry[]) => void ): void { // ResizeObserver is not supported in SSG, so this hook should be disabled on the server-side diff --git a/packages/fdr-sdk/src/navigation/versions/latest/NavigationNodeParent.ts b/packages/fdr-sdk/src/navigation/versions/latest/NavigationNodeParent.ts index 8aa1c18b2f..cb012263ef 100644 --- a/packages/fdr-sdk/src/navigation/versions/latest/NavigationNodeParent.ts +++ b/packages/fdr-sdk/src/navigation/versions/latest/NavigationNodeParent.ts @@ -1,4 +1,6 @@ -import { NavigationNode } from "./NavigationNode"; -import { NavigationNodeLeaf } from "./NavigationNodeLeaf"; +import { FernNavigation } from "../../.."; -export type NavigationNodeParent = Exclude; +export type NavigationNodeParent = Exclude< + FernNavigation.NavigationNode, + FernNavigation.NavigationNodeLeaf +>; diff --git a/packages/fern-docs/bundle/package.json b/packages/fern-docs/bundle/package.json index 4a420c705f..50f659726d 100644 --- a/packages/fern-docs/bundle/package.json +++ b/packages/fern-docs/bundle/package.json @@ -70,12 +70,12 @@ "feed": "^4.2.2", "iron-session": "^8.0.3", "jose": "^5.2.3", - "next": "15.1.6", + "next": "14.2.23", "postcss-import": "^16.0.1", "posthog-node": "^4.2.1", "qs": "6.12.0", - "react": "^19", - "react-dom": "^19", + "react": "^18", + "react-dom": "^18", "schema-dts": "^1.1.2", "server-only": "^0.0.1", "sharp": "^0.33.3", @@ -87,12 +87,12 @@ }, "devDependencies": { "@fern-platform/configs": "workspace:*", - "@next/bundle-analyzer": "15.1.6", + "@next/bundle-analyzer": "14.2.23", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.10", "@types/node": "^18.19.74", - "@types/react": "^19", - "@types/react-dom": "^19", + "@types/react": "^18", + "@types/react-dom": "^18", "autoprefixer": "^10.4.16", "depcheck": "^1.4.7", "eslint": "^9", diff --git a/packages/fern-docs/components/package.json b/packages/fern-docs/components/package.json index 5d282b1dc2..0865285864 100644 --- a/packages/fern-docs/components/package.json +++ b/packages/fern-docs/components/package.json @@ -81,8 +81,8 @@ "iconoir-react": "^7.7.0", "lucide-react": "^0.460.0", "moment": "^2.30.1", - "react": "^19", - "react-dom": "^19", + "react": "^18", + "react-dom": "^18", "sonner": "^1.5.0", "tailwind-merge": "^2.3.0", "ts-extras": "^0.11.0" @@ -104,8 +104,8 @@ "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", "@types/node": "^18.19.74", - "@types/react": "^19", - "@types/react-dom": "^19", + "@types/react": "^18", + "@types/react-dom": "^18", "@types/react-test-renderer": "^18.0.7", "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "^10.4.16", @@ -116,7 +116,7 @@ "jsdom": "^24.0.0", "postcss-import": "^16.0.1", "prettier": "^3.4.2", - "react-test-renderer": "^19", + "react-test-renderer": "^18", "sass": "^1.74.1", "storybook": "^8.5.1", "stylelint": "^16.1.0", @@ -126,8 +126,8 @@ "vitest": "^2.1.4" }, "peerDependencies": { - "react": "^19", - "react-dom": "^19", + "react": "^18", + "react-dom": "^18", "sass": "^1.74.1" } } diff --git a/packages/fern-docs/icons-cdn/package.json b/packages/fern-docs/icons-cdn/package.json index 69e094804d..6b87abf6ef 100644 --- a/packages/fern-docs/icons-cdn/package.json +++ b/packages/fern-docs/icons-cdn/package.json @@ -34,17 +34,17 @@ "@fortawesome/sharp-regular-svg-icons": "^6.7.2", "@fortawesome/sharp-solid-svg-icons": "^6.7.2", "@fortawesome/sharp-thin-svg-icons": "^6.7.2", - "react": "^19", - "react-dom": "^19" + "react": "^18", + "react-dom": "^18" }, "devDependencies": { "@fern-platform/configs": "workspace:*", - "@next/bundle-analyzer": "15.1.6", + "@next/bundle-analyzer": "14.2.23", "@types/node": "^18.19.74", - "@types/react": "^19", + "@types/react": "^18", "depcheck": "^1.4.7", "eslint": "^9", - "next": "15.1.6", + "next": "14.2.23", "prettier": "^3.4.2", "stylelint": "^16.1.0", "typescript": "^5", diff --git a/packages/fern-docs/local-preview-bundle/package.json b/packages/fern-docs/local-preview-bundle/package.json index 09182dda9e..4b1b182b12 100644 --- a/packages/fern-docs/local-preview-bundle/package.json +++ b/packages/fern-docs/local-preview-bundle/package.json @@ -43,24 +43,24 @@ "@fern-docs/utils": "workspace:*", "@fern-platform/fdr-utils": "workspace:*", "cssnano": "^6.0.3", - "next": "15.1.6", + "next": "14.2.23", "node-fetch": "2.7.0", "postcss-import": "^16.0.1", - "react": "^19", - "react-dom": "^19", + "react": "^18", + "react-dom": "^18", "styled-jsx": "^5.1.2", "ts-essentials": "^10.0.1", "url-join": "5.0.0" }, "devDependencies": { "@fern-platform/configs": "workspace:*", - "@next/bundle-analyzer": "15.1.6", + "@next/bundle-analyzer": "14.2.23", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.10", "@types/node": "^18.19.74", "@types/node-fetch": "2.6.9", - "@types/react": "^19", - "@types/react-dom": "^19", + "@types/react": "^18", + "@types/react-dom": "^18", "autoprefixer": "^10.4.16", "depcheck": "^1.4.7", "eslint": "^9", diff --git a/packages/fern-docs/search-ui/package.json b/packages/fern-docs/search-ui/package.json index 12b25802a9..ff098da58d 100644 --- a/packages/fern-docs/search-ui/package.json +++ b/packages/fern-docs/search-ui/package.json @@ -76,15 +76,15 @@ "@tailwindcss/typography": "^0.5.10", "@types/hast": "^3.0.4", "@types/mdast": "^4.0.3", - "@types/react": "^19", - "@types/react-dom": "^19", + "@types/react": "^18", + "@types/react-dom": "^18", "@upstash/qstash": "^2.7.16", "autoprefixer": "^10.4.16", "cssnano": "^6.0.3", - "next": "15.1.6", + "next": "14.2.23", "postcss": "^8.4.33", - "react": "^19", - "react-dom": "^19", + "react": "^18", + "react-dom": "^18", "storybook": "^8.5.1", "swr": "^2.3.0", "tailwindcss": "^3", @@ -92,8 +92,8 @@ "typescript": "^5" }, "peerDependencies": { - "next": "15.1.6", - "react": "^19", - "react-dom": "^19" + "next": "14.2.23", + "react": "^18", + "react-dom": "^18" } } diff --git a/packages/fern-docs/seo/package.json b/packages/fern-docs/seo/package.json index d5e3731cef..8a84fed9e9 100644 --- a/packages/fern-docs/seo/package.json +++ b/packages/fern-docs/seo/package.json @@ -33,15 +33,15 @@ "@fern-api/ui-core-utils": "workspace:*", "@fern-docs/mdx": "workspace:*", "@fern-docs/utils": "workspace:*", - "next": "15.1.6", - "react": "^19", + "next": "14.2.23", + "react": "^18", "schema-dts": "^1.1.2" }, "devDependencies": { "@fern-platform/configs": "workspace:*", "@fern-platform/fdr-utils": "workspace:*", "@types/node": "^18.19.74", - "@types/react": "^19", + "@types/react": "^18", "depcheck": "^1.4.7", "eslint": "^9", "prettier": "^3.4.2", diff --git a/packages/fern-docs/seo/src/__test__/getBreadcrumbList.test.ts b/packages/fern-docs/seo/src/__test__/getBreadcrumbList.test.ts index 480fca8f0a..497eeb6f81 100644 --- a/packages/fern-docs/seo/src/__test__/getBreadcrumbList.test.ts +++ b/packages/fern-docs/seo/src/__test__/getBreadcrumbList.test.ts @@ -39,7 +39,12 @@ describe("getBreadcrumbList", () => { }, ]; expect( - getBreadcrumbList("buildwithfern.com", parents, node, "Overriden Title") + getBreadcrumbList( + "buildwithfern.com", + parents.filter(FernNavigation.hasMetadata), + node, + "Overriden Title" + ) ).toEqual({ "@context": "https://schema.org", "@type": "BreadcrumbList", diff --git a/packages/fern-docs/seo/src/with-seo.ts b/packages/fern-docs/seo/src/with-seo.ts index 55a79a9a66..fc6e0db38f 100644 --- a/packages/fern-docs/seo/src/with-seo.ts +++ b/packages/fern-docs/seo/src/with-seo.ts @@ -5,6 +5,7 @@ import type { WithMetadataConfig, } from "@fern-api/fdr-sdk/docs"; import * as FernNavigation from "@fern-api/fdr-sdk/navigation"; +import { WithNodeMetadata } from "@fern-api/fdr-sdk/navigation"; import { assertNonNullish, visitDiscriminatedUnion, @@ -12,7 +13,6 @@ import { } from "@fern-api/ui-core-utils"; import { markdownToString } from "@fern-docs/mdx"; import { addLeadingSlash, conformTrailingSlash } from "@fern-docs/utils"; - import type { LinkTag, MetaTag, NextSeoProps } from "./types"; import { getBreadcrumbList } from "./with-breadcrumb"; @@ -113,7 +113,12 @@ export function withSeo( // add breadcrumb list if it exists, otherwise compute it seo.breadcrumbList ??= ogMetadata["jsonld:breadcrumb"] ?? - getBreadcrumbList(domain, parents, node, frontmatter.title); + getBreadcrumbList( + domain, + parents.filter(FernNavigation.hasMetadata) as WithNodeMetadata[], + node, + frontmatter.title + ); // add canonical url if frontmatter has it if (frontmatter["canonical-url"] != null) { diff --git a/packages/fern-docs/syntax-highlighter/package.json b/packages/fern-docs/syntax-highlighter/package.json index 90784f08a7..538ec94c02 100644 --- a/packages/fern-docs/syntax-highlighter/package.json +++ b/packages/fern-docs/syntax-highlighter/package.json @@ -32,13 +32,13 @@ "devDependencies": { "@fern-platform/configs": "workspace:*", "@types/hast": "^3.0.4", - "@types/react": "^19", - "@types/react-dom": "^19", - "react": "^19", - "react-dom": "^19" + "@types/react": "^18", + "@types/react-dom": "^18", + "react": "^18", + "react-dom": "^18" }, "peerDependencies": { - "react": "^19", - "react-dom": "^19" + "react": "^18", + "react-dom": "^18" } } diff --git a/packages/fern-docs/ui/package.json b/packages/fern-docs/ui/package.json index 8555085779..2e8a85f16e 100644 --- a/packages/fern-docs/ui/package.json +++ b/packages/fern-docs/ui/package.json @@ -97,14 +97,14 @@ "mdx-bundler": "^10.0.3", "mermaid": "^11.2.1", "moment": "^2.30.1", - "next": "15.1.6", + "next": "14.2.23", "next-mdx-remote": "^5.0.0", "nprogress": "^0.2.0", "numeral": "^2.0.6", "parse-numeric-range": "^1.3.0", "posthog-js": "^1.154.5", - "react": "^19", - "react-dom": "^19", + "react": "^18", + "react-dom": "^18", "react-error-boundary": "^4.0.10", "react-feather": "^2.0.10", "react-instantsearch": "^7.13.7", @@ -146,8 +146,8 @@ "@types/jsonpath": "^0.2.4", "@types/node": "^18.19.74", "@types/numeral": "^2.0.5", - "@types/react": "^19", - "@types/react-dom": "^19", + "@types/react": "^18", + "@types/react-dom": "^18", "@types/three": "^0.170.0", "@types/tinycolor2": "^1.4.6", "@vitejs/plugin-react": "^4.2.1", diff --git a/packages/fern-docs/ui/src/mdx/components/accordion/AccordionGroup.tsx b/packages/fern-docs/ui/src/mdx/components/accordion/AccordionGroup.tsx index e68004154e..ae4f5ad3f5 100644 --- a/packages/fern-docs/ui/src/mdx/components/accordion/AccordionGroup.tsx +++ b/packages/fern-docs/ui/src/mdx/components/accordion/AccordionGroup.tsx @@ -6,7 +6,7 @@ import { } from "@fern-docs/components"; import { useAtom } from "jotai"; import { NextRouter } from "next/router"; -import { forwardRef, ReactNode, useCallback, useEffect, useState } from "react"; +import { ReactNode, useCallback, useEffect, useState } from "react"; import { ANCHOR_ATOM } from "../../../atoms"; export interface AccordionItemProps { @@ -22,57 +22,52 @@ export interface AccordionGroupProps { toc?: boolean; } -export const AccordionGroup = forwardRef( - ({ items = [] }, forwardedRef) => { - const [activeTabs, setActiveTabs] = useState([]); - const [anchor, setAnchor] = useAtom(ANCHOR_ATOM); - useEffect(() => { - if (anchor != null) { - if (items.some((tab) => tab.id === anchor)) { - setActiveTabs((prev) => - prev.includes(anchor) ? prev : [...prev, anchor] - ); - } +export const AccordionGroup = ({ items = [] }: AccordionGroupProps) => { + const [activeTabs, setActiveTabs] = useState([]); + const [anchor, setAnchor] = useAtom(ANCHOR_ATOM); + useEffect(() => { + if (anchor != null) { + if (items.some((tab) => tab.id === anchor)) { + setActiveTabs((prev) => + prev.includes(anchor) ? prev : [...prev, anchor] + ); } - }, [anchor, items]); - - const handleValueChange = useCallback( - (nextActiveTabs: string[]) => { - setActiveTabs((prev) => { - const added = nextActiveTabs.filter((tab) => !prev.includes(tab)); - if (added[0] != null) { - setAnchor(added[0]); - } - return nextActiveTabs; - }); - }, - [setAnchor] - ); + } + }, [anchor, items]); - return ( - - {items.map(({ title, id, children }) => ( - - {title} - -
{children}
-
-
- ))} -
- ); - } -); + const handleValueChange = useCallback( + (nextActiveTabs: string[]) => { + setActiveTabs((prev) => { + const added = nextActiveTabs.filter((tab) => !prev.includes(tab)); + if (added[0] != null) { + setAnchor(added[0]); + } + return nextActiveTabs; + }); + }, + [setAnchor] + ); -AccordionGroup.displayName = "AccordionGroup"; + return ( + + {items.map(({ title, id, children }) => ( + + {title} + +
{children}
+
+
+ ))} +
+ ); +}; diff --git a/packages/fern-docs/ui/src/mdx/components/html-table/Table.tsx b/packages/fern-docs/ui/src/mdx/components/html-table/Table.tsx index 4f9858fcd2..f81e8f7c14 100644 --- a/packages/fern-docs/ui/src/mdx/components/html-table/Table.tsx +++ b/packages/fern-docs/ui/src/mdx/components/html-table/Table.tsx @@ -3,9 +3,12 @@ import * as Dialog from "@radix-ui/react-dialog"; import * as Tooltip from "@radix-ui/react-tooltip"; import clsx from "clsx"; import { Expand } from "iconoir-react"; -import { ComponentProps, FC, useState } from "react"; +import { ComponentPropsWithRef, useState } from "react"; -export const Table: FC> = ({ className, ...rest }) => { +export const Table = ({ + className, + ...rest +}: ComponentPropsWithRef<"table">) => { const [isFullScreen, setIsFullScreen] = useState(false); return ( diff --git a/packages/fern-docs/ui/src/mdx/components/html/image.tsx b/packages/fern-docs/ui/src/mdx/components/html/image.tsx index f0787a5b7a..a40b42f8cf 100644 --- a/packages/fern-docs/ui/src/mdx/components/html/image.tsx +++ b/packages/fern-docs/ui/src/mdx/components/html/image.tsx @@ -2,7 +2,6 @@ import { ComponentProps, ComponentPropsWithoutRef, createContext, - forwardRef, ReactElement, ReactNode, useContext, @@ -21,9 +20,8 @@ export function NoZoom({ children }: { children: ReactNode }) { ); } -export const Image = forwardRef< - HTMLImageElement, - ComponentPropsWithoutRef<"img"> & { +export const Image = ( + props: ComponentPropsWithoutRef<"img"> & { /** * @default false */ @@ -42,7 +40,7 @@ export const Image = forwardRef< blurDataURL?: string | undefined; unoptimized?: boolean | undefined; } ->((props, ref) => { +) => { const { src, width, @@ -64,7 +62,6 @@ export const Image = forwardRef< const fernImage = ( ); -}); +}; Image.displayName = "Image"; diff --git a/packages/fern-docs/ui/src/mdx/components/html/index.tsx b/packages/fern-docs/ui/src/mdx/components/html/index.tsx index f1980c6a16..2f0c86289f 100644 --- a/packages/fern-docs/ui/src/mdx/components/html/index.tsx +++ b/packages/fern-docs/ui/src/mdx/components/html/index.tsx @@ -2,8 +2,8 @@ import cn from "clsx"; import { AnchorHTMLAttributes, ComponentProps, + ComponentPropsWithRef, createElement, - FC, isValidElement, ReactElement, } from "react"; @@ -22,22 +22,14 @@ export const HeadingRenderer = ( ); }; -export const P: FC<{ variant: "api" | "markdown" } & ComponentProps<"p">> = ({ - variant, +export const Strong = ({ className, ...rest -}) => { - return

; -}; - -export const Strong: FC> = ({ - className, - ...rest -}) => { +}: ComponentPropsWithRef<"strong">) => { return ; }; -export const Ol: FC> = ({ className, ...rest }) => { +export const Ol = ({ className, ...rest }: ComponentPropsWithRef<"ol">) => { return (

    > = ({ className, ...rest }) => { ); }; -export const Ul: FC> = ({ className, ...rest }) => { +export const Ul = ({ className, ...rest }: ComponentPropsWithRef<"ul">) => { return (
      > = ({ className, ...rest }) => { ); }; -export const Li: FC> = ({ className, ...rest }) => { +export const Li = ({ className, ...rest }: ComponentPropsWithRef<"li">) => { return
    • ; }; -export const A: FC> = ({ +export const A = ({ className, children, href, ...rest -}) => { +}: AnchorHTMLAttributes) => { const cnCombined = cn("fern-mdx-link", className); const hideExternalLinkIcon = isValidElement(children) && diff --git a/packages/fern-docs/ui/src/mdx/components/iframe/IFrame.tsx b/packages/fern-docs/ui/src/mdx/components/iframe/IFrame.tsx index ab52a74e1b..2a1be06525 100644 --- a/packages/fern-docs/ui/src/mdx/components/iframe/IFrame.tsx +++ b/packages/fern-docs/ui/src/mdx/components/iframe/IFrame.tsx @@ -6,9 +6,7 @@ import { ComponentProps, ReactElement, RefObject, - forwardRef, useEffect, - useImperativeHandle, useRef, useState, } from "react"; @@ -21,59 +19,52 @@ export declare namespace IFrame { } } -export const IFrame = forwardRef( - ( - { - experimental_enableRequestFullscreen, - experimental_onFullscreenChange, - experimental_onReceiveMessage, - ...props - }, - ref - ): ReactElement => { - const iframeRef = useRef(null); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - useImperativeHandle(ref, () => iframeRef.current!); +export const IFrame = ({ + experimental_enableRequestFullscreen, + experimental_onFullscreenChange, + experimental_onReceiveMessage, + ...props +}: IFrame.Props) => { + const iframeRef = useRef(null); - useEffect(() => { - const contentWindow = iframeRef.current?.contentWindow; - if (contentWindow == null || experimental_onReceiveMessage == null) { - return; - } - contentWindow.addEventListener("message", experimental_onReceiveMessage); - return () => { - contentWindow.removeEventListener( - "message", - experimental_onReceiveMessage - ); - }; - }, [experimental_onReceiveMessage]); - - if ( - experimental_enableRequestFullscreen && - typeof document !== "undefined" && - document.fullscreenEnabled - ) { - return ( - -