UNPKG

svelte-tenor

Version:

Tenor GIF components, implemented in Svelte.

134 lines (133 loc) 3.93 kB
/** Represents a GIF object. */ export interface Gif { /** Tenor GIF id. */ id: string; /** GIF description. */ description: string; /** GIF width. */ width: number; /** GIF height. */ height: number; /** Image URL. */ gif: string; } export interface CommonOptions { /** Tenor API key. You may use `LIVDSRZULELA` for testing. */ key: string; /** * Search term locale, formatted as `language_COUNTRY`. * * @default `en_US` */ locale?: string; /** * Safety filter: * * - `off` - G, PG, PG-13, and R (no nudity) * - `low` - G, PG, and PG-13 * - `medium` - G and PG * - `high` - G * * @default `off` * @see https://tenor.com/gifapi/documentation#contentfilter */ safety?: 'off' | 'low' | 'medium' | 'high'; /** * Aspect ratio filter: * * - `all` - no constraints * - `wide` - 0.42 <= aspect ratio <= 2.36 * - `standard` - 0.56 <= aspect ratio <= 1.78 * * @default `all` */ ratio?: 'all' | 'wide' | 'standard'; /** * Video quality filter. Medium is sufficient for most purposes, even on * desktop and hdpi devices. * * @default `medium` */ quality?: 'low' | 'medium' | 'high'; /** * Number of results per page. (max: 50) * * @default 20 */ limit?: number; /** Page id, given by the `next` field of the result. */ page?: string; } export declare type GifDetailsOptions = { key: string; /** Array of GIF ids. */ ids: string[]; quality?: 'low' | 'medium' | 'high'; limit?: number; page?: string; }; export interface SearchOptions extends CommonOptions { /** Search term. */ q: string; } export interface ResultPage { /** GIFs. Yep. */ results: Gif[]; /** Next page id. */ next: string; } export interface SuggestionOptions { /** Tenor API key. You may use `LIVDSRZULELA` for testing. */ key: string; /** Search term. */ q: string; /** * Search term locale, formatted as `language_COUNTRY`. * * @default `en_US` */ locale?: string; /** * Number of results. (max: 50) * * @default 10 */ limit?: number; } /** Gets details about one or several GIFs. */ export declare const gifDetails: ({ key, ids, quality, limit, page, }: GifDetailsOptions) => Promise<ResultPage>; /** Searches for GIFs. */ export declare const search: ({ key, q, locale, quality, safety, ratio, limit, page, }: SearchOptions) => Promise<ResultPage>; /** Searches for GIFs, but shuffles the result. */ export declare const shuffledSearch: ({ key, q, locale, quality, safety, ratio, limit, page, }: SearchOptions) => Promise<ResultPage>; /** Fetches trending GIFs. */ export declare const trending: ({ key, locale, quality, safety, ratio, limit, page, }: CommonOptions) => Promise<ResultPage>; /** Registers a user’s sharing of a GIF. */ export declare const registerShare: (options: { key: string; id: string; locale?: string; q?: string; }) => Promise<{ status: 'ok'; }>; /** Completes the user's search. */ export declare const autocomplete: ({ key, q, locale, limit, }: SuggestionOptions) => Promise<string[]>; /** Returns related search terms. */ export declare const related: ({ key, q, locale, limit, }: SuggestionOptions) => Promise<string[]>; /** Returns trending search terms. */ export declare const trendingTerms: ({ key, locale, limit, }: { key: string; locale?: string | undefined; limit?: number | undefined; }) => Promise<string[]>; /** Returns Tenor GIF categories. */ export declare const categories: ({ key, type, locale, safety, }: { key: string; type?: "trending" | "featured" | undefined; locale?: string | undefined; safety?: "high" | "low" | "medium" | "off" | undefined; }) => Promise<{ term: string; gif: string; }[]>;