angular/goldens/public-api/platform-server/index.md
Alex Rickabaugh 7de1469be6 feat(core): introduce EnvironmentProviders wrapper type (#47669)
This commit introduces a new type `EnvironmentProviders` which can be used
in contexts where Angular accepted `Provider`s destined for
`EnvironmentInjector`s. This includes contexts such as `@NgModule.providers`
and `Route.providers`.

The new type is useful for preventing such providers from accidentally
ending up in `@Component.providers`. It can be used as the return type of
provider functions (such as `provideRouter`) to enforce this safety.

Because `Provider` allows `any[]` nested arrays, the compile-time safety
provided by `EnvironmentProviders` is easily circumvented. However, the
runtime shape of `EnvironmentProviders` is not compatible with component
injectors and will result in a runtime error if it leaks through (NG0207).

A new function `makeEnvironmentProviders` is used to construct this new type
from an array of providers.

The existing `importProvidersFrom` operation previously returned a very
similar type `ImportedNgModuleProviders` which had the same goal. This
machinery is switched over to use the new `EnvironmentProviders` interface
instead (in fact, `ImportedNgModuleProviders` is now just an alias to
`EnvironmentProviders`).

PR Close #47669
2022-10-07 14:03:13 -07:00

3 KiB

API Report File for "@angular/platform-server"

Do not edit this file. It is a report generated by API Extractor.


import { EnvironmentProviders } from '@angular/core';
import * as i0 from '@angular/core';
import * as i1 from '@angular/common/http';
import * as i2 from '@angular/platform-browser/animations';
import * as i3 from '@angular/platform-browser';
import { InjectionToken } from '@angular/core';
import { NgModuleFactory } from '@angular/core';
import { PlatformRef } from '@angular/core';
import { Provider } from '@angular/core';
import { StaticProvider } from '@angular/core';
import { Type } from '@angular/core';
import { Version } from '@angular/core';

// @public
export const BEFORE_APP_SERIALIZED: InjectionToken<(() => void | Promise<void>)[]>;

// @public
export const INITIAL_CONFIG: InjectionToken<PlatformConfig>;

// @public
export interface PlatformConfig {
    baseUrl?: string;
    document?: string;
    url?: string;
    useAbsoluteUrl?: boolean;
}

// @public
export const platformDynamicServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;

// @public (undocumented)
export const platformServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;

// @public
export class PlatformState {
    constructor(_doc: any);
    getDocument(): any;
    renderToString(): string;
    // (undocumented)
    static ɵfac: i0.ɵɵFactoryDeclaration<PlatformState, never>;
    // (undocumented)
    static ɵprov: i0.ɵɵInjectableDeclaration<PlatformState>;
}

// @public
export function renderApplication<T>(rootComponent: Type<T>, options: {
    appId: string;
    document?: string | Document;
    url?: string;
    providers?: Array<Provider | EnvironmentProviders>;
    platformProviders?: Provider[];
}): Promise<string>;

// @public
export function renderModule<T>(moduleType: Type<T>, options: {
    document?: string | Document;
    url?: string;
    extraProviders?: StaticProvider[];
}): Promise<string>;

// @public @deprecated
export function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
    document?: string;
    url?: string;
    extraProviders?: StaticProvider[];
}): Promise<string>;

// @public
export class ServerModule {
    // (undocumented)
    static ɵfac: i0.ɵɵFactoryDeclaration<ServerModule, never>;
    // (undocumented)
    static ɵinj: i0.ɵɵInjectorDeclaration<ServerModule>;
    // (undocumented)
    static ɵmod: i0.ɵɵNgModuleDeclaration<ServerModule, never, [typeof i1.HttpClientModule, typeof i2.NoopAnimationsModule], [typeof i3.BrowserModule]>;
}

// @public @deprecated
export class ServerTransferStateModule {
    // (undocumented)
    static ɵfac: i0.ɵɵFactoryDeclaration<ServerTransferStateModule, never>;
    // (undocumented)
    static ɵinj: i0.ɵɵInjectorDeclaration<ServerTransferStateModule>;
    // (undocumented)
    static ɵmod: i0.ɵɵNgModuleDeclaration<ServerTransferStateModule, never, never, never>;
}

// @public (undocumented)
export const VERSION: Version;

// (No @packageDocumentation comment for this package)