(
bootstrap: (context: BootstrapContext) => Promise<ApplicationRef>,
options: {
document?: string | Document;
url?: string;
platformProviders?: Provider[];
allowedHosts?: Readonly<string>[];
},
)
| 340 | * @publicApi |
| 341 | */ |
| 342 | export async function renderApplication( |
| 343 | bootstrap: (context: BootstrapContext) => Promise<ApplicationRef>, |
| 344 | options: { |
| 345 | document?: string | Document; |
| 346 | url?: string; |
| 347 | platformProviders?: Provider[]; |
| 348 | allowedHosts?: Readonly<string>[]; |
| 349 | }, |
| 350 | ): Promise<string> { |
| 351 | const renderAppLabel = 'renderApplication'; |
| 352 | const bootstrapLabel = 'bootstrap'; |
| 353 | const _renderLabel = '_render'; |
| 354 | const {url, allowedHosts} = options; |
| 355 | |
| 356 | validateAllowedHosts(url, allowedHosts); |
| 357 | |
| 358 | startMeasuring(renderAppLabel); |
| 359 | const platformRef = createServerPlatform(options); |
| 360 | try { |
| 361 | startMeasuring(bootstrapLabel); |
| 362 | const applicationRef = await bootstrap({platformRef}); |
| 363 | stopMeasuring(bootstrapLabel); |
| 364 | |
| 365 | startMeasuring(_renderLabel); |
| 366 | |
| 367 | const measuringLabel = 'whenStable'; |
| 368 | startMeasuring(measuringLabel); |
| 369 | // Block until application is stable. |
| 370 | await applicationRef.whenStable(); |
| 371 | stopMeasuring(measuringLabel); |
| 372 | |
| 373 | const rendered = await renderInternal(platformRef, applicationRef); |
| 374 | stopMeasuring(_renderLabel); |
| 375 | return rendered; |
| 376 | } finally { |
| 377 | await asyncDestroyPlatform(platformRef); |
| 378 | stopMeasuring(renderAppLabel); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | function validateAllowedHosts(url: string | undefined, allowedHosts: string[] | undefined) { |
| 383 | if (typeof url === 'string') { |
no test coverage detected
searching dependent graphs…