/// import type { LwrErrorRoute, LwrRoute, RouteHandlerFunction, RouteHandlerView, View } from './config.js'; import type { AssetSource, BundleDefinition, Endpoints, FlattenedModuleGraphs, ImportMetadata, Json, LwrStringBuilder, ResourceDefinition, RuntimeEnvironment, RuntimeParams, Specifier, ServerData, UriDefinition } from './index.js'; export type ViewIdentity = Pick; export interface ViewSource { name: string; slug: string; ownHash: string; originalSource: string; filePath: string; } export interface CompiledView extends ViewSource { viewId: ViewIdentity; layoutTemplate?: string; immutable?: boolean; properties?: { [key: string]: unknown; }; render: (context: Record, runtimeEnvironment: RuntimeEnvironment) => Promise; } export type NormalizedRenderingResult = Required>; export interface RenderingResult { renderedView: string; metadata?: RenderedViewMetadata; options?: RenderOptions; cache?: CacheResponse; } export interface RenderedView extends NormalizedRenderingResult { compiledView: CompiledView; } export interface CustomElementReference { tagName: string; props?: { [name: string]: string; }; children?: CustomElementReference[]; location?: { startOffset: number; endOffset: number; }; } export interface RenderedViewMetadata { customElements: CustomElementReference[]; assetReferences: AssetReference[]; serverBundles?: Set; serverData?: ServerData; serverDebug?: { warnings?: (Error | string)[]; }; } export interface HtmlMetadata { customElements: CustomElementReference[]; assetReferences: AssetReference[]; } export interface RenderedAssetReference { url: string; tagName?: string; override?: UriDefinition; integrity?: string; } export interface AssetReference extends RenderedAssetReference { importer?: string; relative: boolean; location?: { startOffset: number; endOffset: number; }; } export interface CustomElementRecord { elementName: string; flatGraph: FlattenedModuleGraphs; } export interface RenderedViewRecord { resources?: ResourceDefinition[]; assetReferences?: RenderedAssetReference[]; customElements?: CustomElementRecord[]; serverBundles?: Set; endpoints?: Endpoints; importMetadata?: ImportMetadata; moduleResources: ResourceDefinition[]; bootstrapModule?: { specifier: Specifier; flatGraph: FlattenedModuleGraphs; resources?: ResourceDefinition[]; }; } export interface LinkedViewDefinition { renderedView: string; viewRecord: RenderedViewRecord; immutable: boolean; cache?: CacheResponse; nonce?: string; } export interface ViewRequestQs { [key: string]: undefined | string | string[]; } export interface ViewRequest { url: string; originalUrl?: string; requestPath: string; params?: any; query?: ViewRequestQs; routeHandlerFunction?: RouteHandlerFunction; } export interface CacheResponse { ttl?: string | number; } export interface ViewResponse { status?: number; body: Buffer | string | boolean | Json; cache?: CacheResponse; headers?: Record; cookie?: 'wip'; metadata?: { viewDefinition?: LinkedViewDefinition; }; locale?: string; } export type RouteHandlerViewResponse = ViewDefinitionResponse | ViewResponse; export interface ViewDefinitionResponse { status?: number; view: RouteHandlerView; viewParams: ViewParams; renderOptions?: RenderOptions; cache?: CacheResponse; headers?: Record; cookie?: 'wip'; locale?: string; metadata?: { viewDefinition?: LinkedViewDefinition; }; } export interface ViewProvider { name: string; initialize(): Promise; getView(viewId: ViewIdentity): Promise; } export interface ViewTransformPluginContext { config: { cacheDir: string; }; view: View; viewParams: ViewParams; runtimeEnvironment: RuntimeEnvironment; runtimeParams: RuntimeParams; renderOptions: Required; contentIds: { lwrResourcesId: string; }; importer?: string; } type ViewPluginLinkHook = (builder: LwrStringBuilder, viewContext: ViewTransformPluginContext, viewMetadata: RenderedViewMetadata) => Promise; type ViewPluginLinkHookReturn = void | null | undefined | false | LwrStringBuilder | { builder?: LwrStringBuilder; cache?: CacheResponse; serverBundles?: Set; }; type ViewPluginOptimizeHook = (code: string, assetSource: AssetSource) => Promise; type ViewPluginOptimizeHookReturn = null | undefined | false | string | { code: string; map?: any; }; export interface ViewTransformHooks { link: ViewPluginLinkHook; optimize: ViewPluginOptimizeHook; } export interface ViewTransformPlugin extends Partial { name: string; } export type ViewParams = Record; export interface ViewInfo { id: string; url: string; configAsSrc: boolean; mixedMode: boolean; nonce?: string; ssr: boolean; } export interface RenderOptions { skipMetadataCollection?: boolean; freezeAssets?: boolean; viewParamCacheKey?: Json; } export interface ViewPageContext { id: string; title?: string; url: string; assetBasePath?: string; basePath?: string; locale?: string; nonce?: string; uiBasePath?: string; } export type ViewModuleResourceContext = { isPreload?: boolean; isSSR?: boolean; async?: boolean; nonce?: string; integrity?: string; }; export interface ViewRegistry { addViewProviders(providers: ViewProvider[]): void; addViewTransformers(transformers: ViewTransformPlugin[]): void; initializeViewProviders(): Promise; getView(viewId: ViewIdentity): Promise; getViewDefinition(view: View, viewParams: ViewParams, runtimeEnvironment: R, runtimeParams?: RuntimeParams, renderOptions?: RenderOptions): Promise; hasViewDefinition(view: View, viewParams: ViewParams, runtimeEnvironment: R, runtimeParams?: RuntimeParams, renderOptions?: RenderOptions): boolean; getPublicApi(): PublicViewRegistry; } export type PublicViewRegistry = Pick; export interface ViewHandler { getViewContent(viewRequest: ViewRequest, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): Promise; getViewJson(viewRequest: ViewRequest, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): Promise; getViewConfiguration(viewRequest: ViewRequest, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): Promise; } export interface SsrRequestContext { props: Json; url: string; params: { [key: string]: string; }; query: ViewRequestQs; locale: string; basePath: string; crossRequestCache: Record; } export type MetaTag = { name?: string; httpEquiv?: string; content?: string; property?: string; itemprop?: string; }; export type LinkTag = { href: string; as?: string; rel?: string; fetchpriority?: 'high' | 'low' | 'auto'; type?: string; sizes?: string; hreflang?: string; media?: string; crossorigin?: string; }; export interface HeadMarkup { title?: string; meta?: MetaTag[]; scripts?: { body: string; }[]; links?: LinkTag[]; styles?: { body: string; id?: string; }[]; } export interface SsrDataResponse { props?: { [prop: string]: Json; }; markup?: HeadMarkup; cache?: CacheResponse; warnings?: (Error | string)[]; } export interface DirectToCoreProxy { origin: string; host?: string; servername?: string; } export {}; //# sourceMappingURL=views.d.ts.map