UNPKG

5.62 kBTypeScriptView Raw
1/**
2 * @license Angular v18.2.11
3 * (c) 2010-2024 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7
8import { ApplicationRef } from '@angular/core';
9import { EnvironmentProviders } from '@angular/core';
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 { PlatformRef } from '@angular/core';
16import { Provider } from '@angular/core';
17import { StaticProvider } from '@angular/core';
18import { Type } from '@angular/core';
19import { Version } from '@angular/core';
20
21/**
22 * A function that will be executed when calling `renderApplication` or
23 * `renderModule` just before current platform state is rendered to string.
24 *
25 * @publicApi
26 */
27export declare const BEFORE_APP_SERIALIZED: InjectionToken<readonly (() => void | Promise<void>)[]>;
28
29/**
30 * The DI token for setting the initial config for the platform.
31 *
32 * @publicApi
33 */
34export declare const INITIAL_CONFIG: InjectionToken<PlatformConfig>;
35
36/**
37 * Config object passed to initialize the platform.
38 *
39 * @publicApi
40 */
41export declare interface PlatformConfig {
42 /**
43 * The initial DOM to use to bootstrap the server application.
44 * @default create a new DOM using Domino
45 */
46 document?: string;
47 /**
48 * The URL for the current application state. This is used for initializing
49 * the platform's location. `protocol`, `hostname`, and `port` will be
50 * overridden if `baseUrl` is set.
51 * @default none
52 */
53 url?: string;
54}
55
56/**
57 * @publicApi
58 */
59export declare const platformServer: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
60
61/**
62 * Representation of the current platform state.
63 *
64 * @publicApi
65 */
66export declare class PlatformState {
67 private _doc;
68 constructor(_doc: any);
69 /**
70 * Renders the current state of the platform to string.
71 */
72 renderToString(): string;
73 /**
74 * Returns the current DOM state.
75 */
76 getDocument(): any;
77 static ɵfac: i0.ɵɵFactoryDeclaration<PlatformState, never>;
78 static ɵprov: i0.ɵɵInjectableDeclaration<PlatformState>;
79}
80
81/**
82 * Sets up providers necessary to enable server rendering functionality for the application.
83 *
84 * @usageNotes
85 *
86 * Basic example of how you can add server support to your application:
87 * ```ts
88 * bootstrapApplication(AppComponent, {
89 * providers: [provideServerRendering()]
90 * });
91 * ```
92 *
93 * @publicApi
94 * @returns A set of providers to setup the server.
95 */
96export declare function provideServerRendering(): EnvironmentProviders;
97
98/**
99 * Bootstraps an instance of an Angular application and renders it to a string.
100
101 * ```typescript
102 * const bootstrap = () => bootstrapApplication(RootComponent, appConfig);
103 * const output: string = await renderApplication(bootstrap);
104 * ```
105 *
106 * @param bootstrap A method that when invoked returns a promise that returns an `ApplicationRef`
107 * instance once resolved.
108 * @param options Additional configuration for the render operation:
109 * - `document` - the document of the page to render, either as an HTML string or
110 * as a reference to the `document` instance.
111 * - `url` - the URL for the current render request.
112 * - `platformProviders` - the platform level providers for the current render request.
113 *
114 * @returns A Promise, that returns serialized (to a string) rendered page, once resolved.
115 *
116 * @publicApi
117 */
118export declare function renderApplication<T>(bootstrap: () => Promise<ApplicationRef>, options: {
119 document?: string | Document;
120 url?: string;
121 platformProviders?: Provider[];
122}): Promise<string>;
123
124/**
125 * Bootstraps an application using provided NgModule and serializes the page content to string.
126 *
127 * @param moduleType A reference to an NgModule that should be used for bootstrap.
128 * @param options Additional configuration for the render operation:
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 * - `extraProviders` - set of platform level providers for the current render request.
133 *
134 * @publicApi
135 */
136export declare function renderModule<T>(moduleType: Type<T>, options: {
137 document?: string | Document;
138 url?: string;
139 extraProviders?: StaticProvider[];
140}): Promise<string>;
141
142/**
143 * The ng module for the server.
144 *
145 * @publicApi
146 */
147export declare class ServerModule {
148 static ɵfac: i0.ɵɵFactoryDeclaration<ServerModule, never>;
149 static ɵmod: i0.ɵɵNgModuleDeclaration<ServerModule, never, [typeof i1.HttpClientModule, typeof i2.NoopAnimationsModule], [typeof i3.BrowserModule]>;
150 static ɵinj: i0.ɵɵInjectorDeclaration<ServerModule>;
151}
152
153/**
154 * @publicApi
155 */
156export declare const VERSION: Version;
157
158export declare function ɵdisableSsrProfiling(): void;
159
160/**
161 * This enables an internal performance profiler for SSR apps
162 *
163 * It should not be imported in application code
164 */
165export declare function ɵenableSsrProfiling(): void;
166
167export declare const ɵINTERNAL_SERVER_PLATFORM_PROVIDERS: StaticProvider[];
168
169/**
170 * An internal token that allows providing extra information about the server context
171 * (e.g. whether SSR or SSG was used). The value is a string and characters other
172 * than [a-zA-Z0-9\-] are removed. See the default value in `DEFAULT_SERVER_CONTEXT` const.
173 */
174export declare const ɵSERVER_CONTEXT: InjectionToken<string>;
175
176export declare const ɵSERVER_RENDER_PROVIDERS: Provider[];
177
178export { }