@angular/ssr 19.0.0-rc.1 → 19.0.0-rc.3

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/index.d.ts CHANGED
@@ -174,6 +174,10 @@ declare interface AngularRouterConfigResult {
174
174
  * A list of errors encountered during the route extraction process.
175
175
  */
176
176
  errors: string[];
177
+ /**
178
+ * The specified route for the app-shell, if configured.
179
+ */
180
+ appShellRoute?: string;
177
181
  }
178
182
 
179
183
  /**
@@ -459,14 +463,23 @@ export declare enum PrerenderFallback {
459
463
  }
460
464
 
461
465
  /**
462
- * Configures the necessary providers for server routes configuration.
466
+ /**
467
+ * Sets up the necessary providers for configuring server routes.
468
+ * This function accepts an array of server routes and optional configuration
469
+ * options, returning an `EnvironmentProviders` object that encapsulates
470
+ * the server routes and configuration settings.
463
471
  *
464
472
  * @param routes - An array of server routes to be provided.
473
+ * @param options - (Optional) An object containing additional configuration options for server routes.
474
+ * @returns An `EnvironmentProviders` instance with the server routes configuration.
475
+ *
465
476
  * @returns An `EnvironmentProviders` object that contains the server routes configuration.
477
+ *
466
478
  * @see {@link ServerRoute}
479
+ * @see {@link ServerRoutesConfigOptions}
467
480
  * @developerPreview
468
481
  */
469
- export declare function provideServerRoutesConfig(routes: ServerRoute[]): EnvironmentProviders;
482
+ export declare function provideServerRoutesConfig(routes: ServerRoute[], options?: ServerRoutesConfigOptions): EnvironmentProviders;
470
483
 
471
484
  /**
472
485
  * Different rendering modes for server routes.
@@ -475,14 +488,12 @@ export declare function provideServerRoutesConfig(routes: ServerRoute[]): Enviro
475
488
  * @developerPreview
476
489
  */
477
490
  export declare enum RenderMode {
478
- /** AppShell rendering mode, typically used for pre-rendered shells of the application. */
479
- AppShell = 0,
480
491
  /** Server-Side Rendering (SSR) mode, where content is rendered on the server for each request. */
481
- Server = 1,
492
+ Server = 0,
482
493
  /** Client-Side Rendering (CSR) mode, where content is rendered on the client side in the browser. */
483
- Client = 2,
494
+ Client = 1,
484
495
  /** Static Site Generation (SSG) mode, where content is pre-rendered at build time and served as static files. */
485
- Prerender = 3
496
+ Prerender = 2
486
497
  }
487
498
 
488
499
 
