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