/
opt
/
canhelp
/
node_modules
/
next
/
dist
/
esm
/
server
/
app-render
/
/opt/canhelp/node_modules/next/dist/esm/server/app-render
mkdir
upload
Name
Size
Mode
Actions
metadata-insertion/
-
0755
rm
module-loading/
-
0755
rm
rsc/
-
0755
rm
action-async-storage-instance.js
192
0644
edit
dl
rm
action-async-storage-instance.js.map
503
0644
edit
dl
rm
action-async-storage.external.js
302
0644
edit
dl
rm
action-async-storage.external.js.map
765
0644
edit
dl
rm
action-handler.js
47638
0644
edit
dl
rm
action-handler.js.map
68659
0644
edit
dl
rm
action-utils.js
3705
0644
edit
dl
rm
action-utils.js.map
5560
0644
edit
dl
rm
after-task-async-storage-instance.js
199
0644
edit
dl
rm
after-task-async-storage-instance.js.map
523
0644
edit
dl
rm
after-task-async-storage.external.js
311
0644
edit
dl
rm
after-task-async-storage.external.js.map
1064
0644
edit
dl
rm
app-render-prerender-utils.js
6762
0644
edit
dl
rm
app-render-prerender-utils.js.map
10813
0644
edit
dl
rm
app-render-render-utils.js
1119
0644
edit
dl
rm
app-render-render-utils.js.map
1618
0644
edit
dl
rm
app-render.js
157902
0644
edit
dl
rm
app-render.js.map
239776
0644
edit
dl
rm
async-local-storage.js
1496
0644
edit
dl
rm
async-local-storage.js.map
2735
0644
edit
dl
rm
cache-signal.js
5730
0644
edit
dl
rm
cache-signal.js.map
8119
0644
edit
dl
rm
collect-segment-data.js
13005
0644
edit
dl
rm
collect-segment-data.js.map
22398
0644
edit
dl
rm
create-component-styles-and-scripts.js
1138
0644
edit
dl
rm
create-component-styles-and-scripts.js.map
2482
0644
edit
dl
rm
create-component-tree.js
39485
0644
edit
dl
rm
create-component-tree.js.map
59317
0644
edit
dl
rm
create-error-handler.js
8900
0644
edit
dl
rm
create-error-handler.js.map
13934
0644
edit
dl
rm
create-flight-router-state-from-loader-tree.js
3249
0644
edit
dl
rm
create-flight-router-state-from-loader-tree.js.map
5682
0644
edit
dl
rm
csrf-protection.js
2801
0644
edit
dl
rm
csrf-protection.js.map
3924
0644
edit
dl
rm
dynamic-access-async-storage-instance.js
207
0644
edit
dl
rm
dynamic-access-async-storage-instance.js.map
537
0644
edit
dl
rm
dynamic-access-async-storage.external.js
339
0644
edit
dl
rm
dynamic-access-async-storage.external.js.map
823
0644
edit
dl
rm
dynamic-rendering.js
30863
0644
edit
dl
rm
dynamic-rendering.js.map
45598
0644
edit
dl
rm
encryption-utils-server.js
4277
0644
edit
dl
rm
encryption-utils-server.js.map
7131
0644
edit
dl
rm
encryption-utils.js
6595
0644
edit
dl
rm
encryption-utils.js.map
11128
0644
edit
dl
rm
encryption.js
11249
0644
edit
dl
rm
encryption.js.map
16768
0644
edit
dl
rm
entry-base.js
3181
0644
edit
dl
rm
entry-base.js.map
6055
0644
edit
dl
rm
flight-render-result.js
509
0644
edit
dl
rm
flight-render-result.js.map
987
0644
edit
dl
rm
get-asset-query-string.js
779
0644
edit
dl
rm
get-asset-query-string.js.map
1573
0644
edit
dl
rm
get-css-inlined-link-tags.js
1403
0644
edit
dl
rm
get-css-inlined-link-tags.js.map
2570
0644
edit
dl
rm
get-layer-assets.js
2787
0644
edit
dl
rm
get-layer-assets.js.map
5550
0644
edit
dl
rm
get-preloadable-fonts.js
1294
0644
edit
dl
rm
get-preloadable-fonts.js.map
2384
0644
edit
dl
rm
get-script-nonce-from-header.js
1775
0644
edit
dl
rm
get-script-nonce-from-header.js.map
2784
0644
edit
dl
rm
get-segment-param.js
1358
0644
edit
dl
rm
get-segment-param.js.map
2352
0644
edit
dl
rm
get-short-dynamic-param-type.js
664
0644
edit
dl
rm
get-short-dynamic-param-type.js.map
1167
0644
edit
dl
rm
has-loading-component-in-tree.js
312
0644
edit
dl
rm
has-loading-component-in-tree.js.map
796
0644
edit
dl
rm
interop-default.js
181
0644
edit
dl
rm
interop-default.js.map
394
0644
edit
dl
rm
make-get-server-inserted-html.js
4076
0644
edit
dl
rm
make-get-server-inserted-html.js.map
6615
0644
edit
dl
rm
parse-and-validate-flight-router-state.js
1571
0644
edit
dl
rm
parse-and-validate-flight-router-state.js.map
2435
0644
edit
dl
rm
parse-loader-tree.js
798
0644
edit
dl
rm
parse-loader-tree.js.map
1427
0644
edit
dl
rm
postponed-state.js
5431
0644
edit
dl
rm
postponed-state.js.map
9091
0644
edit
dl
rm
prospective-render-utils.js
2277
0644
edit
dl
rm
prospective-render-utils.js.map
3421
0644
edit
dl
rm
react-large-shell-error.js
370
0644
edit
dl
rm
react-large-shell-error.js.map
773
0644
edit
dl
rm
react-server.node.js
316
0644
edit
dl
rm
react-server.node.js.map
637
0644
edit
dl
rm
render-css-resource.js
2407
0644
edit
dl
rm
render-css-resource.js.map
3963
0644
edit
dl
rm
required-scripts.js
2442
0644
edit
dl
rm
required-scripts.js.map
4294
0644
edit
dl
rm
segment-explorer-path.js
2756
0644
edit
dl
rm
segment-explorer-path.js.map
5208
0644
edit
dl
rm
server-inserted-html.js
1030
0644
edit
dl
rm
server-inserted-html.js.map
1778
0644
edit
dl
rm
strip-flight-headers.js
365
0644
edit
dl
rm
strip-flight-headers.js.map
738
0644
edit
dl
rm
types.js
2020
0644
edit
dl
rm
types.js.map
13145
0644
edit
dl
rm
use-flight-response.js
6758
0644
edit
dl
rm
use-flight-response.js.map
11158
0644
edit
dl
rm
walk-tree-with-flight-router-state.js
10808
0644
edit
dl
rm
walk-tree-with-flight-router-state.js.map
17382
0644
edit
dl
rm
work-async-storage-instance.js
188
0644
edit
dl
rm
work-async-storage-instance.js.map
491
0644
edit
dl
rm
work-async-storage.external.js
292
0644
edit
dl
rm
work-async-storage.external.js.map
4274
0644
edit
dl
rm
work-unit-async-storage-instance.js
197
0644
edit
dl
rm
work-unit-async-storage-instance.js.map
517
0644
edit
dl
rm
work-unit-async-storage.external.js
6423
0644
edit
dl
rm
work-unit-async-storage.external.js.map
20959
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/next/dist/esm/server/app-render/collect-segment-data.js
(13005B)
import { jsx as _jsx } from "react/jsx-runtime"; // eslint-disable-next-line import/no-extraneous-dependencies import { createFromReadableStream } from 'react-server-dom-webpack/client'; // eslint-disable-next-line import/no-extraneous-dependencies import { unstable_prerender as prerender } from 'react-server-dom-webpack/static'; import { streamFromBuffer, streamToBuffer } from '../stream-utils/node-web-streams-helper'; import { waitAtLeastOneReactRenderTask } from '../../lib/scheduler'; import { createSegmentRequestKeyPart, appendSegmentRequestKeyPart, ROOT_SEGMENT_REQUEST_KEY } from '../../shared/lib/segment-cache/segment-value-encoding'; import { getDigestForWellKnownError } from './create-error-handler'; const filterStackFrame = process.env.NODE_ENV !== 'production' ? require('../lib/source-maps').filterStackFrameDEV : undefined; const findSourceMapURL = process.env.NODE_ENV !== 'production' ? require('../lib/source-maps').findSourceMapURLDEV : undefined; function onSegmentPrerenderError(error) { const digest = getDigestForWellKnownError(error); if (digest) { return digest; } // We don't need to log the errors because we would have already done that // when generating the original Flight stream for the whole page. } export async function collectSegmentData(isClientParamParsingEnabled, fullPageDataBuffer, staleTime, clientModules, serverConsumerManifest) { // Traverse the router tree and generate a prefetch response for each segment. // A mutable map to collect the results as we traverse the route tree. const resultMap = new Map(); // Before we start, warm up the module cache by decoding the page data once. // Then we can assume that any remaining async tasks that occur the next time // are due to hanging promises caused by dynamic data access. Note we only // have to do this once per page, not per individual segment. // try { await createFromReadableStream(streamFromBuffer(fullPageDataBuffer), { findSourceMapURL, serverConsumerManifest }); await waitAtLeastOneReactRenderTask(); } catch {} // Create an abort controller that we'll use to stop the stream. const abortController = new AbortController(); const onCompletedProcessingRouteTree = async ()=>{ // Since all we're doing is decoding and re-encoding a cached prerender, if // serializing the stream takes longer than a microtask, it must because of // hanging promises caused by dynamic data. await waitAtLeastOneReactRenderTask(); abortController.abort(); }; // Generate a stream for the route tree prefetch. While we're walking the // tree, we'll also spawn additional tasks to generate the segment prefetches. // The promises for these tasks are pushed to a mutable array that we will // await once the route tree is fully rendered. const segmentTasks = []; const { prelude: treeStream } = await prerender(// RootTreePrefetch is not a valid return type for a React component, but // we need to use a component so that when we decode the original stream // inside of it, the side effects are transferred to the new stream. // @ts-expect-error /*#__PURE__*/ _jsx(PrefetchTreeData, { isClientParamParsingEnabled: isClientParamParsingEnabled, fullPageDataBuffer: fullPageDataBuffer, serverConsumerManifest: serverConsumerManifest, clientModules: clientModules, staleTime: staleTime, segmentTasks: segmentTasks, onCompletedProcessingRouteTree: onCompletedProcessingRouteTree }), clientModules, { filterStackFrame, signal: abortController.signal, onError: onSegmentPrerenderError }); // Write the route tree to a special `/_tree` segment. const treeBuffer = await streamToBuffer(treeStream); resultMap.set('/_tree', treeBuffer); // Now that we've finished rendering the route tree, all the segment tasks // should have been spawned. Await them in parallel and write the segment // prefetches to the result map. for (const [segmentPath, buffer] of (await Promise.all(segmentTasks))){ resultMap.set(segmentPath, buffer); } return resultMap; } async function PrefetchTreeData({ isClientParamParsingEnabled, fullPageDataBuffer, serverConsumerManifest, clientModules, staleTime, segmentTasks, onCompletedProcessingRouteTree }) { // We're currently rendering a Flight response for the route tree prefetch. // Inside this component, decode the Flight stream for the whole page. This is // a hack to transfer the side effects from the original Flight stream (e.g. // Float preloads) onto the Flight stream for the tree prefetch. // TODO: React needs a better way to do this. Needed for Server Actions, too. const initialRSCPayload = await createFromReadableStream(createUnclosingPrefetchStream(streamFromBuffer(fullPageDataBuffer)), { findSourceMapURL, serverConsumerManifest }); const buildId = initialRSCPayload.b; // FlightDataPath is an unsound type, hence the additional checks. const flightDataPaths = initialRSCPayload.f; if (flightDataPaths.length !== 1 && flightDataPaths[0].length !== 3) { console.error('Internal Next.js error: InitialRSCPayload does not match the expected ' + 'shape for a prerendered page during segment prefetch generation.'); return null; } const flightRouterState = flightDataPaths[0][0]; const seedData = flightDataPaths[0][1]; const head = flightDataPaths[0][2]; // Compute the route metadata tree by traversing the FlightRouterState. As we // walk the tree, we will also spawn a task to produce a prefetch response for // each segment. const tree = collectSegmentDataImpl(isClientParamParsingEnabled, flightRouterState, buildId, seedData, clientModules, ROOT_SEGMENT_REQUEST_KEY, segmentTasks); const isHeadPartial = await isPartialRSCData(head, clientModules); // Notify the abort controller that we're done processing the route tree. // Anything async that happens after this point must be due to hanging // promises in the original stream. onCompletedProcessingRouteTree(); // Render the route tree to a special `/_tree` segment. const treePrefetch = { buildId, tree, head, isHeadPartial, staleTime }; return treePrefetch; } function collectSegmentDataImpl(isClientParamParsingEnabled, route, buildId, seedData, clientModules, requestKey, segmentTasks) { // Metadata about the segment. Sent as part of the tree prefetch. Null if // there are no children. let slotMetadata = null; const children = route[1]; const seedDataChildren = seedData !== null ? seedData[2] : null; for(const parallelRouteKey in children){ const childRoute = children[parallelRouteKey]; const childSegment = childRoute[0]; const childSeedData = seedDataChildren !== null ? seedDataChildren[parallelRouteKey] : null; const childRequestKey = appendSegmentRequestKeyPart(requestKey, parallelRouteKey, createSegmentRequestKeyPart(childSegment)); const childTree = collectSegmentDataImpl(isClientParamParsingEnabled, childRoute, buildId, childSeedData, clientModules, childRequestKey, segmentTasks); if (slotMetadata === null) { slotMetadata = {}; } slotMetadata[parallelRouteKey] = childTree; } if (seedData !== null) { // Spawn a task to write the segment data to a new Flight stream. segmentTasks.push(// Since we're already in the middle of a render, wait until after the // current task to escape the current rendering context. waitAtLeastOneReactRenderTask().then(()=>renderSegmentPrefetch(buildId, seedData, requestKey, clientModules))); } else { // This segment does not have any seed data. Skip generating a prefetch // response for it. We'll still include it in the route tree, though. // TODO: We should encode in the route tree whether a segment is missing // so we don't attempt to fetch it for no reason. As of now this shouldn't // ever happen in practice, though. } const segment = route[0]; let name; let paramType = null; let paramKey = null; if (typeof segment === 'string') { name = segment; paramKey = segment; paramType = null; } else { name = segment[0]; paramKey = segment[1]; paramType = segment[2]; } // Metadata about the segment. Sent to the client as part of the // tree prefetch. return { name, paramType, // This value is ommitted from the prefetch response when clientParamParsing // is enabled. The flag only exists while we're testing the feature, in // case there's a bug and we need to revert. // TODO: Remove once clientParamParsing is enabled everywhere. paramKey: isClientParamParsingEnabled ? null : paramKey, slots: slotMetadata, isRootLayout: route[4] === true }; } async function renderSegmentPrefetch(buildId, seedData, requestKey, clientModules) { // Render the segment data to a stream. // In the future, this is where we can include additional metadata, like the // stale time and cache tags. const rsc = seedData[1]; const loading = seedData[3]; const segmentPrefetch = { buildId, rsc, loading, isPartial: await isPartialRSCData(rsc, clientModules) }; // Since all we're doing is decoding and re-encoding a cached prerender, if // it takes longer than a microtask, it must because of hanging promises // caused by dynamic data. Abort the stream at the end of the current task. const abortController = new AbortController(); waitAtLeastOneReactRenderTask().then(()=>abortController.abort()); const { prelude: segmentStream } = await prerender(segmentPrefetch, clientModules, { filterStackFrame, signal: abortController.signal, onError: onSegmentPrerenderError }); const segmentBuffer = await streamToBuffer(segmentStream); if (requestKey === ROOT_SEGMENT_REQUEST_KEY) { return [ '/_index', segmentBuffer ]; } else { return [ requestKey, segmentBuffer ]; } } async function isPartialRSCData(rsc, clientModules) { // We can determine if a segment contains only partial data if it takes longer // than a task to encode, because dynamic data is encoded as an infinite // promise. We must do this in a separate Flight prerender from the one that // actually generates the prefetch stream because we need to include // `isPartial` in the stream itself. let isPartial = false; const abortController = new AbortController(); waitAtLeastOneReactRenderTask().then(()=>{ // If we haven't yet finished the outer task, then it must be because we // accessed dynamic data. isPartial = true; abortController.abort(); }); await prerender(rsc, clientModules, { filterStackFrame, signal: abortController.signal, onError () {}, onPostpone () { // If something postponed, i.e. when Cache Components is not enabled, we can // infer that the RSC data is partial. isPartial = true; } }); return isPartial; } function createUnclosingPrefetchStream(originalFlightStream) { // When PPR is enabled, prefetch streams may contain references that never // resolve, because that's how we encode dynamic data access. In the decoded // object returned by the Flight client, these are reified into hanging // promises that suspend during render, which is effectively what we want. // The UI resolves when it switches to the dynamic data stream // (via useDeferredValue(dynamic, static)). // // However, the Flight implementation currently errors if the server closes // the response before all the references are resolved. As a cheat to work // around this, we wrap the original stream in a new stream that never closes, // and therefore doesn't error. const reader = originalFlightStream.getReader(); return new ReadableStream({ async pull (controller) { while(true){ const { done, value } = await reader.read(); if (!done) { // Pass to the target stream and keep consuming the Flight response // from the server. controller.enqueue(value); continue; } // The server stream has closed. Exit, but intentionally do not close // the target stream. return; } } }); } //# sourceMappingURL=collect-segment-data.js.map
Save
cmd:
run