@angular/ssr 20.0.0-next.1 → 20.0.0-next.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
@@ -1,4 +1,4 @@
1
- import type { ApplicationRef } from '@angular/core';
1
+ import { ApplicationRef } from '@angular/core';
2
2
  import { default as default_2 } from 'beasties';
3
3
  import { DefaultExport } from '@angular/router';
4
4
  import { EnvironmentProviders } from '@angular/core';
@@ -12,8 +12,6 @@ import { Type } from '@angular/core';
12
12
  *
13
13
  * @remarks This class should be instantiated once and used as a singleton across the server-side
14
14
  * application to ensure consistent handling of rendering requests and resource management.
15
- *
16
- * @developerPreview
17
15
  */
18
16
  export declare class AngularAppEngine {
19
17
  /**
@@ -392,7 +390,6 @@ declare class BeastiesBase extends default_2 {
392
390
  * const handler = toWebHandler(app);
393
391
  * export default createRequestHandler(handler);
394
392
  * ```
395
- * @developerPreview
396
393
  */
397
394
  export declare function createRequestHandler(handler: RequestHandlerFunction): RequestHandlerFunction;
398
395
 
@@ -507,7 +504,6 @@ declare interface PartialHTMLElement {
507
504
  * Defines the fallback strategies for Static Site Generation (SSG) routes when a pre-rendered path is not available.
508
505
  * This is particularly relevant for routes with parameterized URLs where some paths might not be pre-rendered at build time.
509
506
  * @see {@link ServerRoutePrerenderWithParams}
510
- * @developerPreview
511
507
  */
512
508
  export declare enum PrerenderFallback {
513
509
  /**
@@ -528,26 +524,44 @@ export declare enum PrerenderFallback {
528
524
  }
529
525
 
530
526
  /**
531
- * Sets up the necessary providers for configuring server routes.
532
- * This function accepts an array of server routes and optional configuration
533
- * options, returning an `EnvironmentProviders` object that encapsulates
534
- * the server routes and configuration settings.
527
+ * Configures server-side rendering for an Angular application.
535
528
  *
536
- * @param routes - An array of server routes to be provided.
537
- * @param features - (Optional) server routes features.
538
- * @returns An `EnvironmentProviders` instance with the server routes configuration.
529
+ * This function sets up the necessary providers for server-side rendering, including
530
+ * support for server routes and app shell. It combines features configured using
531
+ * `withRoutes` and `withAppShell` to provide a comprehensive server-side rendering setup.
539
532
  *
540
- * @see {@link ServerRoute}
541
- * @see {@link withAppShell}
542
- * @developerPreview
533
+ * @param features - Optional features to configure additional server rendering behaviors.
534
+ * @returns An `EnvironmentProviders` instance with the server-side rendering configuration.
535
+ *
536
+ * @example
537
+ * Basic example of how you can enable server-side rendering in your application
538
+ * when using the `bootstrapApplication` function:
539
+ *
540
+ * ```ts
541
+ * import { bootstrapApplication } from '@angular/platform-browser';
542
+ * import { provideServerRendering, withRoutes, withAppShell } from '@angular/ssr';
543
+ * import { AppComponent } from './app/app.component';
544
+ * import { SERVER_ROUTES } from './app/app.server.routes';
545
+ * import { AppShellComponent } from './app/app-shell.component';
546
+ *
547
+ * bootstrapApplication(AppComponent, {
548
+ * providers: [
549
+ * provideServerRendering(
550
+ * withRoutes(SERVER_ROUTES),
551
+ * withAppShell(AppShellComponent)
552
+ * )
553
+ * ]
554
+ * });
555
+ * ```
556
+ * @see {@link withRoutes} configures server-side routing
557
+ * @see {@link withAppShell} configures the application shell
543
558
  */
544
- export declare function provideServerRouting(routes: ServerRoute[], ...features: ServerRoutesFeature<ServerRoutesFeatureKind>[]): EnvironmentProviders;
559
+ export declare function provideServerRendering(...features: ServerRenderingFeature<ServerRenderingFeatureKind>[]): EnvironmentProviders;
545
560
 
546
561
  /**
547
562
  * Different rendering modes for server routes.
548
- * @see {@link provideServerRouting}
563
+ * @see {@link withRoutes}
549
564
  * @see {@link ServerRoute}
550
- * @developerPreview
551
565
  */
552
566
  export declare enum RenderMode {
553
567
  /** Server-Side Rendering (SSR) mode, where content is rendered on the server for each request. */
@@ -565,7 +579,6 @@ export declare enum RenderMode {
565
579
  * @param request - The incoming HTTP request object.
566
580
  * @returns A Promise resolving to a `Response` object, `null`, or directly a `Response`,
567
581
  * supporting both synchronous and asynchronous handling.
568
- * @developerPreview
569
582
  */
570
583
  export declare type RequestHandlerFunction = (request: Request) => Promise<Response | null> | null | Response;
571
584
 
@@ -752,17 +765,33 @@ declare interface ServerAsset {
752
765
  size: number;
753
766
  }
754
767
 
768
+ /**
769
+ * Helper type to represent a server routes feature.
770
+ * @see {@link ServerRenderingFeatureKind}
771
+ */
772
+ declare interface ServerRenderingFeature<FeatureKind extends ServerRenderingFeatureKind> {
773
+ ɵkind: FeatureKind;
774
+ ɵproviders: (Provider | EnvironmentProviders)[];
775
+ }
776
+
777
+ /**
778
+ * Identifies a particular kind of `ServerRenderingFeatureKind`.
779
+ * @see {@link ServerRenderingFeature}
780
+ */
781
+ declare enum ServerRenderingFeatureKind {
782
+ AppShell = 0,
783
+ ServerRoutes = 1
784
+ }
785
+
755
786
  /**
756
787
  * Server route configuration.
757
- * @see {@link provideServerRouting}
758
- * @developerPreview
788
+ * @see {@link withRoutes}
759
789
  */
760
790
  export declare type ServerRoute = ServerRouteClient | ServerRoutePrerender | ServerRoutePrerenderWithParams | ServerRouteServer;
761
791
 
762
792
  /**
763
793
  * A server route that uses Client-Side Rendering (CSR) mode.
764
794
  * @see {@link RenderMode}
765
- * @developerPreview
766
795
  */
767
796
  export declare interface ServerRouteClient extends ServerRouteCommon {
768
797
  /** Specifies that the route uses Client-Side Rendering (CSR) mode. */
@@ -771,7 +800,6 @@ export declare interface ServerRouteClient extends ServerRouteCommon {
771
800
 
772
801
  /**
773
802
  * Common interface for server routes, providing shared properties.
774
- * @developerPreview
775
803
  */
776
804
  export declare interface ServerRouteCommon {
777
805
  /** The path associated with this route. */
@@ -785,7 +813,6 @@ export declare interface ServerRouteCommon {
785
813
  /**
786
814
  * A server route that uses Static Site Generation (SSG) mode.
787
815
  * @see {@link RenderMode}
788
- * @developerPreview
789
816
  */
790
817
  export declare interface ServerRoutePrerender extends Omit<ServerRouteCommon, 'status'> {
791
818
  /** Specifies that the route uses Static Site Generation (SSG) mode. */
@@ -799,7 +826,6 @@ export declare interface ServerRoutePrerender extends Omit<ServerRouteCommon, 's
799
826
  * @see {@link RenderMode}
800
827
  * @see {@link ServerRoutePrerender}
801
828
  * @see {@link PrerenderFallback}
802
- * @developerPreview
803
829
  */
804
830
  export declare interface ServerRoutePrerenderWithParams extends Omit<ServerRoutePrerender, 'fallback'> {
805
831
  /**
@@ -843,7 +869,6 @@ export declare interface ServerRoutePrerenderWithParams extends Omit<ServerRoute
843
869
  /**
844
870
  * A server route that uses Server-Side Rendering (SSR) mode.
845
871
  * @see {@link RenderMode}
846
- * @developerPreview
847
872
  */
848
873
  export declare interface ServerRouteServer extends ServerRouteCommon {
849
874
  /** Specifies that the route uses Server-Side Rendering (SSR) mode. */
@@ -851,42 +876,87 @@ export declare interface ServerRouteServer extends ServerRouteCommon {
851
876
  }
852
877
 
853
878
  /**
854
- * Helper type to represent a server routes feature.
855
- * @see {@link ServerRoutesFeatureKind}
856
- * @developerPreview
857
- */
858
- declare interface ServerRoutesFeature<FeatureKind extends ServerRoutesFeatureKind> {
859
- ɵkind: FeatureKind;
860
- ɵproviders: Provider[];
861
- }
862
-
863
- /**
864
- * Identifies a particular kind of `ServerRoutesFeatureKind`.
865
- * @see {@link ServerRoutesFeature}
866
- * @developerPreview
879
+ * Configures the shell of the application.
880
+ *
881
+ * The app shell is a minimal, static HTML page that is served immediately, while the
882
+ * full Angular application loads in the background. This improves perceived performance
883
+ * by providing instant feedback to the user.
884
+ *
885
+ * This function configures the app shell route, which serves the provided component for
886
+ * requests that do not match any defined server routes.
887
+ *
888
+ * @param component - The Angular component to render for the app shell. Can be a direct
889
+ * component type or a dynamic import function.
890
+ * @returns A `ServerRenderingFeature` object configuring the app shell.
891
+ *
892
+ * @example
893
+ * ```ts
894
+ * import { provideServerRendering, withAppShell, withRoutes } from '@angular/ssr';
895
+ * import { AppShellComponent } from './app-shell.component';
896
+ *
897
+ * provideServerRendering(
898
+ * withRoutes(serverRoutes),
899
+ * withAppShell(AppShellComponent)
900
+ * );
901
+ * ```
902
+ *
903
+ * @example
904
+ * ```ts
905
+ * import { provideServerRendering, withAppShell, withRoutes } from '@angular/ssr';
906
+ *
907
+ * provideServerRendering(
908
+ * withRoutes(serverRoutes),
909
+ * withAppShell(() =>
910
+ * import('./app-shell.component').then((m) => m.AppShellComponent)
911
+ * )
912
+ * );
913
+ * ```
914
+ *
915
+ * @see {@link provideServerRendering}
916
+ * @see {@link https://angular.dev/ecosystem/service-workers/app-shell App shell pattern on Angular.dev}
867
917
  */
868
- declare enum ServerRoutesFeatureKind {
869
- AppShell = 0
870
- }
918
+ export declare function withAppShell(component: Type<unknown> | (() => Promise<Type<unknown> | DefaultExport<Type<unknown>>>)): ServerRenderingFeature<ServerRenderingFeatureKind.AppShell>;
871
919
 
872
920
  /**
873
- * Configures the app shell route with the provided component.
921
+ * Configures server-side routing for the application.
874
922
  *
875
- * The app shell serves as the main entry point for the application and is commonly used
876
- * to enable server-side rendering (SSR) of the application shell. It handles requests
877
- * that do not match any specific server route, providing a fallback mechanism and improving
878
- * perceived performance during navigation.
923
+ * This function registers an array of `ServerRoute` definitions, enabling server-side rendering
924
+ * for specific URL paths. These routes are used to pre-render content on the server, improving
925
+ * initial load performance and SEO.
879
926
  *
880
- * This configuration is particularly useful in applications leveraging Progressive Web App (PWA)
881
- * patterns, such as service workers, to deliver a seamless user experience.
927
+ * @param routes - An array of `ServerRoute` objects, each defining a server-rendered route.
928
+ * @returns A `ServerRenderingFeature` object configuring server-side routes.
882
929
  *
883
- * @param component The Angular component to render for the app shell route.
884
- * @returns A server routes feature configuration for the app shell.
930
+ * @example
931
+ * ```ts
932
+ * import { provideServerRendering, withRoutes, ServerRoute, RenderMode } from '@angular/ssr';
933
+ *
934
+ * const serverRoutes: ServerRoute[] = [
935
+ * {
936
+ * route: '', // This renders the "/" route on the client (CSR)
937
+ * renderMode: RenderMode.Client,
938
+ * },
939
+ * {
940
+ * route: 'about', // This page is static, so we prerender it (SSG)
941
+ * renderMode: RenderMode.Prerender,
942
+ * },
943
+ * {
944
+ * route: 'profile', // This page requires user-specific data, so we use SSR
945
+ * renderMode: RenderMode.Server,
946
+ * },
947
+ * {
948
+ * route: '**', // All other routes will be rendered on the server (SSR)
949
+ * renderMode: RenderMode.Server,
950
+ * },
951
+ * ];
885
952
  *
886
- * @see {@link provideServerRouting}
887
- * @see {@link https://angular.dev/ecosystem/service-workers/app-shell | App shell pattern on Angular.dev}
953
+ * provideServerRendering(withRoutes(serverRoutes));
954
+ * ```
955
+ *
956
+ * @see {@link provideServerRendering}
957
+ * @see {@link ServerRoute}
888
958
  */
889
- export declare function withAppShell(component: Type<unknown> | (() => Promise<Type<unknown> | DefaultExport<Type<unknown>>>)): ServerRoutesFeature<ServerRoutesFeatureKind.AppShell>;
959
+ export declare function withRoutes(routes: ServerRoute[]): ServerRenderingFeature<ServerRenderingFeatureKind.ServerRoutes>;
890
960
 
891
961
  /**
892
962
  * Destroys the existing `AngularServerApp` instance, releasing associated resources and resetting the
package/node/index.d.ts CHANGED
@@ -13,8 +13,6 @@ import { Type } from '@angular/core';
13
13
  *
14
14
  * @remarks This class should be instantiated once and used as a singleton across the server-side
15
15
  * application to ensure consistent handling of rendering requests and resource management.
16
- *
17
- * @developerPreview
18
16
  */
19
17
  export declare class AngularNodeAppEngine {
20
18
  private readonly angularAppEngine;
@@ -127,7 +125,6 @@ export declare interface CommonEngineRenderOptions {
127
125
  * res.send('Hello from Fastify with Node Next Handler!');
128
126
  * }));
129
127
  * ```
130
- * @developerPreview
131
128
  */
132
129
  export declare function createNodeRequestHandler<T extends NodeRequestHandlerFunction>(handler: T): T;
133
130
 
@@ -140,7 +137,6 @@ export declare function createNodeRequestHandler<T extends NodeRequestHandlerFun
140
137
  *
141
138
  * @param nodeRequest - The Node.js request object (`IncomingMessage` or `Http2ServerRequest`) to convert.
142
139
  * @returns A Web Standard `Request` object.
143
- * @developerPreview
144
140
  */
145
141
  export declare function createWebRequestFromNodeRequest(nodeRequest: IncomingMessage | Http2ServerRequest): Request;
146
142
 
@@ -159,7 +155,6 @@ export declare function createWebRequestFromNodeRequest(nodeRequest: IncomingMes
159
155
  *
160
156
  * @param url The URL of the module to check. This should typically be `import.meta.url`.
161
157
  * @returns `true` if the provided URL represents the main entry point, otherwise `false`.
162
- * @developerPreview
163
158
  */
164
159
  export declare function isMainModule(url: string): boolean;
165
160
 
@@ -171,7 +166,6 @@ export declare function isMainModule(url: string): boolean;
171
166
  * @param next - A callback function that signals the completion of the middleware or forwards the error if provided.
172
167
  *
173
168
  * @returns A Promise that resolves to void or simply void. The handler can be asynchronous.
174
- * @developerPreview
175
169
  */
176
170
  export declare type NodeRequestHandlerFunction = (req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => Promise<void> | void;
177
171
 
@@ -185,7 +179,6 @@ export declare type NodeRequestHandlerFunction = (req: IncomingMessage, res: Ser
185
179
  * @param source - The web-standard `Response` object to stream from.
186
180
  * @param destination - The Node.js response object (`ServerResponse` or `Http2ServerResponse`) to stream into.
187
181
  * @returns A promise that resolves once the streaming operation is complete.
188
- * @developerPreview
189
182
  */
190
183
  export declare function writeResponseToNodeResponse(source: Response, destination: ServerResponse | Http2ServerResponse): Promise<void>;
191
184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/ssr",
3
- "version": "20.0.0-next.1",
3
+ "version": "20.0.0-next.3",
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": "20.0.0-next.2",
33
- "@angular/compiler": "20.0.0-next.2",
34
- "@angular/core": "20.0.0-next.2",
35
- "@angular/platform-browser": "20.0.0-next.2",
36
- "@angular/platform-server": "20.0.0-next.2",
37
- "@angular/router": "20.0.0-next.2",
32
+ "@angular/common": "20.0.0-next.3",
33
+ "@angular/compiler": "20.0.0-next.3",
34
+ "@angular/core": "20.0.0-next.3",
35
+ "@angular/platform-browser": "20.0.0-next.3",
36
+ "@angular/platform-server": "20.0.0-next.3",
37
+ "@angular/router": "20.0.0-next.3",
38
38
  "@schematics/angular": "workspace:*"
39
39
  },
40
40
  "sideEffects": false,
@@ -10,11 +10,6 @@ export type Schema = {
10
10
  * determine the project from the current directory.
11
11
  */
12
12
  project: string;
13
- /**
14
- * Configure the server application to use the Angular Server Routing API and App Engine
15
- * APIs (currently in Developer Preview).
16
- */
17
- serverRouting?: boolean;
18
13
  /**
19
14
  * Skip the automatic installation of packages. You will need to manually install the
20
15
  * dependencies later.
@@ -16,10 +16,6 @@
16
16
  "description": "Skip the automatic installation of packages. You will need to manually install the dependencies later.",
17
17
  "type": "boolean",
18
18
  "default": false
19
- },
20
- "serverRouting": {
21
- "description": "Configure the server application to use the Angular Server Routing API and App Engine APIs (currently in Developer Preview).",
22
- "type": "boolean"
23
19
  }
24
20
  },
25
21
  "required": ["project"],