@angular/ssr 19.0.2 → 19.1.0-next.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"node.mjs","sources":["../../../../../../darwin_arm64-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/inline-css-processor.mjs","../../../../../../darwin_arm64-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/peformance-profiler.mjs","../../../../../../darwin_arm64-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/common-engine/common-engine.mjs","../../../../../../darwin_arm64-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/request.mjs","../../../../../../darwin_arm64-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/app-engine.mjs","../../../../../../darwin_arm64-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/handler.mjs","../../../../../../darwin_arm64-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/response.mjs","../../../../../../darwin_arm64-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/module.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 beasties = 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 beasties.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 * A set containing all the pseudo-headers defined in the HTTP/2 specification.\n *\n * This set can be used to filter out pseudo-headers from a list of headers,\n * as they are not allowed to be set directly using the `Node.js` Undici API or\n * the web `Headers` API.\n */\nconst HTTP2_PSEUDO_HEADERS = new Set([':method', ':scheme', ':authority', ':path', ':status']);\n/**\n * Converts a Node.js `IncomingMessage` or `Http2ServerRequest` into a\n * Web Standard `Request` object.\n *\n * This function adapts the Node.js request objects to a format that can\n * be used by web platform APIs.\n *\n * @param nodeRequest - The Node.js request object (`IncomingMessage` or `Http2ServerRequest`) 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 (HTTP2_PSEUDO_HEADERS.has(name)) {\n continue;\n }\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` or `Http2ServerRequest` object to extract URL information from.\n * @returns A `URL` object representing the request URL.\n */\nfunction createRequestUrl(nodeRequest) {\n const { headers, socket, url = '', originalUrl, } = 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(originalUrl ?? 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 * @remarks 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 * Handles an incoming HTTP request by serving prerendered content, performing server-side rendering,\n * or delivering a static file for client-side rendered routes based on the `RenderMode` setting.\n *\n * This method adapts Node.js's `IncomingMessage` or `Http2ServerRequest`\n * to a format compatible with the `AngularAppEngine` and delegates the handling logic to it.\n *\n * @param request - The incoming HTTP request (`IncomingMessage` or `Http2ServerRequest`).\n * @param requestContext - Optional context for rendering, such as metadata associated with the request.\n * @returns A promise that resolves to the resulting HTTP response object, or `null` if no matching Angular route is found.\n *\n * @remarks A request to `https://www.example.com/page/index.html` will serve or render the Angular route\n * corresponding to `https://www.example.com/page`.\n */\n async handle(request, requestContext) {\n const webRequest = createWebRequestFromNodeRequest(request);\n return this.angularAppEngine.handle(webRequest, requestContext);\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 * Attaches metadata to the handler function to mark it as a special handler for Node.js environments.\n *\n * @typeParam T - The type of the handler function.\n * @param handler - The handler function to be defined and annotated.\n * @returns The same handler function passed as an argument, with metadata attached.\n *\n * @example\n * Usage in an Express application:\n * ```ts\n * const app = express();\n * export default createNodeRequestHandler(app);\n * ```\n *\n * @example\n * Usage in a Hono application:\n * ```ts\n * const app = new Hono();\n * export default createNodeRequestHandler(async (req, res, next) => {\n * try {\n * const webRes = await app.fetch(createWebRequestFromNodeRequest(req));\n * if (webRes) {\n * await writeResponseToNodeResponse(webRes, res);\n * } else {\n * next();\n * }\n * } catch (error) {\n * next(error);\n * }\n * }));\n * ```\n *\n * @example\n * Usage in a Fastify application:\n * ```ts\n * const app = Fastify();\n * export default createNodeRequestHandler(async (req, res) => {\n * await app.ready();\n * app.server.emit('request', req, res);\n * res.send('Hello from Fastify with Node Next Handler!');\n * }));\n * ```\n * @developerPreview\n */\nexport function createNodeRequestHandler(handler) {\n handler['__ng_node_request_handler__'] = true;\n return handler;\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 * or `Http2ServerResponse`.\n *\n * This function adapts the web `Response` object to write its content\n * to a Node.js response object, handling both HTTP/1.1 and HTTP/2.\n *\n * @param source - The web-standard `Response` object to stream from.\n * @param destination - The Node.js response object (`ServerResponse` or `Http2ServerResponse`) 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 */\nimport { argv } from 'node:process';\nimport { fileURLToPath } from 'node:url';\n/**\n * Determines whether the provided URL represents the main entry point module.\n *\n * This function checks if the provided URL corresponds to the main ESM module being executed directly.\n * It's useful for conditionally executing code that should only run when a module is the entry point,\n * such as starting a server or initializing an application.\n *\n * It performs two key checks:\n * 1. Verifies if the URL starts with 'file:', ensuring it is a local file.\n * 2. Compares the URL's resolved file path with the first command-line argument (`process.argv[1]`),\n * which points to the file being executed.\n *\n * @param url The URL of the module to check. This should typically be `import.meta.url`.\n * @returns `true` if the provided URL represents the main entry point, otherwise `false`.\n * @developerPreview\n */\nexport function isMainModule(url) {\n return url.startsWith('file:') && argv[1] === fileURLToPath(url);\n}\n"],"names":["InlineCriticalCssProcessor","URL","ɵSERVER_CONTEXT"],"mappings":";;;;;;;;AASO,MAAM,sCAAsC,CAAC;AACpD,IAAI,aAAa,GAAG,IAAI,GAAG,EAAE;AAC7B,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;AAC9D,YAAY,IAAI,eAAe,KAAK,SAAS,EAAE;AAC/C,gBAAgB,eAAe,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;AAC/D,gBAAgB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC;AAC7D;AACA,YAAY,OAAO,eAAe;AAClC,SAAS,EAAE,UAAU,CAAC;AACtB,QAAQ,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;AACrC;AACA;;ACfA,MAAM,uBAAuB,GAAG,KAAK;AAC9B,SAAS,oBAAoB,GAAG;AACvC,IAAI,IAAI,aAAa,GAAG,CAAC;AACzB,IAAI,MAAM,UAAU,GAAG,EAAE;AACzB,IAAI,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,I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AC,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;AACtH,aAAa,CAAC;AACd,SAAS,CAAC;AACV;AACA,QAAQ,OAAO,IAAI,EAAE;AACrB,YAAY,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE;AACvD,YAAY,IAAI,IAAI,EAAE;AACtB,gBAAgB,WAAW,CAAC,GAAG,EAAE;AACjC,gBAAgB;AAChB;AACA,YAAY,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC;AACpC;AACA;AACA,IAAI,MAAM;AACV,QAAQ,WAAW,CAAC,GAAG,CAAC,wBAAwB,CAAC;AACjD;AACA;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,GAAG,EAAE;AAClC,IAAI,OAAO,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,GAAG,CAAC;AACpE;;;;"}
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/handler.mjs","../../../../../../k8-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/response.mjs","../../../../../../k8-fastbuild-ST-70f2edae98f4/bin/packages/angular/ssr/node/src/module.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 beasties = 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 beasties.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 * A set containing all the pseudo-headers defined in the HTTP/2 specification.\n *\n * This set can be used to filter out pseudo-headers from a list of headers,\n * as they are not allowed to be set directly using the `Node.js` Undici API or\n * the web `Headers` API.\n */\nconst HTTP2_PSEUDO_HEADERS = new Set([':method', ':scheme', ':authority', ':path', ':status']);\n/**\n * Converts a Node.js `IncomingMessage` or `Http2ServerRequest` into a\n * Web Standard `Request` object.\n *\n * This function adapts the Node.js request objects to a format that can\n * be used by web platform APIs.\n *\n * @param nodeRequest - The Node.js request object (`IncomingMessage` or `Http2ServerRequest`) 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 (HTTP2_PSEUDO_HEADERS.has(name)) {\n continue;\n }\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` or `Http2ServerRequest` object to extract URL information from.\n * @returns A `URL` object representing the request URL.\n */\nfunction createRequestUrl(nodeRequest) {\n const { headers, socket, url = '', originalUrl, } = 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(originalUrl ?? 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 * @remarks 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 * Handles an incoming HTTP request by serving prerendered content, performing server-side rendering,\n * or delivering a static file for client-side rendered routes based on the `RenderMode` setting.\n *\n * This method adapts Node.js's `IncomingMessage` or `Http2ServerRequest`\n * to a format compatible with the `AngularAppEngine` and delegates the handling logic to it.\n *\n * @param request - The incoming HTTP request (`IncomingMessage` or `Http2ServerRequest`).\n * @param requestContext - Optional context for rendering, such as metadata associated with the request.\n * @returns A promise that resolves to the resulting HTTP response object, or `null` if no matching Angular route is found.\n *\n * @remarks A request to `https://www.example.com/page/index.html` will serve or render the Angular route\n * corresponding to `https://www.example.com/page`.\n */\n async handle(request, requestContext) {\n const webRequest = createWebRequestFromNodeRequest(request);\n return this.angularAppEngine.handle(webRequest, requestContext);\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 * Attaches metadata to the handler function to mark it as a special handler for Node.js environments.\n *\n * @typeParam T - The type of the handler function.\n * @param handler - The handler function to be defined and annotated.\n * @returns The same handler function passed as an argument, with metadata attached.\n *\n * @example\n * Usage in an Express application:\n * ```ts\n * const app = express();\n * export default createNodeRequestHandler(app);\n * ```\n *\n * @example\n * Usage in a Hono application:\n * ```ts\n * const app = new Hono();\n * export default createNodeRequestHandler(async (req, res, next) => {\n * try {\n * const webRes = await app.fetch(createWebRequestFromNodeRequest(req));\n * if (webRes) {\n * await writeResponseToNodeResponse(webRes, res);\n * } else {\n * next();\n * }\n * } catch (error) {\n * next(error);\n * }\n * }));\n * ```\n *\n * @example\n * Usage in a Fastify application:\n * ```ts\n * const app = Fastify();\n * export default createNodeRequestHandler(async (req, res) => {\n * await app.ready();\n * app.server.emit('request', req, res);\n * res.send('Hello from Fastify with Node Next Handler!');\n * }));\n * ```\n * @developerPreview\n */\nexport function createNodeRequestHandler(handler) {\n handler['__ng_node_request_handler__'] = true;\n return handler;\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 * or `Http2ServerResponse`.\n *\n * This function adapts the web `Response` object to write its content\n * to a Node.js response object, handling both HTTP/1.1 and HTTP/2.\n *\n * @param source - The web-standard `Response` object to stream from.\n * @param destination - The Node.js response object (`ServerResponse` or `Http2ServerResponse`) 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 */\nimport { argv } from 'node:process';\nimport { fileURLToPath } from 'node:url';\n/**\n * Determines whether the provided URL represents the main entry point module.\n *\n * This function checks if the provided URL corresponds to the main ESM module being executed directly.\n * It's useful for conditionally executing code that should only run when a module is the entry point,\n * such as starting a server or initializing an application.\n *\n * It performs two key checks:\n * 1. Verifies if the URL starts with 'file:', ensuring it is a local file.\n * 2. Compares the URL's resolved file path with the first command-line argument (`process.argv[1]`),\n * which points to the file being executed.\n *\n * @param url The URL of the module to check. This should typically be `import.meta.url`.\n * @returns `true` if the provided URL represents the main entry point, otherwise `false`.\n * @developerPreview\n */\nexport function isMainModule(url) {\n return url.startsWith('file:') && argv[1] === fileURLToPath(url);\n}\n"],"names":["InlineCriticalCssProcessor","URL","ɵSERVER_CONTEXT"],"mappings":";;;;;;;;AASO,MAAM,sCAAsC,CAAC;AACpD,IAAI,aAAa,GAAG,IAAI,GAAG,EAAE;AAC7B,IAAI,MAAM,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE;AACpC,QAAQ,MAAM,QAAQ,GAAG,IAAIA,2BAA0B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ACA;AACO,SAAS,YAAY,CAAC,GAAG,EAAE;AAClC,IAAI,OAAO,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,GAAG,CAAC;AACpE;;;;"}
package/fesm2022/ssr.mjs CHANGED
@@ -25,7 +25,7 @@ class ServerAssets {
25
25
  * @throws Error - Throws an error if the asset does not exist.
26
26
  */
27
27
  getServerAsset(path) {
28
- const asset = this.manifest.assets.get(path);
28
+ const asset = this.manifest.assets[path];
29
29
  if (!asset) {
30
30
  throw new Error(`Server asset '${path}' does not exist.`);
31
31
  }
@@ -38,7 +38,7 @@ class ServerAssets {
38
38
  * @returns A boolean indicating whether the asset exists.
39
39
  */
40
40
  hasServerAsset(path) {
41
- return this.manifest.assets.has(path);
41
+ return !!this.manifest.assets[path];
42
42
  }
43
43
  /**
44
44
  * Retrieves the asset for 'index.server.html'.
@@ -366,6 +366,39 @@ function isNgModule(value) {
366
366
  return 'ɵmod' in value;
367
367
  }
368
368
 
369
+ /**
370
+ * Creates a promise that resolves with the result of the provided `promise` or rejects with an
371
+ * `AbortError` if the `AbortSignal` is triggered before the promise resolves.
372
+ *
373
+ * @param promise - The promise to monitor for completion.
374
+ * @param signal - An `AbortSignal` used to monitor for an abort event. If the signal is aborted,
375
+ * the returned promise will reject.
376
+ * @param errorMessagePrefix - A custom message prefix to include in the error message when the operation is aborted.
377
+ * @returns A promise that either resolves with the value of the provided `promise` or rejects with
378
+ * an `AbortError` if the `AbortSignal` is triggered.
379
+ *
380
+ * @throws {AbortError} If the `AbortSignal` is triggered before the `promise` resolves.
381
+ */
382
+ function promiseWithAbort(promise, signal, errorMessagePrefix) {
383
+ return new Promise((resolve, reject) => {
384
+ const abortHandler = () => {
385
+ reject(new DOMException(`${errorMessagePrefix} was aborted.\n${signal.reason}`, 'AbortError'));
386
+ };
387
+ // Check for abort signal
388
+ if (signal.aborted) {
389
+ abortHandler();
390
+ return;
391
+ }
392
+ signal.addEventListener('abort', abortHandler, { once: true });
393
+ promise
394
+ .then(resolve)
395
+ .catch(reject)
396
+ .finally(() => {
397
+ signal.removeEventListener('abort', abortHandler);
398
+ });
399
+ });
400
+ }
401
+
369
402
  /**
370
403
  * Different rendering modes for server routes.
371
404
  * @see {@link provideServerRoutesConfig}
@@ -969,47 +1002,53 @@ async function getRoutesFromAngularRouterConfig(bootstrap, document, url, invoke
969
1002
  * Asynchronously extracts routes from the Angular application configuration
970
1003
  * and creates a `RouteTree` to manage server-side routing.
971
1004
  *
972
- * @param url - The URL for server-side rendering. The URL is used to configure `ServerPlatformLocation`. This configuration is crucial
973
- * for ensuring that API requests for relative paths succeed, which is essential for accurate route extraction.
974
- * See:
975
- * - https://github.com/angular/angular/blob/d608b857c689d17a7ffa33bbb510301014d24a17/packages/platform-server/src/location.ts#L51
976
- * - https://github.com/angular/angular/blob/6882cc7d9eed26d3caeedca027452367ba25f2b9/packages/platform-server/src/http.ts#L44
977
- * @param manifest - An optional `AngularAppManifest` that contains the application's routing and configuration details.
978
- * If not provided, the default manifest is retrieved using `getAngularAppManifest()`.
979
- * @param invokeGetPrerenderParams - A boolean flag indicating whether to invoke `getPrerenderParams` for parameterized SSG routes
980
- * to handle prerendering paths. Defaults to `false`.
981
- * @param includePrerenderFallbackRoutes - A flag indicating whether to include fallback routes in the result. Defaults to `true`.
1005
+ * @param options - An object containing the following options:
1006
+ * - `url`: The URL for server-side rendering. The URL is used to configure `ServerPlatformLocation`. This configuration is crucial
1007
+ * for ensuring that API requests for relative paths succeed, which is essential for accurate route extraction.
1008
+ * See:
1009
+ * - https://github.com/angular/angular/blob/d608b857c689d17a7ffa33bbb510301014d24a17/packages/platform-server/src/location.ts#L51
1010
+ * - https://github.com/angular/angular/blob/6882cc7d9eed26d3caeedca027452367ba25f2b9/packages/platform-server/src/http.ts#L44
1011
+ * - `manifest`: An optional `AngularAppManifest` that contains the application's routing and configuration details.
1012
+ * If not provided, the default manifest is retrieved using `getAngularAppManifest()`.
1013
+ * - `invokeGetPrerenderParams`: A boolean flag indicating whether to invoke `getPrerenderParams` for parameterized SSG routes
1014
+ * to handle prerendering paths. Defaults to `false`.
1015
+ * - `includePrerenderFallbackRoutes`: A flag indicating whether to include fallback routes in the result. Defaults to `true`.
1016
+ * - `signal`: An optional `AbortSignal` that can be used to abort the operation.
982
1017
  *
983
1018
  * @returns A promise that resolves to an object containing:
984
1019
  * - `routeTree`: A populated `RouteTree` containing all extracted routes from the Angular application.
985
1020
  * - `appShellRoute`: The specified route for the app-shell, if configured.
986
1021
  * - `errors`: An array of strings representing any errors encountered during the route extraction process.
987
1022
  */
988
- async function extractRoutesAndCreateRouteTree(url, manifest = getAngularAppManifest(), invokeGetPrerenderParams = false, includePrerenderFallbackRoutes = true) {
989
- const routeTree = new RouteTree();
990
- const document = await new ServerAssets(manifest).getIndexServerHtml().text();
991
- const bootstrap = await manifest.bootstrap();
992
- const { baseHref, appShellRoute, routes, errors } = await getRoutesFromAngularRouterConfig(bootstrap, document, url, invokeGetPrerenderParams, includePrerenderFallbackRoutes);
993
- for (const { route, ...metadata } of routes) {
994
- if (metadata.redirectTo !== undefined) {
995
- metadata.redirectTo = joinUrlParts(baseHref, metadata.redirectTo);
996
- }
997
- // Remove undefined fields
998
- // Helps avoid unnecessary test updates
999
- for (const [key, value] of Object.entries(metadata)) {
1000
- if (value === undefined) {
1001
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1002
- delete metadata[key];
1023
+ function extractRoutesAndCreateRouteTree(options) {
1024
+ const { url, manifest = getAngularAppManifest(), invokeGetPrerenderParams = false, includePrerenderFallbackRoutes = true, signal, } = options;
1025
+ async function extract() {
1026
+ const routeTree = new RouteTree();
1027
+ const document = await new ServerAssets(manifest).getIndexServerHtml().text();
1028
+ const bootstrap = await manifest.bootstrap();
1029
+ const { baseHref, appShellRoute, routes, errors } = await getRoutesFromAngularRouterConfig(bootstrap, document, url, invokeGetPrerenderParams, includePrerenderFallbackRoutes);
1030
+ for (const { route, ...metadata } of routes) {
1031
+ if (metadata.redirectTo !== undefined) {
1032
+ metadata.redirectTo = joinUrlParts(baseHref, metadata.redirectTo);
1033
+ }
1034
+ // Remove undefined fields
1035
+ // Helps avoid unnecessary test updates
1036
+ for (const [key, value] of Object.entries(metadata)) {
1037
+ if (value === undefined) {
1038
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1039
+ delete metadata[key];
1040
+ }
1003
1041
  }
1042
+ const fullRoute = joinUrlParts(baseHref, route);
1043
+ routeTree.insert(fullRoute, metadata);
1004
1044
  }
1005
- const fullRoute = joinUrlParts(baseHref, route);
1006
- routeTree.insert(fullRoute, metadata);
1045
+ return {
1046
+ appShellRoute,
1047
+ routeTree,
1048
+ errors,
1049
+ };
1007
1050
  }
1008
- return {
1009
- appShellRoute,
1010
- routeTree,
1011
- errors,
1012
- };
1051
+ return signal ? promiseWithAbort(extract(), signal, 'Routes extraction') : extract();
1013
1052
  }
1014
1053
 
1015
1054
  /**
@@ -1142,7 +1181,7 @@ class ServerRouter {
1142
1181
  }
1143
1182
  // Create and store a new promise for the build process.
1144
1183
  // This prevents concurrent builds by re-using the same promise.
1145
- ServerRouter.#extractionPromise ??= extractRoutesAndCreateRouteTree(url, manifest)
1184
+ ServerRouter.#extractionPromise ??= extractRoutesAndCreateRouteTree({ url, manifest })
1146
1185
  .then(({ routeTree, errors }) => {
1147
1186
  if (errors.length > 0) {
1148
1187
  throw new Error('Error(s) occurred while extracting routes:\n' +
@@ -1587,10 +1626,7 @@ class AngularServerApp {
1587
1626
  return response;
1588
1627
  }
1589
1628
  }
1590
- return Promise.race([
1591
- this.waitForRequestAbort(request),
1592
- this.handleRendering(request, matchedRoute, requestContext),
1593
- ]);
1629
+ return promiseWithAbort(this.handleRendering(request, matchedRoute, requestContext), request.signal, `Request for: ${request.url}`);
1594
1630
  }
1595
1631
  /**
1596
1632
  * Handles serving a prerendered static asset if available for the matched route.
@@ -1611,8 +1647,7 @@ class AngularServerApp {
1611
1647
  if (method !== 'GET' && method !== 'HEAD') {
1612
1648
  return null;
1613
1649
  }
1614
- const { pathname } = stripIndexHtmlFromURL(new URL(request.url));
1615
- const assetPath = stripLeadingSlash(joinUrlParts(pathname, 'index.html'));
1650
+ const assetPath = this.buildServerAssetPathFromRequest(request);
1616
1651
  if (!this.assets.hasServerAsset(assetPath)) {
1617
1652
  return null;
1618
1653
  }
@@ -1645,6 +1680,7 @@ class AngularServerApp {
1645
1680
  if (!this.allowStaticRouteRender && renderMode === RenderMode.Prerender) {
1646
1681
  return null;
1647
1682
  }
1683
+ const url = new URL(request.url);
1648
1684
  const platformProviders = [];
1649
1685
  // Initialize the response with status and headers if available.
1650
1686
  const responseInit = {
@@ -1669,7 +1705,9 @@ class AngularServerApp {
1669
1705
  }
1670
1706
  else if (renderMode === RenderMode.Client) {
1671
1707
  // Serve the client-side rendered version if the route is configured for CSR.
1672
- return new Response(await this.assets.getServerAsset('index.csr.html').text(), responseInit);
1708
+ let html = await this.assets.getServerAsset('index.csr.html').text();
1709
+ html = await this.runTransformsOnHtml(html, url);
1710
+ return new Response(html, responseInit);
1673
1711
  }
1674
1712
  const { manifest: { bootstrap, inlineCriticalCss, locale }, hooks, assets, } = this;
1675
1713
  if (locale !== undefined) {
@@ -1678,13 +1716,9 @@ class AngularServerApp {
1678
1716
  useValue: locale,
1679
1717
  });
1680
1718
  }
1681
- const url = new URL(request.url);
1682
- let html = await assets.getIndexServerHtml().text();
1683
- // Skip extra microtask if there are no pre hooks.
1684
- if (hooks.has('html:transform:pre')) {
1685
- html = await hooks.run('html:transform:pre', { html, url });
1686
- }
1687
1719
  this.boostrap ??= await bootstrap();
1720
+ let html = await assets.getIndexServerHtml().text();
1721
+ html = await this.runTransformsOnHtml(html, url);
1688
1722
  html = await renderAngular(html, this.boostrap, url, platformProviders, SERVER_CONTEXT_VALUE[renderMode]);
1689
1723
  if (inlineCriticalCss) {
1690
1724
  // Optionally inline critical CSS.
@@ -1716,20 +1750,41 @@ class AngularServerApp {
1716
1750
  return new Response(html, responseInit);
1717
1751
  }
1718
1752
  /**
1719
- * Returns a promise that rejects if the request is aborted.
1753
+ * Constructs the asset path on the server based on the provided HTTP request.
1720
1754
  *
1721
- * @param request - The HTTP request object being monitored for abortion.
1722
- * @returns A promise that never resolves and rejects with an `AbortError`
1723
- * if the request is aborted.
1724
- */
1725
- waitForRequestAbort(request) {
1726
- return new Promise((_, reject) => {
1727
- request.signal.addEventListener('abort', () => {
1728
- const abortError = new Error(`Request for: ${request.url} was aborted.\n${request.signal.reason}`);
1729
- abortError.name = 'AbortError';
1730
- reject(abortError);
1731
- }, { once: true });
1732
- });
1755
+ * This method processes the incoming request URL to derive a path corresponding
1756
+ * to the requested asset. It ensures the path points to the correct file (e.g.,
1757
+ * `index.html`) and removes any base href if it is not part of the asset path.
1758
+ *
1759
+ * @param request - The incoming HTTP request object.
1760
+ * @returns The server-relative asset path derived from the request.
1761
+ */
1762
+ buildServerAssetPathFromRequest(request) {
1763
+ let { pathname: assetPath } = new URL(request.url);
1764
+ if (!assetPath.endsWith('/index.html')) {
1765
+ // Append "index.html" to build the default asset path.
1766
+ assetPath = joinUrlParts(assetPath, 'index.html');
1767
+ }
1768
+ const { baseHref } = this.manifest;
1769
+ // Check if the asset path starts with the base href and the base href is not (`/` or ``).
1770
+ if (baseHref.length > 1 && assetPath.startsWith(baseHref)) {
1771
+ // Remove the base href from the start of the asset path to align with server-asset expectations.
1772
+ assetPath = assetPath.slice(baseHref.length);
1773
+ }
1774
+ return stripLeadingSlash(assetPath);
1775
+ }
1776
+ /**
1777
+ * Runs the registered transform hooks on the given HTML content.
1778
+ *
1779
+ * @param html - The raw HTML content to be transformed.
1780
+ * @param url - The URL associated with the HTML content, used for context during transformations.
1781
+ * @returns A promise that resolves to the transformed HTML string.
1782
+ */
1783
+ async runTransformsOnHtml(html, url) {
1784
+ if (this.hooks.has('html:transform:pre')) {
1785
+ html = await this.hooks.run('html:transform:pre', { html, url });
1786
+ }
1787
+ return html;
1733
1788
  }
1734
1789
  }
1735
1790
  let angularServerApp;
@@ -1831,6 +1886,10 @@ class AngularAppEngine {
1831
1886
  * The manifest for the server application.
1832
1887
  */
1833
1888
  manifest = getAngularAppEngineManifest();
1889
+ /**
1890
+ * The number of entry points available in the server application's manifest.
1891
+ */
1892
+ entryPointsCount = Object.keys(this.manifest.entryPoints).length;
1834
1893
  /**
1835
1894
  * A cache that holds entry points, keyed by their potential locale string.
1836
1895
  */
@@ -1889,7 +1948,7 @@ class AngularAppEngine {
1889
1948
  return cachedEntryPoint;
1890
1949
  }
1891
1950
  const { entryPoints } = this.manifest;
1892
- const entryPoint = entryPoints.get(potentialLocale);
1951
+ const entryPoint = entryPoints[potentialLocale];
1893
1952
  if (!entryPoint) {
1894
1953
  return undefined;
1895
1954
  }
@@ -1909,8 +1968,8 @@ class AngularAppEngine {
1909
1968
  * @returns A promise that resolves to the entry point exports or `undefined` if not found.
1910
1969
  */
1911
1970
  getEntryPointExportsForUrl(url) {
1912
- const { entryPoints, basePath } = this.manifest;
1913
- if (entryPoints.size === 1) {
1971
+ const { basePath } = this.manifest;
1972
+ if (this.entryPointsCount === 1) {
1914
1973
  return this.getEntryPointExports('');
1915
1974
  }
1916
1975
  const potentialLocale = getPotentialLocaleIdFromUrl(url, basePath);