{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/server-action-reducer.ts"],"sourcesContent":["import type {\n ActionFlightResponse,\n ActionResult,\n} from '../../../../shared/lib/app-router-types'\nimport { callServer } from '../../../app-call-server'\nimport { findSourceMapURL } from '../../../app-find-source-map-url'\nimport {\n ACTION_HEADER,\n NEXT_ACTION_NOT_FOUND_HEADER,\n NEXT_IS_PRERENDER_HEADER,\n NEXT_HTML_REQUEST_ID_HEADER,\n NEXT_ROUTER_STATE_TREE_HEADER,\n NEXT_URL,\n RSC_CONTENT_TYPE_HEADER,\n NEXT_REQUEST_ID_HEADER,\n} from '../../app-router-headers'\nimport { UnrecognizedActionError } from '../../unrecognized-action-error'\n\n// TODO: Explicitly import from client.browser\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {\n createFromFetch as createFromFetchBrowser,\n createTemporaryReferenceSet,\n encodeReply,\n} from 'react-server-dom-webpack/client'\n\nimport type {\n ReadonlyReducerState,\n ReducerState,\n ServerActionAction,\n ServerActionMutable,\n} from '../router-reducer-types'\nimport { assignLocation } from '../../../assign-location'\nimport { createHrefFromUrl } from '../create-href-from-url'\nimport { handleExternalUrl } from './navigate-reducer'\nimport { applyRouterStatePatchToTree } from '../apply-router-state-patch-to-tree'\nimport { isNavigatingToNewRootLayout } from '../is-navigating-to-new-root-layout'\nimport type { CacheNode } from '../../../../shared/lib/app-router-types'\nimport { handleMutable } from '../handle-mutable'\nimport { fillLazyItemsTillLeafWithHead } from '../fill-lazy-items-till-leaf-with-head'\nimport { createEmptyCacheNode } from '../../app-router'\nimport { hasInterceptionRouteInCurrentTree } from './has-interception-route-in-current-tree'\nimport { handleSegmentMismatch } from '../handle-segment-mismatch'\nimport { refreshInactiveParallelSegments } from '../refetch-inactive-parallel-segments'\nimport {\n normalizeFlightData,\n prepareFlightRouterStateForRequest,\n type NormalizedFlightData,\n} from '../../../flight-data-helpers'\nimport { getRedirectError } from '../../redirect'\nimport { RedirectType } from '../../redirect-error'\nimport { removeBasePath } from '../../../remove-base-path'\nimport { hasBasePath } from '../../../has-base-path'\nimport {\n extractInfoFromServerReferenceId,\n omitUnusedArgs,\n} from '../../../../shared/lib/server-reference-info'\nimport { revalidateEntireCache } from '../../segment-cache'\n\nconst createFromFetch =\n createFromFetchBrowser as (typeof import('react-server-dom-webpack/client.browser'))['createFromFetch']\n\nlet createDebugChannel:\n | typeof import('../../../dev/debug-channel').createDebugChannel\n | undefined\n\nif (\n process.env.NODE_ENV !== 'production' &&\n process.env.__NEXT_REACT_DEBUG_CHANNEL\n) {\n createDebugChannel = (\n require('../../../dev/debug-channel') as typeof import('../../../dev/debug-channel')\n ).createDebugChannel\n}\n\ntype FetchServerActionResult = {\n redirectLocation: URL | undefined\n redirectType: RedirectType | undefined\n actionResult: ActionResult | undefined\n actionFlightData: NormalizedFlightData[] | string | undefined\n isPrerender: boolean\n revalidatedParts: {\n tag: boolean\n cookie: boolean\n paths: string[]\n }\n}\n\nasync function fetchServerAction(\n state: ReadonlyReducerState,\n nextUrl: ReadonlyReducerState['nextUrl'],\n { actionId, actionArgs }: ServerActionAction\n): Promise {\n const temporaryReferences = createTemporaryReferenceSet()\n const info = extractInfoFromServerReferenceId(actionId)\n\n // TODO: Currently, we're only omitting unused args for the experimental \"use\n // cache\" functions. Once the server reference info byte feature is stable, we\n // should apply this to server actions as well.\n const usedArgs =\n info.type === 'use-cache' ? omitUnusedArgs(actionArgs, info) : actionArgs\n\n const body = await encodeReply(usedArgs, { temporaryReferences })\n\n const headers: Record = {\n Accept: RSC_CONTENT_TYPE_HEADER,\n [ACTION_HEADER]: actionId,\n [NEXT_ROUTER_STATE_TREE_HEADER]: prepareFlightRouterStateForRequest(\n state.tree\n ),\n }\n\n if (process.env.NEXT_DEPLOYMENT_ID) {\n headers['x-deployment-id'] = process.env.NEXT_DEPLOYMENT_ID\n }\n\n if (nextUrl) {\n headers[NEXT_URL] = nextUrl\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (self.__next_r) {\n headers[NEXT_HTML_REQUEST_ID_HEADER] = self.__next_r\n }\n\n // Create a new request ID for the server action request. The server uses\n // this to tag debug information sent via WebSocket to the client, which\n // then routes those chunks to the debug channel associated with this ID.\n headers[NEXT_REQUEST_ID_HEADER] = crypto\n .getRandomValues(new Uint32Array(1))[0]\n .toString(16)\n }\n\n const res = await fetch(state.canonicalUrl, { method: 'POST', headers, body })\n\n // Handle server actions that the server didn't recognize.\n const unrecognizedActionHeader = res.headers.get(NEXT_ACTION_NOT_FOUND_HEADER)\n if (unrecognizedActionHeader === '1') {\n throw new UnrecognizedActionError(\n `Server Action \"${actionId}\" was not found on the server. \\nRead more: https://nextjs.org/docs/messages/failed-to-find-server-action`\n )\n }\n\n const redirectHeader = res.headers.get('x-action-redirect')\n const [location, _redirectType] = redirectHeader?.split(';') || []\n let redirectType: RedirectType | undefined\n switch (_redirectType) {\n case 'push':\n redirectType = RedirectType.push\n break\n case 'replace':\n redirectType = RedirectType.replace\n break\n default:\n redirectType = undefined\n }\n\n const isPrerender = !!res.headers.get(NEXT_IS_PRERENDER_HEADER)\n let revalidatedParts: FetchServerActionResult['revalidatedParts']\n try {\n const revalidatedHeader = JSON.parse(\n res.headers.get('x-action-revalidated') || '[[],0,0]'\n )\n revalidatedParts = {\n paths: revalidatedHeader[0] || [],\n tag: !!revalidatedHeader[1],\n cookie: revalidatedHeader[2],\n }\n } catch (e) {\n revalidatedParts = NO_REVALIDATED_PARTS\n }\n\n const redirectLocation = location\n ? assignLocation(\n location,\n new URL(state.canonicalUrl, window.location.href)\n )\n : undefined\n\n const contentType = res.headers.get('content-type')\n const isRscResponse = !!(\n contentType && contentType.startsWith(RSC_CONTENT_TYPE_HEADER)\n )\n\n // Handle invalid server action responses.\n // A valid response must have `content-type: text/x-component`, unless it's an external redirect.\n // (external redirects have an 'x-action-redirect' header, but the body is an empty 'text/plain')\n if (!isRscResponse && !redirectLocation) {\n // The server can respond with a text/plain error message, but we'll fallback to something generic\n // if there isn't one.\n const message =\n res.status >= 400 && contentType === 'text/plain'\n ? await res.text()\n : 'An unexpected response was received from the server.'\n\n throw new Error(message)\n }\n\n let actionResult: FetchServerActionResult['actionResult']\n let actionFlightData: FetchServerActionResult['actionFlightData']\n\n if (isRscResponse) {\n const response: ActionFlightResponse = await createFromFetch(\n Promise.resolve(res),\n {\n callServer,\n findSourceMapURL,\n temporaryReferences,\n debugChannel: createDebugChannel && createDebugChannel(headers),\n }\n )\n\n // An internal redirect can send an RSC response, but does not have a useful `actionResult`.\n actionResult = redirectLocation ? undefined : response.a\n actionFlightData = normalizeFlightData(response.f)\n } else {\n // An external redirect doesn't contain RSC data.\n actionResult = undefined\n actionFlightData = undefined\n }\n\n return {\n actionResult,\n actionFlightData,\n redirectLocation,\n redirectType,\n revalidatedParts,\n isPrerender,\n }\n}\n\nconst NO_REVALIDATED_PARTS = {\n paths: [],\n tag: false,\n cookie: false,\n}\n\n/*\n * This reducer is responsible for calling the server action and processing any side-effects from the server action.\n * It does not mutate the state by itself but rather delegates to other reducers to do the actual mutation.\n */\nexport function serverActionReducer(\n state: ReadonlyReducerState,\n action: ServerActionAction\n): ReducerState {\n const { resolve, reject } = action\n const mutable: ServerActionMutable = {}\n\n let currentTree = state.tree\n\n mutable.preserveCustomHistoryState = false\n\n // only pass along the `nextUrl` param (used for interception routes) if the current route was intercepted.\n // If the route has been intercepted, the action should be as well.\n // Otherwise the server action might be intercepted with the wrong action id\n // (ie, one that corresponds with the intercepted route)\n const nextUrl =\n // We always send the last next-url, not the current when\n // performing a dynamic request. This is because we update\n // the next-url after a navigation, but we want the same\n // interception route to be matched that used the last\n // next-url.\n (state.previousNextUrl || state.nextUrl) &&\n hasInterceptionRouteInCurrentTree(state.tree)\n ? state.previousNextUrl || state.nextUrl\n : null\n\n const navigatedAt = Date.now()\n\n return fetchServerAction(state, nextUrl, action).then(\n async ({\n actionResult,\n actionFlightData: flightData,\n redirectLocation,\n redirectType,\n revalidatedParts,\n }) => {\n let redirectHref: string | undefined\n\n // honor the redirect type instead of defaulting to push in case of server actions.\n if (redirectLocation) {\n if (redirectType === RedirectType.replace) {\n state.pushRef.pendingPush = false\n mutable.pendingPush = false\n } else {\n state.pushRef.pendingPush = true\n mutable.pendingPush = true\n }\n\n redirectHref = createHrefFromUrl(redirectLocation, false)\n mutable.canonicalUrl = redirectHref\n }\n\n if (!flightData) {\n resolve(actionResult)\n\n // If there is a redirect but no flight data we need to do a mpaNavigation.\n if (redirectLocation) {\n return handleExternalUrl(\n state,\n mutable,\n redirectLocation.href,\n state.pushRef.pendingPush\n )\n }\n return state\n }\n\n if (typeof flightData === 'string') {\n // Handle case when navigating to page in `pages` from `app`\n resolve(actionResult)\n\n return handleExternalUrl(\n state,\n mutable,\n flightData,\n state.pushRef.pendingPush\n )\n }\n\n const actionRevalidated =\n revalidatedParts.paths.length > 0 ||\n revalidatedParts.tag ||\n revalidatedParts.cookie\n\n // Store whether this action triggered any revalidation\n // The action queue will use this information to potentially\n // trigger a refresh action if the action was discarded\n // (ie, due to a navigation, before the action completed)\n if (actionRevalidated) {\n action.didRevalidate = true\n }\n\n for (const normalizedFlightData of flightData) {\n const {\n tree: treePatch,\n seedData: cacheNodeSeedData,\n head,\n isRootRender,\n } = normalizedFlightData\n\n if (!isRootRender) {\n // TODO-APP: handle this case better\n console.log('SERVER ACTION APPLY FAILED')\n resolve(actionResult)\n\n return state\n }\n\n // Given the path can only have two items the items are only the router state and rsc for the root.\n const newTree = applyRouterStatePatchToTree(\n // TODO-APP: remove ''\n [''],\n currentTree,\n treePatch,\n redirectHref ? redirectHref : state.canonicalUrl\n )\n\n if (newTree === null) {\n resolve(actionResult)\n\n return handleSegmentMismatch(state, action, treePatch)\n }\n\n if (isNavigatingToNewRootLayout(currentTree, newTree)) {\n resolve(actionResult)\n\n return handleExternalUrl(\n state,\n mutable,\n redirectHref || state.canonicalUrl,\n state.pushRef.pendingPush\n )\n }\n\n // The server sent back RSC data for the server action, so we need to apply it to the cache.\n if (cacheNodeSeedData !== null) {\n const rsc = cacheNodeSeedData[0]\n const cache: CacheNode = createEmptyCacheNode()\n cache.rsc = rsc\n cache.prefetchRsc = null\n cache.loading = cacheNodeSeedData[2]\n fillLazyItemsTillLeafWithHead(\n navigatedAt,\n cache,\n // Existing cache is not passed in as server actions have to invalidate the entire cache.\n undefined,\n treePatch,\n cacheNodeSeedData,\n head\n )\n\n mutable.cache = cache\n revalidateEntireCache(state.nextUrl, newTree)\n if (actionRevalidated) {\n await refreshInactiveParallelSegments({\n navigatedAt,\n state,\n updatedTree: newTree,\n updatedCache: cache,\n includeNextUrl: Boolean(nextUrl),\n canonicalUrl: mutable.canonicalUrl || state.canonicalUrl,\n })\n }\n }\n\n mutable.patchedTree = newTree\n currentTree = newTree\n }\n\n if (redirectLocation && redirectHref) {\n // If the action triggered a redirect, the action promise will be rejected with\n // a redirect so that it's handled by RedirectBoundary as we won't have a valid\n // action result to resolve the promise with. This will effectively reset the state of\n // the component that called the action as the error boundary will remount the tree.\n // The status code doesn't matter here as the action handler will have already sent\n // a response with the correct status code.\n reject(\n getRedirectError(\n hasBasePath(redirectHref)\n ? removeBasePath(redirectHref)\n : redirectHref,\n redirectType || RedirectType.push\n )\n )\n\n // TODO: Investigate why this is needed with Activity.\n if (process.env.__NEXT_CACHE_COMPONENTS) {\n return state\n }\n } else {\n resolve(actionResult)\n }\n\n return handleMutable(state, mutable)\n },\n (e: any) => {\n // When the server action is rejected we don't update the state and instead call the reject handler of the promise.\n reject(e)\n\n return state\n }\n )\n}\n"],"names":["callServer","findSourceMapURL","ACTION_HEADER","NEXT_ACTION_NOT_FOUND_HEADER","NEXT_IS_PRERENDER_HEADER","NEXT_HTML_REQUEST_ID_HEADER","NEXT_ROUTER_STATE_TREE_HEADER","NEXT_URL","RSC_CONTENT_TYPE_HEADER","NEXT_REQUEST_ID_HEADER","UnrecognizedActionError","createFromFetch","createFromFetchBrowser","createTemporaryReferenceSet","encodeReply","assignLocation","createHrefFromUrl","handleExternalUrl","applyRouterStatePatchToTree","isNavigatingToNewRootLayout","handleMutable","fillLazyItemsTillLeafWithHead","createEmptyCacheNode","hasInterceptionRouteInCurrentTree","handleSegmentMismatch","refreshInactiveParallelSegments","normalizeFlightData","prepareFlightRouterStateForRequest","getRedirectError","RedirectType","removeBasePath","hasBasePath","extractInfoFromServerReferenceId","omitUnusedArgs","revalidateEntireCache","createDebugChannel","process","env","NODE_ENV","__NEXT_REACT_DEBUG_CHANNEL","require","fetchServerAction","state","nextUrl","actionId","actionArgs","temporaryReferences","info","usedArgs","type","body","headers","Accept","tree","NEXT_DEPLOYMENT_ID","self","__next_r","crypto","getRandomValues","Uint32Array","toString","res","fetch","canonicalUrl","method","unrecognizedActionHeader","get","redirectHeader","location","_redirectType","split","redirectType","push","replace","undefined","isPrerender","revalidatedParts","revalidatedHeader","JSON","parse","paths","tag","cookie","e","NO_REVALIDATED_PARTS","redirectLocation","URL","window","href","contentType","isRscResponse","startsWith","message","status","text","Error","actionResult","actionFlightData","response","Promise","resolve","debugChannel","a","f","serverActionReducer","action","reject","mutable","currentTree","preserveCustomHistoryState","previousNextUrl","navigatedAt","Date","now","then","flightData","redirectHref","pushRef","pendingPush","actionRevalidated","length","didRevalidate","normalizedFlightData","treePatch","seedData","cacheNodeSeedData","head","isRootRender","console","log","newTree","rsc","cache","prefetchRsc","loading","updatedTree","updatedCache","includeNextUrl","Boolean","patchedTree","__NEXT_CACHE_COMPONENTS"],"mappings":"AAIA,SAASA,UAAU,QAAQ,2BAA0B;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SACEC,aAAa,EACbC,4BAA4B,EAC5BC,wBAAwB,EACxBC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,QAAQ,EACRC,uBAAuB,EACvBC,sBAAsB,QACjB,2BAA0B;AACjC,SAASC,uBAAuB,QAAQ,kCAAiC;AAEzE,8CAA8C;AAC9C,6DAA6D;AAC7D,SACEC,mBAAmBC,sBAAsB,EACzCC,2BAA2B,EAC3BC,WAAW,QACN,kCAAiC;AAQxC,SAASC,cA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