{"version":3,"file":"rx-angular-isr-server.mjs","sources":["../../../../libs/isr/server/src/utils/get-isr-options.ts","../../../../libs/isr/server/src/cache-handlers/filesystem-cache-handler.ts","../../../../libs/isr/server/src/cache-handlers/in-memory-cache-handler.ts","../../../../libs/isr/server/src/isr-server.service.ts","../../../../libs/isr/server/src/http-errors.interceptor.ts","../../../../libs/isr/server/src/utils/add-isr-data-before-serialized.ts","../../../../libs/isr/server/src/isr.module.ts","../../../../libs/isr/server/src/modify-generated-html.ts","../../../../libs/isr/server/src/utils/cache-utils.ts","../../../../libs/isr/server/src/utils/render-url.ts","../../../../libs/isr/server/src/cache-generation.ts","../../../../libs/isr/server/src/isr-logger.ts","../../../../libs/isr/server/src/isr-handler.ts","../../../../libs/isr/server/src/provide-isr.ts","../../../../libs/isr/server/src/rx-angular-isr-server.ts"],"sourcesContent":["/**\n * Get ISR options from html string\n * @param html\n * @returns\n * @example\n * ```typescript\n * const { revalidate, errors } = getRouteISRDataFromHTML(html);\n * ```\n * @internal\n */\nexport function getRouteISRDataFromHTML(html: string): {\n  revalidate: number | null;\n  errors: string[];\n} {\n  const indexOfScriptTag = html?.indexOf(ISR_SCRIPT_TAG);\n\n  // check if script tag is not included\n  if (!html || indexOfScriptTag === -1) {\n    return { revalidate: null, errors: [] };\n  }\n\n  // start from script till the end of html file\n  const isrScript = html.substring(indexOfScriptTag);\n\n  // first occurrence of closing script tag\n  const indexOfCloseScriptTag = isrScript.indexOf('</script>');\n\n  const val = isrScript\n    .substring(0, indexOfCloseScriptTag) // remove close script tag\n    .replace(ISR_SCRIPT_TAG, ''); // remove start script tag\n\n  return JSON.parse(val) as {\n    revalidate: number | null;\n    errors: string[];\n  };\n}\n\n/**\n * Script tag that will be included in the page if one of the routes on the page\n * has `revalidate` key in its route data\n *\n * @internal\n */\nconst ISR_SCRIPT_TAG = '<script id=\"isr-state\" type=\"application/json\">';\n","import {\n  CacheData,\n  CacheHandler,\n  CacheISRConfig,\n} from '@rx-angular/isr/models';\nimport * as fs from 'node:fs';\nimport { join } from 'node:path';\nimport { getRouteISRDataFromHTML } from '../utils/get-isr-options';\n\nexport interface FileSystemCacheOptions {\n  cacheFolderPath: string;\n  prerenderedPagesPath?: string;\n  addPrerenderedPagesToCache?: boolean;\n}\n\ninterface FileSystemCacheData {\n  htmlFilePath: string; // full path to file\n  options: CacheISRConfig;\n  createdAt: number;\n}\n\nexport class FileSystemCacheHandler extends CacheHandler {\n  protected cache = new Map<string, FileSystemCacheData>();\n\n  private get cacheFolderPath(): string {\n    return this.options.cacheFolderPath;\n  }\n\n  constructor(public options: FileSystemCacheOptions) {\n    super();\n\n    if (!options.cacheFolderPath)\n      throw new Error('Cache folder path is required!');\n\n    if (options.addPrerenderedPagesToCache && !options.prerenderedPagesPath) {\n      throw new Error(\n        'Prerendered pages path is required when `addPrerenderedPagesToCache` is enabled!',\n      );\n    }\n\n    this.populateCacheFromFilesystem();\n  }\n\n  async add(\n    cacheKey: string,\n    html: string,\n    config?: CacheISRConfig,\n  ): Promise<void> {\n    return new Promise((resolve, reject) => {\n      // ex: route is like: / or /details/user/1\n\n      // convert route to file name (replace / with __)\n      // ex. /details/user/1 => /details__user__1.html\n      const fileName = convertCacheKeyToFileName(cacheKey) + '.html';\n      const filePath = getFileFullPath(fileName, this.cacheFolderPath);\n\n      fs.writeFile(filePath, html, 'utf-8', (err) => {\n        if (err) reject('Error: 💥 The request was not cached!');\n\n        this.cache.set(cacheKey, {\n          htmlFilePath: filePath,\n          options: config || { revalidate: null },\n          createdAt: Date.now(),\n        });\n\n        resolve();\n      });\n    });\n  }\n\n  get(cacheKey: string): Promise<CacheData> {\n    return new Promise((resolve, reject) => {\n      // ex: route is like: / or /details/user/1\n      // cachedUrl is like: { html: 'full-path-to-cache/__filename.html', options: { revalidate: 60 } }\n      const cachedMeta = this.cache.get(cacheKey);\n\n      if (cachedMeta) {\n        // on html field we have saved path to file\n        this.readFromFile(cachedMeta.htmlFilePath)\n          .then((html) => {\n            const cacheData: CacheData = {\n              html,\n              options: cachedMeta.options,\n              createdAt: cachedMeta.createdAt,\n            };\n            resolve(cacheData);\n          })\n          .catch((err) => {\n            reject(\n              `Error: 💥 Cannot read cache file for route ${cacheKey}: ${cachedMeta.htmlFilePath}, ${err}`,\n            );\n          });\n      } else {\n        reject('Error: 💥 Url is not cached.');\n      }\n    });\n  }\n\n  has(cacheKey: string): Promise<boolean> {\n    return Promise.resolve(this.cache.has(cacheKey));\n  }\n\n  delete(cacheKey: string): Promise<boolean> {\n    return new Promise((resolve, reject) => {\n      const cacheMeta = this.cache.get(cacheKey);\n\n      if (cacheMeta) {\n        fs.unlink(cacheMeta.htmlFilePath, (err) => {\n          if (err) {\n            reject(\n              'Error: 💥 Cannot delete cache file for route ' +\n                cacheKey +\n                `: ${cacheMeta.htmlFilePath}`,\n            );\n          } else {\n            this.cache.delete(cacheKey);\n            resolve(true);\n          }\n        });\n      } else {\n        reject(`Error: 💥 CacheKey: ${cacheKey} is not cached.`);\n      }\n    });\n  }\n\n  getAll(): Promise<string[]> {\n    return Promise.resolve(Array.from(this.cache.keys()));\n  }\n\n  private populateCacheFromFilesystem(): void {\n    if (!fs.existsSync(this.cacheFolderPath)) {\n      console.log('Cache folder does not exist. Creating...');\n\n      fs.mkdir(this.cacheFolderPath, (err) => {\n        if (!err) console.log('Cache folder was created.');\n      });\n    }\n\n    if (this.options.addPrerenderedPagesToCache) {\n      console.log('Adding prerendered pages to cache...');\n      this.addPrerenderedPagesToCache();\n    }\n  }\n\n  override clearCache(): Promise<boolean> {\n    return new Promise((resolve, reject) => {\n      fs.rm(this.cacheFolderPath, { recursive: true, force: true }, (err) => {\n        if (err) {\n          reject('Error: 💥 Cannot delete cache folder.');\n        } else {\n          this.cache.clear();\n          resolve(true);\n        }\n      });\n    });\n  }\n\n  private addPrerenderedPagesToCache() {\n    // move all prerendered pages to cache folder\n    this.transferPrerenderedPagesToCacheFolder();\n\n    // read all files in cache folder and add them to cache\n    const files: string[] = fs.readdirSync(this.cacheFolderPath);\n\n    // '__.html',\n    // '__details.html',\n    // '__details__1.html',\n\n    for (const file of files) {\n      const filePath = join(this.cacheFolderPath, file);\n\n      const fileName = file.replace('.html', ''); // remove .html extension\n      const cacheKey = convertFileNameToCacheKey(fileName);\n\n      const html = fs.readFileSync(filePath, 'utf-8');\n      const { revalidate, errors } = getRouteISRDataFromHTML(html);\n\n      this.cache.set(cacheKey, {\n        htmlFilePath: filePath, // full path to file\n        options: { revalidate, errors },\n        createdAt: Date.now(),\n      });\n\n      console.log('The request was stored in cache! Route: ', cacheKey);\n    }\n  }\n\n  private transferPrerenderedPagesToCacheFolder() {\n    // read all folders in browser folder and check if they have index.html inside\n    // if yes add the folder name to cache as url and index.html as html\n    // then remove the found files because they will be handled by ISR\n\n    const folderPath = this.options.prerenderedPagesPath || '';\n\n    // path is full path to file\n    const pathsToCache: Array<{ path: string; html: string }> = [];\n\n    try {\n      // read all files in folder\n      const files: string[] = fs.readdirSync(folderPath);\n\n      for (const file of files) {\n        const filePath = join(folderPath, file);\n        const isDirectory = fs.statSync(filePath).isDirectory();\n\n        if (file === 'index.html') {\n          const html = fs.readFileSync(filePath, 'utf-8');\n          pathsToCache.push({ path: filePath, html });\n          continue;\n        }\n\n        // if file is directory, read all files inside it\n        if (isDirectory) {\n          // find all index.html files in folder\n          const indexHtmlFiles = findIndexHtmlFilesRecursively(filePath);\n\n          // add all found index.html files to cache\n          pathsToCache.push(...indexHtmlFiles);\n        }\n      }\n    } catch (err) {\n      console.error('ERROR! 💥 ! Cannot read folder: ' + folderPath);\n    }\n\n    for (const { path } of pathsToCache) {\n      // from: '/Users/enea/Documents/GitHub/ngx-isr/dist/ngx-isr-demo/browser/details/1/index.html\n      // to: '/details/1/index.html'\n      const pathWithoutPrerenderedPagesPath = path.replace(\n        this.options.prerenderedPagesPath || '',\n        '',\n      );\n\n      let cacheKey = '';\n      if (pathWithoutPrerenderedPagesPath === '/index.html') {\n        cacheKey = '/';\n      } else {\n        cacheKey = pathWithoutPrerenderedPagesPath\n          .substring(0)\n          .replace('/index.html', '');\n      }\n\n      const newFileName = convertCacheKeyToFileName(cacheKey);\n      const newFilePath =\n        getFileFullPath(newFileName, this.cacheFolderPath) + '.html';\n\n      // console.log({ path, pathWithoutPrerenderedPagesPath, route, newFileName, newFilePath });\n      // this will log:\n      // {\n      //   path: '/Users/enea/Documents/GitHub/ngx-isr/dist/ngx-isr-demo/browser/details/1/index.html',\n      //   pathWithoutPrerenderedPagesPath: '/details/1/index.html',\n      //   route: '/details/1',\n      //   newFileName: '__details__1',\n      //   newFilePath: '/Users/enea/Documents/GitHub/ngx-isr/dist/ngx-isr-demo/browser/cache/__details__1.html'\n      // }\n\n      // copy file to cache folder\n      fs.copyFileSync(path, newFilePath);\n\n      // remove file from the browser folder so that it can be handled by ISR\n      fs.rmSync(path);\n    }\n\n    console.log(\n      `${pathsToCache.length} Prerendered pages were moved to cache folder.`,\n    );\n  }\n\n  private async readFromFile(filePath: string): Promise<string> {\n    return new Promise((resolve, reject) => {\n      fs.readFile(filePath, 'utf-8', (err, data) => {\n        if (err) {\n          console.error('ERROR! 💥 ! Cannot read file: ' + filePath);\n          reject(err);\n        }\n        resolve(data);\n      });\n    });\n  }\n}\n\n/**\n * This function recursively searches for files named 'index.html' in the specified directory and its subdirectories.\n * It returns an array of objects containing the path to each file and its contents as a string.\n * @internal\n * @param {string} path - The string representing the path to the directory to search in.\n * @returns {Array<{ path: string; html: string }>} An array of objects, where each object contains the path and contents of an 'index.html' file found in the specified directory or its subdirectories.\n */\nfunction findIndexHtmlFilesRecursively(\n  path: string,\n): Array<{ path: string; html: string }> {\n  // Initialize an empty array to hold the data for each file found\n  const data: Array<{ path: string; html: string }> = [];\n\n  try {\n    // Read the contents of the specified directory\n    const files = fs.readdirSync(path);\n    // For each file in the directory...\n    files.forEach((file: string) => {\n      const filePath = join(path, file);\n      // If the file is a directory, recursively search it for 'index.html' files\n      if (fs.statSync(filePath).isDirectory()) {\n        data.push(...findIndexHtmlFilesRecursively(filePath));\n      }\n      // If the file is a file named 'index.html', add it to the 'data' array\n      else if (file.includes('index.html')) {\n        const html = fs.readFileSync(filePath, 'utf8');\n        data.push({ path: filePath, html });\n      }\n    });\n  } catch (err) {\n    // If an error occurs, log an error message and return an empty array\n    console.error('ERROR! 💥 ! Cannot read folder: ' + path);\n    return [];\n  }\n\n  // Return the array of data for each 'index.html' file found\n  return data;\n}\n\n/**\n * This function takes a string parameter 'fileName' representing a file name and returns the full path to the file.\n * The full path is obtained by joining the 'cacheFolderPath' string and 'fileName' string using the path separator '/'.\n *\n * @param {string} fileName - The string representing the file name to get the full path for.\n * @param cacheFolderPath - The string representing the path to the cache folder.\n * @returns {string} The string representing the full path to the file.\n */\nfunction getFileFullPath(fileName: string, cacheFolderPath: string): string {\n  // If fileName starts with '/', remove it to prevent double slashes in the file path\n  if (fileName.charAt(0) === '/') {\n    fileName = fileName.slice(1);\n  }\n\n  // Join the cache folder path and the file name using the path separator '/'\n  // Ex. if cacheFolderPath = '/cache' and fileName = 'index.html',\n  // then the full path to the file is '/cache/index.html'\n  return join(cacheFolderPath, '/', fileName);\n}\n\n/**\n * This function takes a string parameter 'route' and replaces all '/' characters in it with '__' and returns the modified string.\n *\n * @internal\n * @param {string} cacheKey - The string representing the route to be converted into a file name.\n * @returns {string} The modified string representing the file name obtained by replacing '/' characters with '__'.\n */\nexport function convertCacheKeyToFileName(cacheKey: string): string {\n  // replace all occurrences of '/' character in the 'route' string with '__' using regular expression\n  return cacheKey\n    .replace(new RegExp('/', 'g'), '__')\n    .replace(new RegExp('\\\\?', 'g'), '++');\n}\n\n/**\n * This function takes a string parameter 'fileName' and replaces all '__' strings in it with '/' and returns the modified string.\n * @param fileName - The string representing the file name to be converted into a route.\n */\nexport function convertFileNameToCacheKey(fileName: string): string {\n  // replace all occurrences of '__' string in the 'fileName' string with '/' using regular expression\n  return fileName\n    .replace(new RegExp('\\\\+\\\\+', 'g'), '?')\n    .replace(new RegExp('__', 'g'), '/');\n}\n","import {\n  CacheData,\n  CacheHandler,\n  CacheISRConfig,\n} from '@rx-angular/isr/models';\n\nconst defaultCacheISRConfig: CacheISRConfig = {\n  revalidate: null,\n  buildId: null,\n};\n\nexport class InMemoryCacheHandler extends CacheHandler {\n  protected cache = new Map<string, CacheData>();\n  constructor() {\n    super();\n  }\n\n  add(\n    cacheKey: string,\n    html: string,\n    config: CacheISRConfig = defaultCacheISRConfig,\n  ): Promise<void> {\n    return new Promise((resolve) => {\n      const cacheData: CacheData = {\n        html,\n        options: config,\n        createdAt: Date.now(),\n      };\n      this.cache.set(cacheKey, cacheData);\n      resolve();\n    });\n  }\n\n  get(cacheKey: string): Promise<CacheData> {\n    return new Promise((resolve, reject) => {\n      if (this.cache.has(cacheKey)) {\n        resolve(this.cache.get(cacheKey) as CacheData);\n      }\n      reject('This url does not exist in cache!');\n    });\n  }\n\n  getAll(): Promise<string[]> {\n    return new Promise((resolve) => {\n      resolve(Array.from(this.cache.keys()));\n    });\n  }\n\n  has(cacheKey: string): Promise<boolean> {\n    return new Promise((resolve) => {\n      resolve(this.cache.has(cacheKey));\n    });\n  }\n\n  delete(cacheKey: string): Promise<boolean> {\n    return new Promise((resolve) => {\n      resolve(this.cache.delete(cacheKey));\n    });\n  }\n\n  override clearCache?(): Promise<boolean> {\n    return new Promise((resolve) => {\n      this.cache.clear();\n      resolve(true);\n    });\n  }\n}\n","import { HttpErrorResponse } from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { ChildActivationEnd, Router } from '@angular/router';\nimport { IsrServiceInterface, IsrState } from '@rx-angular/isr/models';\nimport { filter, map, take } from 'rxjs/operators';\n\nconst initialState: IsrState = {\n  revalidate: null,\n  errors: [],\n  extra: {},\n};\n\n@Injectable({ providedIn: 'root' })\nexport class IsrServerService implements IsrServiceInterface {\n  private readonly router = inject(Router);\n  private state: IsrState = initialState;\n\n  getState(): IsrState {\n    return this.state;\n  }\n\n  patchState(partialState: Partial<IsrState>): void {\n    this.state = { ...this.state, ...partialState };\n  }\n\n  getExtra(): Record<string, unknown> {\n    return this.state.extra;\n  }\n\n  /**\n   * Activate the service and listen to router events\n   * @returns void\n   */\n  activate(): void {\n    this.router.events\n      .pipe(\n        filter((e) => 'snapshot' in e),\n        map((event) => {\n          let snapshot = (event as ChildActivationEnd).snapshot;\n          // get the last child route\n          while (snapshot.firstChild !== null) {\n            snapshot = snapshot.firstChild;\n          }\n          // get the data from the last child route\n          return snapshot.data;\n        }),\n        take(1),\n      )\n      .subscribe((data) => {\n        // if revalidate is defined, set it\n        if (typeof data?.['revalidate'] === 'number') {\n          this.patchState({ revalidate: data['revalidate'] });\n        }\n      });\n  }\n\n  /**\n   * Add error to the state\n   * @param error HttpErrorResponse\n   * @returns void\n   * @example\n   * ```typescript\n   * this.isrService.addError(err);\n   * ```\n   */\n  addError(error: HttpErrorResponse | Error): void {\n    this.patchState({ errors: [...this.getState().errors, error] });\n  }\n\n  /**\n   * Add extra data to the state\n   * @param extra Record<string, any>\n   * @returns void\n   * @example\n   * ```typescript\n   * this.isrService.addExtra({ foo: 'bar' });\n   * ```\n   */\n  addExtra(extra: Record<string, unknown> = {}): void {\n    this.patchState({ extra: { ...this.getExtra(), ...extra } });\n  }\n}\n","import {\n  HTTP_INTERCEPTORS,\n  HttpEvent,\n  HttpHandler,\n  HttpHandlerFn,\n  HttpInterceptor,\n  HttpInterceptorFn,\n  HttpRequest,\n} from '@angular/common/http';\nimport { inject, Injectable, Provider } from '@angular/core';\nimport { catchError, Observable, throwError } from 'rxjs';\nimport { IsrServerService } from './isr-server.service';\n\nexport const httpErrorInterceptorISR: HttpInterceptorFn = (\n  req: HttpRequest<unknown>,\n  next: HttpHandlerFn,\n) => {\n  const isrService = inject(IsrServerService);\n\n  return next(req).pipe(\n    catchError((err) => {\n      isrService.addError(err);\n      return throwError(() => err);\n    }),\n  );\n};\n\n@Injectable()\nexport class HttpErrorsInterceptor implements HttpInterceptor {\n  constructor(private isrService: IsrServerService) {}\n\n  intercept(\n    request: HttpRequest<unknown>,\n    next: HttpHandler,\n  ): Observable<HttpEvent<unknown>> {\n    return next.handle(request).pipe(\n      catchError((err) => {\n        this.isrService.addError(err);\n        return throwError(() => err);\n      }),\n    );\n  }\n}\n\nexport const HTTP_ERROR_PROVIDER_ISR: Provider = {\n  provide: HTTP_INTERCEPTORS,\n  useClass: HttpErrorsInterceptor,\n  multi: true,\n};\n","import { IsrServiceInterface, IsrState } from '@rx-angular/isr/models';\n\ntype ToBeSerializedType = {\n  revalidate: number | null;\n  errors?: Error[];\n  extra?: Record<string, unknown>; // Assuming extra is an object with unknown structure\n};\n\nexport function addIsrDataBeforeSerialized(\n  isrService: IsrServiceInterface,\n  doc: Document,\n): () => Promise<void> {\n  return () => addISRDataToBody(doc, isrService.getState());\n}\n\n// append script with revalidate and errors data for the current route\nfunction addISRDataToBody(\n  doc: Document,\n  { revalidate, errors, extra }: IsrState,\n): Promise<void> {\n  return new Promise<void>((resolve) => {\n    const script = doc.createElement('script');\n    script.id = 'isr-state';\n    script.setAttribute('type', 'application/json');\n\n    let toBeSerialized: ToBeSerializedType = { revalidate };\n    if (errors.length) {\n      toBeSerialized = { ...toBeSerialized, errors };\n    }\n    if (Object.keys(extra).length)\n      toBeSerialized = { ...toBeSerialized, extra };\n\n    script.textContent = JSON.stringify(toBeSerialized);\n    doc.body.appendChild(script);\n    resolve();\n  });\n}\n","import { isPlatformServer } from '@angular/common';\nimport {\n  DOCUMENT,\n  Inject,\n  ModuleWithProviders,\n  NgModule,\n  PLATFORM_ID,\n} from '@angular/core';\nimport { BEFORE_APP_SERIALIZED } from '@angular/platform-server';\nimport { IsrService } from '@rx-angular/isr/browser';\nimport { HTTP_ERROR_PROVIDER_ISR } from './http-errors.interceptor';\nimport { IsrServerService } from './isr-server.service';\nimport { addIsrDataBeforeSerialized } from './utils/add-isr-data-before-serialized';\n\n@NgModule({ providers: [IsrService] })\nexport class IsrModule {\n  constructor(\n    private isrService: IsrService,\n    @Inject(PLATFORM_ID) private platformId: object,\n  ) {\n    // Activate ISR only on the server\n    if (isPlatformServer(platformId)) {\n      isrService.activate();\n    }\n  }\n\n  static forRoot(): ModuleWithProviders<IsrModule> {\n    return {\n      ngModule: IsrModule,\n      providers: [\n        IsrServerService,\n        HTTP_ERROR_PROVIDER_ISR,\n        {\n          provide: IsrService,\n          useExisting: IsrServerService,\n        },\n        {\n          provide: BEFORE_APP_SERIALIZED,\n          useFactory: addIsrDataBeforeSerialized,\n          multi: true,\n          deps: [IsrService, DOCUMENT],\n        },\n      ],\n    };\n  }\n}\n","import { ModifyHtmlCallbackFn } from '@rx-angular/isr/models';\nimport { Request } from 'express';\n\nexport const defaultModifyGeneratedHtml: ModifyHtmlCallbackFn = (\n  req: Request,\n  html: string,\n  revalidateTime?: number | null,\n): string => {\n  const time = new Date().toISOString().replace(/T/, ' ').replace(/\\..+/, '');\n\n  let msg = '<!-- ';\n  msg += `\\n🚀 ISR: Served from cache! \\n⌛ Last updated: ${time}. `;\n  if (revalidateTime)\n    msg += `\\n⏭️ Next refresh is after ${revalidateTime} seconds. `;\n  msg += ' \\n-->';\n  return html + msg;\n};\n","import { RenderVariant } from '@rx-angular/isr/models';\nimport { Request } from 'express';\n\nexport const defaultCacheKeyGenerator = (\n  url: string,\n  allowedQueryParams: string[] | null | undefined,\n  variant: RenderVariant | null,\n): string => {\n  let normalizedUrl = url;\n  if (allowedQueryParams) {\n    // Normalize the URL by removing disallowed query parameters\n    // using http://localhost as the base URL to parse the URL\n    // since the URL constructor requires a base URL to parse relative URLs\n    // it will not be used in the final cache key\n    const urlObj = new URL(url, 'http://localhost');\n    const searchParams = urlObj.searchParams;\n    const filteredSearchParams = new URLSearchParams();\n    searchParams.forEach((value, key) => {\n      if (allowedQueryParams.includes(key)) {\n        filteredSearchParams.append(key, value);\n      }\n    });\n    normalizedUrl = `${urlObj.pathname}${filteredSearchParams.toString() ? '?' + filteredSearchParams.toString() : ''}`;\n  }\n  if (!variant) return normalizedUrl;\n  return `${normalizedUrl}<variantId:${variant.identifier}>`;\n};\n\nexport const getVariant = (\n  req: Request,\n  variants: RenderVariant[] | undefined,\n): RenderVariant | null => {\n  if (!variants) {\n    return null;\n  }\n  return (\n    variants.find((variant: RenderVariant) => variant.detectVariant(req)) ||\n    null\n  );\n};\n","import { APP_BASE_HREF } from '@angular/common';\nimport { Provider, StaticProvider } from '@angular/core';\nimport { ɵSERVER_CONTEXT as SERVER_CONTEXT } from '@angular/platform-server';\nimport {\n  AngularNodeAppEngine,\n  CommonEngine,\n  CommonEngineRenderOptions,\n} from '@angular/ssr/node';\nimport { Request, Response } from 'express';\n\nexport interface RenderUrlConfig {\n  req: Request;\n  res: Response;\n  url: string;\n  indexHtml: string;\n  providers?: Provider[];\n  commonEngine?: CommonEngine;\n  angularAppEngine?: AngularNodeAppEngine;\n  bootstrap?: CommonEngineRenderOptions['bootstrap'];\n  browserDistFolder?: string;\n  inlineCriticalCss?: boolean;\n}\n\nconst EXTRA_PROVIDERS: Provider[] = [\n  { provide: SERVER_CONTEXT, useValue: 'isr' },\n];\n\n// helper method that generates html of an url\nexport const renderUrl = async (options: RenderUrlConfig): Promise<string> => {\n  const {\n    req,\n    res,\n    url,\n    indexHtml,\n    providers,\n    commonEngine,\n    angularAppEngine,\n    bootstrap,\n    browserDistFolder,\n    inlineCriticalCss,\n  } = options;\n\n  // we need to override url of req with the one we have in parameters,\n  // because during invalidate process, the url is not from the request\n  req.url = url;\n  req.originalUrl = url;\n\n  const { protocol, originalUrl, baseUrl, headers } = req;\n  const BASE_URL_PROVIDER: Provider = {\n    provide: APP_BASE_HREF,\n    useValue: baseUrl,\n  };\n\n  return new Promise((resolve, reject) => {\n    const allProviders = providers\n      ? [...providers, ...EXTRA_PROVIDERS] // if providers are provided, we add them to the list\n      : [...EXTRA_PROVIDERS, BASE_URL_PROVIDER]; // if not, we add the default providers\n\n    if (angularAppEngine) {\n      angularAppEngine\n        .handle(req)\n        .then((response) => {\n          if (response) {\n            return response.text();\n          }\n          throw new Error('No response from Angular App Engine');\n        })\n        .then((html) => {\n          resolve(html);\n        })\n        .catch((err) => {\n          reject(err);\n        });\n    } else if (commonEngine) {\n      commonEngine\n        .render({\n          bootstrap,\n          documentFilePath: indexHtml,\n          url: `${protocol}://${headers.host}${originalUrl}`,\n          publicPath: browserDistFolder,\n          inlineCriticalCss: inlineCriticalCss ?? true,\n          providers: [...allProviders] as StaticProvider[], // we need to cast to StaticProvider[] because of a bug in the types\n        })\n        .then((html) => {\n          resolve(html);\n        })\n        .catch((err) => {\n          reject(err);\n        });\n    } else {\n      res.render(\n        indexHtml,\n        { req, providers: allProviders },\n        (err: Error, html: string) => {\n          if (err) {\n            reject(err);\n          } else {\n            resolve(html);\n          }\n        },\n      );\n    }\n  });\n};\n","import { Provider } from '@angular/core';\nimport {\n  CacheHandler,\n  CacheKeyGeneratorFn,\n  ISRHandlerConfig,\n  RenderVariant,\n} from '@rx-angular/isr/models';\nimport { Request, Response } from 'express';\nimport { ISRLogger } from './isr-logger';\nimport { defaultModifyGeneratedHtml } from './modify-generated-html';\nimport { defaultCacheKeyGenerator, getVariant } from './utils/cache-utils';\nimport { getRouteISRDataFromHTML } from './utils/get-isr-options';\nimport { renderUrl, RenderUrlConfig } from './utils/render-url';\n\nexport interface IGeneratedResult {\n  html?: string;\n  errors?: string[];\n}\n\nexport class CacheGeneration {\n  // TODO: make this pluggable because on serverless environments we can't share memory between functions\n  // so we need to use a database or redis cache to store the urls that are on hold if we want to use this feature\n  private urlsOnHold: string[] = []; // urls that have regeneration loading\n\n  constructor(\n    public isrConfig: ISRHandlerConfig,\n    public cache: CacheHandler,\n    public logger: ISRLogger,\n  ) {\n    if (!this.isrConfig.cacheKeyGenerator) {\n      this.isrConfig.cacheKeyGenerator = defaultCacheKeyGenerator;\n    }\n  }\n  getCacheKey: CacheKeyGeneratorFn = (\n    url: string,\n    allowedQueryParams: string[] | null | undefined,\n    variant: RenderVariant | null,\n  ) => {\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    return this.isrConfig.cacheKeyGenerator!(url, allowedQueryParams, variant);\n  };\n\n  async generate(\n    req: Request,\n    res: Response,\n    providers?: Provider[],\n    mode: 'regenerate' | 'generate' = 'regenerate',\n  ): Promise<IGeneratedResult | void> {\n    const { url } = req;\n    const variant = getVariant(req, this.isrConfig.variants);\n    const cacheKey = this.getCacheKey(\n      url,\n      this.isrConfig.allowedQueryParams,\n      variant,\n    );\n\n    return this.generateWithCacheKey(req, res, cacheKey, providers, mode);\n  }\n\n  async generateWithCacheKey(\n    req: Request,\n    res: Response,\n    cacheKey: string,\n    providers?: Provider[],\n    mode: 'regenerate' | 'generate' = 'regenerate',\n  ): Promise<IGeneratedResult | void> {\n    const { url } = req;\n\n    if (mode === 'regenerate') {\n      // only regenerate will use queue to avoid multiple regenerations for the same url\n      // generate mode is used for the request without cache\n      if (this.urlsOnHold.includes(cacheKey)) {\n        this.logger.log('Another generation is on-going for this url...');\n        return;\n      }\n      this.logger.log(`The url: ${cacheKey} is being generated.`);\n\n      this.urlsOnHold.push(cacheKey);\n    }\n\n    const renderUrlConfig: RenderUrlConfig = {\n      req,\n      res,\n      url,\n      indexHtml: this.isrConfig.indexHtml,\n      providers,\n      commonEngine: this.isrConfig.commonEngine,\n      angularAppEngine: this.isrConfig.angularAppEngine,\n      bootstrap: this.isrConfig.bootstrap,\n      browserDistFolder: this.isrConfig.browserDistFolder,\n      inlineCriticalCss: this.isrConfig.inlineCriticalCss,\n    };\n\n    try {\n      const html = await renderUrl(renderUrlConfig);\n      const { revalidate, errors } = getRouteISRDataFromHTML(html);\n\n      // Apply the modify generation callback\n      // If undefined, use the default modifyGeneratedHtml function\n      const finalHtml = this.isrConfig.modifyGeneratedHtml\n        ? this.isrConfig.modifyGeneratedHtml(req, html, revalidate)\n        : defaultModifyGeneratedHtml(req, html, revalidate);\n\n      // if there are errors, don't add the page to cache\n      if (errors?.length && this.isrConfig.skipCachingOnHttpError) {\n        // remove url from urlsOnHold because we want to try to regenerate it again\n        if (mode === 'regenerate') {\n          this.urlsOnHold = this.urlsOnHold.filter((x) => x !== cacheKey);\n        }\n        this.logger.log(\n          `💥 ERROR: Url: ${cacheKey} was not regenerated!`,\n          errors,\n        );\n        return { html: finalHtml, errors };\n      }\n\n      // if revalidate is null we won't cache it\n      // if revalidate is 0, we will never clear the cache automatically\n      // if revalidate is x, we will clear cache every x seconds (after the last request) for that url\n      if (revalidate === null || revalidate === undefined) {\n        // don't do !revalidate because it will also catch \"0\"\n        return { html: finalHtml };\n      }\n\n      // add the regenerated page to cache\n      const addToCache = () => {\n        return this.cache.add(cacheKey, finalHtml, {\n          revalidate,\n          buildId: this.isrConfig.buildId,\n        });\n      };\n\n      try {\n        if (this.isrConfig.nonBlockingRender) {\n          // If enabled, add to cache without waiting (fire-and-forget)\n          addToCache();\n        } else {\n          // If not enabled, wait for cache addition to complete before proceeding\n          await addToCache();\n        }\n      } catch (error) {\n        console.error('Error adding to cache:', error);\n      }\n\n      if (mode === 'regenerate') {\n        // remove from urlsOnHold because we are done\n        this.urlsOnHold = this.urlsOnHold.filter((x) => x !== cacheKey);\n        this.logger.log(`Url: ${cacheKey} was regenerated!`);\n      }\n\n      return { html: finalHtml };\n    } catch (error) {\n      this.logger.log(`Error regenerating url: ${cacheKey}`, error);\n\n      if (mode === 'regenerate') {\n        // Ensure removal from urlsOnHold in case of error\n        this.urlsOnHold = this.urlsOnHold.filter((x) => x !== cacheKey);\n      }\n      throw error;\n    }\n  }\n}\n","/**\n * Logger class for ISR package\n * @internal\n */\nexport class ISRLogger {\n  constructor(private showLogs: boolean) {}\n\n  /**\n   * Log a message to the console\n   * @param message The message to log\n   * @param optionalParams Optional parameters to log\n   * @internal\n   */\n  log(message?: string, ...optionalParams: unknown[]): void {\n    // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n    this.showLogs && console.log(message, ...optionalParams);\n  }\n}\n","import {\n  CacheHandler,\n  InvalidateConfig,\n  ISRHandlerConfig,\n  ModifyHtmlCallbackFn,\n  RenderConfig,\n  ServeFromCacheConfig,\n  VariantRebuildItem,\n} from '@rx-angular/isr/models';\nimport { NextFunction, Request, Response } from 'express';\nimport { CacheGeneration } from './cache-generation';\nimport { InMemoryCacheHandler } from './cache-handlers/in-memory-cache-handler';\nimport { ISRLogger } from './isr-logger';\nimport { getVariant } from './utils/cache-utils';\n\nexport class ISRHandler {\n  protected cache!: CacheHandler;\n  protected cacheGeneration!: CacheGeneration;\n  protected logger: ISRLogger;\n\n  constructor(protected isrConfig: ISRHandlerConfig) {\n    if (!isrConfig) {\n      throw new Error('Provide ISRHandlerConfig!');\n    }\n\n    this.logger = new ISRLogger(this.isrConfig?.enableLogging || false);\n    // if skipCachingOnHttpError is not provided it will default to true\n    isrConfig.skipCachingOnHttpError =\n      isrConfig.skipCachingOnHttpError !== false;\n    // if buildId is not provided it will default to null\n    isrConfig.buildId = isrConfig.buildId || null;\n    // if invalidateSecretToken is not provided it will default to null\n    isrConfig.invalidateSecretToken = isrConfig.invalidateSecretToken || null;\n\n    if (isrConfig.cache && isrConfig.cache instanceof CacheHandler) {\n      this.logger.log('Using custom cache handler!');\n      this.cache = isrConfig.cache;\n    } else {\n      this.logger.log('Using in memory cache handler!');\n      this.cache = new InMemoryCacheHandler();\n    }\n\n    this.cacheGeneration = new CacheGeneration(\n      this.isrConfig,\n      this.cache,\n      this.logger,\n    );\n  }\n\n  async invalidate(\n    req: Request,\n    res: Response,\n    config?: InvalidateConfig,\n  ): Promise<Response> {\n    const { token, urlsToInvalidate } = extractDataFromBody(req);\n\n    if (token !== this.isrConfig.invalidateSecretToken) {\n      return res.json({\n        status: 'error',\n        message: 'Your secret token is wrong!!!',\n      });\n    }\n\n    if (!urlsToInvalidate || !urlsToInvalidate.length) {\n      return res.json({\n        status: 'error',\n        message: 'Please add `urlsToInvalidate` in the payload!',\n      });\n    }\n\n    const notInCache: string[] = [];\n    const urlWithErrors: Record<string, string[]> = {};\n\n    // Include all possible variants in the list of URLs to be invalidated including\n    // their modified request to regenerate the pages\n    const variantUrlsToInvalidate =\n      this.getVariantUrlsToInvalidate(urlsToInvalidate);\n\n    for (const variantUrl of variantUrlsToInvalidate) {\n      const { cacheKey, url, reqSimulator } = variantUrl;\n\n      // check if the url is in cache\n      const urlExists = await this.cache.has(cacheKey);\n\n      if (!urlExists) {\n        notInCache.push(cacheKey);\n        continue;\n      }\n      // override url of req with the one in parameters,\n      req.url = url;\n      try {\n        const result = await this.cacheGeneration.generateWithCacheKey(\n          reqSimulator(req),\n          res,\n          cacheKey,\n          config?.providers,\n          'generate',\n        );\n\n        if (result && result.errors?.length) {\n          urlWithErrors[cacheKey] = result.errors;\n        }\n      } catch (err) {\n        urlWithErrors[cacheKey] = err as string[];\n      }\n    }\n\n    const invalidatedUrls = variantUrlsToInvalidate\n      .map((val) => val.cacheKey)\n      .filter(\n        (cacheKey) =>\n          !notInCache.includes(cacheKey) && !urlWithErrors[cacheKey],\n      );\n\n    if (notInCache.length) {\n      this.logger.log(\n        `Urls: ${notInCache.join(', ')} does not exist in cache.`,\n      );\n    }\n\n    if (Object.keys(urlWithErrors).length) {\n      this.logger.log(\n        `Urls: ${Object.keys(urlWithErrors).join(', ')} had errors while regenerating!`,\n      );\n    }\n\n    if (invalidatedUrls.length) {\n      this.logger.log(`Urls: ${invalidatedUrls.join(', ')} were regenerated!`);\n    }\n\n    const response = {\n      status: 'success',\n      notInCache,\n      urlWithErrors,\n      invalidatedUrls,\n    };\n    return res.json(response);\n  }\n\n  getVariantUrlsToInvalidate(urlsToInvalidate: string[]): VariantRebuildItem[] {\n    const variants = this.isrConfig.variants || [];\n    const result: VariantRebuildItem[] = [];\n\n    const defaultVariant = (req: Request) => req;\n\n    for (const url of urlsToInvalidate) {\n      result.push({ url, cacheKey: url, reqSimulator: defaultVariant });\n      for (const variant of variants) {\n        result.push({\n          url,\n          cacheKey: this.cacheGeneration.getCacheKey(\n            url,\n            this.isrConfig.allowedQueryParams,\n            variant,\n          ),\n          reqSimulator: variant.simulateVariant\n            ? variant.simulateVariant\n            : defaultVariant,\n        });\n      }\n    }\n\n    return result;\n  }\n\n  async serveFromCache(\n    req: Request,\n    res: Response,\n    next: NextFunction,\n    config?: ServeFromCacheConfig,\n  ): Promise<Response | void> {\n    try {\n      const variant = getVariant(req, this.isrConfig.variants);\n      const cacheKey = this.cacheGeneration.getCacheKey(\n        req.url,\n        this.isrConfig.allowedQueryParams,\n        variant,\n      );\n      const cacheData = await this.cache.get(cacheKey);\n      const { html, options: cacheConfig, createdAt } = cacheData;\n\n      const cacheHasBuildId =\n        cacheConfig.buildId !== null && cacheConfig.buildId !== undefined;\n\n      if (cacheHasBuildId && cacheConfig.buildId !== this.isrConfig.buildId) {\n        // Cache is from a different build. Serve user using SSR\n        next();\n        return;\n      }\n\n      // Cache exists. Send it.\n      this.logger.log(`Page was retrieved from cache: `, cacheKey);\n      let finalHtml = html;\n\n      // if the cache is expired, we will regenerate it\n      if (cacheConfig.revalidate && cacheConfig.revalidate > 0) {\n        const lastCacheDateDiff = (Date.now() - createdAt) / 1000; // in seconds\n\n        if (lastCacheDateDiff > cacheConfig.revalidate) {\n          const generate = () => {\n            return this.cacheGeneration.generateWithCacheKey(\n              req,\n              res,\n              cacheKey,\n              config?.providers,\n              'regenerate',\n            );\n          };\n\n          try {\n            // regenerate the page without awaiting, so the user gets the cached page immediately\n            if (this.isrConfig.backgroundRevalidation) {\n              generate();\n            } else {\n              const result = await generate();\n              if (result?.html) {\n                finalHtml = result.html;\n              }\n            }\n          } catch (error) {\n            console.error('Error generating html', error);\n            next();\n          }\n        }\n      }\n\n      return res.send(finalHtml);\n    } catch (error) {\n      // Cache does not exist. Serve user using SSR\n      next();\n    }\n  }\n\n  async render(\n    req: Request,\n    res: Response,\n    next: NextFunction,\n    config?: RenderConfig,\n  ): Promise<Response | void> {\n    // TODO: remove this in a major as a BREAKING CHANGE\n    if (config?.modifyGeneratedHtml) {\n      if (this.isrConfig.modifyGeneratedHtml !== undefined) {\n        console.warn(\n          'You can only specify `modifyGeneratedHtml` once. The one in render function will be removed in the next version.',\n        );\n      }\n      const patchedModifyFn: ModifyHtmlCallbackFn = (\n        req: Request,\n        html: string,\n      ) => {\n        return config.modifyGeneratedHtml?.(req, html) || html;\n      };\n      this.isrConfig['modifyGeneratedHtml'] = patchedModifyFn;\n    }\n\n    try {\n      const result = await this.cacheGeneration.generate(\n        req,\n        res,\n        config?.providers,\n        'generate',\n      );\n      if (!result) {\n        throw new Error('Error while generating the page!');\n      } else {\n        return res.send(result.html);\n      }\n    } catch (error) {\n      next();\n    }\n  }\n}\n\nconst extractDataFromBody = (\n  req: Request,\n): { token: string | null; urlsToInvalidate: string[] } => {\n  const { urlsToInvalidate, token } = req.body as {\n    urlsToInvalidate: string[];\n    token: string;\n  };\n  return { urlsToInvalidate, token };\n};\n","import { isPlatformServer } from '@angular/common';\nimport {\n  DOCUMENT,\n  EnvironmentProviders,\n  inject,\n  makeEnvironmentProviders,\n  PLATFORM_ID,\n  provideEnvironmentInitializer,\n} from '@angular/core';\nimport { BEFORE_APP_SERIALIZED } from '@angular/platform-server';\nimport { IsrService } from '@rx-angular/isr/browser';\nimport {\n  HTTP_ERROR_PROVIDER_ISR,\n  httpErrorInterceptorISR,\n} from './http-errors.interceptor';\nimport { IsrServerService } from './isr-server.service';\nimport { addIsrDataBeforeSerialized } from './utils/add-isr-data-before-serialized';\n\n/**\n * @description\n * This function registers the providers needed for ISR to work.\n *\n * @returns {EnvironmentProviders} The providers for the application.\n *\n * @example\n * ```\n * import { provideISR } from '@rx-angular/isr/server';\n *\n * @NgModule({\n *  providers: [ provideISR() ]\n * })\n * export class AppServerModule {}\n * ```\n *\n * To configure ISR in a standalone application:\n * ```\n * const serverConfig: ApplicationConfig = {\n *   providers: [\n *     provideServerRendering()\n *     provideISR()\n *   ],\n * };\n * export const config = mergeApplicationConfig(appConfig, serverConfig);\n * ```\n */\nexport const provideISR = (): EnvironmentProviders => {\n  return makeEnvironmentProviders([\n    IsrServerService,\n    HTTP_ERROR_PROVIDER_ISR,\n    {\n      provide: IsrService,\n      useExisting: IsrServerService,\n    },\n    {\n      provide: BEFORE_APP_SERIALIZED,\n      useFactory: addIsrDataBeforeSerialized,\n      multi: true,\n      deps: [IsrServerService, DOCUMENT],\n    },\n    provideEnvironmentInitializer(() => {\n      const isrService = inject(IsrService);\n      const platformId = inject(PLATFORM_ID);\n      // Activate ISR only on the server\n      if (isPlatformServer(platformId)) {\n        isrService.activate();\n      }\n    }),\n  ]);\n};\n\n/**\n * @description\n * This function registers the providers needed for ISR to work.\n *\n * @usage\n * ```ts\n * import { isrHttpInterceptors } from '@rx-angular/isr/server';\n *\n * providers: [\n *   provideHttpClient(\n *     withInterceptors(isrHttpInterceptors)\n *   )\n * ]\n * ```\n */\nexport const isrHttpInterceptors = [httpErrorInterceptorISR];\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.IsrServerService","SERVER_CONTEXT"],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;AASG;AACG,SAAU,uBAAuB,CAAC,IAAY,EAAA;IAIlD,MAAM,gBAAgB,GAAG,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC;;IAGtD,IAAI,CAAC,IAAI,IAAI,gBAAgB,KAAK,CAAC,CAAC,EAAE;QACpC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;;;IAIzC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC;;IAGlD,MAAM,qBAAqB,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;IAE5D,MAAM,GAAG,GAAG;AACT,SAAA,SAAS,CAAC,CAAC,EAAE,qBAAqB,CAAC;AACnC,SAAA,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AAE/B,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAGpB;AACH;AAEA;;;;;AAKG;AACH,MAAM,cAAc,GAAG,iDAAiD;;ACtBlE,MAAO,sBAAuB,SAAQ,YAAY,CAAA;AAGtD,IAAA,I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