@iconify/react
Advanced tools
Comparing version 3.1.3 to 3.1.4
@@ -43,3 +43,3 @@ import { default as React_2 } from 'react'; | ||
*/ | ||
export declare function buildIcon(icon: IconifyIcon, customisations: RawIconCustomisations): IconifyIconBuildResult; | ||
export declare function buildIcon(icon: IconifyIcon, customisations?: RawIconCustomisations): IconifyIconBuildResult; | ||
@@ -76,7 +76,2 @@ /** | ||
/** | ||
* Callback to track status | ||
*/ | ||
declare type GetQueryStatus = () => QueryStatus; | ||
/** | ||
* Block icon | ||
@@ -176,6 +171,6 @@ * | ||
/** | ||
* Optional setFetch and getFetch (should be imported from ./modules/fetch if fetch is used) | ||
* Set and get fetch() | ||
*/ | ||
setFetch?: (item: typeof fetch) => void; | ||
getFetch?: () => typeof fetch | null; | ||
setFetch: (item: typeof fetch) => void; | ||
getFetch: () => typeof fetch | null; | ||
/** | ||
@@ -208,3 +203,3 @@ * List all API providers (from config) | ||
export declare type IconifyAPISendQuery = (host: string, params: IconifyAPIQueryParams, status: PendingQueryItem) => void; | ||
export declare type IconifyAPISendQuery = (host: string, params: IconifyAPIQueryParams, callback: QueryModuleResponse) => void; | ||
@@ -230,3 +225,3 @@ /** | ||
calculateSize: (size: string | number, ratio: number, precision?: number) => string | number; | ||
buildIcon: (icon: IconifyIcon, customisations: RawIconCustomisations) => IconifyIconBuildResult; | ||
buildIcon: (icon: IconifyIcon, customisations?: RawIconCustomisations) => IconifyIconBuildResult; | ||
} | ||
@@ -608,13 +603,2 @@ | ||
/** | ||
* Item in pending items list | ||
*/ | ||
declare interface PendingQueryItem { | ||
readonly getQueryStatus: GetQueryStatus; | ||
status: QueryItemStatus; | ||
readonly resource: RedundancyResource; | ||
readonly done: QueryDoneCallback; | ||
abort?: QueryAbortCallback; | ||
} | ||
/** | ||
* Callback for "abort" pending item. | ||
@@ -629,26 +613,15 @@ */ | ||
*/ | ||
declare type QueryDoneCallback = (data?: unknown, error?: unknown) => void; | ||
declare type QueryDoneCallback = (data?: QueryModuleResponseData, error?: QueryModuleResponseData) => void; | ||
/** | ||
* Execution status | ||
*/ | ||
declare type QueryItemStatus = 'pending' | 'completed' | 'aborted' | 'failed'; | ||
declare type QueryModuleResponse = (status: QueryModuleResponseType, data: QueryModuleResponseData) => void; | ||
/** | ||
* Custom payload | ||
* Response from query module | ||
*/ | ||
declare type QueryPayload = unknown; | ||
declare type QueryModuleResponseData = unknown; | ||
/** | ||
* Status for query | ||
* Response from query module | ||
*/ | ||
declare interface QueryStatus { | ||
readonly abort: () => void; | ||
readonly subscribe: (callback?: QueryDoneCallback, overwrite?: boolean) => void; | ||
readonly payload: QueryPayload; | ||
status: QueryItemStatus; | ||
startTime: number; | ||
queriesSent: number; | ||
queriesPending: number; | ||
} | ||
declare type QueryModuleResponseType = 'success' | 'next' | 'abort'; | ||
@@ -680,4 +653,4 @@ /** | ||
index: number; | ||
timeout: number | TimeoutCallback; | ||
rotate: number | RotationTimeoutCallback; | ||
timeout: number; | ||
rotate: number; | ||
random: boolean; | ||
@@ -711,11 +684,2 @@ dataAfterTimeout: boolean; | ||
/** | ||
* Callback for "rotate" configuration property. | ||
* Returns number of milliseconds to wait before trying next resource. | ||
*/ | ||
declare interface RotationTimeoutCallback { | ||
(queriesSent: number, // Number of queries sent, starts with 1 for timeout after first resource | ||
startTime: number): number; | ||
} | ||
/** | ||
* Share storage between components | ||
@@ -725,10 +689,2 @@ */ | ||
/** | ||
* Callback for "timeout" configuration property. | ||
* Returns number of milliseconds to wait before failing query, while there are pending resources. | ||
*/ | ||
declare interface TimeoutCallback { | ||
(startTime: number): number; | ||
} | ||
export { } |
@@ -145,2 +145,3 @@ 'use strict'; | ||
function validateIconSet(obj, options) { | ||
var _a; | ||
const fix = !!(options == null ? void 0 : options.fix); | ||
@@ -194,3 +195,10 @@ if (typeof obj !== "object" || obj === null || typeof obj.icons !== "object" || !obj.icons) { | ||
}); | ||
if (!Object.keys(data.icons).length) { | ||
if (data.not_found !== void 0 && !(data.not_found instanceof Array)) { | ||
if (fix) { | ||
delete data.not_found; | ||
} else { | ||
throw new Error("Invalid not_found list"); | ||
} | ||
} | ||
if (!Object.keys(data.icons).length && !((_a = data.not_found) == null ? void 0 : _a.length)) { | ||
throw new Error("Icon set is empty"); | ||
@@ -276,3 +284,3 @@ } | ||
Object.keys(chars).forEach((char) => { | ||
var _a; | ||
var _a2; | ||
if (!char.match(matchChar) || typeof chars[char] !== "string") { | ||
@@ -286,3 +294,3 @@ if (fix) { | ||
const target = chars[char]; | ||
if (data.icons[target] === void 0 && ((_a = data.aliases) == null ? void 0 : _a[target]) === void 0) { | ||
if (data.icons[target] === void 0 && ((_a2 = data.aliases) == null ? void 0 : _a2[target]) === void 0) { | ||
if (fix) { | ||
@@ -289,0 +297,0 @@ delete chars[char]; |
@@ -5,3 +5,3 @@ { | ||
"author": "Vjacheslav Trushkin", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"license": "MIT", | ||
@@ -41,2 +41,7 @@ "bugs": "https://github.com/iconify/iconify/issues", | ||
"default": "./dist/offline.js" | ||
}, | ||
"./dist/offline": { | ||
"import": "./dist/offline.mjs", | ||
"types": "./dist/offline.d.ts", | ||
"default": "./dist/offline.js" | ||
} | ||
@@ -58,6 +63,3 @@ }, | ||
"typescript": "^4.5.5" | ||
}, | ||
"dependencies": { | ||
"cross-fetch": "^3.1.5" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
0
217832
7204
- Removedcross-fetch@^3.1.5
- Removedcross-fetch@3.2.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)