import * as 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 { NextRouter } from "next/dist/shared/lib/router/router"; import { AppType, ComponentsEnhancer, DocumentInitialProps, DocumentProps, DocumentType, getDisplayName, loadGetInitialProps, NextComponentType, RenderPage, RenderPageResult, HtmlContext, } from "next/dist/shared/lib/utils"; import * as NextDocument from "next/document"; import * as ReactDOMServer from "react-dom/server.browser"; import * as url from "url"; import * as React from "react"; import * as ReactIs from "react-is"; import { BODY_RENDER_TARGET } from "next/constants"; 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"); const notImplementedProxy = (base) => new Proxy( {}, { deleteProperty: function (target, prop) { return undefined; }, enumerate: function (oTarget, sKey) { return [].entries(); }, ownKeys: function (oTarget, sKey) { return [].values(); }, has: function (oTarget, sKey) { return false; }, defineProperty: function (oTarget, sKey, oDesc) { return undefined; }, getOwnPropertyDescriptor: function (oTarget, sKey) { return undefined; }, get(this, prop) { throw new ReferenceError( `${base} is not available for this environment.` ); }, set(this, prop, value) { throw new ReferenceError( `${base} is not available for this environment.` ); }, } ); function getScripts(files: DocumentFiles) { const { context, props } = this; const { assetPrefix, buildManifest, isDevelopment, devOnlyCacheBusterQueryString, disableOptimizedLoading, } = context; const normalScripts = files.allFiles.filter(isJSFile); const lowPriorityScripts = buildManifest.lowPriorityFiles?.filter(isJSFile); return [...normalScripts, ...lowPriorityScripts].map((file) => { return (