| Server IP : 13.235.167.51 / Your IP : 216.73.217.116 Web Server : Apache System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64 User : root ( 0) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/control.machinox.in/node_modules/next/dist/server/app-render/ |
Upload File : |
{"version":3,"sources":["../../../src/server/app-render/manifests-singleton.ts"],"sourcesContent":["import type { ActionManifest } from '../../build/webpack/plugins/flight-client-entry-plugin'\nimport type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin'\nimport type { DeepReadonly } from '../../shared/lib/deep-readonly'\nimport { InvariantError } from '../../shared/lib/invariant-error'\nimport { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'\nimport { pathHasPrefix } from '../../shared/lib/router/utils/path-has-prefix'\nimport { removePathPrefix } from '../../shared/lib/router/utils/remove-path-prefix'\nimport { workAsyncStorage } from './work-async-storage.external'\n\nexport interface ServerModuleMap {\n readonly [name: string]: {\n readonly id: string | number\n readonly name: string\n readonly chunks: Readonly<Array<string>> // currently not used\n readonly async?: boolean\n }\n}\n\n// This is a global singleton that is, among other things, also used to\n// encode/decode bound args of server function closures. This can't be using a\n// AsyncLocalStorage as it might happen at the module level.\nconst MANIFESTS_SINGLETON = Symbol.for('next.server.manifests')\n\ninterface ManifestsSingleton {\n readonly clientReferenceManifestsPerRoute: Map<\n string,\n DeepReadonly<ClientReferenceManifest>\n >\n readonly proxiedClientReferenceManifest: DeepReadonly<ClientReferenceManifest>\n serverActionsManifest: DeepReadonly<ActionManifest>\n serverModuleMap: ServerModuleMap\n}\n\ntype GlobalThisWithManifests = typeof globalThis & {\n [MANIFESTS_SINGLETON]?: ManifestsSingleton\n}\n\ntype ClientReferenceManifestMappingProp =\n | 'clientModules'\n | 'rscModuleMapping'\n | 'edgeRscModuleMapping'\n | 'ssrModuleMapping'\n | 'edgeSSRModuleMapping'\n\nconst globalThisWithManifests = globalThis as GlobalThisWithManifests\n\nfunction createProxiedClientReferenceManifest(\n clientReferenceManifestsPerRoute: Map<\n string,\n DeepReadonly<ClientReferenceManifest>\n >\n): DeepReadonly<ClientReferenceManifest> {\n const createMappingProxy = (prop: ClientReferenceManifestMappingProp) => {\n return new Proxy(\n {},\n {\n get(_, id: string) {\n const workStore = workAsyncStorage.getStore()\n\n if (workStore) {\n const currentManifest = clientReferenceManifestsPerRoute.get(\n workStore.route\n )\n\n if (currentManifest?.[prop][id]) {\n return currentManifest[prop][id]\n }\n\n // In development, we also check all other manifests to see if the\n // module exists there. This is to support a scenario where React's\n // I/O tracking (dev-only) creates a connection from one page to\n // another through an emitted async I/O node that references client\n // components from the other page, e.g. in owner props.\n // TODO: Maybe we need to add a `debugBundlerConfig` option to React\n // to avoid this workaround. The current workaround has the\n // disadvantage that one might accidentally or intentionally share\n // client references across pages (e.g. by storing them in a global\n // variable), which would then only be caught in production.\n if (process.env.NODE_ENV !== 'production') {\n for (const [\n route,\n manifest,\n ] of clientReferenceManifestsPerRoute) {\n if (route === workStore.route) {\n continue\n }\n\n const entry = manifest[prop][id]\n\n if (entry !== undefined) {\n return entry\n }\n }\n }\n } else {\n // If there's no work store defined, we can assume that a client\n // reference manifest is needed during module evaluation, e.g. to\n // create a server function using a higher-order function. This\n // might also use client components which need to be serialized by\n // Flight, and therefore client references need to be resolvable. In\n // that case we search all page manifests to find the module.\n for (const manifest of clientReferenceManifestsPerRoute.values()) {\n const entry = manifest[prop][id]\n\n if (entry !== undefined) {\n return entry\n }\n }\n }\n\n return undefined\n },\n }\n )\n }\n\n const mappingProxies = new Map<\n ClientReferenceManifestMappingProp,\n ReturnType<typeof createMappingProxy>\n >()\n\n return new Proxy(\n {},\n {\n get(_, prop) {\n const workStore = workAsyncStorage.getStore()\n\n switch (prop) {\n case 'moduleLoading':\n case 'entryCSSFiles':\n case 'entryJSFiles': {\n if (!workStore) {\n throw new InvariantError(\n `Cannot access \"${prop}\" without a work store.`\n )\n }\n\n const currentManifest = clientReferenceManifestsPerRoute.get(\n workStore.route\n )\n\n if (!currentManifest) {\n throw new InvariantError(\n `The client reference manifest for route \"${workStore.route}\" does not exist.`\n )\n }\n\n return currentManifest[prop]\n }\n case 'clientModules':\n case 'rscModuleMapping':\n case 'edgeRscModuleMapping':\n case 'ssrModuleMapping':\n case 'edgeSSRModuleMapping': {\n let proxy = mappingProxies.get(prop)\n\n if (!proxy) {\n proxy = createMappingProxy(prop)\n mappingProxies.set(prop, proxy)\n }\n\n return proxy\n }\n default: {\n throw new InvariantError(\n `This is a proxied client reference manifest. The property \"${String(prop)}\" is not handled.`\n )\n }\n }\n },\n }\n ) as DeepReadonly<ClientReferenceManifest>\n}\n\n/**\n * This function creates a Flight-acceptable server module map proxy from our\n * Server Reference Manifest similar to our client module map. This is because\n * our manifest contains a lot of internal Next.js data that are relevant to the\n * runtime, workers, etc. that React doesn't need to know.\n */\nfunction createServerModuleMap(): ServerModuleMap {\n return new Proxy(\n {},\n {\n get: (_, id: string) => {\n const workers =\n getServerActionsManifest()[\n process.env.NEXT_RUNTIME === 'edge' ? 'edge' : 'node'\n ]?.[id]?.workers\n\n if (!workers) {\n return undefined\n }\n\n const workStore = workAsyncStorage.getStore()\n\n let workerEntry:\n | { moduleId: string | number; async: boolean }\n | undefined\n\n if (workStore) {\n workerEntry = workers[normalizeWorkerPageName(workStore.page)]\n } else {\n // If there's no work store defined, we can assume that a server\n // module map is needed during module evaluation, e.g. to create a\n // server action using a higher-order function. Therefore it should be\n // safe to return any entry from the manifest that matches the action\n // ID. They all refer to the same module ID, which must also exist in\n // the current page bundle. TODO: This is currently not guaranteed in\n // Turbopack, and needs to be fixed.\n workerEntry = Object.values(workers).at(0)\n }\n\n if (!workerEntry) {\n return undefined\n }\n\n const { moduleId, async } = workerEntry\n\n return { id: moduleId, name: id, chunks: [], async }\n },\n }\n )\n}\n\n/**\n * The flight entry loader keys actions by bundlePath. bundlePath corresponds\n * with the relative path (including 'app') to the page entrypoint.\n */\nfunction normalizeWorkerPageName(pageName: string) {\n if (pathHasPrefix(pageName, 'app')) {\n return pageName\n }\n\n return 'app' + pageName\n}\n\n/**\n * Converts a bundlePath (relative path to the entrypoint) to a routable page\n * name.\n */\nfunction denormalizeWorkerPageName(bundlePath: string) {\n return normalizeAppPath(removePathPrefix(bundlePath, 'app'))\n}\n\n/**\n * Checks if the requested action has a worker for the current page.\n * If not, it returns the first worker that has a handler for the action.\n */\nexport function selectWorkerForForwarding(\n actionId: string,\n pageName: string\n): string | undefined {\n const serverActionsManifest = getServerActionsManifest()\n const workers =\n serverActionsManifest[\n process.env.NEXT_RUNTIME === 'edge' ? 'edge' : 'node'\n ][actionId]?.workers\n\n // There are no workers to handle this action, nothing to forward to.\n if (!workers) {\n return\n }\n\n // If there is an entry for the current page, we don't need to forward.\n if (workers[normalizeWorkerPageName(pageName)]) {\n return\n }\n\n // Otherwise, grab the first worker that has a handler for this action id.\n return denormalizeWorkerPageName(Object.keys(workers)[0])\n}\n\nexport function setManifestsSingleton({\n page,\n clientReferenceManifest,\n serverActionsManifest,\n}: {\n page: string\n clientReferenceManifest: DeepReadonly<ClientReferenceManifest>\n serverActionsManifest: DeepReadonly<ActionManifest>\n}) {\n const existingSingleton = globalThisWithManifests[MANIFESTS_SINGLETON]\n\n if (existingSingleton) {\n existingSingleton.clientReferenceManifestsPerRoute.set(\n normalizeAppPath(page),\n clientReferenceManifest\n )\n\n existingSingleton.serverActionsManifest = serverActionsManifest\n } else {\n const clientReferenceManifestsPerRoute = new Map<\n string,\n DeepReadonly<ClientReferenceManifest>\n >([[normalizeAppPath(page), clientReferenceManifest]])\n\n const proxiedClientReferenceManifest = createProxiedClientReferenceManifest(\n clientReferenceManifestsPerRoute\n )\n\n globalThisWithManifests[MANIFESTS_SINGLETON] = {\n clientReferenceManifestsPerRoute,\n proxiedClientReferenceManifest,\n serverActionsManifest,\n serverModuleMap: createServerModuleMap(),\n }\n }\n}\n\nfunction getManifestsSingleton(): ManifestsSingleton {\n const manifestSingleton = globalThisWithManifests[MANIFESTS_SINGLETON]\n\n if (!manifestSingleton) {\n throw new InvariantError('The manifests singleton was not initialized.')\n }\n\n return manifestSingleton\n}\n\nexport function getClientReferenceManifest(): DeepReadonly<ClientReferenceManifest> {\n return getManifestsSingleton().proxiedClientReferenceManifest\n}\n\nexport function getServerActionsManifest(): DeepReadonly<ActionManifest> {\n return getManifestsSingleton().serverActionsManifest\n}\n\nexport function getServerModuleMap() {\n return getManifestsSingleton().serverModuleMap\n}\n"],"names":["getClientReferenceManifest","getServerActionsManifest","getServerModuleMap","selectWorkerForForwarding","setManifestsSingleton","MANIFESTS_SINGLETON","Symbol","for","globalThisWithManifests","globalThis","createProxiedClientReferenceManifest","clientReferenceManifestsPerRoute","createMappingProxy","prop","Proxy","get","_","id","workStore","workAsyncStorage","getStore","currentManifest","route","process","env","NODE_ENV","manifest","entry","undefined","values","mappingProxies","Map","InvariantError","proxy","set","String","createServerModuleMap","workers","NEXT_RUNTIME","workerEntry","normalizeWorkerPageName","page","Object","at","moduleId","async","name","chunks","pageName","pathHasPrefix","denormalizeWorkerPageName","bundlePath","normalizeAppPath","removePathPrefix","actionId","serverActionsManifest","keys","clientReferenceManifest","existingSingleton","proxiedClientReferenceManifest","serverModuleMap","getManifestsSingleton","manifestSingleton"],"mappings":";;;;;;;;;;;;;;;;;;IAgUgBA,0BAA0B;eAA1BA;;IAIAC,wBAAwB;eAAxBA;;IAIAC,kBAAkB;eAAlBA;;IA/EAC,yBAAyB;eAAzBA;;IAwBAC,qBAAqB;eAArBA;;;gCA9Qe;0BACE;+BACH;kCACG;0CACA;AAWjC,uEAAuE;AACvE,8EAA8E;AAC9E,4DAA4D;AAC5D,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AAuBvC,MAAMC,0BAA0BC;AAEhC,SAASC,qCACPC,gCAGC;IAED,MAAMC,qBAAqB,CAACC;QAC1B,OAAO,IAAIC,MACT,C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