({
app,
url,
cookies,
pathname,
cachedExp,
}: GetBootDataParams)
| 187 | }; |
| 188 | |
| 189 | export async function getBootData({ |
| 190 | app, |
| 191 | url, |
| 192 | cookies, |
| 193 | pathname, |
| 194 | cachedExp, |
| 195 | }: GetBootDataParams): Promise<Boot> { |
| 196 | const cached = |
| 197 | cachedExp?.fv && Object.keys(cachedExp.features ?? {}).length |
| 198 | ? cachedExp |
| 199 | : undefined; |
| 200 | const result = await fetchBoot( |
| 201 | getBootURL(app, url, pathname, cached?.fv), |
| 202 | app, |
| 203 | cookies, |
| 204 | ); |
| 205 | |
| 206 | if (!result.exp || result.exp.f) { |
| 207 | return enrichBootWithFeatures(result); |
| 208 | } |
| 209 | |
| 210 | if (cached && cached.fv === result.exp.fv) { |
| 211 | return { |
| 212 | ...result, |
| 213 | exp: { ...result.exp, features: cached.features }, |
| 214 | }; |
| 215 | } |
| 216 | |
| 217 | const fullResult = await fetchBoot( |
| 218 | getBootURL(app, url, pathname), |
| 219 | app, |
| 220 | cookies, |
| 221 | ); |
| 222 | return enrichBootWithFeatures(fullResult); |
| 223 | } |
no test coverage detected