@angular/ssr 21.0.0-next.0 → 21.0.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/node.mjs +246 -408
- package/fesm2022/node.mjs.map +1 -1
- package/fesm2022/ssr.mjs +1304 -2398
- package/fesm2022/ssr.mjs.map +1 -1
- package/package.json +10 -10
- package/schematics/ng-add/index.js +1 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.js +1 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/{node/index.d.ts → types/node.d.ts} +5 -5
- package/{index.d.ts → types/ssr.d.ts} +39 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/ssr",
|
|
3
|
-
"version": "21.0.0-next.
|
|
3
|
+
"version": "21.0.0-next.10",
|
|
4
4
|
"description": "Angular server side rendering utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@angular-devkit/schematics": "workspace:*",
|
|
32
|
-
"@angular/common": "21.0.0-
|
|
33
|
-
"@angular/compiler": "21.0.0-
|
|
34
|
-
"@angular/core": "21.0.0-
|
|
35
|
-
"@angular/platform-browser": "21.0.0-
|
|
36
|
-
"@angular/platform-server": "21.0.0-
|
|
37
|
-
"@angular/router": "21.0.0-
|
|
32
|
+
"@angular/common": "21.0.0-rc.0",
|
|
33
|
+
"@angular/compiler": "21.0.0-rc.0",
|
|
34
|
+
"@angular/core": "21.0.0-rc.0",
|
|
35
|
+
"@angular/platform-browser": "21.0.0-rc.0",
|
|
36
|
+
"@angular/platform-server": "21.0.0-rc.0",
|
|
37
|
+
"@angular/router": "21.0.0-rc.0",
|
|
38
38
|
"@schematics/angular": "workspace:*",
|
|
39
39
|
"beasties": "0.3.5"
|
|
40
40
|
},
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"url": "https://github.com/angular/angular-cli.git"
|
|
46
46
|
},
|
|
47
47
|
"module": "./fesm2022/ssr.mjs",
|
|
48
|
-
"typings": "./
|
|
48
|
+
"typings": "./types/ssr.d.ts",
|
|
49
49
|
"exports": {
|
|
50
50
|
"./package.json": {
|
|
51
51
|
"default": "./package.json"
|
|
52
52
|
},
|
|
53
53
|
".": {
|
|
54
|
-
"types": "./
|
|
54
|
+
"types": "./types/ssr.d.ts",
|
|
55
55
|
"default": "./fesm2022/ssr.mjs"
|
|
56
56
|
},
|
|
57
57
|
"./node": {
|
|
58
|
-
"types": "./node
|
|
58
|
+
"types": "./types/node.d.ts",
|
|
59
59
|
"default": "./fesm2022/node.mjs"
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -9,3 +9,4 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
11
11
|
exports.default = (options) => (0, schematics_1.externalSchematic)('@schematics/angular', 'ssr', options);
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAEH,2DAA+D;AAG/D,kBAAe,CAAC,OAAmB,EAAE,EAAE,CAAC,IAAA,8BAAiB,EAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":";AACA,mFAAmF;AACnF,oFAAoF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Type, ApplicationRef, StaticProvider } from '@angular/core';
|
|
2
|
+
import { BootstrapContext } from '@angular/platform-browser';
|
|
2
3
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
4
|
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
|
4
5
|
|
|
5
6
|
interface CommonEngineOptions {
|
|
6
7
|
/** A method that when invoked returns a promise that returns an `ApplicationRef` instance once resolved or an NgModule. */
|
|
7
|
-
bootstrap?: Type<{}> | (() => Promise<ApplicationRef>);
|
|
8
|
+
bootstrap?: Type<{}> | ((context: BootstrapContext) => Promise<ApplicationRef>);
|
|
8
9
|
/** A set of platform level providers for all requests. */
|
|
9
10
|
providers?: StaticProvider[];
|
|
10
11
|
/** Enable request performance profiling data collection and printing the results in the server console. */
|
|
@@ -12,7 +13,7 @@ interface CommonEngineOptions {
|
|
|
12
13
|
}
|
|
13
14
|
interface CommonEngineRenderOptions {
|
|
14
15
|
/** A method that when invoked returns a promise that returns an `ApplicationRef` instance once resolved or an NgModule. */
|
|
15
|
-
bootstrap?: Type<{}> | (() => Promise<ApplicationRef>);
|
|
16
|
+
bootstrap?: Type<{}> | ((context: BootstrapContext) => Promise<ApplicationRef>);
|
|
16
17
|
/** A set of platform level providers for the current request. */
|
|
17
18
|
providers?: StaticProvider[];
|
|
18
19
|
url?: string;
|
|
@@ -117,7 +118,7 @@ type NodeRequestHandlerFunction = (req: IncomingMessage, res: ServerResponse, ne
|
|
|
117
118
|
* } catch (error) {
|
|
118
119
|
* next(error);
|
|
119
120
|
* }
|
|
120
|
-
* })
|
|
121
|
+
* });
|
|
121
122
|
* ```
|
|
122
123
|
*
|
|
123
124
|
* @example
|
|
@@ -127,8 +128,7 @@ type NodeRequestHandlerFunction = (req: IncomingMessage, res: ServerResponse, ne
|
|
|
127
128
|
* export default createNodeRequestHandler(async (req, res) => {
|
|
128
129
|
* await app.ready();
|
|
129
130
|
* app.server.emit('request', req, res);
|
|
130
|
-
*
|
|
131
|
-
* }));
|
|
131
|
+
* });
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
134
|
declare function createNodeRequestHandler<T extends NodeRequestHandlerFunction>(handler: T): T;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Type, EnvironmentProviders, Provider, ApplicationRef } from '@angular/core';
|
|
2
2
|
import { DefaultExport } from '@angular/router';
|
|
3
|
-
import
|
|
3
|
+
import { BootstrapContext } from '@angular/platform-browser';
|
|
4
|
+
import Beasties from '../third_party/beasties';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Identifies a particular kind of `ServerRenderingFeatureKind`.
|
|
@@ -169,19 +170,19 @@ type ServerRoute = ServerRouteClient | ServerRoutePrerender | ServerRoutePrerend
|
|
|
169
170
|
*
|
|
170
171
|
* const serverRoutes: ServerRoute[] = [
|
|
171
172
|
* {
|
|
172
|
-
*
|
|
173
|
+
* path: '', // This renders the "/" route on the client (CSR)
|
|
173
174
|
* renderMode: RenderMode.Client,
|
|
174
175
|
* },
|
|
175
176
|
* {
|
|
176
|
-
*
|
|
177
|
+
* path: 'about', // This page is static, so we prerender it (SSG)
|
|
177
178
|
* renderMode: RenderMode.Prerender,
|
|
178
179
|
* },
|
|
179
180
|
* {
|
|
180
|
-
*
|
|
181
|
+
* path: 'profile', // This page requires user-specific data, so we use SSR
|
|
181
182
|
* renderMode: RenderMode.Server,
|
|
182
183
|
* },
|
|
183
184
|
* {
|
|
184
|
-
*
|
|
185
|
+
* path: '**', // All other routes will be rendered on the server (SSR)
|
|
185
186
|
* renderMode: RenderMode.Server,
|
|
186
187
|
* },
|
|
187
188
|
* ];
|
|
@@ -249,20 +250,23 @@ declare function withAppShell(component: Type<unknown> | (() => Promise<Type<unk
|
|
|
249
250
|
* when using the `bootstrapApplication` function:
|
|
250
251
|
*
|
|
251
252
|
* ```ts
|
|
252
|
-
* import { bootstrapApplication } from '@angular/platform-browser';
|
|
253
|
+
* import { bootstrapApplication, BootstrapContext } from '@angular/platform-browser';
|
|
253
254
|
* import { provideServerRendering, withRoutes, withAppShell } from '@angular/ssr';
|
|
254
255
|
* import { AppComponent } from './app/app.component';
|
|
255
256
|
* import { SERVER_ROUTES } from './app/app.server.routes';
|
|
256
257
|
* import { AppShellComponent } from './app/app-shell.component';
|
|
257
258
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
259
|
+
* const bootstrap = (context: BootstrapContext) =>
|
|
260
|
+
* bootstrapApplication(AppComponent, {
|
|
261
|
+
* providers: [
|
|
262
|
+
* provideServerRendering(
|
|
263
|
+
* withRoutes(SERVER_ROUTES),
|
|
264
|
+
* withAppShell(AppShellComponent),
|
|
265
|
+
* ),
|
|
266
|
+
* ],
|
|
267
|
+
* }, context);
|
|
268
|
+
*
|
|
269
|
+
* export default bootstrap;
|
|
266
270
|
* ```
|
|
267
271
|
* @see {@link withRoutes} configures server-side routing
|
|
268
272
|
* @see {@link withAppShell} configures the application shell
|
|
@@ -435,7 +439,7 @@ declare class RouteTree<AdditionalMetadata extends Record<string, unknown> = {}>
|
|
|
435
439
|
* - A reference to an Angular component or module (`Type<unknown>`) that serves as the root of the application.
|
|
436
440
|
* - A function that returns a `Promise<ApplicationRef>`, which resolves with the root application reference.
|
|
437
441
|
*/
|
|
438
|
-
type AngularBootstrap = Type<unknown> | (() => Promise<ApplicationRef>);
|
|
442
|
+
type AngularBootstrap = Type<unknown> | ((context: BootstrapContext) => Promise<ApplicationRef>);
|
|
439
443
|
|
|
440
444
|
/**
|
|
441
445
|
* Represents a server asset stored in the manifest.
|
|
@@ -782,11 +786,10 @@ declare class AngularServerApp {
|
|
|
782
786
|
*/
|
|
783
787
|
private readonly textDecoder;
|
|
784
788
|
/**
|
|
785
|
-
*
|
|
786
|
-
*
|
|
789
|
+
* A cache that stores critical CSS to avoid re-processing for every request, improving performance.
|
|
790
|
+
* This cache uses a Least Recently Used (LRU) eviction policy.
|
|
787
791
|
*
|
|
788
|
-
*
|
|
789
|
-
* the least recently accessed page's critical CSS will be removed to make space for new entries.
|
|
792
|
+
* @see {@link MAX_INLINE_CSS_CACHE_ENTRIES} for the maximum number of entries this cache can hold.
|
|
790
793
|
*/
|
|
791
794
|
private readonly criticalCssLRUCache;
|
|
792
795
|
/**
|
|
@@ -808,7 +811,6 @@ declare class AngularServerApp {
|
|
|
808
811
|
*
|
|
809
812
|
* @param request - The incoming HTTP request for serving a static page.
|
|
810
813
|
* @param matchedRoute - The metadata of the matched route for rendering.
|
|
811
|
-
* If not provided, the method attempts to find a matching route based on the request URL.
|
|
812
814
|
* @returns A promise that resolves to a `Response` object if the prerendered page is found, or `null`.
|
|
813
815
|
*/
|
|
814
816
|
private handleServe;
|
|
@@ -818,12 +820,28 @@ declare class AngularServerApp {
|
|
|
818
820
|
*
|
|
819
821
|
* @param request - The incoming HTTP request to be processed.
|
|
820
822
|
* @param matchedRoute - The metadata of the matched route for rendering.
|
|
821
|
-
* If not provided, the method attempts to find a matching route based on the request URL.
|
|
822
823
|
* @param requestContext - Optional additional context for rendering, such as request metadata.
|
|
823
824
|
*
|
|
824
825
|
* @returns A promise that resolves to the rendered response, or null if no matching route is found.
|
|
825
826
|
*/
|
|
826
827
|
private handleRendering;
|
|
828
|
+
/**
|
|
829
|
+
* Inlines critical CSS into the given HTML content.
|
|
830
|
+
*
|
|
831
|
+
* @param html The HTML content to process.
|
|
832
|
+
* @param url The URL associated with the request, for logging purposes.
|
|
833
|
+
* @returns A promise that resolves to the HTML with inlined critical CSS.
|
|
834
|
+
*/
|
|
835
|
+
private inlineCriticalCss;
|
|
836
|
+
/**
|
|
837
|
+
* Inlines critical CSS into the given HTML content.
|
|
838
|
+
* This method uses a cache to avoid reprocessing the same HTML content multiple times.
|
|
839
|
+
*
|
|
840
|
+
* @param html The HTML content to process.
|
|
841
|
+
* @param url The URL associated with the request, for logging purposes.
|
|
842
|
+
* @returns A promise that resolves to the HTML with inlined critical CSS.
|
|
843
|
+
*/
|
|
844
|
+
private inlineCriticalCssWithCache;
|
|
827
845
|
/**
|
|
828
846
|
* Constructs the asset path on the server based on the provided HTTP request.
|
|
829
847
|
*
|