@@ -707,17 +718,7 @@ declare interface ServerAsset {
707
718
  * @see {@link provideServerRoutesConfig}
708
719
  * @developerPreview
709
720
  */
710
- export declare type ServerRoute = ServerRouteAppShell | ServerRouteClient | ServerRoutePrerender | ServerRoutePrerenderWithParams | ServerRouteServer;
711
-
712
- /**
713
- * A server route that uses AppShell rendering mode.
714
- * @see {@link RenderMode}
715
- * @developerPreview
716
- */
717
- export declare interface ServerRouteAppShell extends Omit<ServerRouteCommon, 'headers' | 'status'> {
718
- /** Specifies that the route uses AppShell rendering mode. */
719
- renderMode: RenderMode.AppShell;
720
- }
721
+ export declare type ServerRoute = ServerRouteClient | ServerRoutePrerender | ServerRoutePrerenderWithParams | ServerRouteServer;
721
722
 
722
723
  /**
723
724
  * A server route that uses Client-Side Rendering (CSR) mode.
@@ -800,6 +801,26 @@ export declare interface ServerRoutePrerenderWithParams extends Omit<ServerRoute
800
801
  getPrerenderParams: () => Promise<Record<string, string>[]>;
801
802
  }
802
803
 
804
+ /**
805
+ * Configuration options for server routes.
806
+ *
807
+ * This interface defines the optional settings available for configuring server routes
808
+ * in the server-side environment, such as specifying a path to the app shell route.
809
+ *
810
+ * @see {@link provideServerRoutesConfig}
811
+ * @developerPreview
812
+ */
813
+ export declare interface ServerRoutesConfigOptions {
814
+ /**
815
+ * Defines the route to be used as the app shell, which serves as the main entry
816
+ * point for the application. This route is often used to enable server-side rendering
817
+ * of the application shell for requests that do not match any specific server route.
818
+ *
819
+ * @see {@link https://angular.dev/ecosystem/service-workers/app-shell | App shell pattern on Angular.dev}
820
+ */
821
+ appShellRoute?: string;
822
+ }
823
+
803
824
  /**
804
825
  * A server route that uses Server-Side Rendering (SSR) mode.
805
826
  * @see {@link RenderMode}
@@ -836,10 +857,12 @@ export declare function ɵdestroyAngularServerApp(): void;
836
857
  *
837
858
  * @returns A promise that resolves to an object containing:
838
859
  * - `routeTree`: A populated `RouteTree` containing all extracted routes from the Angular application.
860
+ * - `appShellRoute`: The specified route for the app-shell, if configured.
839
861
  * - `errors`: An array of strings representing any errors encountered during the route extraction process.
840
862
  */
841
863
  export declare function ɵextractRoutesAndCreateRouteTree(url: URL, manifest?: AngularAppManifest, invokeGetPrerenderParams?: boolean, includePrerenderFallbackRoutes?: boolean): Promise<{
842
864
  routeTree: RouteTree;
865
+ appShellRoute?: string;
843
866
  errors: string[];
844
867
  }>;
845
868
 
package/node/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { ApplicationRef } from '@angular/core';
2
+ import type { Http2ServerRequest } from 'node:http2';
3
+ import type { Http2ServerResponse } from 'node:http2';
2
4
  import type { IncomingMessage } from 'node:http';
3
5
  import type { ServerResponse } from 'node:http';
4
6
  import { StaticProvider } from '@angular/core';
@@ -20,14 +22,17 @@ export declare class AngularNodeAppEngine {
20
22
  * Handles an incoming HTTP request by serving prerendered content, performing server-side rendering,
21
23
  * or delivering a static file for client-side rendered routes based on the `RenderMode` setting.
22
24
  *
23
- * @param request - The HTTP request to handle.
25
+ * This method adapts Node.js's `IncomingMessage` or `Http2ServerRequest`
26
+ * to a format compatible with the `AngularAppEngine` and delegates the handling logic to it.
27
+ *
28
+ * @param request - The incoming HTTP request (`IncomingMessage` or `Http2ServerRequest`).
24
29
  * @param requestContext - Optional context for rendering, such as metadata associated with the request.
25
30
  * @returns A promise that resolves to the resulting HTTP response object, or `null` if no matching Angular route is found.
26
31
  *
27
32
  * @remarks A request to `https://www.example.com/page/index.html` will serve or render the Angular route
28
33
  * corresponding to `https://www.example.com/page`.
29
34
  */
30
- handle(request: IncomingMessage, requestContext?: unknown): Promise<Response | null>;
35
+ handle(request: IncomingMessage | Http2ServerRequest, requestContext?: unknown): Promise<Response | null>;
31
36
  }
32
37
 
33
38
  /**
@@ -127,13 +132,17 @@ export declare interface CommonEngineRenderOptions {
127
132
  export declare function createNodeRequestHandler<T extends NodeRequestHandlerFunction>(handler: T): T;
128
133
 
129
134
  /**
130
- * Converts a Node.js `IncomingMessage` into a Web Standard `Request`.
135
+ * Converts a Node.js `IncomingMessage` or `Http2ServerRequest` into a
136
+ * Web Standard `Request` object.
137
+ *
138
+ * This function adapts the Node.js request objects to a format that can
139
+ * be used by web platform APIs.
131
140
  *
132
- * @param nodeRequest - The Node.js `IncomingMessage` object to convert.
141
+ * @param nodeRequest - The Node.js request object (`IncomingMessage` or `Http2ServerRequest`) to convert.
133
142
  * @returns A Web Standard `Request` object.
134
143
  * @developerPreview
135
144
  */
136
- export declare function createWebRequestFromNodeRequest(nodeRequest: IncomingMessage): Request;
145
+ export declare function createWebRequestFromNodeRequest(nodeRequest: IncomingMessage | Http2ServerRequest): Request;
137
146
 
138
147
 
139
148
  /**
@@ -167,13 +176,17 @@ export declare function isMainModule(url: string): boolean;
167
176
  export declare type NodeRequestHandlerFunction = (req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => Promise<void> | void;
168
177
 
169
178
  /**
170
- * Streams a web-standard `Response` into a Node.js `ServerResponse`.
179
+ * Streams a web-standard `Response` into a Node.js `ServerResponse`
180
+ * or `Http2ServerResponse`.
181
+ *
182
+ * This function adapts the web `Response` object to write its content
183
+ * to a Node.js response object, handling both HTTP/1.1 and HTTP/2.
171
184
  *
172
185
  * @param source - The web-standard `Response` object to stream from.
173
- * @param destination - The Node.js `ServerResponse` object to stream into.
186
+ * @param destination - The Node.js response object (`ServerResponse` or `Http2ServerResponse`) to stream into.
174
187
  * @returns A promise that resolves once the streaming operation is complete.
175
188
  * @developerPreview
176
189
  */
177
- export declare function writeResponseToNodeResponse(source: Response, destination: ServerResponse): Promise<void>;
190
+ export declare function writeResponseToNodeResponse(source: Response, destination: ServerResponse | Http2ServerResponse<Http2ServerRequest>): Promise<void>;
178
191
 
179
192
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/ssr",
3
- "version": "19.0.0-rc.1",
3
+ "version": "19.0.0-rc.3",
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-rc.0",
26
- "@angular/compiler": "19.0.0-rc.0",
27
- "@angular/core": "19.0.0-rc.0",
28
- "@angular/platform-browser": "19.0.0-rc.0",
29
- "@angular/platform-server": "19.0.0-rc.0",
30
- "@angular/router": "19.0.0-rc.0",
25
+ "@angular/common": "19.0.0-rc.3",
26
+ "@angular/compiler": "19.0.0-rc.3",
27
+ "@angular/core": "19.0.0-rc.3",
28
+ "@angular/platform-browser": "19.0.0-rc.3",
29
+ "@angular/platform-server": "19.0.0-rc.3",
30
+ "@angular/router": "19.0.0-rc.3",
31
31
  "@bazel/runfiles": "^5.8.1"
32
32
  },
