@analogjs/platform 1.7.1 → 1.7.2-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/platform",
3
- "version": "1.7.1",
3
+ "version": "1.7.2-beta.1",
4
4
  "description": "The fullstack meta-framework for Angular",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "nitropack": "^2.9.0",
28
- "@analogjs/vite-plugin-angular": "^1.7.1",
29
- "@analogjs/vite-plugin-nitro": "^1.7.1",
28
+ "@analogjs/vite-plugin-angular": "^1.7.2-beta.1",
29
+ "@analogjs/vite-plugin-nitro": "^1.7.2-beta.1",
30
30
  "vitefu": "^0.2.5"
31
31
  },
32
32
  "peerDependencies": {
@@ -1,16 +1,10 @@
1
1
  import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
2
- import {
3
- provideServerRendering,
4
- ɵSERVER_CONTEXT as SERVER_CONTEXT,
5
- } from '@angular/platform-server';
2
+ import { provideServerRendering } from '@angular/platform-server';
6
3
 
7
4
  import { appConfig } from './app.config';
8
5
 
9
6
  const serverConfig: ApplicationConfig = {
10
- providers: [
11
- provideServerRendering(),
12
- { provide: SERVER_CONTEXT, useValue: 'ssr-analog' },
13
- ],
7
+ providers: [provideServerRendering()],
14
8
  };
15
9
 
16
10
  export const config = mergeApplicationConfig(appConfig, serverConfig);
@@ -1,7 +1,11 @@
1
1
  import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2
- import { provideHttpClient, withFetch } from '@angular/common/http';
2
+ import {
3
+ provideHttpClient,
4
+ withFetch,
5
+ withInterceptors,
6
+ } from '@angular/common/http';
3
7
  import { provideClientHydration } from '@angular/platform-browser';
4
- import { provideFileRouter } from '@analogjs/router';
8
+ import { provideFileRouter, requestContextInterceptor } from '@analogjs/router';
5
9
  <% if (addTRPC) { %>
6
10
  import { provideTrpcClient } from '../trpc-client';
7
11
  <% } %>
@@ -11,7 +15,10 @@ export const appConfig: ApplicationConfig = {
11
15
  provideZoneChangeDetection({ eventCoalescing: true }),
12
16
  provideFileRouter(),
13
17
  provideClientHydration(),
14
- provideHttpClient(withFetch()),
18
+ provideHttpClient(
19
+ withFetch(),
20
+ withInterceptors([requestContextInterceptor])
21
+ ),
15
22
  <% if (addTRPC) { %>
16
23
  provideTrpcClient(),
17
24
  <% } %>
@@ -1,23 +1,32 @@
1
1
  import 'zone.js/node';
2
2
  import '@angular/platform-server/init';
3
-
4
3
  import { enableProdMode } from '@angular/core';
5
- import { renderApplication } from '@angular/platform-server';
6
4
  import { bootstrapApplication } from '@angular/platform-browser';
5
+ import { renderApplication } from '@angular/platform-server';
6
+ import { provideServerContext } from '@analogjs/router/server';
7
+ import { ServerContext } from '@analogjs/router/tokens';
7
8
 
8
- import { AppComponent } from './app/app.component';
9
9
  import { config } from './app/app.config.server';
10
+ import { AppComponent } from './app/app.component';
10
11
 
11
12
  if (import.meta.env.PROD) {
12
13
  enableProdMode();
13
14
  }
14
15
 
15
- const bootstrap = () => bootstrapApplication(AppComponent, config);
16
+ export function bootstrap() {
17
+ return bootstrapApplication(AppComponent, config);
18
+ }
16
19
 
17
- export default async function render(url: string, document: string) {
20
+ export default async function render(
21
+ url: string,
22
+ document: string,
23
+ serverContext: ServerContext
24
+ ) {
18
25
  const html = await renderApplication(bootstrap, {
19
26
  document,
20
27
  url,
28
+ platformProviders: [provideServerContext(serverContext)],
21
29
  });
30
+
22
31
  return html;
23
32
  }