import type { Uri, UriCancelRequest, UriRequest, UriResponse } from "../lens-core-module/generated-types"; import type { Lens } from "../lens/Lens"; export declare function extractSchemeAndRoute(uri: Uri): { scheme: string; route: string; }; export declare function isUriHandlers(value: unknown): value is UriHandlers; export declare function isUriResponse(value: unknown): value is UriResponse; /** * Provides a way for a lens to call into external services that work under HTTP-like protocol. * @internal */ export interface UriHandler { /** * [scheme]://[route] pattern that this handler processes or an array of patterns. */ uri: Uri | Uri[]; /** * Camera Kit starts applying a Lens. Initialize any state that this handler needs for the application. * This callback follows the session's Lens state and runs before the Lens can send its first URI request. * It also runs for Lenses that send no requests. Each new application, including the same Lens, calls it again. * The application can still fail after this callback. * This callback must be synchronous. Thrown errors are logged as warnings and do not interrupt Lens application. * * @example * ```ts * const replies = new Map void>() * const handler: UriHandler = { * uri: 'app://my-extension', * onLensApply() { replies.clear() }, * handleRequest(request, reply) { replies.set(request.identifier, reply) }, * cancelRequest(request) { replies.delete(request.requestId) }, * onLensRemove() { replies.clear() } * } * ``` */ onLensApply?(lens: Lens): void; /** * Camera Kit ends this handler's current Lens application. Release its resources and stop asynchronous work. * This callback follows the session's Lens state. It runs when another application starts, the application * fails, Lens removal completes, or the session is destroyed. * Each {@link UriHandler.onLensApply} notification has at most one matching removal notification. * The previous application receives this callback before the next receives {@link UriHandler.onLensApply}. * This callback must be synchronous. Thrown errors are logged as warnings. */ onLensRemove?(lens: Lens): void; /** * Called to process the provided request. * @param request Lens request. * @param reply A callback function to send response back. * The function can be called none or multiple number of times. * @param lens Lens the request is coming from. */ handleRequest(request: UriRequest, reply: (response: UriResponse) => void, lens: Lens): void; /** * Called to indicated that URI request initated earlier is cancelled. * @param request Lens request. * @param lens Lens the request is coming from. */ cancelRequest?(request: UriCancelRequest, lens: Lens): void; } /** * Array of {@link UriHandler} objects. * @internal */ export type UriHandlers = UriHandler[]; /** * An extension point for client URI handlers. * @internal */ export declare const uriHandlersFactory: { (): UriHandlers; token: "UriHandlers"; dependencies: []; }; export { Uri, UriCancelRequest, UriRequest, UriResponse } from "../lens-core-module/generated-types"; //# sourceMappingURL=UriHandlers.d.ts.map