-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Upgrades
@buttery/docs
to React Router v7 (#38)
- Loading branch information
1 parent
b251e7d
commit 0386bd8
Showing
76 changed files
with
701 additions
and
5,281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
"@buttery/builtins": patch | ||
"@buttery/cli": patch | ||
"@buttery/commands": patch | ||
"@buttery/components": patch | ||
"@buttery/core": patch | ||
"@buttery/docs": patch | ||
"@buttery/icons": patch | ||
"@buttery/logs": patch | ||
"@buttery/meta": patch | ||
"@buttery/tokens": patch | ||
"@buttery/tsconfig": patch | ||
--- | ||
|
||
Upgrades `@buttery/docs` to use ReactRouter v7. This changeset is important in order to support the ongoing major releases of React Router and eventually React 19. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import { ButteryDocsClient } from "@buttery/docs/client"; | ||
import ReactDOMClient from "react-dom/client"; | ||
import { ButteryDocsApp } from "./entry.app"; | ||
import { routes } from "./routes"; | ||
|
||
ReactDOMClient.hydrateRoot( | ||
document.getElementById("root") as HTMLElement, | ||
<ButteryDocsClient> | ||
<ButteryDocsApp /> | ||
</ButteryDocsClient> | ||
<ButteryDocsClient routes={routes} /> | ||
); |
45 changes: 3 additions & 42 deletions
45
packages/buttery-docs/app/entry.server.cloudflare-pages.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,6 @@ | ||
// add the beginning of your app entry | ||
import "vite/modulepreload-polyfill"; | ||
import { createRenderCloudflarePages } from "@buttery/docs/server.cloudflare-pages"; | ||
import { routes } from "./routes"; | ||
|
||
import { | ||
ButteryDocsServer, | ||
type HandleRequestCloudflarePagesRenderFunction, | ||
} from "@buttery/docs/server"; | ||
import type { ReactDOMServerReadableStream } from "react-dom/server"; | ||
import { renderToReadableStream } from "react-dom/server"; | ||
import { ButteryDocsApp } from "./entry.app"; | ||
|
||
const ABORT_DELAY = 5000; | ||
|
||
export const render: HandleRequestCloudflarePagesRenderFunction = async ( | ||
context, | ||
responseStatusCode | ||
) => { | ||
const controller = new AbortController(); | ||
const timeoutId = setTimeout(() => controller.abort(), ABORT_DELAY); | ||
|
||
// Render the app to a ReadableStream using React's server renderer | ||
const stream = (await renderToReadableStream( | ||
<ButteryDocsServer {...context}> | ||
<ButteryDocsApp /> | ||
</ButteryDocsServer>, | ||
{ | ||
signal: controller.signal, | ||
onError(error: unknown) { | ||
if (!controller.signal.aborted) { | ||
// Log streaming rendering errors from inside the shell | ||
console.error(error); | ||
} | ||
responseStatusCode = 500; | ||
}, | ||
} | ||
)) as ReactDOMServerReadableStream; | ||
|
||
stream.allReady.then(() => clearTimeout(timeoutId)); | ||
|
||
// regardless of streaming, we're going to wait on everything since it's just | ||
// a documentation site. We don't need to over engineer this... yanno? | ||
await stream.allReady; | ||
|
||
return stream; | ||
}; | ||
export const render = createRenderCloudflarePages(routes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,6 @@ | ||
// add the beginning of your app entry | ||
import "vite/modulepreload-polyfill"; | ||
import { createRenderDev } from "@buttery/docs/server.dev"; | ||
import { routes } from "./routes"; | ||
|
||
import type { ButteryMeta } from "@buttery/meta"; | ||
import { ButteryMetaProvider } from "@buttery/meta/react"; | ||
import { StrictMode } from "react"; | ||
import { | ||
type RenderToPipeableStreamOptions, | ||
renderToPipeableStream, | ||
} from "react-dom/server"; | ||
import { StaticRouter } from "react-router-dom/server"; | ||
import { ButteryDocsApp } from "./entry.app"; | ||
|
||
export async function render( | ||
url: string, | ||
ButteryMeta: ButteryMeta, | ||
_ssrManifest?: string, | ||
options?: RenderToPipeableStreamOptions | ||
) { | ||
// Render the app to a ReadableStream using React's server renderer | ||
return renderToPipeableStream( | ||
<StrictMode> | ||
<ButteryMetaProvider ButteryMeta={ButteryMeta}> | ||
<StaticRouter location={url}> | ||
<ButteryDocsApp /> | ||
</StaticRouter> | ||
</ButteryMetaProvider> | ||
</StrictMode>, | ||
options | ||
); | ||
} | ||
export const render = createRenderDev(routes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import "@buttery/docs/css"; | ||
import { header } from "virtual:data"; | ||
import { routeDocs, routeGraph, routeIndex } from "virtual:routes"; | ||
import { createButteryDocsRoutes } from "@buttery/docs/app"; | ||
|
||
export const routes = createButteryDocsRoutes({ | ||
header, | ||
routeGraph, | ||
routeDocs, | ||
routeIndex, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.