UNPKG

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