UNPKG

8.95 kBTypeScriptView Raw
1/**
2 * @license Angular v15.0.1
3 * (c) 2010-2022 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7
8import { EnvironmentProviders } from '@angular/core';
9import { EventManager } from '@angular/platform-browser';
10import * as i0 from '@angular/core';
11import * as i1 from '@angular/common/http';
12import * as i2 from '@angular/platform-browser/animations';
13import * as i3 from '@angular/platform-browser';
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 document of the page to render, either as an HTML string or
130 * as a reference to the `document` instance.
131 * - `url` - the URL for the current render request.
132 * - `providers` - set of application level providers for the current render request.
133 * - `platformProviders` - the platform level providers for the current render request.
134 *
135 * @returns A Promise, that returns serialized (to a string) rendered page, once resolved.
136 *
137 * @publicApi
138 * @developerPreview
139 */
140export declare function renderApplication<T>(rootComponent: Type<T>, options: {
141 appId: string;
142 document?: string | Document;
143 url?: string;
144 providers?: Array<Provider | EnvironmentProviders>;
145 platformProviders?: Provider[];
146}): Promise<string>;
147
148/**
149 * Bootstraps an application using provided NgModule and serializes the page content to string.
150 *
151 * @param moduleType A reference to an NgModule that should be used for bootstrap.
152 * @param options Additional configuration for the render operation:
153 * - `document` - the document of the page to render, either as an HTML string or
154 * as a reference to the `document` instance.
155 * - `url` - the URL for the current render request.
156 * - `extraProviders` - set of platform level providers for the current render request.
157 *
158 * @publicApi
159 */
160export declare function renderModule<T>(moduleType: Type<T>, options: {
161 document?: string | Document;
162 url?: string;
163 extraProviders?: StaticProvider[];
164}): Promise<string>;
165
166/**
167 * Bootstraps an application using provided {@link NgModuleFactory} and serializes the page content
168 * to string.
169 *
170 * @param moduleFactory An instance of the {@link NgModuleFactory} that should be used for
171 * bootstrap.
172 * @param options Additional configuration for the render operation:
173 * - `document` - the document of the page to render, either as an HTML string or
174 * as a reference to the `document` instance.
175 * - `url` - the URL for the current render request.
176 * - `extraProviders` - set of platform level providers for the current render request.
177 *
178 * @publicApi
179 *
180 * @deprecated
181 * This symbol is no longer necessary as of Angular v13.
182 * Use {@link renderModule} API instead.
183 */
184export declare function renderModuleFactory<T>(moduleFactory: NgModuleFactory<T>, options: {
185 document?: string;
186 url?: string;
187 extraProviders?: StaticProvider[];
188}): Promise<string>;
189
190/**
191 * The ng module for the server.
192 *
193 * @publicApi
194 */
195export declare class ServerModule {
196 static ɵfac: i0.ɵɵFactoryDeclaration<ServerModule, never>;
197 static ɵmod: i0.ɵɵNgModuleDeclaration<ServerModule, never, [typeof i1.HttpClientModule, typeof i2.NoopAnimationsModule], [typeof i3.BrowserModule]>;
198 static ɵinj: i0.ɵɵInjectorDeclaration<ServerModule>;
199}
200
201/**
202 * NgModule to install on the server side while using the `TransferState` to transfer state from
203 * server to client.
204 *
205 * Note: this module is not needed if the `renderApplication` function is used.
206 * The `renderApplication` makes all providers from this module available in the application.
207 *
208 * @publicApi
209 * @deprecated no longer needed, you can inject the `TransferState` in an app without providing
210 * this module.
211 */
212export declare class ServerTransferStateModule {
213 static ɵfac: i0.ɵɵFactoryDeclaration<ServerTransferStateModule, never>;
214 static ɵmod: i0.ɵɵNgModuleDeclaration<ServerTransferStateModule, never, never, never>;
215 static ɵinj: i0.ɵɵInjectorDeclaration<ServerTransferStateModule>;
216}
217
218/**
219 * @publicApi
220 */
221export declare const VERSION: Version;
222
223export declare const ɵINTERNAL_SERVER_PLATFORM_PROVIDERS: StaticProvider[];
224
225/**
226 * An internal token that allows providing extra information about the server context
227 * (e.g. whether SSR or SSG was used). The value is a string and characters other
228 * than [a-zA-Z0-9\-] are removed. See the default value in `DEFAULT_SERVER_CONTEXT` const.
229 */
230export declare const ɵSERVER_CONTEXT: InjectionToken<string>;
231
232export declare const ɵSERVER_RENDER_PROVIDERS: Provider[];
233
234export declare class ɵServerRendererFactory2 implements RendererFactory2 {
235 private eventManager;
236 private ngZone;
237 private document;
238 private sharedStylesHost;
239 private rendererByCompId;
240 private defaultRenderer;
241 private schema;
242 constructor(eventManager: EventManager, ngZone: NgZone, document: any, sharedStylesHost: ɵSharedStylesHost);
243 createRenderer(element: any, type: RendererType2 | null): Renderer2;
244 begin(): void;
245 end(): void;
246 static ɵfac: i0.ɵɵFactoryDeclaration<ɵServerRendererFactory2, never>;
247 static ɵprov: i0.ɵɵInjectableDeclaration<ɵServerRendererFactory2>;
248}
249
250export declare function ɵsetDomTypes(): void;
251
252export { }
253
\No newline at end of file