code: function setupPage( pageName ) {
           assert( pageName ).hasType( String ).isNotNull();
  
           publishDebugInfo( 'willLoad.page', { page: pageName } );
  
           return pageLoader.load( pageName )
              .then( page => {
                 areaHelper = createAreaHelper( page, log );
                 visibilityManager.setAreaHelper( areaHelper );
  
                 const layoutPromise = layoutLoader.load( page.layout )
                    .then( layoutInfo => {
                       cleanUpLayout = renderLayout( pageElement, areaHelper, layoutInfo );
                    } );
  
                 localeManager.subscribe();
                 const layoutWidget = widget => layoutWidgetAdapterFor( areaHelper, widget );
  
                 // instantiate controllers wrapped by widget adapters
                 const widgetPromises = widgetsForPage( page )
                    .map( widget => 'layout' in widget ?
                       layoutWidget( widget ) :
                       widgetLoader.load( widget, {}, instanceContext ) );
  
                 return Promise.all( [ ...widgetPromises, layoutPromise ] )
                    .then( results => results.slice( 0, -1 ) );
              } )
              .then( widgetAdapterWrappers => {
                 publishDebugInfo( 'didLoad.page', { page: pageName } );
  
                 activePage = pageName;
                 activeWidgetAdapterWrappers = widgetAdapterWrappers;
              } )
              .then( localeManager.initialize )
              .then( () => {
                 return eventBus.publishAndGatherReplies(
                    'beginLifecycleRequest.default', LIFECYCLE_EVENT, EVENT_OPTIONS
                 );
              } )
              .then( visibilityManager.initialize )
              // Give the widgets (a little) time to settle on the event bus before $digesting and painting:
              .then( () => delay( WIDGET_ATTACH_DELAY_MS ) )
              .then( () => areaHelper.attachWidgets( activeWidgetAdapterWrappers ) );
        }
docs: //////////////////////////////////////////////////////////////////////////////////////////////////////