mirror of
https://github.com/iconify/iconify.git
synced 2024-12-13 14:13:06 +00:00
Move common types for SVG framework to reusable files
This commit is contained in:
parent
b38eb3bc74
commit
782c8d3865
@ -1,16 +1,27 @@
|
||||
import { IconifyJSON } from '@iconify/types';
|
||||
import { IconifyIconName } from '@iconify/core/lib/icon/name';
|
||||
import { IconifyIcon } from '@iconify/core/lib/icon';
|
||||
import {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '@iconify/core/lib/interfaces/loader';
|
||||
import { IconifyAPIConfig } from '@iconify/core/lib/api/config';
|
||||
import { IconifyAPIConfig, GetAPIConfig } from '@iconify/core/lib/api/config';
|
||||
import { IconifyAPIInternalStorage } from '@iconify/core/lib/api/';
|
||||
import { IconifyAPIModule } from '@iconify/core/lib/api/modules';
|
||||
|
||||
/**
|
||||
* Cache types
|
||||
*/
|
||||
export type IconifyCacheType = 'local' | 'session' | 'all';
|
||||
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyAPI {
|
||||
/* Scan DOM */
|
||||
/**
|
||||
* Toggle local and session storage
|
||||
*/
|
||||
enableCache: (storage: IconifyCacheType, value: boolean) => void;
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
@ -28,3 +39,27 @@ export interface IconifyAPI {
|
||||
customConfig: Partial<IconifyAPIConfig>
|
||||
) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exposed internal functions
|
||||
*
|
||||
* Used by plug-ins, such as Icon Finder
|
||||
*
|
||||
* Important: any changes published in a release must be backwards compatible.
|
||||
*/
|
||||
export interface IconifyExposedAPIInternals {
|
||||
/**
|
||||
* Get internal API data, used by Icon Finder
|
||||
*/
|
||||
getAPI: (provider: string) => IconifyAPIInternalStorage | undefined;
|
||||
|
||||
/**
|
||||
* Get API config, used by custom modules
|
||||
*/
|
||||
getAPIConfig: GetAPIConfig;
|
||||
|
||||
/**
|
||||
* Set API module
|
||||
*/
|
||||
setAPIModule: (provider: string, item: IconifyAPIModule) => void;
|
||||
}
|
||||
|
40
packages/iconify/src/common.ts
Normal file
40
packages/iconify/src/common.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { IconifyJSON } from '@iconify/types';
|
||||
import { IconifyIcon } from '@iconify/core/lib/icon';
|
||||
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyGlobalCommon {
|
||||
/* General section */
|
||||
/**
|
||||
* Get version
|
||||
*/
|
||||
getVersion: () => string;
|
||||
|
||||
/* Getting icons */
|
||||
/**
|
||||
* Check if icon exists
|
||||
*/
|
||||
iconExists: (name: string) => boolean;
|
||||
|
||||
/**
|
||||
* Get icon data with all properties
|
||||
*/
|
||||
getIcon: (name: string) => IconifyIcon | null;
|
||||
|
||||
/**
|
||||
* List all available icons
|
||||
*/
|
||||
listIcons: (provider?: string, prefix?: string) => string[];
|
||||
|
||||
/* Add icons */
|
||||
/**
|
||||
* Add icon to storage
|
||||
*/
|
||||
addIcon: (name: string, data: IconifyIcon) => boolean;
|
||||
|
||||
/**
|
||||
* Add icon set to storage
|
||||
*/
|
||||
addCollection: (data: IconifyJSON, provider?: string) => boolean;
|
||||
}
|
@ -39,7 +39,7 @@ import { finder as iconifyFinder } from './finders/iconify';
|
||||
import { storeCache, loadCache, config } from '@iconify/core/lib/cache/storage';
|
||||
|
||||
// API
|
||||
import { IconifyAPI } from './api';
|
||||
import { IconifyAPI, IconifyExposedAPIInternals } from './api';
|
||||
import {
|
||||
API,
|
||||
getRedundancyCache,
|
||||
@ -78,6 +78,11 @@ import { renderIcon } from './renderer/render';
|
||||
import { IconifyScanner } from './scanner';
|
||||
import { scanDOM } from './scanner/scan';
|
||||
|
||||
// Other
|
||||
import { IconifyExposedCommonInternals } from './internals';
|
||||
import { IconifyGlobalCommon } from './common';
|
||||
import { IconifyCacheType } from '../dist/iconify';
|
||||
|
||||
/**
|
||||
* Export required types
|
||||
*/
|
||||
@ -105,13 +110,9 @@ export {
|
||||
GetAPIConfig,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPISendQuery,
|
||||
IconifyCacheType,
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache types
|
||||
*/
|
||||
export type IconifyCacheType = 'local' | 'session' | 'all';
|
||||
|
||||
/**
|
||||
* Exposed internal functions
|
||||
*
|
||||
@ -119,79 +120,19 @@ export type IconifyCacheType = 'local' | 'session' | 'all';
|
||||
*
|
||||
* Important: any changes published in a release must be backwards compatible.
|
||||
*/
|
||||
export interface IconifyExposedInternals {
|
||||
/**
|
||||
* Calculate width knowing height and width/height ratio (or vice versa)
|
||||
*/
|
||||
calculateSize: (
|
||||
size: IconifyIconSize,
|
||||
ratio: number,
|
||||
precision?: number
|
||||
) => IconifyIconSize;
|
||||
|
||||
/**
|
||||
* Get internal API data, used by Icon Finder
|
||||
*/
|
||||
getAPI: (provider: string) => IconifyAPIInternalStorage | undefined;
|
||||
|
||||
/**
|
||||
* Get API config, used by custom modules
|
||||
*/
|
||||
getAPIConfig: GetAPIConfig;
|
||||
|
||||
/**
|
||||
* Set API module
|
||||
*/
|
||||
setAPIModule: (provider: string, item: IconifyAPIModule) => void;
|
||||
}
|
||||
export interface IconifyExposedInternals
|
||||
extends IconifyExposedAPIInternals,
|
||||
IconifyExposedCommonInternals {}
|
||||
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyGlobal
|
||||
extends IconifyScanner,
|
||||
extends IconifyGlobalCommon,
|
||||
IconifyScanner,
|
||||
IconifyObserver,
|
||||
IconifyRenderer,
|
||||
IconifyAPI {
|
||||
/* General section */
|
||||
/**
|
||||
* Get version
|
||||
*/
|
||||
getVersion: () => string;
|
||||
|
||||
/* Getting icons */
|
||||
/**
|
||||
* Check if icon exists
|
||||
*/
|
||||
iconExists: (name: string) => boolean;
|
||||
|
||||
/**
|
||||
* Get icon data with all properties
|
||||
*/
|
||||
getIcon: (name: string) => IconifyIcon | null;
|
||||
|
||||
/**
|
||||
* List all available icons
|
||||
*/
|
||||
listIcons: (provider?: string, prefix?: string) => string[];
|
||||
|
||||
/* Add icons */
|
||||
/**
|
||||
* Add icon to storage
|
||||
*/
|
||||
addIcon: (name: string, data: IconifyIcon) => boolean;
|
||||
|
||||
/**
|
||||
* Add icon set to storage
|
||||
*/
|
||||
addCollection: (data: IconifyJSON, provider?: string) => boolean;
|
||||
|
||||
/* Scan DOM */
|
||||
/**
|
||||
* Toggle local and session storage
|
||||
*/
|
||||
enableCache: (storage: IconifyCacheType, value: boolean) => void;
|
||||
|
||||
/**
|
||||
* Expose internal functions
|
||||
*/
|
||||
|
@ -27,7 +27,6 @@ import { replaceIDs } from '@iconify/core/lib/builder/ids';
|
||||
import { calcSize } from '@iconify/core/lib/builder/calc-size';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
import { browserModules } from './modules';
|
||||
|
||||
// Finders
|
||||
@ -47,6 +46,10 @@ import { renderIcon } from './renderer/render';
|
||||
import { IconifyScanner } from './scanner';
|
||||
import { scanDOM } from './scanner/scan';
|
||||
|
||||
// Other
|
||||
import { IconifyExposedCommonInternals } from './internals';
|
||||
import { IconifyGlobalCommon } from './common';
|
||||
|
||||
/**
|
||||
* Export required types
|
||||
*/
|
||||
@ -71,58 +74,17 @@ export { IconifyIconBuildResult };
|
||||
*
|
||||
* Important: any changes published in a release must be backwards compatible.
|
||||
*/
|
||||
export interface IconifyExposedInternals {
|
||||
/**
|
||||
* Calculate width knowing height and width/height ratio (or vice versa)
|
||||
*/
|
||||
calculateSize: (
|
||||
size: IconifyIconSize,
|
||||
ratio: number,
|
||||
precision?: number
|
||||
) => IconifyIconSize;
|
||||
}
|
||||
export interface IconifyExposedInternals
|
||||
extends IconifyExposedCommonInternals {}
|
||||
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyGlobal
|
||||
extends IconifyScanner,
|
||||
extends IconifyGlobalCommon,
|
||||
IconifyScanner,
|
||||
IconifyObserver,
|
||||
IconifyRenderer {
|
||||
/* General section */
|
||||
/**
|
||||
* Get version
|
||||
*/
|
||||
getVersion: () => string;
|
||||
|
||||
/* Getting icons */
|
||||
/**
|
||||
* Check if icon exists
|
||||
*/
|
||||
iconExists: (name: string) => boolean;
|
||||
|
||||
/**
|
||||
* Get icon data with all properties
|
||||
*/
|
||||
getIcon: (name: string) => IconifyIcon | null;
|
||||
|
||||
/**
|
||||
* List all available icons
|
||||
*/
|
||||
listIcons: (provider?: string, prefix?: string) => string[];
|
||||
|
||||
/* Add icons */
|
||||
/**
|
||||
* Add icon to storage
|
||||
*/
|
||||
addIcon: (name: string, data: IconifyIcon) => boolean;
|
||||
|
||||
/**
|
||||
* Add icon set to storage
|
||||
*/
|
||||
addCollection: (data: IconifyJSON, provider?: string) => boolean;
|
||||
|
||||
/* Scan DOM */
|
||||
/**
|
||||
* Expose internal functions
|
||||
*/
|
||||
|
19
packages/iconify/src/internals.ts
Normal file
19
packages/iconify/src/internals.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { IconifyIconSize } from '@iconify/core/lib/customisations';
|
||||
|
||||
/**
|
||||
* Exposed internal functions
|
||||
*
|
||||
* Used by plug-ins, such as Icon Finder
|
||||
*
|
||||
* Important: any changes published in a release must be backwards compatible.
|
||||
*/
|
||||
export interface IconifyExposedCommonInternals {
|
||||
/**
|
||||
* Calculate width knowing height and width/height ratio (or vice versa)
|
||||
*/
|
||||
calculateSize: (
|
||||
size: IconifyIconSize,
|
||||
ratio: number,
|
||||
precision?: number
|
||||
) => IconifyIconSize;
|
||||
}
|
Loading…
Reference in New Issue
Block a user