( children: ReactNodeList, options?: Options, )
| 72 | }; |
| 73 | |
| 74 | function prerender( |
| 75 | children: ReactNodeList, |
| 76 | options?: Options, |
| 77 | ): Promise<StaticResult> { |
| 78 | return new Promise((resolve, reject) => { |
| 79 | const onFatalError = reject; |
| 80 | |
| 81 | function onAllReady() { |
| 82 | const stream = new ReadableStream( |
| 83 | { |
| 84 | type: 'bytes', |
| 85 | pull: (controller): ?Promise<void> => { |
| 86 | startFlowing(request, controller); |
| 87 | }, |
| 88 | cancel: (reason): ?Promise<void> => { |
| 89 | stopFlowing(request); |
| 90 | abort(request, reason); |
| 91 | }, |
| 92 | }, |
| 93 | // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams. |
| 94 | {highWaterMark: 0}, |
| 95 | ); |
| 96 | |
| 97 | const result: StaticResult = |
| 98 | enablePostpone || enableHalt |
| 99 | ? { |
| 100 | postponed: getPostponedState(request), |
| 101 | prelude: stream, |
| 102 | } |
| 103 | : ({ |
| 104 | prelude: stream, |
| 105 | }: any); |
| 106 | resolve(result); |
| 107 | } |
| 108 | |
| 109 | const onHeaders = options ? options.onHeaders : undefined; |
| 110 | let onHeadersImpl; |
| 111 | if (onHeaders) { |
| 112 | onHeadersImpl = (headersDescriptor: HeadersDescriptor) => { |
| 113 | onHeaders(new Headers(headersDescriptor)); |
| 114 | }; |
| 115 | } |
| 116 | |
| 117 | const resources = createResumableState( |
| 118 | options ? options.identifierPrefix : undefined, |
| 119 | options ? options.unstable_externalRuntimeSrc : undefined, |
| 120 | options ? options.bootstrapScriptContent : undefined, |
| 121 | options ? options.bootstrapScripts : undefined, |
| 122 | options ? options.bootstrapModules : undefined, |
| 123 | ); |
| 124 | const request = createPrerenderRequest( |
| 125 | children, |
| 126 | resources, |
| 127 | createRenderState( |
| 128 | resources, |
| 129 | undefined, // nonce is not compatible with prerendered bootstrap scripts |
| 130 | options ? options.unstable_externalRuntimeSrc : undefined, |
| 131 | options ? options.importMap : undefined, |
nothing calls this directly
no test coverage detected