From 9e0c2a051a0011b80f87fd86782b6f4741d60df9 Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Wed, 8 Jan 2025 15:53:30 +1100 Subject: [PATCH] Remove playground entry files (#12703) --- .../framework-express/app/entry.client.tsx | 12 -- .../framework-express/app/entry.server.tsx | 121 ------------------ playground/framework-spa/app/entry.client.tsx | 12 -- playground/framework-spa/app/entry.server.tsx | 19 --- playground/framework/app/entry.client.tsx | 12 -- playground/framework/app/entry.server.tsx | 121 ------------------ 6 files changed, 297 deletions(-) delete mode 100644 playground/framework-express/app/entry.client.tsx delete mode 100644 playground/framework-express/app/entry.server.tsx delete mode 100644 playground/framework-spa/app/entry.client.tsx delete mode 100644 playground/framework-spa/app/entry.server.tsx delete mode 100644 playground/framework/app/entry.client.tsx delete mode 100644 playground/framework/app/entry.server.tsx diff --git a/playground/framework-express/app/entry.client.tsx b/playground/framework-express/app/entry.client.tsx deleted file mode 100644 index 5b5cd4caf..000000000 --- a/playground/framework-express/app/entry.client.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { HydratedRouter } from "react-router/dom"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/playground/framework-express/app/entry.server.tsx b/playground/framework-express/app/entry.server.tsx deleted file mode 100644 index 1a1cbe6a5..000000000 --- a/playground/framework-express/app/entry.server.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "react-router"; -import { createReadableStreamFromReadable } from "@react-router/node"; -import { ServerRouter } from "react-router"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - reactRouterContext: EntryContext, - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - reactRouterContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - reactRouterContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - reactRouterContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, 5000); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - reactRouterContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, 5000); - }); -} diff --git a/playground/framework-spa/app/entry.client.tsx b/playground/framework-spa/app/entry.client.tsx deleted file mode 100644 index 5b5cd4caf..000000000 --- a/playground/framework-spa/app/entry.client.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { HydratedRouter } from "react-router/dom"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/playground/framework-spa/app/entry.server.tsx b/playground/framework-spa/app/entry.server.tsx deleted file mode 100644 index ffccd44a5..000000000 --- a/playground/framework-spa/app/entry.server.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import type { EntryContext } from "react-router"; -import { ServerRouter } from "react-router"; -import { renderToString } from "react-dom/server"; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - reactRouterContext: EntryContext -) { - let html = renderToString( - - ); - html = "\n" + html; - return new Response(html, { - headers: { "Content-Type": "text/html" }, - status: responseStatusCode, - }); -} diff --git a/playground/framework/app/entry.client.tsx b/playground/framework/app/entry.client.tsx deleted file mode 100644 index 5b5cd4caf..000000000 --- a/playground/framework/app/entry.client.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { HydratedRouter } from "react-router/dom"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/playground/framework/app/entry.server.tsx b/playground/framework/app/entry.server.tsx deleted file mode 100644 index 1a1cbe6a5..000000000 --- a/playground/framework/app/entry.server.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "react-router"; -import { createReadableStreamFromReadable } from "@react-router/node"; -import { ServerRouter } from "react-router"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - reactRouterContext: EntryContext, - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - reactRouterContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - reactRouterContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - reactRouterContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, 5000); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - reactRouterContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, 5000); - }); -}