33
33
  "sideEffects": false,
@@ -50,10 +50,6 @@
50
50
  "./node": {
51
51
  "types": "./node/index.d.ts",
52
52
  "default": "./fesm2022/node.mjs"
53
- },
54
- "./tokens": {
55
- "types": "./tokens/index.d.ts",
56
- "default": "./fesm2022/tokens.mjs"
57
53
  }
58
54
  }
59
55
  }
@@ -1021,6 +1021,36 @@ function requireNode$1 () {
1021
1021
  return cloned
1022
1022
  }
1023
1023
 
1024
+ function sourceOffset(inputCSS, position) {
1025
+ // Not all custom syntaxes support `offset` in `source.start` and `source.end`
1026
+ if (
1027
+ position &&
1028
+ typeof position.offset !== 'undefined'
1029
+ ) {
1030
+ return position.offset;
1031
+ }
1032
+
1033
+ let column = 1;
1034
+ let line = 1;
1035
+ let offset = 0;
1036
+
1037
+ for (let i = 0; i < inputCSS.length; i++) {
1038
+ if (line === position.line && column === position.column) {
1039
+ offset = i;
1040
+ break
1041
+ }
1042
+
1043
+ if (inputCSS[i] === '\n') {
1044
+ column = 1;
1045
+ line += 1;
1046
+ } else {
1047
+ column += 1;
1048
+ }
1049
+ }
1050
+
1051
+ return offset
1052
+ }
1053
+
1024
1054
  class Node {
1025
1055
  constructor(defaults = {}) {
1026
1056
  this.raws = {};
@@ -1163,25 +1193,29 @@ function requireNode$1 () {
1163
1193
  return this.parent.nodes[index + 1]
1164
1194
  }
1165
1195
 
1166
- positionBy(opts, stringRepresentation) {
1196
+ positionBy(opts) {
1167
1197
  let pos = this.source.start;
1168
1198
  if (opts.index) {
1169
- pos = this.positionInside(opts.index, stringRepresentation);
1199
+ pos = this.positionInside(opts.index);
1170
1200
  } else if (opts.word) {
1171
- stringRepresentation = this.toString();
1201
+ let stringRepresentation = this.source.input.css.slice(
1202
+ sourceOffset(this.source.input.css, this.source.start),
1203
+ sourceOffset(this.source.input.css, this.source.end)
1204
+ );
1172
1205
  let index = stringRepresentation.indexOf(opts.word);
1173
- if (index !== -1) pos = this.positionInside(index, stringRepresentation);
1206
+ if (index !== -1) pos = this.positionInside(index);
1174
1207
  }
1175
1208
  return pos
1176
1209
  }
1177
1210
 
1178
- positionInside(index, stringRepresentation) {
1179
- let string = stringRepresentation || this.toString();
1211
+ positionInside(index) {
1180
1212
  let column = this.source.start.column;
1181
1213
  let line = this.source.start.line;
1214
+ let offset = sourceOffset(this.source.input.css, this.source.start);
1215
+ let end = offset + index;
1182
1216
 
1183
- for (let i = 0; i < index; i++) {
1184
- if (string[i] === '\n') {
1217
+ for (let i = offset; i < end; i++) {
1218
+ if (this.source.input.css[i] === '\n') {
1185
1219
  column = 1;
1186
1220
  line += 1;
1187
1221
  } else {
@@ -1214,13 +1248,15 @@ function requireNode$1 () {
1214
1248
  };
1215
1249
 
1216
1250
  if (opts.word) {
1217
- let stringRepresentation = this.toString();
1251
+ let stringRepresentation = this.source.input.css.slice(
1252
+ sourceOffset(this.source.input.css, this.source.start),
1253
+ sourceOffset(this.source.input.css, this.source.end)
1254
+ );
1218
1255
  let index = stringRepresentation.indexOf(opts.word);
1219
1256
  if (index !== -1) {
1220
- start = this.positionInside(index, stringRepresentation);
1257
+ start = this.positionInside(index);
1221
1258
  end = this.positionInside(
1222
1259
  index + opts.word.length,
1223
- stringRepresentation
1224
1260
  );
1225
1261
  }
1226
1262
  } else {
@@ -4783,7 +4819,7 @@ function requireProcessor () {
4783
4819
 
4784
4820
  class Processor {
4785
4821
  constructor(plugins = []) {
4786
- this.version = '8.4.47';
4822
+ this.version = '8.4.49';
4787
4823
  this.plugins = this.normalize(plugins);
4788
4824
  }
4789
4825