From ed9e64805feab8e84b2debf09534c7eaa23574c4 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 19 Sep 2023 04:33:58 -0700 Subject: Delete long-broken package which is causing confusion --- packages/bun-framework-next/renderDocument.tsx | 835 ------------------------- 1 file changed, 835 deletions(-) delete mode 100644 packages/bun-framework-next/renderDocument.tsx (limited to 'packages/bun-framework-next/renderDocument.tsx') diff --git a/packages/bun-framework-next/renderDocument.tsx b/packages/bun-framework-next/renderDocument.tsx deleted file mode 100644 index 5eae9ebf1..000000000 --- a/packages/bun-framework-next/renderDocument.tsx +++ /dev/null @@ -1,835 +0,0 @@ -import App from "next/app"; -import { AmpStateContext } from "next/dist/shared/lib/amp-context"; -import { HeadManagerContext } from "next/dist/shared/lib/head-manager-context"; -import Loadable from "next/dist/shared/lib/loadable"; -import { LoadableContext } from "next/dist/shared/lib/loadable-context"; -import { RouterContext } from "next/dist/shared/lib/router-context"; -import type { NextRouter } from "next/dist/shared/lib/router/router"; -import { - getDisplayName, - loadGetInitialProps, - type AppType, - type ComponentsEnhancer, - type DocumentInitialProps, - type DocumentProps, - type DocumentType, - type NextComponentType, - type RenderPage, - type RenderPageResult, -} from "next/dist/shared/lib/utils"; -import { HtmlContext } from "next/dist/shared/lib/html-context"; -import type { RenderOpts } from "next/dist/server/render"; -import * as NextDocument from "next/document"; -import * as ReactDOMServer from "react-dom/server.browser"; -import * as React from "react"; -import * as ReactIs from "react-is"; -import packageJson from "next/package.json"; - -const nextVersion = packageJson.version; - -function appendNextBody(documentHTML: string, pageContent: string) { - if (nextVersion.startsWith("12.0")) { - const NEXT_12_0_BODY_RENDER_TARGET = "__NEXT_BODY_RENDER_TARGET__"; - - const bodyRenderIdx = documentHTML.indexOf(NEXT_12_0_BODY_RENDER_TARGET); - - if (!documentHTML.startsWith("")) { - documentHTML = "" + documentHTML; - } - - return ( - documentHTML.substring(0, bodyRenderIdx) + - pageContent + - documentHTML.substring( - bodyRenderIdx + NEXT_12_0_BODY_RENDER_TARGET.length, - ) - ); - } else { - var [renderTargetPrefix, renderTargetSuffix] = documentHTML.split( - "", - ); - - if (!renderTargetPrefix || !renderTargetSuffix) { - throw new Error( - "Can't find where your starts or where the ends. \nThis is probably a version incompatibility. Please mention this error in Bun's discord\n\n" + - documentHTML, - ); - } - - if (!renderTargetPrefix.startsWith("")) { - renderTargetPrefix = "" + renderTargetPrefix; - } - - return ( - renderTargetPrefix + - `
${pageContent || ""}
` + - renderTargetSuffix - ); - } -} - -const dev = process.env.NODE_ENV === "development"; - -type ParsedUrlQuery = Record; - -const isJSFile = (file: string) => - file.endsWith(".js") || - file.endsWith(".jsx") || - file.endsWith(".mjs") || - file.endsWith(".ts") || - file.endsWith(".tsx"); - -type DocumentFiles = { - sharedFiles: readonly string[]; - pageFiles: readonly string[]; - allFiles: readonly string[]; -}; - -function getScripts(files: DocumentFiles) { - const { context, props } = this; - const { - assetPrefix, - buildManifest, - isDevelopment, - devOnlyCacheBusterQueryString, - } = context; - - const normalScripts = files?.allFiles?.filter(isJSFile) ?? []; - const lowPriorityScripts = - buildManifest?.lowPriorityFiles?.filter(isJSFile) ?? []; - var entryPointIndex = -1; - const scripts = [...normalScripts, ...lowPriorityScripts].map( - (file, index) => { - // if (file.includes(".entry.")) { - // entryPointIndex = index; - // } - - return ( -