import type { Lens, CameraKit, CameraKitSession } from "@snap/camera-kit"; import { TypedCustomEvent, TypedEventTarget } from "@snap/camera-kit"; import type { ListenLensPushResponse_ExcludedLens_Code } from "./generated-api-client/camera_kit/v3/push_to_device"; import type { Code } from "./generated-api-client/core/snap_status_code"; export declare class Push2Web { /** * Use this property to subscribe for the different types of events that can occur during push 2 web execution. * * Subscribe to `error` event to be aware if something has happened during the lens push, * with network communication or any other type of error, * event object also contains detailed explanation of the cause. * * Use `subscriptionChanged` event to be aware when subscription state is changed. * * Use `lensReceived` event to be aware when new lens is received from Lens Studio, * also you can get the additional details about the pushed lens. * * @example *```ts *push2web.events.addEventListener('error', ({ detail }) => { * if (detail.name === 'LensExcludedError') { * console.log(`Lens is excluded from the push, by the following reason: ${detail.reason}.`) * } *}) *``` */ readonly events: TypedEventTarget; private readonly push2WebExtension; private readonly pushedLenses; private accessToken; private subscription?; /** * Create new instance of Push2Web object, * it can be used to start listening for the events, * subscribe or unsubscribe for notifications from Lens Studio. * Also provides the extension object for the @snap/camera-kit package. */ constructor(); /** * The extension object must be passed to the Camera Kit object during its bootstrap process. * This is a requirement for the proper functioning of push to web functionality. * * @example * ```ts *import { bootstrapCameraKit } from "@snap/camera-kit"; * *const push2web = new Push2Web(); *const extensions = (container) => container.provides(push2Web.extension); * *const cameraKit = await bootstrapCameraKit({ apiToken: "token from developer portal" }, extensions); *const cameraKitSession = await cameraKit.createSession(); * ``` */ get extension(): import("@snap/camera-kit").PartialContainer<{ lensSources: import("@snap/camera-kit").LensSource[]; externalMetrics: import("rxjs").Observable[]; }, { externalMetrics: import("rxjs").Observable[]; }>; /** * Initiate subscription for the events from Lens Studio. * * @param accessToken - After user will be logged in to the web page, * using Snapchat account, you can get access token from Login Kit. * @param cameraKitSession - Instance of CameraKitSession object form @snap/camera-kit package. * @param repository - Instance of LensRepository object from @snap/camera-kit package. * @returns @SubscriptionInstance */ subscribe(accessToken: string, cameraKitSession: CameraKitSession, repository: CameraKit["lensRepository"]): SubscriptionInstance; } export declare enum State { /** * The extension is listening for the events about pushed Lens from Lens Studio. */ Subscribed = "Subscribed", /** * The extension is not listening for any events about pushed Lens. */ Unsubscribed = "Unsubscribed" } export declare const version = "1.17.0"; /** * Generic error event */ export type GenericErrorEvent = { /** * Type of the event. */ name: "GenericError"; /** * The reason of the error event. */ cause: Error; }; /** * Error related to communication channel between the web page and Lens Studio. */ export type CommunicationErrorEvent = { /** * Type of the event. */ name: "CommunicationError"; /** * The reason of the error event. */ cause: Error; /** * gRPC connection code */ grpcCode: number; /** * gRPC connection status */ grpcStatus: Code; }; /** * This error will occur if the lens is excluded from push for any reason. */ export type LensExcludedErrorEvent = { /** * Type of the event. */ name: "LensExcludedError"; /** * The reason of the error event. */ cause: Error; /** * Lens id */ lensId: string; /** * Contains the reason why the lens was excluded. * @deprecated Use `cause.message` instead. */ reason: ListenLensPushResponse_ExcludedLens_Code; }; /** * Object that represents active connection with Lens Studio. */ export type SubscriptionInstance = { /** * Close current connection and unsubscribe from the events form Lens Studio. */ unsubscribe(): void; /** * This method can be used to provide a new access token for an active connection * in case the previous one has expired. * @param accessToken Login Kit access token */ updateAccessToken(accessToken: string): void; }; export type ErrorEvent = TypedCustomEvent<"error", GenericErrorEvent | CommunicationErrorEvent | LensExcludedErrorEvent>; export type LensReceivedEvent = TypedCustomEvent<"lensReceived", Lens>; export type SubscriptionChangedEvent = TypedCustomEvent<"subscriptionChanged", State>; export type Push2WebEvents = LensReceivedEvent | ErrorEvent | SubscriptionChangedEvent; export type EventType = "error" | "lensReceived" | "subscriptionChanged";