@angular/ssr 19.0.0-next.7 → 19.0.0-next.9
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/LICENSE +21 -0
- package/fesm2022/node.mjs +50 -1
- package/fesm2022/node.mjs.map +1 -1
- package/fesm2022/ssr.mjs +299 -45
- package/fesm2022/ssr.mjs.map +1 -1
- package/index.d.ts +125 -17
- package/node/index.d.ts +57 -0
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ApplicationRef } from '@angular/core';
|
|
2
2
|
import { default as default_2 } from 'critters';
|
|
3
3
|
import { EnvironmentProviders } from '@angular/core';
|
|
4
|
+
import { InjectionToken } from '@angular/core';
|
|
4
5
|
import type { Type } from '@angular/core';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -26,6 +27,10 @@ export declare class AngularAppEngine {
|
|
|
26
27
|
* The manifest for the server application.
|
|
27
28
|
*/
|
|
28
29
|
private readonly manifest;
|
|
30
|
+
/**
|
|
31
|
+
* A cache that holds entry points, keyed by their potential locale string.
|
|
32
|
+
*/
|
|
33
|
+
private readonly entryPointsCache;
|
|
29
34
|
/**
|
|
30
35
|
* Renders a response for the given HTTP request using the server application.
|
|
31
36
|
*
|
|
@@ -42,18 +47,6 @@ export declare class AngularAppEngine {
|
|
|
42
47
|
* rather than an application route.
|
|
43
48
|
*/
|
|
44
49
|
render(request: Request, requestContext?: unknown): Promise<Response | null>;
|
|
45
|
-
/**
|
|
46
|
-
* Retrieves the entry point path and locale for the Angular server application based on the provided URL.
|
|
47
|
-
*
|
|
48
|
-
* This method determines the appropriate entry point and locale for rendering the application by examining the URL.
|
|
49
|
-
* If there is only one entry point available, it is returned regardless of the URL.
|
|
50
|
-
* Otherwise, the method extracts a potential locale identifier from the URL and looks up the corresponding entry point.
|
|
51
|
-
*
|
|
52
|
-
* @param url - The URL used to derive the locale and determine the appropriate entry point.
|
|
53
|
-
* @returns A function that returns a promise resolving to an object with the `EntryPointExports` type,
|
|
54
|
-
* or `undefined` if no matching entry point is found for the extracted locale.
|
|
55
|
-
*/
|
|
56
|
-
private getEntryPointFromUrl;
|
|
57
50
|
/**
|
|
58
51
|
* Retrieves HTTP headers for a request associated with statically generated (SSG) pages,
|
|
59
52
|
* based on the URL pathname.
|
|
@@ -63,6 +56,25 @@ export declare class AngularAppEngine {
|
|
|
63
56
|
* @note This function should be used exclusively for retrieving headers of SSG pages.
|
|
64
57
|
*/
|
|
65
58
|
getPrerenderHeaders(request: Request): ReadonlyMap<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves the exports for a specific entry point, caching the result.
|
|
61
|
+
*
|
|
62
|
+
* @param potentialLocale - The locale string used to find the corresponding entry point.
|
|
63
|
+
* @returns A promise that resolves to the entry point exports or `undefined` if not found.
|
|
64
|
+
*/
|
|
65
|
+
private getEntryPointExports;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the entry point for a given URL by determining the locale and mapping it to
|
|
68
|
+
* the appropriate application bundle.
|
|
69
|
+
*
|
|
70
|
+
* This method determines the appropriate entry point and locale for rendering the application by examining the URL.
|
|
71
|
+
* If there is only one entry point available, it is returned regardless of the URL.
|
|
72
|
+
* Otherwise, the method extracts a potential locale identifier from the URL and looks up the corresponding entry point.
|
|
73
|
+
*
|
|
74
|
+
* @param url - The URL of the request.
|
|
75
|
+
* @returns A promise that resolves to the entry point exports or `undefined` if not found.
|
|
76
|
+
*/
|
|
77
|
+
private getEntryPointExportsForUrl;
|
|
66
78
|
}
|
|
67
79
|
|
|
68
80
|
/**
|
|
@@ -120,6 +132,11 @@ declare interface AngularAppManifest {
|
|
|
120
132
|
* It is used for route matching and navigation within the server application.
|
|
121
133
|
*/
|
|
122
134
|
readonly routes?: SerializableRouteTreeNode;
|
|
135
|
+
/**
|
|
136
|
+
* An optional string representing the locale or language code to be used for
|
|
137
|
+
* the application, aiding with localization and rendering content specific to the locale.
|
|
138
|
+
*/
|
|
139
|
+
readonly locale?: string;
|
|
123
140
|
}
|
|
124
141
|
|
|
125
142
|
/**
|
|
@@ -192,6 +209,14 @@ declare class AngularServerApp {
|
|
|
192
209
|
* The bootstrap mechanism for the server application.
|
|
193
210
|
*/
|
|
194
211
|
private boostrap;
|
|
212
|
+
/**
|
|
213
|
+
* Cache for storing critical CSS for pages.
|
|
214
|
+
* Stores a maximum of MAX_INLINE_CSS_CACHE_ENTRIES entries.
|
|
215
|
+
*
|
|
216
|
+
* Uses an LRU (Least Recently Used) eviction policy, meaning that when the cache is full,
|
|
217
|
+
* the least recently accessed page's critical CSS will be removed to make space for new entries.
|
|
218
|
+
*/
|
|
219
|
+
private readonly criticalCssLRUCache;
|
|
195
220
|
/**
|
|
196
221
|
* Renders a response for the given HTTP request using the server application.
|
|
197
222
|
*
|
|
@@ -233,6 +258,31 @@ declare class AngularServerApp {
|
|
|
233
258
|
private handleRendering;
|
|
234
259
|
}
|
|
235
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Annotates a request handler function with metadata, marking it as a special
|
|
263
|
+
* handler.
|
|
264
|
+
*
|
|
265
|
+
* @param handler - The request handler function to be annotated.
|
|
266
|
+
* @returns The same handler function passed in, with metadata attached.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* Example usage in a Hono application:
|
|
270
|
+
* ```ts
|
|
271
|
+
* const app = new Hono();
|
|
272
|
+
* export default createRequestHandler(app.fetch);
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* Example usage in a H3 application:
|
|
277
|
+
* ```ts
|
|
278
|
+
* const app = createApp();
|
|
279
|
+
* const handler = toWebHandler(app);
|
|
280
|
+
* export default createRequestHandler(handler);
|
|
281
|
+
* ```
|
|
282
|
+
* @developerPreview
|
|
283
|
+
*/
|
|
284
|
+
export declare function createRequestHandler(handler: RequestHandlerFunction): RequestHandlerFunction;
|
|
285
|
+
|
|
236
286
|
declare interface CrittersBase {
|
|
237
287
|
embedLinkedStylesheet(link: PartialHTMLElement, document: PartialDocument): Promise<unknown>;
|
|
238
288
|
}
|
|
@@ -310,13 +360,14 @@ declare interface HooksMapping {
|
|
|
310
360
|
|
|
311
361
|
|
|
312
362
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
363
|
+
* Defines a handler function type for transforming HTML content.
|
|
364
|
+
* This function receives an object with the HTML to be processed.
|
|
315
365
|
*
|
|
316
|
-
* @param ctx -
|
|
317
|
-
* @returns The
|
|
366
|
+
* @param ctx - An object containing the URL and HTML content to be transformed.
|
|
367
|
+
* @returns The transformed HTML as a string or a promise that resolves to the transformed HTML.
|
|
318
368
|
*/
|
|
319
369
|
declare type HtmlTransformHandler = (ctx: {
|
|
370
|
+
url: URL;
|
|
320
371
|
html: string;
|
|
321
372
|
}) => string | Promise<string>;
|
|
322
373
|
|
|
@@ -392,6 +443,34 @@ export declare enum RenderMode {
|
|
|
392
443
|
Prerender = 3
|
|
393
444
|
}
|
|
394
445
|
|
|
446
|
+
/**
|
|
447
|
+
* Injection token for the current request.
|
|
448
|
+
* @developerPreview
|
|
449
|
+
*/
|
|
450
|
+
export declare const REQUEST: InjectionToken<Request>;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Injection token for additional request context.
|
|
454
|
+
* @developerPreview
|
|
455
|
+
*/
|
|
456
|
+
export declare const REQUEST_CONTEXT: InjectionToken<unknown>;
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Function for handling HTTP requests in a web environment.
|
|
461
|
+
*
|
|
462
|
+
* @param request - The incoming HTTP request object.
|
|
463
|
+
* @returns A Promise resolving to a `Response` object, `null`, or directly a `Response`,
|
|
464
|
+
* supporting both synchronous and asynchronous handling.
|
|
465
|
+
*/
|
|
466
|
+
declare type RequestHandlerFunction = (request: Request) => Promise<Response | null> | null | Response;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Injection token for the response initialization options.
|
|
470
|
+
* @developerPreview
|
|
471
|
+
*/
|
|
472
|
+
export declare const RESPONSE_INIT: InjectionToken<ResponseInit>;
|
|
473
|
+
|
|
395
474
|
/**
|
|
396
475
|
* A route tree implementation that supports efficient route matching, including support for wildcard routes.
|
|
397
476
|
* This structure is useful for organizing and retrieving routes in a hierarchical manner,
|
|
@@ -455,7 +534,7 @@ declare class RouteTree<AdditionalMetadata extends Record<string, unknown> = {}>
|
|
|
455
534
|
*
|
|
456
535
|
* @param node - The current node to start the traversal from. Defaults to the root node of the tree.
|
|
457
536
|
*/
|
|
458
|
-
|
|
537
|
+
traverse(node?: RouteTreeNode<AdditionalMetadata>): Generator<RouteTreeNodeMetadata & AdditionalMetadata>;
|
|
459
538
|
/**
|
|
460
539
|
* Extracts the path segments from a given route string.
|
|
461
540
|
*
|
|
@@ -495,6 +574,35 @@ declare class RouteTree<AdditionalMetadata extends Record<string, unknown> = {}>
|
|
|
495
574
|
private createEmptyRouteTreeNode;
|
|
496
575
|
}
|
|
497
576
|
|
|
577
|
+
/**
|
|
578
|
+
* Represents a node within the route tree structure.
|
|
579
|
+
* Each node corresponds to a route segment and may have associated metadata and child nodes.
|
|
580
|
+
* The `AdditionalMetadata` type parameter allows for extending the node metadata with custom data.
|
|
581
|
+
*/
|
|
582
|
+
declare interface RouteTreeNode<AdditionalMetadata extends Record<string, unknown>> {
|
|
583
|
+
/**
|
|
584
|
+
* The segment value associated with this node.
|
|
585
|
+
* A segment is a single part of a route path, typically delimited by slashes (`/`).
|
|
586
|
+
* For example, in the route `/users/:id/profile`, the segments are `users`, `:id`, and `profile`.
|
|
587
|
+
* Segments can also be wildcards (`*`), which match any segment in that position of the route.
|
|
588
|
+
*/
|
|
589
|
+
segment: string;
|
|
590
|
+
/**
|
|
591
|
+
* The index indicating the order in which the route was inserted into the tree.
|
|
592
|
+
* This index helps determine the priority of routes during matching, with lower indexes
|
|
593
|
+
* indicating earlier inserted routes.
|
|
594
|
+
*/
|
|
595
|
+
insertionIndex: number;
|
|
596
|
+
/**
|
|
597
|
+
* A map of child nodes, keyed by their corresponding route segment or wildcard.
|
|
598
|
+
*/
|
|
599
|
+
children: Map<string, RouteTreeNode<AdditionalMetadata>>;
|
|
600
|
+
/**
|
|
601
|
+
* Optional metadata associated with this node, providing additional information such as redirects.
|
|
602
|
+
*/
|
|
603
|
+
metadata?: RouteTreeNodeMetadata & AdditionalMetadata;
|
|
604
|
+
}
|
|
605
|
+
|
|
498
606
|
/**
|
|
499
607
|
* Describes metadata associated with a node in the route tree.
|
|
500
608
|
* This metadata includes information such as the route path and optional redirect instructions.
|
package/node/index.d.ts
CHANGED
|
@@ -109,6 +109,52 @@ export declare interface CommonEngineRenderOptions {
|
|
|
109
109
|
publicPath?: string;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Attaches metadata to the handler function to mark it as a special handler for Node.js environments.
|
|
114
|
+
*
|
|
115
|
+
* @typeParam T - The type of the handler function.
|
|
116
|
+
* @param handler - The handler function to be defined and annotated.
|
|
117
|
+
* @returns The same handler function passed as an argument, with metadata attached.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* Usage in an Express application:
|
|
121
|
+
* ```ts
|
|
122
|
+
* const app = express();
|
|
123
|
+
* export default createNodeRequestHandler(app);
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* Usage in a Hono application:
|
|
128
|
+
* ```ts
|
|
129
|
+
* const app = new Hono();
|
|
130
|
+
* export default createNodeRequestHandler(async (req, res, next) => {
|
|
131
|
+
* try {
|
|
132
|
+
* const webRes = await app.fetch(createWebRequestFromNodeRequest(req));
|
|
133
|
+
* if (webRes) {
|
|
134
|
+
* await writeResponseToNodeResponse(webRes, res);
|
|
135
|
+
* } else {
|
|
136
|
+
* next();
|
|
137
|
+
* }
|
|
138
|
+
* } catch (error) {
|
|
139
|
+
* next(error);
|
|
140
|
+
* }
|
|
141
|
+
* }));
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* Usage in a Fastify application:
|
|
146
|
+
* ```ts
|
|
147
|
+
* const app = Fastify();
|
|
148
|
+
* export default createNodeRequestHandler(async (req, res) => {
|
|
149
|
+
* await app.ready();
|
|
150
|
+
* app.server.emit('request', req, res);
|
|
151
|
+
* res.send('Hello from Fastify with Node Next Handler!');
|
|
152
|
+
* }));
|
|
153
|
+
* ```
|
|
154
|
+
* @developerPreview
|
|
155
|
+
*/
|
|
156
|
+
export declare function createNodeRequestHandler<T extends RequestHandlerFunction>(handler: T): T;
|
|
157
|
+
|
|
112
158
|
/**
|
|
113
159
|
* Converts a Node.js `IncomingMessage` into a Web Standard `Request`.
|
|
114
160
|
*
|
|
@@ -137,6 +183,17 @@ export declare function createWebRequestFromNodeRequest(nodeRequest: IncomingMes
|
|
|
137
183
|
*/
|
|
138
184
|
export declare function isMainModule(url: string): boolean;
|
|
139
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Represents a middleware function for handling HTTP requests in a Node.js environment.
|
|
188
|
+
*
|
|
189
|
+
* @param req - The incoming HTTP request object.
|
|
190
|
+
* @param res - The outgoing HTTP response object.
|
|
191
|
+
* @param next - A callback function that signals the completion of the middleware or forwards the error if provided.
|
|
192
|
+
*
|
|
193
|
+
* @returns A Promise that resolves to void or simply void. The handler can be asynchronous.
|
|
194
|
+
*/
|
|
195
|
+
declare type RequestHandlerFunction = (req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => Promise<void> | void;
|
|
196
|
+
|
|
140
197
|
/**
|
|
141
198
|
* Streams a web-standard `Response` into a Node.js `ServerResponse`.
|
|
142
199
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/ssr",
|
|
3
|
-
"version": "19.0.0-next.
|
|
3
|
+
"version": "19.0.0-next.9",
|
|
4
4
|
"description": "Angular server side rendering utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/angular/angular-cli",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"@angular/router": "^19.0.0-next.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@angular/common": "19.0.0-next.
|
|
26
|
-
"@angular/compiler": "19.0.0-next.
|
|
27
|
-
"@angular/core": "19.0.0-next.
|
|
28
|
-
"@angular/platform-browser": "19.0.0-next.
|
|
29
|
-
"@angular/platform-server": "19.0.0-next.
|
|
30
|
-
"@angular/router": "19.0.0-next.
|
|
25
|
+
"@angular/common": "19.0.0-next.7",
|
|
26
|
+
"@angular/compiler": "19.0.0-next.7",
|
|
27
|
+
"@angular/core": "19.0.0-next.7",
|
|
28
|
+
"@angular/platform-browser": "19.0.0-next.7",
|
|
29
|
+
"@angular/platform-server": "19.0.0-next.7",
|
|
30
|
+
"@angular/router": "19.0.0-next.7",
|
|
31
31
|
"@bazel/runfiles": "^5.8.1"
|
|
32
32
|
},
|
|
33
33
|
"schematics": "./schematics/collection.json",
|