UNPKG

7.63 kBTypeScriptView Raw
1/**
2 * @license Angular v14.0.4
3 * (c) 2010-2022 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7
8import { EventManager } from '@angular/platform-browser';
9import * as i0 from '@angular/core';
10import * as i1 from '@angular/common/http';
11import * as i2 from '@angular/platform-browser/animations';
12import * as i3 from '@angular/platform-browser';
13import { ImportedNgModuleProviders } from '@angular/core';
14import { InjectionToken } from '@angular/core';
15import { NgModuleFactory } from '@angular/core';
16import { NgZone } from '@angular/core';
17import { PlatformRef } from '@angular/core';
18import { Provider } from '@angular/core';
19import { Renderer2 } from '@angular/core';
20import { RendererFactory2 } from '@angular/core';
21import { RendererType2 } from '@angular/core';
22import { StaticProvider } from '@angular/core';
23import { Type } from '@angular/core';
24import { Version } from '@angular/core';
25import { ɵSharedStylesHost } from '@angular/platform-browser';
26
27/**
28 * A function that will be executed when calling `renderApplication`, `renderModuleFactory` or
29 * `renderModule` just before current platform state is rendered to string.
30 *
31 * @publicApi
32 */
33export declare const BEFORE_APP_SERIALIZED: InjectionToken<(() => void | Promise<void>)[]>;
34
35/**
36 * The DI token for setting the initial config for the platform.
37 *
38 * @publicApi
39 */
40export declare const INITIAL_CONFIG: InjectionToken<PlatformConfig>;
41
42/**
43 * Config object passed to initialize the platform.
44 *
45 * @publicApi
46 */
47export declare interface PlatformConfig {
48 /**
49 * The initial DOM to use to bootstrap the server application.
50 * @default create a new DOM using Domino
51 */
52 document?: string;
53 /**
54 * The URL for the current application state. This is used for initializing
55 * the platform's location. `protocol`, `hostname`, and `port` will be
56 * overridden if `baseUrl` is set.
57 * @default none
58 */
59 url?: string;
60 /**
61 * Whether to append the absolute URL to any relative HTTP requests. If set to
62 * true, this logic executes prior to any HTTP interceptors that may run later
63 * on in the request. `baseUrl` must be supplied if this flag is enabled.
64 * @default false
65 */
66 useAbsoluteUrl?: boolean;
67 /**
68 * The base URL for resolving absolute URL for HTTP requests. It must be set
69 * if `useAbsoluteUrl` is true, and must consist of protocol, hostname,
70 * and optional port. This option has no effect if `useAbsoluteUrl` is not
71 * enabled.
72 */
73 baseUrl?: string;
74}
75
76/**
77 * The server platform that supports the runtime compiler.
78 *
79 * @publicApi
80 */
81export declare const platformDynamicServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
82
83/**
84 * @publicApi
85 */
86export declare const platformServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
87
88/**
89 * Representation of the current platform state.
90 *
91 * @publicApi
92 */
93export declare class PlatformState {
94 private _doc;
95 constructor(_doc: any);
96 /**
97 * Renders the current state of the platform to string.
98 */
99 renderToString(): string;
100 /**
101 * Returns the current DOM state.
102 */
103 getDocument(): any;
104 static ɵfac: i0.ɵɵFactoryDeclaration<PlatformState, never>;
105 static ɵprov: i0.ɵɵInjectableDeclaration<PlatformState>;
106}
107
108/**
109 * Bootstraps an instance of an Angular application and renders it to a string.
110 *
111 * Note: the root component passed into this function *must* be a standalone one (should have the
112 * `standalone: true` flag in the `@Component` decorator config).
113 *
114 * ```typescript
115 * @Component({
116 * standalone: true,
117 * template: 'Hello world!'
118 * })
119 * class RootComponent {}
120 *
121 * const output: string = await renderApplication(RootComponent, {appId: 'server-app'});
122 * ```
123 *
124 * @param rootComponent A reference to a Standalone Component that should be rendered.
125 * @param options Additional configuration for the render operation:
126 * - `appId` - a string identifier of this application. The appId is used to prefix all
127 * server-generated stylings and state keys of the application in TransferState
128 * use-cases.
129 * - `document` - the full document HTML of the page to render, as a string.
130 * - `url` - the URL for the current render request.
131 * - `providers` - set of application level providers for the current render request.
132 * - `platformProviders` - the platform level providers for the current render request.
133 * @returns A Promise, that returns serialized (to a string) rendered page, once resolved.
134 *
135 * @publicApi
136 * @developerPreview
137 */
138export declare function renderApplication<T>(rootComponent: Type<T>, options: {
139 appId: string;
140 document?: string;
141 url?: string;
142 providers?: Array<Provider | ImportedNgModuleProviders>;
143 platformProviders?: Provider[];
144}): Promise<string>;
145
146/**
147 * Renders a Module to string.
148 *
149 * `document` is the full document HTML of the page to render, as a string.
150 * `url` is the URL for the current render request.
151 * `extraProviders` are the platform level providers for the current render request.
152 *
153 * @publicApi
154 */
155export declare function renderModule<T>(module: Type<T>, options: {
156 document?: string;
157 url?: string;
158 extraProviders?: StaticProvider[];
159}): Promise<string>;
160
161/**
162 * Renders a {@link NgModuleFactory} to string.
163 *
164 * `document` is the full document HTML of the page to render, as a string.
165 * `url` is the URL for the current render request.
166 * `extraProviders` are the platform level providers for the current render request.
167 *
168 * @publicApi
169 *
170 * @deprecated
171 * This symbol is no longer necessary as of Angular v13.
172 * Use {@link renderModule} API instead.
173 */
174export declare function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
175 document?: string;
176 url?: string;
177 extraProviders?: StaticProvider[];
178}): Promise<string>;
179
180/**
181 * The ng module for the server.
182 *
183 * @publicApi
184 */
185export declare class ServerModule {
186 static ɵfac: i0.ɵɵFactoryDeclaration<ServerModule, never>;
187 static ɵmod: i0.ɵɵNgModuleDeclaration<ServerModule, never, [typeof i1.HttpClientModule, typeof i2.NoopAnimationsModule], [typeof i3.BrowserModule]>;
188 static ɵinj: i0.ɵɵInjectorDeclaration<ServerModule>;
189}
190
191/**
192 * NgModule to install on the server side while using the `TransferState` to transfer state from
193 * server to client.
194 *
195 * @publicApi
196 */
197export declare class ServerTransferStateModule {
198 static ɵfac: i0.ɵɵFactoryDeclaration<ServerTransferStateModule, never>;
199 static ɵmod: i0.ɵɵNgModuleDeclaration<ServerTransferStateModule, never, never, never>;
200 static ɵinj: i0.ɵɵInjectorDeclaration<ServerTransferStateModule>;
201}
202
203/**
204 * @publicApi
205 */
206export declare const VERSION: Version;
207
208export declare const ɵINTERNAL_SERVER_PLATFORM_PROVIDERS: StaticProvider[];
209
210export declare const ɵSERVER_RENDER_PROVIDERS: Provider[];
211
212export declare class ɵServerRendererFactory2 implements RendererFactory2 {
213 private eventManager;
214 private ngZone;
215 private document;
216 private sharedStylesHost;
217 private rendererByCompId;
218 private defaultRenderer;
219 private schema;
220 constructor(eventManager: EventManager, ngZone: NgZone, document: any, sharedStylesHost: ɵSharedStylesHost);
221 createRenderer(element: any, type: RendererType2 | null): Renderer2;
222 begin(): void;
223 end(): void;
224 static ɵfac: i0.ɵɵFactoryDeclaration<ɵServerRendererFactory2, never>;
225 static ɵprov: i0.ɵɵInjectableDeclaration<ɵServerRendererFactory2>;
226}
227
228export declare function ɵsetDomTypes(): void;
229
230export { }
231
\No newline at end of file