UNPKG

1.23 kBTypeScriptView Raw
1import * as React from 'react';
2declare type Callback = (...args: any[]) => void;
3export declare type ErrorCallback = (error: Error | FetchError) => void;
4export declare type LoadCallback = (src: string, isCached: boolean) => void;
5export declare type PlainObject<T = unknown> = Record<string | number | symbol, T>;
6export declare type PreProcessorCallback = (code: string) => string;
7export interface Props extends Omit<React.SVGProps<SVGElement>, 'onLoad' | 'onError' | 'ref'> {
8 baseURL?: string;
9 cacheRequests?: boolean;
10 children?: React.ReactNode;
11 description?: string;
12 fetchOptions?: RequestInit;
13 innerRef?: React.Ref<SVGElement>;
14 loader?: React.ReactNode;
15 onError?: ErrorCallback;
16 onLoad?: LoadCallback;
17 preProcessor?: PreProcessorCallback;
18 src: string;
19 title?: string;
20 uniqueHash?: string;
21 uniquifyIDs?: boolean;
22}
23export interface State {
24 content: string;
25 element: React.ReactNode;
26 hasCache: boolean;
27 status: string;
28}
29export interface FetchError extends Error {
30 code: string;
31 errno: string;
32 message: string;
33 type: string;
34}
35export interface StorageItem {
36 content: string;
37 queue: Callback[];
38 status: string;
39}
40export {};