export declare class FragmentGateway { #private; private fragmentConfigs; private routeMap; constructor(config?: FragmentGatewayConfig); get piercingStyles(): string | undefined; /** * Registers a fragment in the gateway worker so that it can be integrated * with the gateway worker. * * @param fragmentConfig Configuration object for the fragment. */ registerFragment(fragmentConfig: FragmentConfig): void; matchRequestToFragment(urlPath: string, requestFragmentId?: string): FragmentConfig | null | undefined; } /** * Configuration object for the registration of a fragment in the app's gateway worker. */ export interface FragmentConfig { /** * Unique Id for the fragment. */ fragmentId: string; /** * Whether the fragment should be pierced into the app shell on the server-side by the fragment gateway. * * Defaults to true. */ piercing?: boolean; /** * Styles to apply to the fragment before it gets pierced, their purpose * is to style the fragment in such a way to make it look as close as possible * to the final pierced view (so that the piercing operation can look seamless). * * For best results they should use the following selector: * :not(web-fragment) > web-fragment-host[fragment-id="fragmentId"] */ piercingClassNames?: string[]; /** * @deprecated use `piercingClassNames` instead * */ prePiercingClassNames?: string[]; /** * An array of route patterns this fragment should handle serving. * Pattern format must adhere to https://github.com/pillarjs/path-to-regexp#parameters syntax */ routePatterns: string[]; /** * The endpoint URL of the fragment application, or a `fetch` function compatible with the standard [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). * This will be fetched on any request paths matching the specified `routePatterns` */ endpoint: string | typeof fetch; /** * @deprecated use `endpoint` instead */ upstream?: string; /** * An optional list of fragment response headers to append to the combined response from the fragment gateway created by piercing the fragment into the host response. */ forwardFragmentHeaders?: string[]; /** * An optional list of headers to append to the iframe response when initializing the reframed iframe. */ iframeHeaders?: Record; /** * Handler/Fallback to apply when the fetch for a fragment ssr code fails. * It allows the gateway to serve the provided fallback response instead of an error response straight * from the server. * * @param req the request sent to the fragment * @param failedRes the failed response (with a 4xx or 5xx status) or the thrown error * @returns the response to use for the document's ssr */ onSsrFetchError?: (req: Request, failedResOrError: Response | Error) => SSRFetchErrorResponse | Promise; } export interface SSRFetchErrorResponse { response: Response; overrideResponse?: boolean; } export interface FragmentGatewayConfig { piercingStyles?: string; /** * @deprecated use `piercingStyles` instead */ prePiercingStyles?: string; } export interface FragmentMiddlewareOptions { additionalHeaders?: HeadersInit; mode?: 'production' | 'development'; }