mirror of
https://github.com/iconify/iconify.git
synced 2024-12-14 06:28:24 +00:00
Move files to clean up directory structure in SVG framework
This commit is contained in:
parent
49b9d09f6f
commit
135bf723fb
57
packages/iconify/src/api/index.ts
Normal file
57
packages/iconify/src/api/index.ts
Normal file
@ -0,0 +1,57 @@
|
||||
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';
|
||||
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyAPI {
|
||||
/* 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[];
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
loadIcons: (
|
||||
icons: (IconifyIconName | string)[],
|
||||
callback?: IconifyIconLoaderCallback
|
||||
) => IconifyIconLoaderAbort;
|
||||
|
||||
/* Add icons */
|
||||
/**
|
||||
* Add icon to storage
|
||||
*/
|
||||
addIcon: (name: string, data: IconifyIcon) => boolean;
|
||||
|
||||
/**
|
||||
* Add icon set to storage
|
||||
*/
|
||||
addCollection: (data: IconifyJSON, provider?: string) => boolean;
|
||||
|
||||
/* API stuff */
|
||||
/**
|
||||
* Add API provider
|
||||
*/
|
||||
addAPIProvider: (
|
||||
provider: string,
|
||||
customConfig: Partial<IconifyAPIConfig>
|
||||
) => void;
|
||||
}
|
@ -39,6 +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 {
|
||||
API,
|
||||
getRedundancyCache,
|
||||
@ -64,13 +65,16 @@ import {
|
||||
} from '@iconify/core/lib/interfaces/loader';
|
||||
|
||||
// Observer
|
||||
import { observer } from './modules/observer';
|
||||
import { IconifyObserver } from './observer';
|
||||
import { observer } from './observer/observer';
|
||||
|
||||
// Render
|
||||
import { renderIcon } from './render';
|
||||
import { IconifyRenderer } from './renderer';
|
||||
import { renderIcon } from './renderer/render';
|
||||
|
||||
// Scan
|
||||
import { scanDOM } from './scan';
|
||||
import { IconifyScanner } from './scanner';
|
||||
import { scanDOM } from './scanner/scan';
|
||||
|
||||
/**
|
||||
* Export required types
|
||||
@ -142,102 +146,18 @@ export interface IconifyExposedInternals {
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyGlobal {
|
||||
export interface IconifyGlobal
|
||||
extends 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[];
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
loadIcons: (
|
||||
icons: (IconifyIconName | string)[],
|
||||
callback?: IconifyIconLoaderCallback
|
||||
) => IconifyIconLoaderAbort;
|
||||
|
||||
/* Rendering icons */
|
||||
renderSVG: (
|
||||
name: string,
|
||||
customisations: IconifyIconCustomisations
|
||||
) => SVGElement | null;
|
||||
|
||||
renderHTML: (
|
||||
name: string,
|
||||
customisations: IconifyIconCustomisations
|
||||
) => string | null;
|
||||
|
||||
/**
|
||||
* Get icon data
|
||||
*/
|
||||
renderIcon: (
|
||||
name: string,
|
||||
customisations: IconifyIconCustomisations
|
||||
) => IconifyIconBuildResult | null;
|
||||
|
||||
/**
|
||||
* Replace IDs in icon body, should be used when parsing buildIcon() result
|
||||
*/
|
||||
replaceIDs: (body: 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;
|
||||
|
||||
/* API stuff */
|
||||
/**
|
||||
* Pause DOM observer
|
||||
*/
|
||||
pauseObserver: () => void;
|
||||
|
||||
/**
|
||||
* Resume DOM observer
|
||||
*/
|
||||
resumeObserver: () => void;
|
||||
|
||||
/**
|
||||
* Add API provider
|
||||
*/
|
||||
addAPIProvider: (
|
||||
provider: string,
|
||||
customConfig: Partial<IconifyAPIConfig>
|
||||
) => void;
|
||||
|
||||
/* Scan DOM */
|
||||
/**
|
||||
* Scan DOM
|
||||
*/
|
||||
scanDOM: (root?: HTMLElement) => void;
|
||||
|
||||
/**
|
||||
* Set root node
|
||||
*/
|
||||
setRoot: (root: HTMLElement) => void;
|
||||
|
||||
/**
|
||||
* Toggle local and session storage
|
||||
*/
|
||||
@ -249,6 +169,9 @@ export interface IconifyGlobal {
|
||||
_internal: IconifyExposedInternals;
|
||||
}
|
||||
|
||||
// Export dependencies
|
||||
export { IconifyObserver, IconifyScanner, IconifyRenderer, IconifyAPI };
|
||||
|
||||
/**
|
||||
* Get icon name
|
||||
*/
|
||||
@ -430,12 +353,6 @@ const Iconify: IconifyGlobal = {
|
||||
// Add icon set
|
||||
addCollection: addCollection,
|
||||
|
||||
// Pause observer
|
||||
pauseObserver: observer.pause,
|
||||
|
||||
// Resume observer
|
||||
resumeObserver: observer.resume,
|
||||
|
||||
// API providers
|
||||
addAPIProvider: setAPIConfig,
|
||||
|
||||
@ -469,6 +386,10 @@ const Iconify: IconifyGlobal = {
|
||||
}
|
||||
},
|
||||
|
||||
// Observer
|
||||
pauseObserver: observer.pause,
|
||||
resumeObserver: observer.resume,
|
||||
|
||||
// Exposed internal functions
|
||||
_internal: {
|
||||
// Calculate size
|
||||
|
14
packages/iconify/src/observer/index.ts
Normal file
14
packages/iconify/src/observer/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyObserver {
|
||||
/**
|
||||
* Pause DOM observer
|
||||
*/
|
||||
pauseObserver: () => void;
|
||||
|
||||
/**
|
||||
* Resume DOM observer
|
||||
*/
|
||||
resumeObserver: () => void;
|
||||
}
|
33
packages/iconify/src/renderer/index.ts
Normal file
33
packages/iconify/src/renderer/index.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { IconifyIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import { IconifyIconBuildResult } from '@iconify/core/lib/builder';
|
||||
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyRenderer {
|
||||
/**
|
||||
* Render icons
|
||||
*/
|
||||
renderSVG: (
|
||||
name: string,
|
||||
customisations: IconifyIconCustomisations
|
||||
) => SVGElement | null;
|
||||
|
||||
renderHTML: (
|
||||
name: string,
|
||||
customisations: IconifyIconCustomisations
|
||||
) => string | null;
|
||||
|
||||
/**
|
||||
* Get icon data
|
||||
*/
|
||||
renderIcon: (
|
||||
name: string,
|
||||
customisations: IconifyIconCustomisations
|
||||
) => IconifyIconBuildResult | null;
|
||||
|
||||
/**
|
||||
* Replace IDs in icon body, should be used when parsing buildIcon() result
|
||||
*/
|
||||
replaceIDs: (body: string) => string;
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
import { PlaceholderElement } from './finder';
|
||||
import { FullIconifyIcon } from '@iconify/core/lib/icon';
|
||||
import {
|
||||
IconifyIconCustomisations,
|
||||
@ -6,12 +5,13 @@ import {
|
||||
} from '@iconify/core/lib/customisations';
|
||||
import { iconToSVG } from '@iconify/core/lib/builder';
|
||||
import { replaceIDs } from '@iconify/core/lib/builder/ids';
|
||||
import { PlaceholderElement } from '../finder';
|
||||
import {
|
||||
IconifyElement,
|
||||
IconifyElementData,
|
||||
elementDataProperty,
|
||||
elementFinderProperty,
|
||||
} from './element';
|
||||
} from '../element';
|
||||
|
||||
/**
|
||||
* Replace element with SVG
|
14
packages/iconify/src/scanner/index.ts
Normal file
14
packages/iconify/src/scanner/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
export interface IconifyScanner {
|
||||
/**
|
||||
* Scan DOM
|
||||
*/
|
||||
scanDOM: (root?: HTMLElement) => void;
|
||||
|
||||
/**
|
||||
* Set root node
|
||||
*/
|
||||
setRoot: (root: HTMLElement) => void;
|
||||
}
|
@ -2,10 +2,10 @@ import { IconifyIconName } from '@iconify/core/lib/icon/name';
|
||||
import { getStorage, getIcon } from '@iconify/core/lib/storage';
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
import { FullIconifyIcon } from '@iconify/core/lib/icon';
|
||||
import { findPlaceholders } from './finder';
|
||||
import { browserModules, getRoot } from './modules';
|
||||
import { IconifyElementData, elementDataProperty } from './element';
|
||||
import { renderIcon } from './render';
|
||||
import { findPlaceholders } from '../finder';
|
||||
import { browserModules, getRoot } from '../modules';
|
||||
import { IconifyElementData, elementDataProperty } from '../element';
|
||||
import { renderIcon } from '../renderer/render';
|
||||
|
||||
/**
|
||||
* Flag to avoid scanning DOM too often
|
Loading…
Reference in New Issue
Block a user