@angular/ssr 19.0.0-next.3 → 19.0.0-next.4

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 CHANGED
@@ -2,7 +2,7 @@ import { ɵSERVER_CONTEXT as _SERVER_CONTEXT, renderApplication, renderModule }
2
2
  import * as fs from 'node:fs';
3
3
  import { dirname, join, normalize, resolve } from 'node:path';
4
4
  import { URL as URL$1 } from 'node:url';
5
- import { ɵInlineCriticalCssProcessor as _InlineCriticalCssProcessor } from '@angular/ssr';
5
+ import { ɵInlineCriticalCssProcessor as _InlineCriticalCssProcessor, AngularAppEngine } from '@angular/ssr';
6
6
  import { readFile } from 'node:fs/promises';
7
7
 
8
8
  class CommonEngineInlineCriticalCssProcessor {
@@ -181,59 +181,6 @@ function isBootstrapFn(value) {
181
181
  return typeof value === 'function' && !('ɵmod' in value);
182
182
  }
183
183
 
184
- /**
185
- * Streams a web-standard `Response` into a Node.js `ServerResponse`.
186
- *
187
- * @param source - The web-standard `Response` object to stream from.
188
- * @param destination - The Node.js `ServerResponse` object to stream into.
189
- * @returns A promise that resolves once the streaming operation is complete.
190
- * @developerPreview
191
- */
192
- async function writeResponseToNodeResponse(source, destination) {
193
- const { status, headers, body } = source;
194
- destination.statusCode = status;
195
- let cookieHeaderSet = false;
196
- for (const [name, value] of headers.entries()) {
197
- if (name === 'set-cookie') {
198
- if (cookieHeaderSet) {
199
- continue;
200
- }
201
- // Sets the 'set-cookie' header only once to ensure it is correctly applied.
202
- // Concatenating 'set-cookie' values can lead to incorrect behavior, so we use a single value from `headers.getSetCookie()`.
203
- destination.setHeader(name, headers.getSetCookie());
204
- cookieHeaderSet = true;
205
- }
206
- else {
207
- destination.setHeader(name, value);
208
- }
209
- }
210
- if (!body) {
211
- destination.end();
212
- return;
213
- }
214
- try {
215
- const reader = body.getReader();
216
- destination.on('close', () => {
217
- reader.cancel().catch((error) => {
218
- // eslint-disable-next-line no-console
219
- console.error(`An error occurred while writing the response body for: ${destination.req.url}.`, error);
220
- });
221
- });
222
- // eslint-disable-next-line no-constant-condition
223
- while (true) {
224
- const { done, value } = await reader.read();
225
- if (done) {
226
- destination.end();
227
- break;
228
- }
229
- destination.write(value);
230
- }
231
- }
232
- catch {
233
- destination.end('Internal server error.');
234
- }
235
- }
236
-
237
184
  /**
238
185
  * Converts a Node.js `IncomingMessage` into a Web Standard `Request`.
239
186
  *
@@ -292,5 +239,117 @@ function createRequestUrl(nodeRequest) {
292
239
  return new URL(url, `${protocol}://${hostnameWithPort}`);
293
240
  }
294
241
 
295
- export { CommonEngine, createWebRequestFromNodeRequest, writeResponseToNodeResponse };
242
+ /**
243
+ * Angular server application engine.
244
+ * Manages Angular server applications (including localized ones), handles rendering requests,
245
+ * and optionally transforms index HTML before rendering.
246
+ *
247
+ * @note This class should be instantiated once and used as a singleton across the server-side
248
+ * application to ensure consistent handling of rendering requests and resource management.
249
+ *
250
+ * @developerPreview
251
+ */
252
+ class AngularNodeAppEngine {
253
+ angularAppEngine = new AngularAppEngine();
254
+ /**
255
+ * Renders an HTTP response based on the incoming request using the Angular server application.
256
+ *
257
+ * The method processes the incoming request, determines the appropriate route, and prepares the
258
+ * rendering context to generate a response. If the request URL corresponds to a static file (excluding `/index.html`),
259
+ * the method returns `null`.
260
+ *
261
+ * Example: A request to `https://www.example.com/page/index.html` will render the Angular route
262
+ * associated with `https://www.example.com/page`.
263
+ *
264
+ * @param request - The incoming HTTP request object to be rendered.
265
+ * @param requestContext - Optional additional context for the request, such as metadata or custom settings.
266
+ * @returns A promise that resolves to a `Response` object, or `null` if the request URL is for a static file
267
+ * (e.g., `./logo.png`) rather than an application route.
268
+ */
269
+ render(request, requestContext) {
270
+ return this.angularAppEngine.render(createWebRequestFromNodeRequest(request), requestContext);
271
+ }
272
+ /**
273
+ * Retrieves HTTP headers for a request associated with statically generated (SSG) pages,
274
+ * based on the URL pathname.
275
+ *
276
+ * @param request - The incoming request object.
277
+ * @returns A `Map` containing the HTTP headers as key-value pairs.
278
+ * @note This function should be used exclusively for retrieving headers of SSG pages.
279
+ * @example
280
+ * ```typescript
281
+ * const angularAppEngine = new AngularNodeAppEngine();
282
+ *
283
+ * app.use(express.static('dist/browser', {
284
+ * setHeaders: (res, path) => {
285
+ * // Retrieve headers for the current request
286
+ * const headers = angularAppEngine.getHeaders(res.req);
287
+ *
288
+ * // Apply the retrieved headers to the response
289
+ * for (const { key, value } of headers) {
290
+ * res.setHeader(key, value);
291
+ * }
292
+ * }
293
+ }));
294
+ * ```
295
+ */
296
+ getHeaders(request) {
297
+ return this.angularAppEngine.getHeaders(createWebRequestFromNodeRequest(request));
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Streams a web-standard `Response` into a Node.js `ServerResponse`.
303
+ *
304
+ * @param source - The web-standard `Response` object to stream from.
305
+ * @param destination - The Node.js `ServerResponse` object to stream into.
306
+ * @returns A promise that resolves once the streaming operation is complete.
307
+ * @developerPreview
308
+ */
309
+ async function writeResponseToNodeResponse(source, destination) {
310
+ const { status, headers, body } = source;
311
+ destination.statusCode = status;
312
+ let cookieHeaderSet = false;
313
+ for (const [name, value] of headers.entries()) {
314
+ if (name === 'set-cookie') {
315
+ if (cookieHeaderSet) {
316
+ continue;
317
+ }
318
+ // Sets the 'set-cookie' header only once to ensure it is correctly applied.
319
+ // Concatenating 'set-cookie' values can lead to incorrect behavior, so we use a single value from `headers.getSetCookie()`.
320
+ destination.setHeader(name, headers.getSetCookie());
321
+ cookieHeaderSet = true;
322
+ }
323
+ else {
324
+ destination.setHeader(name, value);
325
+ }
326
+ }
327
+ if (!body) {
328
+ destination.end();
329
+ return;
330
+ }
331
+ try {
332
+ const reader = body.getReader();
333
+ destination.on('close', () => {
334
+ reader.cancel().catch((error) => {
335
+ // eslint-disable-next-line no-console
336
+ console.error(`An error occurred while writing the response body for: ${destination.req.url}.`, error);
337
+ });
338
+ });
339
+ // eslint-disable-next-line no-constant-condition
340
+ while (true) {
341
+ const { done, value } = await reader.read();
342
+ if (done) {
343
+ destination.end();
344
+ break;
345
+ }
346
+ destination.write(value);
347
+ }
348
+ }
349
+ catch {
350
+ destination.end('Internal server error.');
351
+ }
352
+ }
353
+
354
+ export { AngularNodeAppEngine, CommonEngine, createWebRequestFromNodeRequest, writeResponseToNodeResponse };
296
355
  //# sourceMappingURL=node.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.mjs","sources":["../../../../../../darwin-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/inline-css-processor.mjs","../../../../../../darwin-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/peformance-profiler.mjs","../../../../../../darwin-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/common-engine.mjs","../../../../../../darwin-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/response.mjs","../../../../../../darwin-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/request.mjs"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport { ɵInlineCriticalCssProcessor as InlineCriticalCssProcessor } from '@angular/ssr';\nimport { readFile } from 'node:fs/promises';\nexport class CommonEngineInlineCriticalCssProcessor {\n resourceCache = new Map();\n async process(html, outputPath) {\n const critters = new InlineCriticalCssProcessor(async (path) => {\n let resourceContent = this.resourceCache.get(path);\n if (resourceContent === undefined) {\n resourceContent = await readFile(path, 'utf-8');\n this.resourceCache.set(path, resourceContent);\n }\n return resourceContent;\n }, outputPath);\n return critters.process(html);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nconst PERFORMANCE_MARK_PREFIX = '🅰️';\nexport function printPerformanceLogs() {\n let maxWordLength = 0;\n const benchmarks = [];\n for (const { name, duration } of performance.getEntriesByType('measure')) {\n if (!name.startsWith(PERFORMANCE_MARK_PREFIX)) {\n continue;\n }\n // `🅰️:Retrieve SSG Page` -> `Retrieve SSG Page:`\n const step = name.slice(PERFORMANCE_MARK_PREFIX.length + 1) + ':';\n if (step.length > maxWordLength) {\n maxWordLength = step.length;\n }\n benchmarks.push([step, `${duration.toFixed(1)}ms`]);\n performance.clearMeasures(name);\n }\n /* eslint-disable no-console */\n console.log('********** Performance results **********');\n for (const [step, value] of benchmarks) {\n const spaces = maxWordLength - step.length + 5;\n console.log(step + ' '.repeat(spaces) + value);\n }\n console.log('*****************************************');\n /* eslint-enable no-console */\n}\nexport async function runMethodAndMeasurePerf(label, asyncMethod) {\n const labelName = `${PERFORMANCE_MARK_PREFIX}:${label}`;\n const startLabel = `start:${labelName}`;\n const endLabel = `end:${labelName}`;\n try {\n performance.mark(startLabel);\n return await asyncMethod();\n }\n finally {\n performance.mark(endLabel);\n performance.measure(labelName, startLabel, endLabel);\n performance.clearMarks(startLabel);\n performance.clearMarks(endLabel);\n }\n}\nexport function noopRunMethodAndMeasurePerf(label, asyncMethod) {\n return asyncMethod();\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';\nimport * as fs from 'node:fs';\nimport { dirname, join, normalize, resolve } from 'node:path';\nimport { URL } from 'node:url';\nimport { CommonEngineInlineCriticalCssProcessor } from './inline-css-processor';\nimport { noopRunMethodAndMeasurePerf, printPerformanceLogs, runMethodAndMeasurePerf, } from './peformance-profiler';\nconst SSG_MARKER_REGEXP = /ng-server-context=[\"']\\w*\\|?ssg\\|?\\w*[\"']/;\n/**\n * A common engine to use to server render an application.\n */\nexport class CommonEngine {\n options;\n templateCache = new Map();\n inlineCriticalCssProcessor = new CommonEngineInlineCriticalCssProcessor();\n pageIsSSG = new Map();\n constructor(options) {\n this.options = options;\n }\n /**\n * Render an HTML document for a specific URL with specified\n * render options\n */\n async render(opts) {\n const enablePerformanceProfiler = this.options?.enablePerformanceProfiler;\n const runMethod = enablePerformanceProfiler\n ? runMethodAndMeasurePerf\n : noopRunMethodAndMeasurePerf;\n let html = await runMethod('Retrieve SSG Page', () => this.retrieveSSGPage(opts));\n if (html === undefined) {\n html = await runMethod('Render Page', () => this.renderApplication(opts));\n if (opts.inlineCriticalCss !== false) {\n const content = await runMethod('Inline Critical CSS', () => \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.inlineCriticalCss(html, opts));\n html = content;\n }\n }\n if (enablePerformanceProfiler) {\n printPerformanceLogs();\n }\n return html;\n }\n inlineCriticalCss(html, opts) {\n const outputPath = opts.publicPath ?? (opts.documentFilePath ? dirname(opts.documentFilePath) : '');\n return this.inlineCriticalCssProcessor.process(html, outputPath);\n }\n async retrieveSSGPage(opts) {\n const { publicPath, documentFilePath, url } = opts;\n if (!publicPath || !documentFilePath || url === undefined) {\n return undefined;\n }\n const { pathname } = new URL(url, 'resolve://');\n // Do not use `resolve` here as otherwise it can lead to path traversal vulnerability.\n // See: https://portswigger.net/web-security/file-path-traversal\n const pagePath = join(publicPath, pathname, 'index.html');\n if (this.pageIsSSG.get(pagePath)) {\n // Serve pre-rendered page.\n return fs.promises.readFile(pagePath, 'utf-8');\n }\n if (!pagePath.startsWith(normalize(publicPath))) {\n // Potential path traversal detected.\n return undefined;\n }\n if (pagePath === resolve(documentFilePath) || !(await exists(pagePath))) {\n // View matches with prerender path or file does not exist.\n this.pageIsSSG.set(pagePath, false);\n return undefined;\n }\n // Static file exists.\n const content = await fs.promises.readFile(pagePath, 'utf-8');\n const isSSG = SSG_MARKER_REGEXP.test(content);\n this.pageIsSSG.set(pagePath, isSSG);\n return isSSG ? content : undefined;\n }\n async renderApplication(opts) {\n const moduleOrFactory = this.options?.bootstrap ?? opts.bootstrap;\n if (!moduleOrFactory) {\n throw new Error('A module or bootstrap option must be provided.');\n }\n const extraProviders = [\n { provide: ɵSERVER_CONTEXT, useValue: 'ssr' },\n ...(opts.providers ?? []),\n ...(this.options?.providers ?? []),\n ];\n let document = opts.document;\n if (!document && opts.documentFilePath) {\n document = await this.getDocument(opts.documentFilePath);\n }\n const commonRenderingOptions = {\n url: opts.url,\n document,\n };\n return isBootstrapFn(moduleOrFactory)\n ? renderApplication(moduleOrFactory, {\n platformProviders: extraProviders,\n ...commonRenderingOptions,\n })\n : renderModule(moduleOrFactory, { extraProviders, ...commonRenderingOptions });\n }\n /** Retrieve the document from the cache or the filesystem */\n async getDocument(filePath) {\n let doc = this.templateCache.get(filePath);\n if (!doc) {\n doc = await fs.promises.readFile(filePath, 'utf-8');\n this.templateCache.set(filePath, doc);\n }\n return doc;\n }\n}\nasync function exists(path) {\n try {\n await fs.promises.access(path, fs.constants.F_OK);\n return true;\n }\n catch {\n return false;\n }\n}\nfunction isBootstrapFn(value) {\n // We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:\n return typeof value === 'function' && !('ɵmod' in value);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n/**\n * Streams a web-standard `Response` into a Node.js `ServerResponse`.\n *\n * @param source - The web-standard `Response` object to stream from.\n * @param destination - The Node.js `ServerResponse` object to stream into.\n * @returns A promise that resolves once the streaming operation is complete.\n * @developerPreview\n */\nexport async function writeResponseToNodeResponse(source, destination) {\n const { status, headers, body } = source;\n destination.statusCode = status;\n let cookieHeaderSet = false;\n for (const [name, value] of headers.entries()) {\n if (name === 'set-cookie') {\n if (cookieHeaderSet) {\n continue;\n }\n // Sets the 'set-cookie' header only once to ensure it is correctly applied.\n // Concatenating 'set-cookie' values can lead to incorrect behavior, so we use a single value from `headers.getSetCookie()`.\n destination.setHeader(name, headers.getSetCookie());\n cookieHeaderSet = true;\n }\n else {\n destination.setHeader(name, value);\n }\n }\n if (!body) {\n destination.end();\n return;\n }\n try {\n const reader = body.getReader();\n destination.on('close', () => {\n reader.cancel().catch((error) => {\n // eslint-disable-next-line no-console\n console.error(`An error occurred while writing the response body for: ${destination.req.url}.`, error);\n });\n });\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n destination.end();\n break;\n }\n destination.write(value);\n }\n }\n catch {\n destination.end('Internal server error.');\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n/**\n * Converts a Node.js `IncomingMessage` into a Web Standard `Request`.\n *\n * @param nodeRequest - The Node.js `IncomingMessage` object to convert.\n * @returns A Web Standard `Request` object.\n * @developerPreview\n */\nexport function createWebRequestFromNodeRequest(nodeRequest) {\n const { headers, method = 'GET' } = nodeRequest;\n const withBody = method !== 'GET' && method !== 'HEAD';\n return new Request(createRequestUrl(nodeRequest), {\n method,\n headers: createRequestHeaders(headers),\n body: withBody ? nodeRequest : undefined,\n duplex: withBody ? 'half' : undefined,\n });\n}\n/**\n * Creates a `Headers` object from Node.js `IncomingHttpHeaders`.\n *\n * @param nodeHeaders - The Node.js `IncomingHttpHeaders` object to convert.\n * @returns A `Headers` object containing the converted headers.\n */\nfunction createRequestHeaders(nodeHeaders) {\n const headers = new Headers();\n for (const [name, value] of Object.entries(nodeHeaders)) {\n if (typeof value === 'string') {\n headers.append(name, value);\n }\n else if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(name, item);\n }\n }\n }\n return headers;\n}\n/**\n * Creates a `URL` object from a Node.js `IncomingMessage`, taking into account the protocol, host, and port.\n *\n * @param nodeRequest - The Node.js `IncomingMessage` object to extract URL information from.\n * @returns A `URL` object representing the request URL.\n */\nfunction createRequestUrl(nodeRequest) {\n const { headers, socket, url = '' } = nodeRequest;\n const protocol = headers['x-forwarded-proto'] ?? ('encrypted' in socket && socket.encrypted ? 'https' : 'http');\n const hostname = headers['x-forwarded-host'] ?? headers.host ?? headers[':authority'];\n const port = headers['x-forwarded-port'] ?? socket.localPort;\n if (Array.isArray(hostname)) {\n throw new Error('host value cannot be an array.');\n }\n let hostnameWithPort = hostname;\n if (port && !hostname?.includes(':')) {\n hostnameWithPort += `:${port}`;\n }\n return new URL(url, `${protocol}://${hostnameWithPort}`);\n}\n"],"names":["InlineCriticalCssProcessor","URL","ɵSERVER_CONTEXT"],"mappings":";;;;;;;AASO,MAAM,sCAAsC,CAAC;AACpD,IAAI,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;AAC9B,IAAI,MAAM,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE;AACpC,QAAQ,MAAM,QAAQ,GAAG,IAAIA,2BAA0B,CAAC,OAAO,IAAI,KAAK;AACxE,YAAY,IAAI,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC/D,YAAY,IAAI,eAAe,KAAK,SAAS,EAAE;AAC/C,gBAAgB,eAAe,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAChE,gBAAgB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC9D,aAAa;AACb,YAAY,OAAO,eAAe,CAAC;AACnC,SAAS,EAAE,UAAU,CAAC,CAAC;AACvB,QAAQ,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACtC,KAAK;AACL;;ACfA,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAC/B,SAAS,oBAAoB,GAAG;AACvC,IAAI,IAAI,aAAa,GAAG,CAAC,CAAC;AAC1B,IAAI,MAAM,UAAU,GAAG,EAAE,CAAC;AAC1B,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE;AAC9E,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE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,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE;AAC1C,QAAQ,gBAAgB,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACvC,KAAK;AACL,IAAI,OAAO,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAC7D;;;;"}
1
+ {"version":3,"file":"node.mjs","sources":["../../../../../../k8-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/inline-css-processor.mjs","../../../../../../k8-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/peformance-profiler.mjs","../../../../../../k8-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/common-engine.mjs","../../../../../../k8-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/request.mjs","../../../../../../k8-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/app-engine.mjs","../../../../../../k8-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/response.mjs"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport { ɵInlineCriticalCssProcessor as InlineCriticalCssProcessor } from '@angular/ssr';\nimport { readFile } from 'node:fs/promises';\nexport class CommonEngineInlineCriticalCssProcessor {\n resourceCache = new Map();\n async process(html, outputPath) {\n const critters = new InlineCriticalCssProcessor(async (path) => {\n let resourceContent = this.resourceCache.get(path);\n if (resourceContent === undefined) {\n resourceContent = await readFile(path, 'utf-8');\n this.resourceCache.set(path, resourceContent);\n }\n return resourceContent;\n }, outputPath);\n return critters.process(html);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nconst PERFORMANCE_MARK_PREFIX = '🅰️';\nexport function printPerformanceLogs() {\n let maxWordLength = 0;\n const benchmarks = [];\n for (const { name, duration } of performance.getEntriesByType('measure')) {\n if (!name.startsWith(PERFORMANCE_MARK_PREFIX)) {\n continue;\n }\n // `🅰️:Retrieve SSG Page` -> `Retrieve SSG Page:`\n const step = name.slice(PERFORMANCE_MARK_PREFIX.length + 1) + ':';\n if (step.length > maxWordLength) {\n maxWordLength = step.length;\n }\n benchmarks.push([step, `${duration.toFixed(1)}ms`]);\n performance.clearMeasures(name);\n }\n /* eslint-disable no-console */\n console.log('********** Performance results **********');\n for (const [step, value] of benchmarks) {\n const spaces = maxWordLength - step.length + 5;\n console.log(step + ' '.repeat(spaces) + value);\n }\n console.log('*****************************************');\n /* eslint-enable no-console */\n}\nexport async function runMethodAndMeasurePerf(label, asyncMethod) {\n const labelName = `${PERFORMANCE_MARK_PREFIX}:${label}`;\n const startLabel = `start:${labelName}`;\n const endLabel = `end:${labelName}`;\n try {\n performance.mark(startLabel);\n return await asyncMethod();\n }\n finally {\n performance.mark(endLabel);\n performance.measure(labelName, startLabel, endLabel);\n performance.clearMarks(startLabel);\n performance.clearMarks(endLabel);\n }\n}\nexport function noopRunMethodAndMeasurePerf(label, asyncMethod) {\n return asyncMethod();\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';\nimport * as fs from 'node:fs';\nimport { dirname, join, normalize, resolve } from 'node:path';\nimport { URL } from 'node:url';\nimport { CommonEngineInlineCriticalCssProcessor } from './inline-css-processor';\nimport { noopRunMethodAndMeasurePerf, printPerformanceLogs, runMethodAndMeasurePerf, } from './peformance-profiler';\nconst SSG_MARKER_REGEXP = /ng-server-context=[\"']\\w*\\|?ssg\\|?\\w*[\"']/;\n/**\n * A common engine to use to server render an application.\n */\nexport class CommonEngine {\n options;\n templateCache = new Map();\n inlineCriticalCssProcessor = new CommonEngineInlineCriticalCssProcessor();\n pageIsSSG = new Map();\n constructor(options) {\n this.options = options;\n }\n /**\n * Render an HTML document for a specific URL with specified\n * render options\n */\n async render(opts) {\n const enablePerformanceProfiler = this.options?.enablePerformanceProfiler;\n const runMethod = enablePerformanceProfiler\n ? runMethodAndMeasurePerf\n : noopRunMethodAndMeasurePerf;\n let html = await runMethod('Retrieve SSG Page', () => this.retrieveSSGPage(opts));\n if (html === undefined) {\n html = await runMethod('Render Page', () => this.renderApplication(opts));\n if (opts.inlineCriticalCss !== false) {\n const content = await runMethod('Inline Critical CSS', () => \n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.inlineCriticalCss(html, opts));\n html = content;\n }\n }\n if (enablePerformanceProfiler) {\n printPerformanceLogs();\n }\n return html;\n }\n inlineCriticalCss(html, opts) {\n const outputPath = opts.publicPath ?? (opts.documentFilePath ? dirname(opts.documentFilePath) : '');\n return this.inlineCriticalCssProcessor.process(html, outputPath);\n }\n async retrieveSSGPage(opts) {\n const { publicPath, documentFilePath, url } = opts;\n if (!publicPath || !documentFilePath || url === undefined) {\n return undefined;\n }\n const { pathname } = new URL(url, 'resolve://');\n // Do not use `resolve` here as otherwise it can lead to path traversal vulnerability.\n // See: https://portswigger.net/web-security/file-path-traversal\n const pagePath = join(publicPath, pathname, 'index.html');\n if (this.pageIsSSG.get(pagePath)) {\n // Serve pre-rendered page.\n return fs.promises.readFile(pagePath, 'utf-8');\n }\n if (!pagePath.startsWith(normalize(publicPath))) {\n // Potential path traversal detected.\n return undefined;\n }\n if (pagePath === resolve(documentFilePath) || !(await exists(pagePath))) {\n // View matches with prerender path or file does not exist.\n this.pageIsSSG.set(pagePath, false);\n return undefined;\n }\n // Static file exists.\n const content = await fs.promises.readFile(pagePath, 'utf-8');\n const isSSG = SSG_MARKER_REGEXP.test(content);\n this.pageIsSSG.set(pagePath, isSSG);\n return isSSG ? content : undefined;\n }\n async renderApplication(opts) {\n const moduleOrFactory = this.options?.bootstrap ?? opts.bootstrap;\n if (!moduleOrFactory) {\n throw new Error('A module or bootstrap option must be provided.');\n }\n const extraProviders = [\n { provide: ɵSERVER_CONTEXT, useValue: 'ssr' },\n ...(opts.providers ?? []),\n ...(this.options?.providers ?? []),\n ];\n let document = opts.document;\n if (!document && opts.documentFilePath) {\n document = await this.getDocument(opts.documentFilePath);\n }\n const commonRenderingOptions = {\n url: opts.url,\n document,\n };\n return isBootstrapFn(moduleOrFactory)\n ? renderApplication(moduleOrFactory, {\n platformProviders: extraProviders,\n ...commonRenderingOptions,\n })\n : renderModule(moduleOrFactory, { extraProviders, ...commonRenderingOptions });\n }\n /** Retrieve the document from the cache or the filesystem */\n async getDocument(filePath) {\n let doc = this.templateCache.get(filePath);\n if (!doc) {\n doc = await fs.promises.readFile(filePath, 'utf-8');\n this.templateCache.set(filePath, doc);\n }\n return doc;\n }\n}\nasync function exists(path) {\n try {\n await fs.promises.access(path, fs.constants.F_OK);\n return true;\n }\n catch {\n return false;\n }\n}\nfunction isBootstrapFn(value) {\n // We can differentiate between a module and a bootstrap function by reading compiler-generated `ɵmod` static property:\n return typeof value === 'function' && !('ɵmod' in value);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n/**\n * Converts a Node.js `IncomingMessage` into a Web Standard `Request`.\n *\n * @param nodeRequest - The Node.js `IncomingMessage` object to convert.\n * @returns A Web Standard `Request` object.\n * @developerPreview\n */\nexport function createWebRequestFromNodeRequest(nodeRequest) {\n const { headers, method = 'GET' } = nodeRequest;\n const withBody = method !== 'GET' && method !== 'HEAD';\n return new Request(createRequestUrl(nodeRequest), {\n method,\n headers: createRequestHeaders(headers),\n body: withBody ? nodeRequest : undefined,\n duplex: withBody ? 'half' : undefined,\n });\n}\n/**\n * Creates a `Headers` object from Node.js `IncomingHttpHeaders`.\n *\n * @param nodeHeaders - The Node.js `IncomingHttpHeaders` object to convert.\n * @returns A `Headers` object containing the converted headers.\n */\nfunction createRequestHeaders(nodeHeaders) {\n const headers = new Headers();\n for (const [name, value] of Object.entries(nodeHeaders)) {\n if (typeof value === 'string') {\n headers.append(name, value);\n }\n else if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(name, item);\n }\n }\n }\n return headers;\n}\n/**\n * Creates a `URL` object from a Node.js `IncomingMessage`, taking into account the protocol, host, and port.\n *\n * @param nodeRequest - The Node.js `IncomingMessage` object to extract URL information from.\n * @returns A `URL` object representing the request URL.\n */\nfunction createRequestUrl(nodeRequest) {\n const { headers, socket, url = '' } = nodeRequest;\n const protocol = headers['x-forwarded-proto'] ?? ('encrypted' in socket && socket.encrypted ? 'https' : 'http');\n const hostname = headers['x-forwarded-host'] ?? headers.host ?? headers[':authority'];\n const port = headers['x-forwarded-port'] ?? socket.localPort;\n if (Array.isArray(hostname)) {\n throw new Error('host value cannot be an array.');\n }\n let hostnameWithPort = hostname;\n if (port && !hostname?.includes(':')) {\n hostnameWithPort += `:${port}`;\n }\n return new URL(url, `${protocol}://${hostnameWithPort}`);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport { AngularAppEngine } from '@angular/ssr';\nimport { createWebRequestFromNodeRequest } from './request';\n/**\n * Angular server application engine.\n * Manages Angular server applications (including localized ones), handles rendering requests,\n * and optionally transforms index HTML before rendering.\n *\n * @note This class should be instantiated once and used as a singleton across the server-side\n * application to ensure consistent handling of rendering requests and resource management.\n *\n * @developerPreview\n */\nexport class AngularNodeAppEngine {\n angularAppEngine = new AngularAppEngine();\n /**\n * Renders an HTTP response based on the incoming request using the Angular server application.\n *\n * The method processes the incoming request, determines the appropriate route, and prepares the\n * rendering context to generate a response. If the request URL corresponds to a static file (excluding `/index.html`),\n * the method returns `null`.\n *\n * Example: A request to `https://www.example.com/page/index.html` will render the Angular route\n * associated with `https://www.example.com/page`.\n *\n * @param request - The incoming HTTP request object to be rendered.\n * @param requestContext - Optional additional context for the request, such as metadata or custom settings.\n * @returns A promise that resolves to a `Response` object, or `null` if the request URL is for a static file\n * (e.g., `./logo.png`) rather than an application route.\n */\n render(request, requestContext) {\n return this.angularAppEngine.render(createWebRequestFromNodeRequest(request), requestContext);\n }\n /**\n * Retrieves HTTP headers for a request associated with statically generated (SSG) pages,\n * based on the URL pathname.\n *\n * @param request - The incoming request object.\n * @returns A `Map` containing the HTTP headers as key-value pairs.\n * @note This function should be used exclusively for retrieving headers of SSG pages.\n * @example\n * ```typescript\n * const angularAppEngine = new AngularNodeAppEngine();\n *\n * app.use(express.static('dist/browser', {\n * setHeaders: (res, path) => {\n * // Retrieve headers for the current request\n * const headers = angularAppEngine.getHeaders(res.req);\n *\n * // Apply the retrieved headers to the response\n * for (const { key, value } of headers) {\n * res.setHeader(key, value);\n * }\n * }\n }));\n * ```\n */\n getHeaders(request) {\n return this.angularAppEngine.getHeaders(createWebRequestFromNodeRequest(request));\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n/**\n * Streams a web-standard `Response` into a Node.js `ServerResponse`.\n *\n * @param source - The web-standard `Response` object to stream from.\n * @param destination - The Node.js `ServerResponse` object to stream into.\n * @returns A promise that resolves once the streaming operation is complete.\n * @developerPreview\n */\nexport async function writeResponseToNodeResponse(source, destination) {\n const { status, headers, body } = source;\n destination.statusCode = status;\n let cookieHeaderSet = false;\n for (const [name, value] of headers.entries()) {\n if (name === 'set-cookie') {\n if (cookieHeaderSet) {\n continue;\n }\n // Sets the 'set-cookie' header only once to ensure it is correctly applied.\n // Concatenating 'set-cookie' values can lead to incorrect behavior, so we use a single value from `headers.getSetCookie()`.\n destination.setHeader(name, headers.getSetCookie());\n cookieHeaderSet = true;\n }\n else {\n destination.setHeader(name, value);\n }\n }\n if (!body) {\n destination.end();\n return;\n }\n try {\n const reader = body.getReader();\n destination.on('close', () => {\n reader.cancel().catch((error) => {\n // eslint-disable-next-line no-console\n console.error(`An error occurred while writing the response body for: ${destination.req.url}.`, error);\n });\n });\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n destination.end();\n break;\n }\n destination.write(value);\n }\n }\n catch {\n destination.end('Internal server error.');\n }\n}\n"],"names":["InlineCriticalCssProcessor","URL","ɵSERVER_CONTEXT"],"mappings":";;;;;;;AASO,MAAM,sCAAsC,CAAC;AACpD,IAAI,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;AAC9B,IAAI,MAAM,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE;AACpC,QAAQ,MAAM,QAAQ,GAAG,IAAIA,2BAA0B,CAAC,OAAO,IAAI,KAAK;AACxE,YAAY,IAAI,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC/D,YAAY,IAAI,eAAe,KAAK,SAAS,EAAE;AAC/C,gBAAgB,eAAe,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAChE,gBAAgB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC9D,aAAa;AACb,YAAY,OAAO,eAAe,CAAC;AACnC,SAAS,EAAE,UAAU,CAAC,CAAC;AACvB,QAAQ,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACtC,KAAK;AACL;;ACfA,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAC/B,SAAS,oBAAoB,GAAG;AACvC,IAAI,IAAI,aAAa,GAAG,CAAC,CAAC;AAC1B,IAAI,MAAM,UAAU,GAAG,EAAE,CAAC;AAC1B,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE;A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b,YAAY,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/C,SAAS;AACT,KAAK;AACL,IAAI,IAAI,CAAC,IAAI,EAAE;AACf,QAAQ,WAAW,CAAC,GAAG,EAAE,CAAC;AAC1B,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,IAAI;AACR,QAAQ,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;AACxC,QAAQ,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM;AACtC,YAAY,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK;AAC7C;AACA,gBAAgB,OAAO,CAAC,KAAK,CAAC,CAAC,uDAAuD,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACvH,aAAa,CAAC,CAAC;AACf,SAAS,CAAC,CAAC;AACX;AACA,QAAQ,OAAO,IAAI,EAAE;AACrB,YAAY,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;AACxD,YAAY,IAAI,IAAI,EAAE;AACtB,gBAAgB,WAAW,CAAC,GAAG,EAAE,CAAC;AAClC,gBAAgB,MAAM;AACtB,aAAa;AACb,YAAY,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrC,SAAS;AACT,KAAK;AACL,IAAI,MAAM;AACV,QAAQ,WAAW,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAClD,KAAK;AACL;;;;"}
package/fesm2022/ssr.mjs CHANGED
@@ -575,7 +575,7 @@ async function getRoutesFromAngularRouterConfig(bootstrap, document, url) {
575
575
  async function extractRoutesAndCreateRouteTree(url, manifest = getAngularAppManifest()) {
576
576
  const routeTree = new RouteTree();
577
577
  const document = await new ServerAssets(manifest).getIndexServerHtml();
578
- const { baseHref, routes } = await getRoutesFromAngularRouterConfig(manifest.bootstrap(), document, url);
578
+ const { baseHref, routes } = await getRoutesFromAngularRouterConfig(await manifest.bootstrap(), document, url);
579
579
  for (let { route, redirectTo } of routes) {
580
580
  route = joinUrlParts(baseHref, route);
581
581
  redirectTo = redirectTo === undefined ? undefined : joinUrlParts(baseHref, redirectTo);
@@ -1030,7 +1030,8 @@ class AngularServerApp {
1030
1030
  if (hooks.has('html:transform:pre')) {
1031
1031
  html = await hooks.run('html:transform:pre', { html });
1032
1032
  }
1033
- html = await renderAngular(html, manifest.bootstrap(), new URL(request.url), platformProviders);
1033
+ this.boostrap ??= await manifest.bootstrap();
1034
+ html = await renderAngular(html, this.boostrap, new URL(request.url), platformProviders);
1034
1035
  if (manifest.inlineCriticalCss) {
1035
1036
  // Optionally inline critical CSS.
1036
1037
  this.inlineCriticalCssProcessor ??= new InlineCriticalCssProcessor((path) => {
@@ -1069,6 +1070,8 @@ function destroyAngularServerApp() {
1069
1070
  angularServerApp = undefined;
1070
1071
  }
1071
1072
 
1073
+ // ɵgetRoutesFromAngularRouterConfig is only used by the Webpack based server builder.
1074
+
1072
1075
  /**
1073
1076
  * Extracts a potential locale ID from a given URL based on the specified base path.
1074
1077
  *
@@ -1108,6 +1111,11 @@ function getPotentialLocaleIdFromUrl(url, basePath) {
1108
1111
  * Angular server application engine.
1109
1112
  * Manages Angular server applications (including localized ones), handles rendering requests,
1110
1113
  * and optionally transforms index HTML before rendering.
1114
+ *
1115
+ * @note This class should be instantiated once and used as a singleton across the server-side
1116
+ * application to ensure consistent handling of rendering requests and resource management.
1117
+ *
1118
+ * @developerPreview
1111
1119
  */
1112
1120
  class AngularAppEngine {
1113
1121
  constructor() {
@@ -1182,35 +1190,23 @@ class AngularAppEngine {
1182
1190
  const potentialLocale = getPotentialLocaleIdFromUrl(url, basePath);
1183
1191
  return entryPoints.get(potentialLocale);
1184
1192
  }
1193
+ /**
1194
+ * Retrieves HTTP headers for a request associated with statically generated (SSG) pages,
1195
+ * based on the URL pathname.
1196
+ *
1197
+ * @param request - The incoming request object.
1198
+ * @returns A `Map` containing the HTTP headers as key-value pairs.
1199
+ * @note This function should be used exclusively for retrieving headers of SSG pages.
1200
+ */
1201
+ getHeaders(request) {
1202
+ if (this.manifest.staticPathsHeaders.size === 0) {
1203
+ return new Map();
1204
+ }
1205
+ const { pathname } = stripIndexHtmlFromURL(new URL(request.url));
1206
+ const headers = this.manifest.staticPathsHeaders.get(pathname);
1207
+ return new Map(headers);
1208
+ }
1185
1209
  }
1186
- let angularAppEngine;
1187
- /**
1188
- * Retrieves an existing `AngularAppEngine` instance or creates a new one if none exists.
1189
- *
1190
- * This method ensures that only a single instance of `AngularAppEngine` is created and reused across
1191
- * the application lifecycle, providing efficient resource management. If the instance does not exist,
1192
- * it will be instantiated upon the first call.
1193
- *
1194
- * @developerPreview
1195
- * @returns The existing or newly created instance of `AngularAppEngine`.
1196
- */
1197
- function getOrCreateAngularAppEngine() {
1198
- return (angularAppEngine ??= new AngularAppEngine());
1199
- }
1200
- /**
1201
- * Destroys the current `AngularAppEngine` instance, releasing any associated resources.
1202
- *
1203
- * This method resets the reference to the `AngularAppEngine` instance to `undefined`, allowing
1204
- * a new instance to be created on the next call to `getOrCreateAngularAppEngine()`. It is typically
1205
- * used when reinitializing the server environment or refreshing the application state is necessary.
1206
- *
1207
- * @developerPreview
1208
- */
1209
- function destroyAngularAppEngine() {
1210
- angularAppEngine = undefined;
1211
- }
1212
-
1213
- // ɵgetRoutesFromAngularRouterConfig is only used by the Webpack based server builder.
1214
1210
 
1215
- export { destroyAngularAppEngine, getOrCreateAngularAppEngine, AngularAppEngine as ɵAngularAppEngine, InlineCriticalCssProcessor as ɵInlineCriticalCssProcessor, ServerRenderContext as ɵServerRenderContext, destroyAngularServerApp as ɵdestroyAngularServerApp, extractRoutesAndCreateRouteTree as ɵextractRoutesAndCreateRouteTree, getOrCreateAngularServerApp as ɵgetOrCreateAngularServerApp, getRoutesFromAngularRouterConfig as ɵgetRoutesFromAngularRouterConfig, setAngularAppEngineManifest as ɵsetAngularAppEngineManifest, setAngularAppManifest as ɵsetAngularAppManifest };
1211
+ export { AngularAppEngine, InlineCriticalCssProcessor as ɵInlineCriticalCssProcessor, ServerRenderContext as ɵServerRenderContext, destroyAngularServerApp as ɵdestroyAngularServerApp, extractRoutesAndCreateRouteTree as ɵextractRoutesAndCreateRouteTree, getOrCreateAngularServerApp as ɵgetOrCreateAngularServerApp, getRoutesFromAngularRouterConfig as ɵgetRoutesFromAngularRouterConfig, setAngularAppEngineManifest as ɵsetAngularAppEngineManifest, setAngularAppManifest as ɵsetAngularAppManifest };
1216
1212
  //# sourceMappingURL=ssr.mjs.map