rn-url-preview
Version:
React Native URL Preview component
85 lines (84 loc) • 3.24 kB
TypeScript
/// <reference types="react" />
import { PreviewData } from "./types";
/**
* Regular expression to match email addresses
*/
export declare const REGEX_EMAIL: RegExp;
/**
* Regular expression to match image content types
*/
export declare const REGEX_IMAGE_CONTENT_TYPE: RegExp;
/**
* Regular expression to extract image source from img tags
* Considers empty line after img tag and takes only the src field
* Space before src to avoid matching data-src attributes
*/
export declare const REGEX_IMAGE_TAG: RegExp;
/**
* Regular expression to match URLs (http, https, ftp protocols)
*/
export declare const REGEX_LINK: RegExp;
/**
* Regular expression to extract meta tags
* Handles both property and name attributes with content
* Supports both single and double quotes
*/
export declare const REGEX_META: RegExp;
/**
* Regular expression to extract page title
*/
export declare const REGEX_TITLE: RegExp;
/**
* Recursively processes and renders special elements based on given filters and properties.
*
* @param {React.ReactNode} children - The children elements to be rendered.
* @param {Object} props - Additional properties to pass to the children elements.
* @returns {React.ReactNode[]} - The filtered and modified children elements.
*/
export declare function renderSpecialElementHelper({ children, props, }: {
children: React.ReactNode;
props?: {
[key: string]: {
[key: string]: any;
};
};
}): React.ReactNode[];
/**
* Resolves relative image URLs to absolute URLs
*
* @param {string} baseUrl - The base URL of the page
* @param {string} imageUrl - The image URL to resolve
* @returns {string|undefined} - The resolved absolute image URL or undefined
*/
export declare const getActualImageUrlHelper: (baseUrl: string, imageUrl?: string) => string | undefined;
/**
* Decodes HTML entities in text
*
* @param {string} text - The text to decode
* @returns {string|undefined} - The decoded text or undefined
*/
export declare const getHtmlEntitiesDecodedTextHelper: (text?: string) => string | undefined;
/**
* Helper to extract content from meta tags based on property/name type
*
* @param {string} left - First string (could be property/name or content)
* @param {string} right - Second string (could be property/name or content)
* @param {string} type - The type to look for (e.g., "og:title", "description")
* @returns {string|undefined} - The extracted content or undefined
*/
export declare const getContentHelper: (left: string, right: string, type: string) => string | undefined;
/**
* Helper to process image URLs for preview data
*
* @param {string} url - The image URL to process
* @returns {Promise<string|undefined>} - The processed image URL or undefined
*/
export declare const getPreviewDataImageHelper: (url?: string) => Promise<string | undefined>;
/**
* Extracts preview data (title, description, image) from a URL
*
* @param {string} text - The text containing a URL
* @param {number} requestTimeout - Timeout for the fetch request in milliseconds
* @returns {Promise<PreviewData>} - The extracted preview data
*/
export declare const getPreviewDataHelper: (text: string, requestTimeout?: number) => Promise<PreviewData>;