import { CacheHandler, CacheISRConfig, CacheData, ISRHandlerConfig, CacheKeyGeneratorFn, InvalidateConfig, VariantRebuildItem, ServeFromCacheConfig, RenderConfig, IsrServiceInterface, IsrState } from '@rx-angular/isr/models'; import * as i0 from '@angular/core'; import { ModuleWithProviders, Provider, EnvironmentProviders } from '@angular/core'; import { IsrService } from '@rx-angular/isr/browser'; import { Request, Response, NextFunction } from 'express'; import * as _angular_common_http from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http'; interface FileSystemCacheOptions { cacheFolderPath: string; prerenderedPagesPath?: string; addPrerenderedPagesToCache?: boolean; } interface FileSystemCacheData { htmlFilePath: string; options: CacheISRConfig; createdAt: number; } declare class FileSystemCacheHandler extends CacheHandler { options: FileSystemCacheOptions; protected cache: Map; private get cacheFolderPath(); constructor(options: FileSystemCacheOptions); add(cacheKey: string, html: string, config?: CacheISRConfig): Promise; get(cacheKey: string): Promise; has(cacheKey: string): Promise; delete(cacheKey: string): Promise; getAll(): Promise; private populateCacheFromFilesystem; clearCache(): Promise; private addPrerenderedPagesToCache; private transferPrerenderedPagesToCacheFolder; private readFromFile; } declare class InMemoryCacheHandler extends CacheHandler { protected cache: Map; constructor(); add(cacheKey: string, html: string, config?: CacheISRConfig): Promise; get(cacheKey: string): Promise; getAll(): Promise; has(cacheKey: string): Promise; delete(cacheKey: string): Promise; clearCache?(): Promise; } declare class IsrModule { private isrService; private platformId; constructor(isrService: IsrService, platformId: object); static forRoot(): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } /** * Logger class for ISR package * @internal */ declare class ISRLogger { private showLogs; constructor(showLogs: boolean); /** * Log a message to the console * @param message The message to log * @param optionalParams Optional parameters to log * @internal */ log(message?: string, ...optionalParams: unknown[]): void; } interface IGeneratedResult { html?: string; errors?: string[]; } declare class CacheGeneration { isrConfig: ISRHandlerConfig; cache: CacheHandler; logger: ISRLogger; private urlsOnHold; constructor(isrConfig: ISRHandlerConfig, cache: CacheHandler, logger: ISRLogger); getCacheKey: CacheKeyGeneratorFn; generate(req: Request, res: Response, providers?: Provider[], mode?: 'regenerate' | 'generate'): Promise; generateWithCacheKey(req: Request, res: Response, cacheKey: string, providers?: Provider[], mode?: 'regenerate' | 'generate'): Promise; } declare class ISRHandler { protected isrConfig: ISRHandlerConfig; protected cache: CacheHandler; protected cacheGeneration: CacheGeneration; protected logger: ISRLogger; constructor(isrConfig: ISRHandlerConfig); invalidate(req: Request, res: Response, config?: InvalidateConfig): Promise; getVariantUrlsToInvalidate(urlsToInvalidate: string[]): VariantRebuildItem[]; serveFromCache(req: Request, res: Response, next: NextFunction, config?: ServeFromCacheConfig): Promise; render(req: Request, res: Response, next: NextFunction, config?: RenderConfig): Promise; } declare class IsrServerService implements IsrServiceInterface { private readonly router; private state; getState(): IsrState; patchState(partialState: Partial): void; getExtra(): Record; /** * Activate the service and listen to router events * @returns void */ activate(): void; /** * Add error to the state * @param error HttpErrorResponse * @returns void * @example * ```typescript * this.isrService.addError(err); * ``` */ addError(error: HttpErrorResponse | Error): void; /** * Add extra data to the state * @param extra Record * @returns void * @example * ```typescript * this.isrService.addExtra({ foo: 'bar' }); * ``` */ addExtra(extra?: Record): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * @description * This function registers the providers needed for ISR to work. * * @returns {EnvironmentProviders} The providers for the application. * * @example * ``` * import { provideISR } from '@rx-angular/isr/server'; * * @NgModule({ * providers: [ provideISR() ] * }) * export class AppServerModule {} * ``` * * To configure ISR in a standalone application: * ``` * const serverConfig: ApplicationConfig = { * providers: [ * provideServerRendering() * provideISR() * ], * }; * export const config = mergeApplicationConfig(appConfig, serverConfig); * ``` */ declare const provideISR: () => EnvironmentProviders; /** * @description * This function registers the providers needed for ISR to work. * * @usage * ```ts * import { isrHttpInterceptors } from '@rx-angular/isr/server'; * * providers: [ * provideHttpClient( * withInterceptors(isrHttpInterceptors) * ) * ] * ``` */ declare const isrHttpInterceptors: _angular_common_http.HttpInterceptorFn[]; export { FileSystemCacheHandler, ISRHandler, InMemoryCacheHandler, IsrModule, IsrServerService, isrHttpInterceptors, provideISR }; export type { FileSystemCacheOptions };