MCPcopy
hub / github.com/angular/angular / renderApplication

Function renderApplication

packages/platform-server/src/utils.ts:342–380  ·  view source on GitHub ↗
(
  bootstrap: (context: BootstrapContext) => Promise<ApplicationRef>,
  options: {
    document?: string | Document;
    url?: string;
    platformProviders?: Provider[];
    allowedHosts?: Readonly<string>[];
  },
)

Source from the content-addressed store, hash-verified

340 * @publicApi
341 */
342export 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
382function validateAllowedHosts(url: string | undefined, allowedHosts: string[] | undefined) {
383 if (typeof url === 'string') {

Callers 8

ssrFunction · 0.90
utils_spec.tsFile · 0.90
runTestFunction · 0.90
server.tsFile · 0.90
runTestFunction · 0.90
server.tsFile · 0.90
renderFunction · 0.90

Calls 8

validateAllowedHostsFunction · 0.85
startMeasuringFunction · 0.85
createServerPlatformFunction · 0.85
stopMeasuringFunction · 0.85
renderInternalFunction · 0.85
asyncDestroyPlatformFunction · 0.85
whenStableMethod · 0.65
bootstrapFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…