1 | import React, { SVGProps, ReactNode, RefObject } from 'react';
|
2 |
|
3 | declare const STATUS: {
|
4 | readonly IDLE: "idle";
|
5 | readonly LOADING: "loading";
|
6 | readonly LOADED: "loaded";
|
7 | readonly FAILED: "failed";
|
8 | readonly READY: "ready";
|
9 | readonly UNSUPPORTED: "unsupported";
|
10 | };
|
11 |
|
12 | type ErrorCallback = (error: Error | FetchError) => void;
|
13 | type LoadCallback = (src: string, isCached: boolean) => void;
|
14 | type PlainObject<T = unknown> = Record<string, T>;
|
15 | type PreProcessorCallback = (code: string) => string;
|
16 | type Props = Simplify<Omit<SVGProps<SVGElement>, 'onLoad' | 'onError' | 'ref'> & {
|
17 | baseURL?: string;
|
18 | cacheRequests?: boolean;
|
19 | children?: ReactNode;
|
20 | description?: string;
|
21 | fetchOptions?: RequestInit;
|
22 | innerRef?: RefObject<SVGElement | null>;
|
23 | loader?: ReactNode;
|
24 | onError?: ErrorCallback;
|
25 | onLoad?: LoadCallback;
|
26 | preProcessor?: PreProcessorCallback;
|
27 | src: string;
|
28 | title?: string | null;
|
29 | uniqueHash?: string;
|
30 | uniquifyIDs?: boolean;
|
31 | }>;
|
32 | type Simplify<T> = {
|
33 | [KeyType in keyof T]: T[KeyType];
|
34 | } & {};
|
35 | type Status = (typeof STATUS)[keyof typeof STATUS];
|
36 | interface FetchError extends Error {
|
37 | code: string;
|
38 | errno: string;
|
39 | message: string;
|
40 | type: string;
|
41 | }
|
42 | interface State {
|
43 | content: string;
|
44 | element: ReactNode;
|
45 | isCached: boolean;
|
46 | status: Status;
|
47 | }
|
48 | interface StorageItem {
|
49 | content: string;
|
50 | status: Status;
|
51 | }
|
52 |
|
53 | declare class CacheStore {
|
54 | private cacheApi;
|
55 | private readonly cacheStore;
|
56 | private readonly subscribers;
|
57 | isReady: boolean;
|
58 | constructor();
|
59 | onReady(callback: () => void): void;
|
60 | get(url: string, fetchOptions?: RequestInit): Promise<string>;
|
61 | set(url: string, data: StorageItem): void;
|
62 | isCached(url: string): boolean;
|
63 | private fetchAndAddToInternalCache;
|
64 | private fetchAndAddToPersistentCache;
|
65 | private handleLoading;
|
66 | keys(): Array<string>;
|
67 | data(): Array<Record<string, StorageItem>>;
|
68 | delete(url: string): Promise<void>;
|
69 | clear(): Promise<void>;
|
70 | }
|
71 |
|
72 | declare let cacheStore: CacheStore;
|
73 | declare function InlineSVG(props: Props): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
74 |
|
75 | export { type ErrorCallback, type FetchError, type LoadCallback, type PlainObject, type PreProcessorCallback, type Props, type Simplify, type State, type Status, type StorageItem, cacheStore, InlineSVG as default };
|
76 | export = InlineSVG |
\ | No newline at end of file |