mirror of
https://github.com/iconify/iconify.git
synced 2025-02-12 08:38:30 +00:00
Merge branch 'dev/reusable-api' into dev/next
This commit is contained in:
commit
e6f69c6901
62
packages/browser-tests/package-lock.json
generated
62
packages/browser-tests/package-lock.json
generated
@ -9,8 +9,8 @@
|
||||
"version": "2.0.0",
|
||||
"license": "(Apache-2.0 OR GPL-2.0)",
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.1.1",
|
||||
"@iconify/iconify": "^2.0.0",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/iconify": "^2.1.0-beta.2",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
@ -29,38 +29,39 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.2.tgz",
|
||||
"integrity": "sha512-1NgvJqGqiXXhoT/O5R1pTvZTfbByMaT+rJeazt4jWH6G56RJLMuJ0iBjUBJWfKCLQQ1nsFAurxpdhpvfCJLI5g==",
|
||||
"version": "1.2.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.2.tgz",
|
||||
"integrity": "sha512-BnlanmZB5h+OXP0FIsfjMqsrAaDdHxVN5Y5jjYU4KrqaEwh9BiaIIr7lS/rXGk4UdnLps2NDjhkobuC7DXqm6A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.2"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/iconify": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/iconify/-/iconify-2.0.2.tgz",
|
||||
"integrity": "sha512-m3MDKXYRRsrVLZFFUkSaTv9/jTk0sLOlIhlmupj2/VhHnZt0i3ACyUD7rx/Vd5bLvtotrHaT5e/ZOLP7uiFmKQ==",
|
||||
"version": "2.1.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/iconify/-/iconify-2.1.0-beta.2.tgz",
|
||||
"integrity": "sha512-Me3zjSTP00qy4tUyIsHlY7W3YK/7wBFYpenfiPT+/Dexeeq9rr0nf4TFMF2d/q171CI0u0mOVrNgU8L+jnYqCQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.0.6"
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "http://github.com/sponsors/cyberalien"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.6.tgz",
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.7.tgz",
|
||||
"integrity": "sha512-zdwkVc67O9SqI/svsogD2s+XB3Uk4Xx+PrMEn5Qm3ktKSXFveZL0iP3yzqbrFg1KRRd93nRs4QycLaIRMhA0Pg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/utils": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.4.tgz",
|
||||
"integrity": "sha512-ZB9EWAzPmHtSVWWYJaQLgIWJbScdX4NmlDpQcgt8F6SZys1SR8/Ol2rK8+SsbSJKHsJduzKj3JmeEetsJ7Xjdw==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.7.tgz",
|
||||
"integrity": "sha512-ciJNYlqSxWdIZcCbE9FPL3o9o/U8ok0s8B7uf4lcGR57qyMaz3IUfihiBIb8YBr4eVp7eQDT2zV1Xpikkh/ePg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
@ -1756,35 +1757,36 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.2.tgz",
|
||||
"integrity": "sha512-1NgvJqGqiXXhoT/O5R1pTvZTfbByMaT+rJeazt4jWH6G56RJLMuJ0iBjUBJWfKCLQQ1nsFAurxpdhpvfCJLI5g==",
|
||||
"version": "1.2.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.2.tgz",
|
||||
"integrity": "sha512-BnlanmZB5h+OXP0FIsfjMqsrAaDdHxVN5Y5jjYU4KrqaEwh9BiaIIr7lS/rXGk4UdnLps2NDjhkobuC7DXqm6A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.2"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"@iconify/iconify": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/iconify/-/iconify-2.0.2.tgz",
|
||||
"integrity": "sha512-m3MDKXYRRsrVLZFFUkSaTv9/jTk0sLOlIhlmupj2/VhHnZt0i3ACyUD7rx/Vd5bLvtotrHaT5e/ZOLP7uiFmKQ==",
|
||||
"version": "2.1.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/iconify/-/iconify-2.1.0-beta.2.tgz",
|
||||
"integrity": "sha512-Me3zjSTP00qy4tUyIsHlY7W3YK/7wBFYpenfiPT+/Dexeeq9rr0nf4TFMF2d/q171CI0u0mOVrNgU8L+jnYqCQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cross-fetch": "^3.0.6"
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.6.tgz",
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.7.tgz",
|
||||
"integrity": "sha512-zdwkVc67O9SqI/svsogD2s+XB3Uk4Xx+PrMEn5Qm3ktKSXFveZL0iP3yzqbrFg1KRRd93nRs4QycLaIRMhA0Pg==",
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/utils": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.4.tgz",
|
||||
"integrity": "sha512-ZB9EWAzPmHtSVWWYJaQLgIWJbScdX4NmlDpQcgt8F6SZys1SR8/Ol2rK8+SsbSJKHsJduzKj3JmeEetsJ7Xjdw==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.7.tgz",
|
||||
"integrity": "sha512-ciJNYlqSxWdIZcCbE9FPL3o9o/U8ok0s8B7uf4lcGR57qyMaz3IUfihiBIb8YBr4eVp7eQDT2zV1Xpikkh/ePg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
|
@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"description": "Browser tests for @iconify/iconify package",
|
||||
"author": "Vjacheslav Trushkin <cyberalien@gmail.com> (https://iconify.design)",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0-beta.2",
|
||||
"license": "(Apache-2.0 OR GPL-2.0)",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
@ -18,8 +18,8 @@
|
||||
"build:dist": "rollup -c rollup.config.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.1.1",
|
||||
"@iconify/iconify": "^2.0.0",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/iconify": "^2.1.0-beta.2",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
|
@ -1,26 +1,26 @@
|
||||
import mocha from 'mocha';
|
||||
import chai from 'chai';
|
||||
|
||||
import { FakeData, setFakeData, prepareQuery, sendQuery } from './fake-api';
|
||||
import { API } from '@iconify/core/lib/api/';
|
||||
import { setAPIModule } from '@iconify/core/lib/api/modules';
|
||||
import { setAPIConfig } from '@iconify/core/lib/api/config';
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
import { loadIcons } from '@iconify/core/lib/api/icons';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
// Set API
|
||||
setAPIModule('', {
|
||||
prepare: prepareQuery,
|
||||
send: sendQuery,
|
||||
});
|
||||
coreModules.api = API;
|
||||
|
||||
let prefixCounter = 0;
|
||||
function nextPrefix(): string {
|
||||
return 'fake-api-' + prefixCounter++;
|
||||
}
|
||||
|
||||
describe('Testing fake API', () => {
|
||||
before(() => {
|
||||
setAPIModule('', {
|
||||
prepare: prepareQuery,
|
||||
send: sendQuery,
|
||||
});
|
||||
});
|
||||
|
||||
it('Loading results', (done) => {
|
||||
const provider = nextPrefix();
|
||||
const prefix = nextPrefix();
|
||||
@ -30,12 +30,10 @@ describe('Testing fake API', () => {
|
||||
prefix,
|
||||
icons: {
|
||||
icon1: {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
icon2: {
|
||||
body:
|
||||
'<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -48,7 +46,7 @@ describe('Testing fake API', () => {
|
||||
setFakeData(provider, prefix, data);
|
||||
|
||||
// Attempt to load icons
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
provider + ':' + prefix + ':icon1',
|
||||
provider + ':' + prefix + ':icon2',
|
||||
@ -81,12 +79,10 @@ describe('Testing fake API', () => {
|
||||
prefix,
|
||||
icons: {
|
||||
icon1: {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
icon2: {
|
||||
body:
|
||||
'<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -100,7 +96,7 @@ describe('Testing fake API', () => {
|
||||
|
||||
// Attempt to load icons
|
||||
const start = Date.now();
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
{
|
||||
provider,
|
||||
@ -144,8 +140,7 @@ describe('Testing fake API', () => {
|
||||
prefix,
|
||||
icons: {
|
||||
icon1: {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -161,7 +156,7 @@ describe('Testing fake API', () => {
|
||||
|
||||
// Attempt to load icons
|
||||
let counter = 0;
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
provider + ':' + prefix + ':icon1',
|
||||
provider + ':' + prefix + ':icon2',
|
||||
|
@ -13,11 +13,13 @@ import { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
// Add finders
|
||||
addFinder(iconifyFinder);
|
||||
addFinder(iconifyIconFinder);
|
||||
|
||||
describe('Testing legacy finder', () => {
|
||||
before(() => {
|
||||
// Add finders
|
||||
addFinder(iconifyFinder);
|
||||
addFinder(iconifyIconFinder);
|
||||
});
|
||||
|
||||
it('Finding nodes', () => {
|
||||
const node = getNode('finder');
|
||||
node.innerHTML =
|
||||
|
@ -13,11 +13,13 @@ import { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
// Add finders
|
||||
addFinder(iconifyFinder);
|
||||
addFinder(iconifyIconFinder);
|
||||
|
||||
describe('Testing finder', () => {
|
||||
before(() => {
|
||||
// Add finders
|
||||
addFinder(iconifyFinder);
|
||||
addFinder(iconifyIconFinder);
|
||||
});
|
||||
|
||||
it('Finding nodes', () => {
|
||||
const node = getNode('finder');
|
||||
node.innerHTML =
|
||||
|
@ -19,31 +19,34 @@ import { IconifyElement } from '@iconify/iconify/lib/modules/element';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
// Add finders
|
||||
addFinder(iconifyIconFinder);
|
||||
addFinder(iconifyFinder);
|
||||
|
||||
describe('Testing legacy renderer', () => {
|
||||
// Add mentioned icons to storage
|
||||
const storage = getStorage('', 'mdi');
|
||||
addIconSet(storage, {
|
||||
prefix: 'mdi',
|
||||
icons: {
|
||||
'account-box': {
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
|
||||
before(() => {
|
||||
// Add finders
|
||||
addFinder(iconifyIconFinder);
|
||||
addFinder(iconifyFinder);
|
||||
|
||||
// Add mentioned icons to storage
|
||||
addIconSet(storage, {
|
||||
prefix: 'mdi',
|
||||
icons: {
|
||||
'account-box': {
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
},
|
||||
'account-cash': {
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
'account-cash': {
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
height: 24,
|
||||
width: 24,
|
||||
height: 24,
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert placeholders to SVG', () => {
|
||||
|
@ -19,31 +19,34 @@ import { IconifyElement } from '@iconify/iconify/lib/modules/element';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
// Add finders
|
||||
addFinder(iconifyIconFinder);
|
||||
addFinder(iconifyFinder);
|
||||
|
||||
describe('Testing renderer', () => {
|
||||
// Add mentioned icons to storage
|
||||
const storage = getStorage('', 'mdi');
|
||||
addIconSet(storage, {
|
||||
prefix: 'mdi',
|
||||
icons: {
|
||||
'account-box': {
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
|
||||
before(() => {
|
||||
// Add finders
|
||||
addFinder(iconifyIconFinder);
|
||||
addFinder(iconifyFinder);
|
||||
|
||||
// Add mentioned icons to storage
|
||||
addIconSet(storage, {
|
||||
prefix: 'mdi',
|
||||
icons: {
|
||||
'account-box': {
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
},
|
||||
'account-cash': {
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
'account-cash': {
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
height: 24,
|
||||
width: 24,
|
||||
height: 24,
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert placeholders to SVG', () => {
|
||||
|
@ -19,24 +19,21 @@ addFinder(iconifyIconFinder);
|
||||
describe('Scanning DOM', () => {
|
||||
// Add mentioned icons to storage
|
||||
const storage = getStorage('', 'mdi');
|
||||
|
||||
addIconSet(storage, {
|
||||
prefix: 'mdi',
|
||||
icons: {
|
||||
'account-box': {
|
||||
body:
|
||||
'<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
},
|
||||
'account-cash': {
|
||||
body:
|
||||
'<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body:
|
||||
'<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
|
@ -16,35 +16,34 @@ import {
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
// Add finders
|
||||
addFinder(iconifyFinder);
|
||||
addFinder(iconifyIconFinder);
|
||||
|
||||
describe('Observe DOM', () => {
|
||||
// Add mentioned icons to storage
|
||||
const storage = getStorage('', 'mdi');
|
||||
addIconSet(storage, {
|
||||
prefix: 'mdi',
|
||||
icons: {
|
||||
'account-box': {
|
||||
body:
|
||||
'<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
|
||||
before(() => {
|
||||
// Add finders
|
||||
addFinder(iconifyFinder);
|
||||
addFinder(iconifyIconFinder);
|
||||
|
||||
// Add mentioned icons to storage
|
||||
addIconSet(storage, {
|
||||
prefix: 'mdi',
|
||||
icons: {
|
||||
'account-box': {
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
},
|
||||
'account-cash': {
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
'account-cash': {
|
||||
body:
|
||||
'<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body:
|
||||
'<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
height: 24,
|
||||
width: 24,
|
||||
height: 24,
|
||||
});
|
||||
});
|
||||
|
||||
it('Basic test', (done) => {
|
||||
|
@ -4,10 +4,8 @@ import chai from 'chai';
|
||||
import { getNode, setRoot } from './node';
|
||||
import { addFinder } from '@iconify/iconify/lib/modules/finder';
|
||||
import { FakeData, setFakeData, prepareQuery, sendQuery } from './fake-api';
|
||||
import { API } from '@iconify/core/lib/api/';
|
||||
import { setAPIModule } from '@iconify/core/lib/api/modules';
|
||||
import { setAPIConfig } from '@iconify/core/lib/api/config';
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
import { finder as iconifyFinder } from '@iconify/iconify/lib/finders/iconify';
|
||||
import { finder as iconifyIconFinder } from '@iconify/iconify/lib/finders/iconify-icon';
|
||||
import { listRootNodes } from '@iconify/iconify/lib/modules/root';
|
||||
@ -15,23 +13,24 @@ import { scanDOM, scanElement } from '@iconify/iconify/lib/modules/scanner';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
// Add finders
|
||||
addFinder(iconifyFinder);
|
||||
addFinder(iconifyIconFinder);
|
||||
|
||||
// Set API
|
||||
setAPIModule('', {
|
||||
prepare: prepareQuery,
|
||||
send: sendQuery,
|
||||
});
|
||||
coreModules.api = API;
|
||||
|
||||
let prefixCounter = 0;
|
||||
function nextPrefix(): string {
|
||||
return 'scan-dom-api-' + prefixCounter++;
|
||||
}
|
||||
|
||||
describe('Scanning DOM with API', () => {
|
||||
before(() => {
|
||||
// Add finders
|
||||
addFinder(iconifyFinder);
|
||||
addFinder(iconifyIconFinder);
|
||||
|
||||
// Set API
|
||||
setAPIModule('', {
|
||||
prepare: prepareQuery,
|
||||
send: sendQuery,
|
||||
});
|
||||
});
|
||||
|
||||
it('Scan DOM with API', (done) => {
|
||||
const provider = nextPrefix();
|
||||
const prefix1 = nextPrefix();
|
||||
@ -50,12 +49,10 @@ describe('Scanning DOM with API', () => {
|
||||
prefix: prefix1,
|
||||
icons: {
|
||||
'account-cash': {
|
||||
body:
|
||||
'<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -71,12 +68,10 @@ describe('Scanning DOM with API', () => {
|
||||
prefix: prefix2,
|
||||
icons: {
|
||||
'account-box': {
|
||||
body:
|
||||
'<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body:
|
||||
'<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -163,12 +158,10 @@ describe('Scanning DOM with API', () => {
|
||||
prefix: prefix1,
|
||||
icons: {
|
||||
'account-cash': {
|
||||
body:
|
||||
'<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -184,12 +177,10 @@ describe('Scanning DOM with API', () => {
|
||||
prefix: prefix2,
|
||||
icons: {
|
||||
'account-box': {
|
||||
body:
|
||||
'<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body:
|
||||
'<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -205,12 +196,10 @@ describe('Scanning DOM with API', () => {
|
||||
prefix: prefix1,
|
||||
icons: {
|
||||
'account-box': {
|
||||
body:
|
||||
'<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body:
|
||||
'<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -318,12 +307,10 @@ describe('Scanning DOM with API', () => {
|
||||
prefix: prefix1,
|
||||
icons: {
|
||||
'account-cash': {
|
||||
body:
|
||||
'<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
body: '<path d="M11 8c0 2.21-1.79 4-4 4s-4-1.79-4-4s1.79-4 4-4s4 1.79 4 4m0 6.72V20H0v-2c0-2.21 3.13-4 7-4c1.5 0 2.87.27 4 .72M24 20H13V3h11v17m-8-8.5a2.5 2.5 0 0 1 5 0a2.5 2.5 0 0 1-5 0M22 7a2 2 0 0 1-2-2h-3c0 1.11-.89 2-2 2v9a2 2 0 0 1 2 2h3c0-1.1.9-2 2-2V7z" fill="currentColor"/>',
|
||||
},
|
||||
'home': {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -339,12 +326,10 @@ describe('Scanning DOM with API', () => {
|
||||
prefix: prefix2,
|
||||
icons: {
|
||||
'account-box': {
|
||||
body:
|
||||
'<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
body: '<path d="M6 17c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6m9-9a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3M3 5v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z" fill="currentColor"/>',
|
||||
},
|
||||
'account': {
|
||||
body:
|
||||
'<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
body: '<path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
@ -423,8 +408,7 @@ describe('Scanning DOM with API', () => {
|
||||
prefix,
|
||||
icons: {
|
||||
home: {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { PendingQueryItem } from '@iconify/api-redundancy';
|
||||
import {
|
||||
APIQueryParams,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIIconsQueryParams,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
} from '@iconify/core/lib/api/modules';
|
||||
import { IconifyJSON } from '@iconify/types';
|
||||
@ -38,20 +39,20 @@ export function setFakeData(
|
||||
providerFakeData[prefix].push(item);
|
||||
}
|
||||
|
||||
interface FakeAPIQueryParams extends APIQueryParams {
|
||||
interface FakeAPIQueryParams extends IconifyAPIIconsQueryParams {
|
||||
data: FakeData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare params
|
||||
*/
|
||||
export const prepareQuery: IconifyAPIPrepareQuery = (
|
||||
export const prepareQuery: IconifyAPIPrepareIconsQuery = (
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
// Find items that have query
|
||||
const items: APIQueryParams[] = [];
|
||||
const items: IconifyAPIIconsQueryParams[] = [];
|
||||
let missing = icons.slice(0);
|
||||
|
||||
if (fakeData[provider] === void 0) {
|
||||
@ -59,6 +60,7 @@ export const prepareQuery: IconifyAPIPrepareQuery = (
|
||||
}
|
||||
const providerFakeData = fakeData[provider];
|
||||
|
||||
const type = 'icons';
|
||||
if (providerFakeData[prefix] !== void 0) {
|
||||
providerFakeData[prefix].forEach((item) => {
|
||||
const matches = item.icons.filter(
|
||||
@ -72,6 +74,7 @@ export const prepareQuery: IconifyAPIPrepareQuery = (
|
||||
// Contains at least one matching icon
|
||||
missing = missing.filter((icon) => matches.indexOf(icon) === -1);
|
||||
const query: FakeAPIQueryParams = {
|
||||
type,
|
||||
provider,
|
||||
prefix,
|
||||
icons: matches,
|
||||
@ -89,9 +92,15 @@ export const prepareQuery: IconifyAPIPrepareQuery = (
|
||||
*/
|
||||
export const sendQuery: IconifyAPISendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
params: IconifyAPIQueryParams,
|
||||
status: PendingQueryItem
|
||||
): void => {
|
||||
if (params.type !== 'icons') {
|
||||
// Fake API supports only icons
|
||||
status.done(void 0, 400);
|
||||
return;
|
||||
}
|
||||
|
||||
const provider = params.provider;
|
||||
const prefix = params.prefix;
|
||||
const icons = params.icons;
|
||||
|
434
packages/core/package-lock.json
generated
434
packages/core/package-lock.json
generated
@ -1,20 +1,21 @@
|
||||
{
|
||||
"name": "@iconify/core",
|
||||
"version": "1.1.3",
|
||||
"version": "1.2.0-beta.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@iconify/core",
|
||||
"version": "1.1.3",
|
||||
"version": "1.2.0-beta.2",
|
||||
"license": "(Apache-2.0 OR GPL-2.0)",
|
||||
"dependencies": {
|
||||
"@iconify/api-redundancy": "^1.0.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/library-builder": "^1.0.0",
|
||||
"@iconify/library-builder": "^1.0.2",
|
||||
"@types/chai": "^4.2.18",
|
||||
"@types/mocha": "^8.2.2",
|
||||
"@types/node": "^15.3.0",
|
||||
@ -37,9 +38,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/helper-validator-identifier": {
|
||||
"version": "7.14.9",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.9.tgz",
|
||||
"integrity": "sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g==",
|
||||
"version": "7.15.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz",
|
||||
"integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
@ -176,9 +177,9 @@
|
||||
"integrity": "sha512-cdjhaq0ALKjVMTgPZR3T4C9GzvsFa7awltd7uGf8nmw96uIEpgRJpmkOksZV7oyTtN0kfMmLMs/ZGTA0t4rEEQ=="
|
||||
},
|
||||
"node_modules/@iconify/library-builder": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/library-builder/-/library-builder-1.0.0.tgz",
|
||||
"integrity": "sha512-xdzmA5JrD+LBPfR2b2e9lb+pQXgK+nkJhL7qTaGpNCHwCsa8HeQZyuEtvTdMUKqONeEEvZkvdUdv/lK1fn3Jtw==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/library-builder/-/library-builder-1.0.2.tgz",
|
||||
"integrity": "sha512-3fxQIxApNwTrlzdEC2wYstYgAdzsAYOHHpDn4TEddBb/mTxmI5eZwWIDsMLdqXrr1iMoxSAqeipp19JaC2e1Gg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "^15.3.0",
|
||||
@ -313,53 +314,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz",
|
||||
"integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz",
|
||||
"integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz",
|
||||
"integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/experimental-utils": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.31.1.tgz",
|
||||
@ -384,7 +338,35 @@
|
||||
"eslint": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/experimental-utils/node_modules/@typescript-eslint/scope-manager": {
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.1.tgz",
|
||||
"integrity": "sha512-dnVZDB6FhpIby6yVbHkwTKkn2ypjVIfAR9nh+kYsA/ZL0JlTsd22BiDjouotisY3Irmd3OW1qlk9EI5R8GrvRQ==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "4.31.1",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/typescript-estree": "4.31.1",
|
||||
"debug": "^4.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10.12.0 || >=12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz",
|
||||
"integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==",
|
||||
@ -401,7 +383,7 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/experimental-utils/node_modules/@typescript-eslint/types": {
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz",
|
||||
"integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==",
|
||||
@ -414,7 +396,7 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/experimental-utils/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz",
|
||||
"integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==",
|
||||
@ -441,7 +423,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/experimental-utils/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz",
|
||||
"integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==",
|
||||
@ -458,112 +440,6 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.0.tgz",
|
||||
"integrity": "sha512-+92YRNHFdXgq+GhWQPT2bmjX09X7EH36JfgN2/4wmhtwV/HPxozpCNst8jrWcngLtEVd/4zAwA6BKojAlf+YqA==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "4.29.0",
|
||||
"@typescript-eslint/types": "4.29.0",
|
||||
"@typescript-eslint/typescript-estree": "4.29.0",
|
||||
"debug": "^4.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10.12.0 || >=12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.0.tgz",
|
||||
"integrity": "sha512-HPq7XAaDMM3DpmuijxLV9Io8/6pQnliiXMQUcAdjpJJSR+fdmbD/zHCd7hMkjJn04UQtCQBtshgxClzg6NIS2w==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "4.29.0",
|
||||
"@typescript-eslint/visitor-keys": "4.29.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.0.tgz",
|
||||
"integrity": "sha512-2YJM6XfWfi8pgU2HRhTp7WgRw78TCRO3dOmSpAvIQ8MOv4B46JD2chnhpNT7Jq8j0APlIbzO1Bach734xxUl4A==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.0.tgz",
|
||||
"integrity": "sha512-8ZpNHDIOyqzzgZrQW9+xQ4k5hM62Xy2R4RPO3DQxMc5Rq5QkCdSpk/drka+DL9w6sXNzV5nrdlBmf8+x495QXQ==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "4.29.0",
|
||||
"@typescript-eslint/visitor-keys": "4.29.0",
|
||||
"debug": "^4.3.1",
|
||||
"globby": "^11.0.3",
|
||||
"is-glob": "^4.0.1",
|
||||
"semver": "^7.3.5",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10.12.0 || >=12.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.0.tgz",
|
||||
"integrity": "sha512-LoaofO1C/jAJYs0uEpYMXfHboGXzOJeV118X4OsZu9f7rG7Pr9B3+4HTU8+err81rADa4xfQmAxnRnPAI2jp+Q==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "4.29.0",
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@ungap/promise-all-settled": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
|
||||
@ -617,9 +493,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-regex": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
|
||||
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@ -869,6 +745,14 @@
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"dependencies": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@ -925,9 +809,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/deep-is": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
|
||||
"integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
|
||||
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
@ -1273,9 +1157,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fastq": {
|
||||
"version": "1.11.1",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.11.1.tgz",
|
||||
"integrity": "sha512-HOnr8Mc60eNYl1gzwp6r5RoUyAn5/glBolUzP/Ez6IFVPMPirxn/9phgL6zhOtaTy7ISwPvQ+wT+hfcRZh/bzw==",
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz",
|
||||
"integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"reusify": "^1.0.4"
|
||||
@ -1440,9 +1324,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "13.10.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.10.0.tgz",
|
||||
"integrity": "sha512-piHC3blgLGFjvOuMmWZX60f+na1lXFDhQXBf1UYp2fXPXqvEUbOhNwi6BsQ0bQishwedgnjkwv1d9zKf+MWw3g==",
|
||||
"version": "13.11.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz",
|
||||
"integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"type-fest": "^0.20.2"
|
||||
@ -1912,6 +1796,14 @@
|
||||
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/normalize-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||
@ -2366,9 +2258,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/table/node_modules/ajv": {
|
||||
"version": "8.6.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.2.tgz",
|
||||
"integrity": "sha512-9807RlWAgT564wT+DjeyU5OFMPjmzxVobvDFmNAhY+5zD6A2ly3jDp6sgnfyDtlIQ+7H97oc/DGCzzfu9rjw9w==",
|
||||
"version": "8.6.3",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz",
|
||||
"integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
@ -2673,9 +2565,9 @@
|
||||
}
|
||||
},
|
||||
"@babel/helper-validator-identifier": {
|
||||
"version": "7.14.9",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.9.tgz",
|
||||
"integrity": "sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g==",
|
||||
"version": "7.15.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz",
|
||||
"integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==",
|
||||
"dev": true
|
||||
},
|
||||
"@babel/highlight": {
|
||||
@ -2787,9 +2679,9 @@
|
||||
"integrity": "sha512-cdjhaq0ALKjVMTgPZR3T4C9GzvsFa7awltd7uGf8nmw96uIEpgRJpmkOksZV7oyTtN0kfMmLMs/ZGTA0t4rEEQ=="
|
||||
},
|
||||
"@iconify/library-builder": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/library-builder/-/library-builder-1.0.0.tgz",
|
||||
"integrity": "sha512-xdzmA5JrD+LBPfR2b2e9lb+pQXgK+nkJhL7qTaGpNCHwCsa8HeQZyuEtvTdMUKqONeEEvZkvdUdv/lK1fn3Jtw==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/library-builder/-/library-builder-1.0.2.tgz",
|
||||
"integrity": "sha512-3fxQIxApNwTrlzdEC2wYstYgAdzsAYOHHpDn4TEddBb/mTxmI5eZwWIDsMLdqXrr1iMoxSAqeipp19JaC2e1Gg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "^15.3.0",
|
||||
@ -2897,34 +2789,6 @@
|
||||
"regexpp": "^3.1.0",
|
||||
"semver": "^7.3.5",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz",
|
||||
"integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz",
|
||||
"integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz",
|
||||
"integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/experimental-utils": {
|
||||
@ -2939,91 +2803,45 @@
|
||||
"@typescript-eslint/typescript-estree": "4.31.1",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"eslint-utils": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz",
|
||||
"integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz",
|
||||
"integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz",
|
||||
"integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1",
|
||||
"debug": "^4.3.1",
|
||||
"globby": "^11.0.3",
|
||||
"is-glob": "^4.0.1",
|
||||
"semver": "^7.3.5",
|
||||
"tsutils": "^3.21.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz",
|
||||
"integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.0.tgz",
|
||||
"integrity": "sha512-+92YRNHFdXgq+GhWQPT2bmjX09X7EH36JfgN2/4wmhtwV/HPxozpCNst8jrWcngLtEVd/4zAwA6BKojAlf+YqA==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.1.tgz",
|
||||
"integrity": "sha512-dnVZDB6FhpIby6yVbHkwTKkn2ypjVIfAR9nh+kYsA/ZL0JlTsd22BiDjouotisY3Irmd3OW1qlk9EI5R8GrvRQ==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/scope-manager": "4.29.0",
|
||||
"@typescript-eslint/types": "4.29.0",
|
||||
"@typescript-eslint/typescript-estree": "4.29.0",
|
||||
"@typescript-eslint/scope-manager": "4.31.1",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/typescript-estree": "4.31.1",
|
||||
"debug": "^4.3.1"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/scope-manager": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.0.tgz",
|
||||
"integrity": "sha512-HPq7XAaDMM3DpmuijxLV9Io8/6pQnliiXMQUcAdjpJJSR+fdmbD/zHCd7hMkjJn04UQtCQBtshgxClzg6NIS2w==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz",
|
||||
"integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.29.0",
|
||||
"@typescript-eslint/visitor-keys": "4.29.0"
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.0.tgz",
|
||||
"integrity": "sha512-2YJM6XfWfi8pgU2HRhTp7WgRw78TCRO3dOmSpAvIQ8MOv4B46JD2chnhpNT7Jq8j0APlIbzO1Bach734xxUl4A==",
|
||||
"dev": true,
|
||||
"peer": true
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz",
|
||||
"integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.0.tgz",
|
||||
"integrity": "sha512-8ZpNHDIOyqzzgZrQW9+xQ4k5hM62Xy2R4RPO3DQxMc5Rq5QkCdSpk/drka+DL9w6sXNzV5nrdlBmf8+x495QXQ==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz",
|
||||
"integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.29.0",
|
||||
"@typescript-eslint/visitor-keys": "4.29.0",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"@typescript-eslint/visitor-keys": "4.31.1",
|
||||
"debug": "^4.3.1",
|
||||
"globby": "^11.0.3",
|
||||
"is-glob": "^4.0.1",
|
||||
@ -3032,13 +2850,12 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "4.29.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.0.tgz",
|
||||
"integrity": "sha512-LoaofO1C/jAJYs0uEpYMXfHboGXzOJeV118X4OsZu9f7rG7Pr9B3+4HTU8+err81rADa4xfQmAxnRnPAI2jp+Q==",
|
||||
"version": "4.31.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz",
|
||||
"integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.29.0",
|
||||
"@typescript-eslint/types": "4.31.1",
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
}
|
||||
},
|
||||
@ -3080,9 +2897,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
|
||||
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-styles": {
|
||||
@ -3273,6 +3090,14 @@
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"requires": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@ -3309,9 +3134,9 @@
|
||||
}
|
||||
},
|
||||
"deep-is": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
|
||||
"integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
|
||||
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
|
||||
"dev": true
|
||||
},
|
||||
"delayed-stream": {
|
||||
@ -3572,9 +3397,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"fastq": {
|
||||
"version": "1.11.1",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.11.1.tgz",
|
||||
"integrity": "sha512-HOnr8Mc60eNYl1gzwp6r5RoUyAn5/glBolUzP/Ez6IFVPMPirxn/9phgL6zhOtaTy7ISwPvQ+wT+hfcRZh/bzw==",
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz",
|
||||
"integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"reusify": "^1.0.4"
|
||||
@ -3696,9 +3521,9 @@
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"version": "13.10.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.10.0.tgz",
|
||||
"integrity": "sha512-piHC3blgLGFjvOuMmWZX60f+na1lXFDhQXBf1UYp2fXPXqvEUbOhNwi6BsQ0bQishwedgnjkwv1d9zKf+MWw3g==",
|
||||
"version": "13.11.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.11.0.tgz",
|
||||
"integrity": "sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"type-fest": "^0.20.2"
|
||||
@ -4053,6 +3878,11 @@
|
||||
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
||||
"dev": true
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||
},
|
||||
"normalize-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||
@ -4347,9 +4177,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": {
|
||||
"version": "8.6.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.2.tgz",
|
||||
"integrity": "sha512-9807RlWAgT564wT+DjeyU5OFMPjmzxVobvDFmNAhY+5zD6A2ly3jDp6sgnfyDtlIQ+7H97oc/DGCzzfu9rjw9w==",
|
||||
"version": "8.6.3",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.3.tgz",
|
||||
"integrity": "sha512-SMJOdDP6LqTkD0Uq8qLi+gMwSt0imXLSV080qFVwJCpH9U6Mb+SUGHAXM0KNbcBPguytWyvFxcHgMLe2D2XSpw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fast-deep-equal": "^3.1.1",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "@iconify/core",
|
||||
"description": "Reusable files used by multiple Iconify packages",
|
||||
"author": "Vjacheslav Trushkin <cyberalien@gmail.com> (https://iconify.design)",
|
||||
"version": "1.1.3",
|
||||
"version": "1.2.0-beta.2",
|
||||
"license": "(Apache-2.0 OR GPL-2.0)",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
@ -34,17 +34,9 @@
|
||||
"require": "./lib/api/functions.js",
|
||||
"import": "./lib/api/functions.mjs"
|
||||
},
|
||||
"./lib/api/": {
|
||||
"require": "./lib/api/index.js",
|
||||
"import": "./lib/api/index.mjs"
|
||||
},
|
||||
"./lib/api": {
|
||||
"require": "./lib/api/index.js",
|
||||
"import": "./lib/api/index.mjs"
|
||||
},
|
||||
"./lib/api/index": {
|
||||
"require": "./lib/api/index.js",
|
||||
"import": "./lib/api/index.mjs"
|
||||
"./lib/api/icons": {
|
||||
"require": "./lib/api/icons.js",
|
||||
"import": "./lib/api/icons.mjs"
|
||||
},
|
||||
"./lib/api/modules": {
|
||||
"require": "./lib/api/modules.js",
|
||||
@ -62,6 +54,14 @@
|
||||
"require": "./lib/api/modules/mock.js",
|
||||
"import": "./lib/api/modules/mock.mjs"
|
||||
},
|
||||
"./lib/api/params": {
|
||||
"require": "./lib/api/params.js",
|
||||
"import": "./lib/api/params.mjs"
|
||||
},
|
||||
"./lib/api/query": {
|
||||
"require": "./lib/api/query.js",
|
||||
"import": "./lib/api/query.mjs"
|
||||
},
|
||||
"./lib/browser-storage/functions": {
|
||||
"require": "./lib/browser-storage/functions.js",
|
||||
"import": "./lib/browser-storage/functions.mjs"
|
||||
@ -82,6 +82,10 @@
|
||||
"require": "./lib/builder/functions.js",
|
||||
"import": "./lib/builder/functions.mjs"
|
||||
},
|
||||
"./lib/cache": {
|
||||
"require": "./lib/cache.js",
|
||||
"import": "./lib/cache.mjs"
|
||||
},
|
||||
"./lib/icon/list": {
|
||||
"require": "./lib/icon/list.js",
|
||||
"import": "./lib/icon/list.mjs"
|
||||
@ -90,22 +94,6 @@
|
||||
"require": "./lib/icon/sort.js",
|
||||
"import": "./lib/icon/sort.mjs"
|
||||
},
|
||||
"./lib/interfaces/api": {
|
||||
"require": "./lib/interfaces/api.js",
|
||||
"import": "./lib/interfaces/api.mjs"
|
||||
},
|
||||
"./lib/interfaces/cache": {
|
||||
"require": "./lib/interfaces/cache.js",
|
||||
"import": "./lib/interfaces/cache.mjs"
|
||||
},
|
||||
"./lib/interfaces/loader": {
|
||||
"require": "./lib/interfaces/loader.js",
|
||||
"import": "./lib/interfaces/loader.mjs"
|
||||
},
|
||||
"./lib/modules": {
|
||||
"require": "./lib/modules.js",
|
||||
"import": "./lib/modules.mjs"
|
||||
},
|
||||
"./lib/storage/functions": {
|
||||
"require": "./lib/storage/functions.js",
|
||||
"import": "./lib/storage/functions.mjs"
|
||||
@ -118,10 +106,11 @@
|
||||
"dependencies": {
|
||||
"@iconify/api-redundancy": "^1.0.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/library-builder": "^1.0.0",
|
||||
"@iconify/library-builder": "^1.0.2",
|
||||
"@types/chai": "^4.2.18",
|
||||
"@types/mocha": "^8.2.2",
|
||||
"@types/node": "^15.3.0",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import type {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '../interfaces/loader';
|
||||
} from './icons';
|
||||
import { getStorage } from '../storage/storage';
|
||||
import type { SortedIcons } from '../icon/sort';
|
||||
import type { IconifyIconSource } from '@iconify/utils/lib/icon/name';
|
||||
@ -25,10 +25,13 @@ interface CallbackItem {
|
||||
|
||||
// Records sorted by provider and prefix
|
||||
// This export is only for unit testing, should not be used
|
||||
export const callbacks: Record<string, Record<string, CallbackItem[]>> =
|
||||
Object.create(null);
|
||||
const pendingUpdates: Record<string, Record<string, boolean>> =
|
||||
Object.create(null);
|
||||
export const callbacks: Record<
|
||||
string,
|
||||
Record<string, CallbackItem[]>
|
||||
> = Object.create(null);
|
||||
const pendingUpdates: Record<string, Record<string, boolean>> = Object.create(
|
||||
null
|
||||
);
|
||||
|
||||
/**
|
||||
* Remove callback
|
||||
|
@ -17,7 +17,7 @@ export type PartialIconifyAPIConfig = Partial<IconifyAPIConfig> &
|
||||
/**
|
||||
* Create full API configuration from partial data
|
||||
*/
|
||||
function createConfig(
|
||||
export function createAPIConfig(
|
||||
source: PartialIconifyAPIConfig
|
||||
): IconifyAPIConfig | null {
|
||||
let resources;
|
||||
@ -100,7 +100,7 @@ while (fallBackAPISources.length > 0) {
|
||||
}
|
||||
|
||||
// Add default API
|
||||
configStorage[''] = createConfig({
|
||||
configStorage[''] = createAPIConfig({
|
||||
resources: ['https://api.iconify.design'].concat(fallBackAPI),
|
||||
}) as IconifyAPIConfig;
|
||||
|
||||
@ -111,7 +111,7 @@ export function setAPIConfig(
|
||||
provider: string,
|
||||
customConfig: PartialIconifyAPIConfig
|
||||
): boolean {
|
||||
const config = createConfig(customConfig);
|
||||
const config = createAPIConfig(customConfig);
|
||||
if (config === null) {
|
||||
return false;
|
||||
}
|
||||
@ -127,6 +127,13 @@ export type GetAPIConfig = (provider: string) => IconifyAPIConfig | undefined;
|
||||
/**
|
||||
* Get API configuration
|
||||
*/
|
||||
export const getAPIConfig: GetAPIConfig = (
|
||||
provider: string
|
||||
): IconifyAPIConfig | undefined => configStorage[provider];
|
||||
export function getAPIConfig(provider: string): IconifyAPIConfig | undefined {
|
||||
return configStorage[provider];
|
||||
}
|
||||
|
||||
/**
|
||||
* List API providers
|
||||
*/
|
||||
export function listAPIProviders(): string[] {
|
||||
return Object.keys(configStorage);
|
||||
}
|
||||
|
@ -1,14 +1,27 @@
|
||||
import type { IconifyAPIInternalStorage } from '.';
|
||||
import { API, getRedundancyCache } from '.';
|
||||
import type {
|
||||
QueryAbortCallback,
|
||||
QueryDoneCallback,
|
||||
} from '@iconify/api-redundancy';
|
||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||
import { sendAPIQuery } from './query';
|
||||
import { loadIcons } from './icons';
|
||||
import type {
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyIconLoaderCallback,
|
||||
} from '../interfaces/loader';
|
||||
import type { GetAPIConfig, PartialIconifyAPIConfig } from './config';
|
||||
import { getAPIConfig, setAPIConfig } from './config';
|
||||
import type { IconifyAPIModule } from './modules';
|
||||
} from './icons';
|
||||
import type {
|
||||
GetAPIConfig,
|
||||
PartialIconifyAPIConfig,
|
||||
} from './config';
|
||||
import { getAPIConfig, setAPIConfig, listAPIProviders } from './config';
|
||||
import type {
|
||||
IconifyAPIModule,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
} from './modules';
|
||||
import { setAPIModule } from './modules';
|
||||
import type { MergeParams, IconifyAPIMergeQueryParams } from './params';
|
||||
import { mergeParams } from './params';
|
||||
|
||||
/**
|
||||
* Iconify API functions
|
||||
@ -32,7 +45,7 @@ export interface IconifyAPIFunctions {
|
||||
}
|
||||
|
||||
export const APIFunctions: IconifyAPIFunctions = {
|
||||
loadIcons: API.loadIcons,
|
||||
loadIcons,
|
||||
addAPIProvider: setAPIConfig,
|
||||
};
|
||||
|
||||
@ -44,31 +57,55 @@ export const APIFunctions: IconifyAPIFunctions = {
|
||||
* Important: any changes published in a release must be backwards compatible.
|
||||
*/
|
||||
export interface IconifyAPIInternalFunctions {
|
||||
/**
|
||||
* 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
|
||||
* Set custom API module
|
||||
*/
|
||||
setAPIModule: (provider: string, item: IconifyAPIModule) => void;
|
||||
|
||||
/**
|
||||
* Optional setFetch (should be imported from ./modules/fetch if fetch is used)
|
||||
*
|
||||
* Used to set custom fetch function, such as one provided by cross-fetch, making fetch usable on server
|
||||
* Send API query
|
||||
*/
|
||||
sendAPIQuery: (
|
||||
target: string | PartialIconifyAPIConfig,
|
||||
query: IconifyAPIQueryParams,
|
||||
callback: QueryDoneCallback
|
||||
) => QueryAbortCallback;
|
||||
|
||||
/**
|
||||
* Optional setFetch and getFetch (should be imported from ./modules/fetch if fetch is used)
|
||||
*/
|
||||
setFetch?: (item: typeof fetch) => void;
|
||||
getFetch?: () => typeof fetch | null;
|
||||
|
||||
/**
|
||||
* List all API providers (from config)
|
||||
*/
|
||||
listAPIProviders: () => string[];
|
||||
|
||||
/**
|
||||
* Merge parameters
|
||||
*/
|
||||
mergeParams: MergeParams;
|
||||
}
|
||||
|
||||
export const APIInternalFunctions: IconifyAPIInternalFunctions = {
|
||||
getAPI: getRedundancyCache,
|
||||
getAPIConfig,
|
||||
setAPIModule,
|
||||
sendAPIQuery,
|
||||
listAPIProviders,
|
||||
mergeParams,
|
||||
};
|
||||
|
||||
/**
|
||||
* Types needed for internal functions
|
||||
*/
|
||||
export type {
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
};
|
||||
|
@ -1,32 +1,53 @@
|
||||
import type { Redundancy, QueryModuleCallback } from '@iconify/api-redundancy';
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
import { initRedundancy } from '@iconify/api-redundancy';
|
||||
import type { SortedIcons } from '../icon/sort';
|
||||
import { sortIcons } from '../icon/sort';
|
||||
import type {
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyLoadIcons,
|
||||
} from '../interfaces/loader';
|
||||
import type { IsPending, IconifyAPI } from '../interfaces/api';
|
||||
import { storeCallback, updateCallbacks } from './callbacks';
|
||||
import { getAPIModule } from './modules';
|
||||
import type { IconifyAPIConfig } from './config';
|
||||
import { getAPIConfig } from './config';
|
||||
import { getStorage, addIconSet } from '../storage/storage';
|
||||
import { coreModules } from '../modules';
|
||||
import type {
|
||||
IconifyIconName,
|
||||
IconifyIconSource,
|
||||
} from '@iconify/utils/lib/icon/name';
|
||||
import { listToIcons } from '../icon/list';
|
||||
import { allowSimpleNames } from '../storage/functions';
|
||||
import { sendAPIQuery } from './query';
|
||||
import { cache } from '../cache';
|
||||
|
||||
// Empty abort callback for loadIcons()
|
||||
function emptyCallback(): void {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to abort loading (usually just removes callback because loading is already in progress)
|
||||
*/
|
||||
export type IconifyIconLoaderAbort = () => void;
|
||||
|
||||
/**
|
||||
* Loader callback
|
||||
*
|
||||
* Provides list of icons that have been loaded
|
||||
*/
|
||||
export type IconifyIconLoaderCallback = (
|
||||
loaded: IconifyIconName[],
|
||||
missing: IconifyIconName[],
|
||||
pending: IconifyIconName[],
|
||||
unsubscribe: IconifyIconLoaderAbort
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Function to load icons
|
||||
*/
|
||||
export type IconifyLoadIcons = (
|
||||
icons: (IconifyIconName | string)[],
|
||||
callback?: IconifyIconLoaderCallback
|
||||
) => IconifyIconLoaderAbort;
|
||||
|
||||
/**
|
||||
* Function to check if icon is pending
|
||||
*/
|
||||
export type IsPending = (icon: IconifyIconName) => boolean;
|
||||
|
||||
/**
|
||||
* List of icons that are being loaded.
|
||||
*
|
||||
@ -63,38 +84,6 @@ const loaderFlags: Record<string, Record<string, boolean>> = Object.create(
|
||||
);
|
||||
const queueFlags: Record<string, Record<string, boolean>> = Object.create(null);
|
||||
|
||||
// Redundancy instances cache, sorted by provider
|
||||
export interface IconifyAPIInternalStorage {
|
||||
config: IconifyAPIConfig;
|
||||
redundancy: Redundancy;
|
||||
}
|
||||
const redundancyCache: Record<string, IconifyAPIInternalStorage> =
|
||||
Object.create(null);
|
||||
|
||||
/**
|
||||
* Get Redundancy instance for provider
|
||||
*/
|
||||
export function getRedundancyCache(
|
||||
provider: string
|
||||
): IconifyAPIInternalStorage | undefined {
|
||||
if (redundancyCache[provider] === void 0) {
|
||||
const config = getAPIConfig(provider);
|
||||
if (!config) {
|
||||
// No way to load icons because configuration is not set!
|
||||
return;
|
||||
}
|
||||
|
||||
const redundancy = initRedundancy(config);
|
||||
const cachedReundancy = {
|
||||
config,
|
||||
redundancy,
|
||||
};
|
||||
redundancyCache[provider] = cachedReundancy;
|
||||
}
|
||||
|
||||
return redundancyCache[provider];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when new icons have been loaded
|
||||
*/
|
||||
@ -158,9 +147,6 @@ function loadNewIcons(provider: string, prefix: string, icons: string[]): void {
|
||||
.sort();
|
||||
}
|
||||
|
||||
// Redundancy item
|
||||
let cachedReundancy: IconifyAPIInternalStorage;
|
||||
|
||||
// Trigger update on next tick, mering multiple synchronous requests into one asynchronous request
|
||||
if (!providerQueueFlags[prefix]) {
|
||||
providerQueueFlags[prefix] = true;
|
||||
@ -179,72 +165,54 @@ function loadNewIcons(provider: string, prefix: string, icons: string[]): void {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get API config and Redundancy instance
|
||||
if (cachedReundancy === void 0) {
|
||||
const redundancy = getRedundancyCache(provider);
|
||||
if (redundancy === void 0) {
|
||||
// No way to load icons because configuration is not set!
|
||||
err();
|
||||
return;
|
||||
}
|
||||
cachedReundancy = redundancy;
|
||||
}
|
||||
|
||||
// Prepare parameters and run queries
|
||||
const params = api.prepare(provider, prefix, icons);
|
||||
params.forEach((item) => {
|
||||
cachedReundancy.redundancy.query(
|
||||
item,
|
||||
api.send as QueryModuleCallback,
|
||||
(data, error) => {
|
||||
const storage = getStorage(provider, prefix);
|
||||
sendAPIQuery(provider, item, (data, error) => {
|
||||
const storage = getStorage(provider, prefix);
|
||||
|
||||
// Check for error
|
||||
if (typeof data !== 'object') {
|
||||
if (error !== 404) {
|
||||
// Do not handle error unless it is 404
|
||||
// Check for error
|
||||
if (typeof data !== 'object') {
|
||||
if (error !== 404) {
|
||||
// Do not handle error unless it is 404
|
||||
return;
|
||||
}
|
||||
|
||||
// Not found: mark as missing
|
||||
const t = Date.now();
|
||||
item.icons.forEach((name) => {
|
||||
storage.missing[name] = t;
|
||||
});
|
||||
} else {
|
||||
// Add icons to storage
|
||||
try {
|
||||
const added = addIconSet(
|
||||
storage,
|
||||
data as IconifyJSON,
|
||||
'all'
|
||||
);
|
||||
if (typeof added === 'boolean') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Not found: mark as missing
|
||||
const t = Date.now();
|
||||
item.icons.forEach((name) => {
|
||||
storage.missing[name] = t;
|
||||
// Remove added icons from pending list
|
||||
const pending = providerPendingIcons[prefix];
|
||||
added.forEach((name) => {
|
||||
delete pending[name];
|
||||
});
|
||||
} else {
|
||||
// Add icons to storage
|
||||
try {
|
||||
const added = addIconSet(
|
||||
storage,
|
||||
data as IconifyJSON,
|
||||
'all'
|
||||
);
|
||||
if (typeof added === 'boolean') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove added icons from pending list
|
||||
const pending = providerPendingIcons[prefix];
|
||||
added.forEach((name) => {
|
||||
delete pending[name];
|
||||
});
|
||||
|
||||
// Cache API response
|
||||
if (coreModules.cache) {
|
||||
coreModules.cache(
|
||||
provider,
|
||||
data as IconifyJSON
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// Cache API response
|
||||
if (cache.store) {
|
||||
cache.store(provider, data as IconifyJSON);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
// Trigger update on next tick
|
||||
loadedNewIcons(provider, prefix);
|
||||
}
|
||||
);
|
||||
|
||||
// Trigger update on next tick
|
||||
loadedNewIcons(provider, prefix);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -253,18 +221,20 @@ function loadNewIcons(provider: string, prefix: string, icons: string[]): void {
|
||||
/**
|
||||
* Check if icon is being loaded
|
||||
*/
|
||||
const isPending: IsPending = (icon: IconifyIconName): boolean => {
|
||||
export const isPending: IsPending = (icon: IconifyIconName): boolean => {
|
||||
const provider = icon.provider;
|
||||
const prefix = icon.prefix;
|
||||
return (
|
||||
pendingIcons[icon.provider] !== void 0 &&
|
||||
pendingIcons[icon.provider][icon.prefix] !== void 0 &&
|
||||
pendingIcons[icon.provider][icon.prefix][icon.name] !== void 0
|
||||
pendingIcons[provider] &&
|
||||
pendingIcons[provider][prefix] &&
|
||||
pendingIcons[provider][prefix][icon.name] !== void 0
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
const loadIcons: IconifyLoadIcons = (
|
||||
export const loadIcons: IconifyLoadIcons = (
|
||||
icons: (IconifyIconName | string)[],
|
||||
callback?: IconifyIconLoaderCallback
|
||||
): IconifyIconLoaderAbort => {
|
||||
@ -369,11 +339,3 @@ const loadIcons: IconifyLoadIcons = (
|
||||
? storeCallback(callback, sortedIcons, sources)
|
||||
: emptyCallback;
|
||||
};
|
||||
|
||||
/**
|
||||
* Export module
|
||||
*/
|
||||
export const API: IconifyAPI = {
|
||||
isPending,
|
||||
loadIcons,
|
||||
};
|
@ -1,27 +1,36 @@
|
||||
import type { PendingQueryItem } from '@iconify/api-redundancy';
|
||||
import type { GetAPIConfig } from '../api/config';
|
||||
|
||||
/**
|
||||
* Params for sendQuery()
|
||||
*/
|
||||
export interface APIQueryParams {
|
||||
export interface IconifyAPIIconsQueryParams {
|
||||
type: 'icons';
|
||||
provider: string;
|
||||
prefix: string;
|
||||
icons: string[];
|
||||
}
|
||||
export interface IconifyAPICustomQueryParams {
|
||||
type: 'custom';
|
||||
provider?: string; // Provider is optional. If missing, temporary config is created based on host
|
||||
uri: string;
|
||||
}
|
||||
|
||||
export type IconifyAPIQueryParams =
|
||||
| IconifyAPIIconsQueryParams
|
||||
| IconifyAPICustomQueryParams;
|
||||
|
||||
/**
|
||||
* Functions to implement in module
|
||||
*/
|
||||
export type IconifyAPIPrepareQuery = (
|
||||
export type IconifyAPIPrepareIconsQuery = (
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
) => APIQueryParams[];
|
||||
) => IconifyAPIIconsQueryParams[];
|
||||
|
||||
export type IconifyAPISendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
params: IconifyAPIQueryParams,
|
||||
status: PendingQueryItem
|
||||
) => void;
|
||||
|
||||
@ -29,7 +38,7 @@ export type IconifyAPISendQuery = (
|
||||
* API modules
|
||||
*/
|
||||
export interface IconifyAPIModule {
|
||||
prepare: IconifyAPIPrepareQuery;
|
||||
prepare: IconifyAPIPrepareIconsQuery;
|
||||
send: IconifyAPISendQuery;
|
||||
}
|
||||
|
||||
@ -49,12 +58,5 @@ export function setAPIModule(provider: string, item: IconifyAPIModule): void {
|
||||
* Get API module
|
||||
*/
|
||||
export function getAPIModule(provider: string): IconifyAPIModule | undefined {
|
||||
return storage[provider] === void 0 ? storage[''] : storage[provider];
|
||||
return storage[provider] || storage[''];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return API interface
|
||||
*/
|
||||
export type GetIconifyAPIModule = (
|
||||
getAPIConfig: GetAPIConfig
|
||||
) => IconifyAPIModule;
|
||||
|
@ -1,17 +1,13 @@
|
||||
import type { PendingQueryItem } from '@iconify/api-redundancy';
|
||||
import type {
|
||||
APIQueryParams,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIModule,
|
||||
GetIconifyAPIModule,
|
||||
IconifyAPIIconsQueryParams,
|
||||
} from '../modules';
|
||||
import type { GetAPIConfig } from '../config';
|
||||
|
||||
/**
|
||||
* Endpoint
|
||||
*/
|
||||
const endPoint = '{prefix}.json?icons={icons}';
|
||||
import { getAPIConfig } from '../config';
|
||||
import { mergeParams } from '../params';
|
||||
|
||||
/**
|
||||
* Cache
|
||||
@ -20,164 +16,244 @@ const maxLengthCache: Record<string, number> = Object.create(null);
|
||||
const pathCache: Record<string, string> = Object.create(null);
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
*
|
||||
* Use this to set 'cross-fetch' in node.js environment if you are retrieving icons on server side.
|
||||
* Not needed when using stuff like Next.js or SvelteKit because components use API only on client side.
|
||||
* Get fetch function
|
||||
*/
|
||||
let fetchModule: typeof fetch | null = null;
|
||||
try {
|
||||
fetchModule = fetch;
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
type FetchType = typeof fetch;
|
||||
const detectFetch = (): FetchType | null => {
|
||||
let callback;
|
||||
|
||||
export function setFetch(fetch: typeof fetchModule): void {
|
||||
fetchModule = fetch;
|
||||
// Try global fetch
|
||||
try {
|
||||
callback = fetch;
|
||||
if (typeof callback === 'function') {
|
||||
return callback;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
// Try cross-fetch
|
||||
try {
|
||||
// Obfuscate require() to avoid cross-fetch being bundled by Webpack
|
||||
const chunk = String.fromCharCode(114) + String.fromCharCode(101);
|
||||
const req = (global as unknown as Record<string, FetchType>)[
|
||||
chunk + 'qui' + chunk
|
||||
];
|
||||
callback = req('cross-fetch');
|
||||
if (typeof callback === 'function') {
|
||||
return callback;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch function
|
||||
*/
|
||||
let fetchModule: FetchType | null = detectFetch();
|
||||
|
||||
/**
|
||||
* Set custom fetch() function
|
||||
*/
|
||||
export function setFetch(fetch: unknown): void {
|
||||
fetchModule = fetch as FetchType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return API module
|
||||
* Get fetch() function. Used by Icon Finder Core
|
||||
*/
|
||||
export const getAPIModule: GetIconifyAPIModule = (
|
||||
getAPIConfig: GetAPIConfig
|
||||
): IconifyAPIModule => {
|
||||
/**
|
||||
* Calculate maximum icons list length for prefix
|
||||
*/
|
||||
function calculateMaxLength(provider: string, prefix: string): number {
|
||||
// Get config and store path
|
||||
const config = getAPIConfig(provider);
|
||||
if (!config) {
|
||||
return 0;
|
||||
}
|
||||
export function getFetch(): typeof fetchModule {
|
||||
return fetchModule;
|
||||
}
|
||||
|
||||
// Calculate
|
||||
let result;
|
||||
if (!config.maxURL) {
|
||||
result = 0;
|
||||
} else {
|
||||
let maxHostLength = 0;
|
||||
config.resources.forEach((item) => {
|
||||
const host = item as string;
|
||||
maxHostLength = Math.max(maxHostLength, host.length);
|
||||
});
|
||||
|
||||
// Get available length
|
||||
result =
|
||||
config.maxURL -
|
||||
maxHostLength -
|
||||
config.path.length -
|
||||
endPoint
|
||||
.replace('{provider}', provider)
|
||||
.replace('{prefix}', prefix)
|
||||
.replace('{icons}', '').length;
|
||||
}
|
||||
|
||||
// Cache stuff and return result
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
pathCache[cacheKey] = config.path;
|
||||
maxLengthCache[cacheKey] = result;
|
||||
return result;
|
||||
/**
|
||||
* Calculate maximum icons list length for prefix
|
||||
*/
|
||||
function calculateMaxLength(provider: string, prefix: string): number {
|
||||
// Get config and store path
|
||||
const config = getAPIConfig(provider);
|
||||
if (!config) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare params
|
||||
*/
|
||||
const prepare: IconifyAPIPrepareQuery = (
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
const results: APIQueryParams[] = [];
|
||||
// Calculate
|
||||
let result;
|
||||
if (!config.maxURL) {
|
||||
result = 0;
|
||||
} else {
|
||||
let maxHostLength = 0;
|
||||
config.resources.forEach((item) => {
|
||||
const host = item as string;
|
||||
maxHostLength = Math.max(maxHostLength, host.length);
|
||||
});
|
||||
|
||||
// Get maximum icons list length
|
||||
let maxLength = maxLengthCache[prefix];
|
||||
if (maxLength === void 0) {
|
||||
maxLength = calculateMaxLength(provider, prefix);
|
||||
// Get available length
|
||||
const url = mergeParams(prefix + '.json', {
|
||||
icons: '',
|
||||
});
|
||||
|
||||
result =
|
||||
config.maxURL - maxHostLength - config.path.length - url.length;
|
||||
}
|
||||
|
||||
// Cache stuff and return result
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
pathCache[provider] = config.path;
|
||||
maxLengthCache[cacheKey] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare params
|
||||
*/
|
||||
const prepare: IconifyAPIPrepareIconsQuery = (
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
const results: IconifyAPIIconsQueryParams[] = [];
|
||||
|
||||
// Get maximum icons list length
|
||||
let maxLength = maxLengthCache[prefix];
|
||||
if (maxLength === void 0) {
|
||||
maxLength = calculateMaxLength(provider, prefix);
|
||||
}
|
||||
|
||||
// Split icons
|
||||
const type = 'icons';
|
||||
let item: IconifyAPIIconsQueryParams = {
|
||||
type,
|
||||
provider,
|
||||
prefix,
|
||||
icons: [],
|
||||
};
|
||||
let length = 0;
|
||||
icons.forEach((name, index) => {
|
||||
length += name.length + 1;
|
||||
if (length >= maxLength && index > 0) {
|
||||
// Next set
|
||||
results.push(item);
|
||||
item = {
|
||||
type,
|
||||
provider,
|
||||
prefix,
|
||||
icons: [],
|
||||
};
|
||||
length = name.length;
|
||||
}
|
||||
|
||||
// Split icons
|
||||
let item: APIQueryParams = {
|
||||
provider,
|
||||
prefix,
|
||||
icons: [],
|
||||
};
|
||||
let length = 0;
|
||||
icons.forEach((name, index) => {
|
||||
length += name.length + 1;
|
||||
if (length >= maxLength && index > 0) {
|
||||
// Next set
|
||||
results.push(item);
|
||||
item = {
|
||||
provider,
|
||||
prefix,
|
||||
icons: [],
|
||||
};
|
||||
length = name.length;
|
||||
item.icons.push(name);
|
||||
});
|
||||
results.push(item);
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get path
|
||||
*/
|
||||
function getPath(provider?: string): string {
|
||||
if (typeof provider === 'string') {
|
||||
if (pathCache[provider] === void 0) {
|
||||
const config = getAPIConfig(provider);
|
||||
if (!config) {
|
||||
return '/';
|
||||
}
|
||||
pathCache[provider] = config.path;
|
||||
}
|
||||
|
||||
return pathCache[provider];
|
||||
}
|
||||
|
||||
// No provider config, assume path is '/'
|
||||
return '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
const send: IconifyAPISendQuery = (
|
||||
host: string,
|
||||
params: IconifyAPIQueryParams,
|
||||
status: PendingQueryItem
|
||||
): void => {
|
||||
if (!fetchModule) {
|
||||
// Fail: return "424 Failed Dependency" (its not meant to be used like that, but it is the closest match)
|
||||
status.done(void 0, 424);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get path
|
||||
let path = getPath(params.provider);
|
||||
switch (params.type) {
|
||||
case 'icons': {
|
||||
const prefix = params.prefix;
|
||||
const icons = params.icons;
|
||||
const iconsList = icons.join(',');
|
||||
|
||||
path += mergeParams(prefix + '.json', {
|
||||
icons: iconsList,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'custom': {
|
||||
const uri = params.uri;
|
||||
path += uri.slice(0, 1) === '/' ? uri.slice(1) : uri;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Fail: return 400 Bad Request
|
||||
status.done(void 0, 400);
|
||||
return;
|
||||
}
|
||||
|
||||
// Error code to return if fetch throws an error: "503 Service Unavailable"
|
||||
let defaultError = 503;
|
||||
|
||||
// console.log('API query:', host + path);
|
||||
fetchModule(host + path)
|
||||
.then((response) => {
|
||||
if (response.status !== 200) {
|
||||
setTimeout(() => {
|
||||
// Complete on next tick to get out of try...catch
|
||||
status.done(void 0, response.status);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
item.icons.push(name);
|
||||
});
|
||||
results.push(item);
|
||||
// Parse JSON, fail with "501 Not Implemented" if response cannot be decoded
|
||||
defaultError = 501;
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
if (typeof data !== 'object' || data === null) {
|
||||
setTimeout(() => {
|
||||
// Complete on next tick to get out of try...catch
|
||||
status.done(void 0, defaultError);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
const send: IconifyAPISendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
status: PendingQueryItem
|
||||
): void => {
|
||||
const provider = params.provider;
|
||||
const prefix = params.prefix;
|
||||
const icons = params.icons;
|
||||
const iconsList = icons.join(',');
|
||||
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
const path =
|
||||
pathCache[cacheKey] +
|
||||
endPoint
|
||||
.replace('{provider}', provider)
|
||||
.replace('{prefix}', prefix)
|
||||
.replace('{icons}', iconsList);
|
||||
|
||||
if (!fetchModule) {
|
||||
// Fail: return 424 Failed Dependency (its not meant to be used like that, but it is the best match)
|
||||
status.done(void 0, 424);
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log('API query:', host + path);
|
||||
fetchModule(host + path)
|
||||
.then((response) => {
|
||||
if (response.status !== 200) {
|
||||
status.done(void 0, response.status);
|
||||
return;
|
||||
}
|
||||
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
if (typeof data !== 'object' || data === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Store cache and complete
|
||||
// Store cache and complete on next tick
|
||||
setTimeout(() => {
|
||||
// Complete on next tick to get out of try...catch
|
||||
status.done(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
// Error
|
||||
status.done(void 0, err.errno);
|
||||
});
|
||||
};
|
||||
|
||||
// Return functions
|
||||
return {
|
||||
prepare,
|
||||
send,
|
||||
};
|
||||
})
|
||||
.catch(() => {
|
||||
status.done(void 0, defaultError);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Export module
|
||||
*/
|
||||
export const fetchAPIModule: IconifyAPIModule = {
|
||||
prepare,
|
||||
send,
|
||||
};
|
||||
|
@ -1,12 +1,13 @@
|
||||
import type { PendingQueryItem } from '@iconify/api-redundancy';
|
||||
import type {
|
||||
APIQueryParams,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIModule,
|
||||
GetIconifyAPIModule,
|
||||
IconifyAPIIconsQueryParams,
|
||||
} from '../modules';
|
||||
import type { GetAPIConfig } from '../config';
|
||||
import { getAPIConfig } from '../config';
|
||||
import { mergeParams } from '../params';
|
||||
|
||||
/**
|
||||
* Global
|
||||
@ -14,11 +15,7 @@ import type { GetAPIConfig } from '../config';
|
||||
type Callback = (data: unknown) => void;
|
||||
type JSONPRoot = Record<string, Callback>;
|
||||
let rootVar: JSONPRoot | null = null;
|
||||
|
||||
/**
|
||||
* Endpoint
|
||||
*/
|
||||
let endPoint = '{prefix}.js?icons={icons}&callback={callback}';
|
||||
let rootVarName: string | null = null;
|
||||
|
||||
/**
|
||||
* Cache: provider:prefix = value
|
||||
@ -74,169 +71,159 @@ function getGlobal(): JSONPRoot {
|
||||
}
|
||||
|
||||
// Change end point
|
||||
endPoint = endPoint.replace(
|
||||
'{callback}',
|
||||
prefix + extraPrefix + '.{cb}'
|
||||
);
|
||||
rootVarName = prefix + extraPrefix + '.{cb}';
|
||||
}
|
||||
|
||||
return rootVar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return API module
|
||||
* Calculate maximum icons list length for prefix
|
||||
*/
|
||||
export const getAPIModule: GetIconifyAPIModule = (
|
||||
getAPIConfig: GetAPIConfig
|
||||
): IconifyAPIModule => {
|
||||
/**
|
||||
* Calculate maximum icons list length for prefix
|
||||
*/
|
||||
function calculateMaxLength(provider: string, prefix: string): number {
|
||||
// Get config and store path
|
||||
const config = getAPIConfig(provider);
|
||||
if (!config) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Calculate
|
||||
let result;
|
||||
if (!config.maxURL) {
|
||||
result = 0;
|
||||
} else {
|
||||
let maxHostLength = 0;
|
||||
config.resources.forEach((item) => {
|
||||
const host = item as string;
|
||||
maxHostLength = Math.max(maxHostLength, host.length);
|
||||
});
|
||||
|
||||
// Make sure global is set
|
||||
getGlobal();
|
||||
|
||||
// Extra width: prefix (3) + counter (4) - '{cb}' (4)
|
||||
const extraLength = 3;
|
||||
|
||||
// Get available length
|
||||
result =
|
||||
config.maxURL -
|
||||
maxHostLength -
|
||||
config.path.length -
|
||||
endPoint
|
||||
.replace('{provider}', provider)
|
||||
.replace('{prefix}', prefix)
|
||||
.replace('{icons}', '').length -
|
||||
extraLength;
|
||||
}
|
||||
|
||||
// Cache stuff and return result
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
pathCache[cacheKey] = config.path;
|
||||
maxLengthCache[cacheKey] = result;
|
||||
return result;
|
||||
function calculateMaxLength(provider: string, prefix: string): number {
|
||||
// Get config and store path
|
||||
const config = getAPIConfig(provider);
|
||||
if (!config) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare params
|
||||
*/
|
||||
const prepare: IconifyAPIPrepareQuery = (
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
const results: APIQueryParams[] = [];
|
||||
|
||||
// Get maximum icons list length
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
let maxLength = maxLengthCache[cacheKey];
|
||||
if (maxLength === void 0) {
|
||||
maxLength = calculateMaxLength(provider, prefix);
|
||||
}
|
||||
|
||||
// Split icons
|
||||
let item: APIQueryParams = {
|
||||
provider,
|
||||
prefix,
|
||||
icons: [],
|
||||
};
|
||||
let length = 0;
|
||||
icons.forEach((name, index) => {
|
||||
length += name.length + 1;
|
||||
if (length >= maxLength && index > 0) {
|
||||
// Next set
|
||||
results.push(item);
|
||||
item = {
|
||||
provider,
|
||||
prefix,
|
||||
icons: [],
|
||||
};
|
||||
length = name.length;
|
||||
}
|
||||
|
||||
item.icons.push(name);
|
||||
// Calculate
|
||||
let result;
|
||||
if (!config.maxURL) {
|
||||
result = 0;
|
||||
} else {
|
||||
let maxHostLength = 0;
|
||||
config.resources.forEach((item) => {
|
||||
const host = item as string;
|
||||
maxHostLength = Math.max(maxHostLength, host.length);
|
||||
});
|
||||
results.push(item);
|
||||
|
||||
return results;
|
||||
// Make sure global is set
|
||||
getGlobal();
|
||||
|
||||
// Get available length
|
||||
const url = mergeParams(prefix + '.js', {
|
||||
icons: '',
|
||||
callback: rootVarName!,
|
||||
});
|
||||
result =
|
||||
config.maxURL - maxHostLength - config.path.length - url.length;
|
||||
}
|
||||
|
||||
// Cache stuff and return result
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
pathCache[cacheKey] = config.path;
|
||||
maxLengthCache[cacheKey] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare params
|
||||
*/
|
||||
const prepare: IconifyAPIPrepareIconsQuery = (
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
const results: IconifyAPIIconsQueryParams[] = [];
|
||||
|
||||
// Get maximum icons list length
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
let maxLength = maxLengthCache[cacheKey];
|
||||
if (maxLength === void 0) {
|
||||
maxLength = calculateMaxLength(provider, prefix);
|
||||
}
|
||||
|
||||
// Split icons
|
||||
const type = 'icons';
|
||||
let item: IconifyAPIIconsQueryParams = {
|
||||
type,
|
||||
provider,
|
||||
prefix,
|
||||
icons: [],
|
||||
};
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
const send: IconifyAPISendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
status: PendingQueryItem
|
||||
): void => {
|
||||
const provider = params.provider;
|
||||
const prefix = params.prefix;
|
||||
const icons = params.icons;
|
||||
const iconsList = icons.join(',');
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
|
||||
// Create callback prefix
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const cbPrefix = prefix.split('-').shift()!.slice(0, 3);
|
||||
|
||||
const global = getGlobal();
|
||||
|
||||
// Callback hash
|
||||
let cbCounter = hash(
|
||||
provider + ':' + host + ':' + prefix + ':' + iconsList
|
||||
);
|
||||
while (global[cbPrefix + cbCounter] !== void 0) {
|
||||
cbCounter++;
|
||||
let length = 0;
|
||||
icons.forEach((name, index) => {
|
||||
length += name.length + 1;
|
||||
if (length >= maxLength && index > 0) {
|
||||
// Next set
|
||||
results.push(item);
|
||||
item = {
|
||||
type,
|
||||
provider,
|
||||
prefix,
|
||||
icons: [],
|
||||
};
|
||||
length = name.length;
|
||||
}
|
||||
const callbackName = cbPrefix + cbCounter;
|
||||
|
||||
const path =
|
||||
pathCache[cacheKey] +
|
||||
endPoint
|
||||
.replace('{provider}', provider)
|
||||
.replace('{prefix}', prefix)
|
||||
.replace('{icons}', iconsList)
|
||||
.replace('{cb}', callbackName);
|
||||
item.icons.push(name);
|
||||
});
|
||||
results.push(item);
|
||||
|
||||
global[callbackName] = (data: unknown): void => {
|
||||
// Remove callback and complete query
|
||||
delete global[callbackName];
|
||||
status.done(data);
|
||||
};
|
||||
|
||||
// Create URI
|
||||
const uri = host + path;
|
||||
// console.log('API query:', uri);
|
||||
|
||||
// Create script and append it to head
|
||||
const script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.async = true;
|
||||
script.src = uri;
|
||||
document.head.appendChild(script);
|
||||
};
|
||||
|
||||
// Return functions
|
||||
return {
|
||||
prepare,
|
||||
send,
|
||||
};
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
const send: IconifyAPISendQuery = (
|
||||
host: string,
|
||||
params: IconifyAPIQueryParams,
|
||||
status: PendingQueryItem
|
||||
): void => {
|
||||
if (params.type !== 'icons') {
|
||||
// JSONP supports only icons
|
||||
status.done(void 0, 400);
|
||||
return;
|
||||
}
|
||||
|
||||
const provider = params.provider;
|
||||
const prefix = params.prefix;
|
||||
const icons = params.icons;
|
||||
const iconsList = icons.join(',');
|
||||
const cacheKey = provider + ':' + prefix;
|
||||
|
||||
// Create callback prefix
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const cbPrefix = prefix.split('-').shift()!.slice(0, 3);
|
||||
|
||||
const global = getGlobal();
|
||||
|
||||
// Callback hash
|
||||
let cbCounter = hash(
|
||||
provider + ':' + host + ':' + prefix + ':' + iconsList
|
||||
);
|
||||
while (global[cbPrefix + cbCounter] !== void 0) {
|
||||
cbCounter++;
|
||||
}
|
||||
const callbackName = cbPrefix + cbCounter;
|
||||
|
||||
const url = mergeParams(prefix + '.js', {
|
||||
icons: iconsList,
|
||||
callback: rootVarName!.replace('{cb}', callbackName),
|
||||
});
|
||||
const path = pathCache[cacheKey] + url;
|
||||
|
||||
global[callbackName] = (data: unknown): void => {
|
||||
// Remove callback and complete query
|
||||
delete global[callbackName];
|
||||
status.done(data);
|
||||
};
|
||||
|
||||
// Create URI
|
||||
const uri = host + path;
|
||||
// console.log('API query:', uri);
|
||||
|
||||
// Create script and append it to head
|
||||
const script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.async = true;
|
||||
script.src = uri;
|
||||
document.head.appendChild(script);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return API module
|
||||
*/
|
||||
export const jsonpAPIModule: IconifyAPIModule = { prepare, send };
|
||||
|
@ -1,7 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars-experimental */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import type { PendingQueryItem } from '@iconify/api-redundancy';
|
||||
import type { APIQueryParams, IconifyAPIModule } from '../modules';
|
||||
import type {
|
||||
IconifyAPIIconsQueryParams,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPIModule,
|
||||
} from '../modules';
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
|
||||
/**
|
||||
@ -15,9 +19,20 @@ export type IconifyMockAPIDelayCallback = (
|
||||
/**
|
||||
* Fake API result
|
||||
*/
|
||||
export interface IconifyMockAPI {
|
||||
// Request parameters
|
||||
interface IconifyMockAPIBase {
|
||||
// Response
|
||||
// Number if error should be sent, JSON on success
|
||||
response: number | IconifyJSON | Record<string, unknown>;
|
||||
|
||||
// Delay for response: in milliseconds or callback
|
||||
delay?: number | IconifyMockAPIDelayCallback;
|
||||
}
|
||||
|
||||
export interface IconifyMockIconsAPI extends IconifyMockAPIBase {
|
||||
type: 'icons';
|
||||
provider: string;
|
||||
|
||||
// Request parameters
|
||||
prefix: string;
|
||||
|
||||
// If icons list is missing, applies to all requests
|
||||
@ -27,40 +42,109 @@ export interface IconifyMockAPI {
|
||||
// Response
|
||||
// Number if error should be sent, JSON on success
|
||||
response: number | IconifyJSON;
|
||||
|
||||
// Delay for response: in milliseconds or callback
|
||||
delay?: number | IconifyMockAPIDelayCallback;
|
||||
}
|
||||
|
||||
export interface IconifyMockCustomAPI extends IconifyMockAPIBase {
|
||||
type: 'custom';
|
||||
provider: string;
|
||||
|
||||
// Request parameters
|
||||
uri: string;
|
||||
|
||||
// Response
|
||||
// Number if error should be sent, JSON on success
|
||||
response: number | Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface IconifyMockCustomHostAPI extends IconifyMockAPIBase {
|
||||
type: 'host';
|
||||
host: string;
|
||||
|
||||
// Request parameters
|
||||
uri: string;
|
||||
|
||||
// Response
|
||||
// Number if error should be sent, JSON on success
|
||||
response: number | Record<string, unknown>;
|
||||
}
|
||||
|
||||
export type IconifyMockAPI =
|
||||
| IconifyMockIconsAPI
|
||||
| IconifyMockCustomAPI
|
||||
| IconifyMockCustomHostAPI;
|
||||
|
||||
/**
|
||||
* Fake API storage
|
||||
* Fake API storage for icons
|
||||
*
|
||||
* [provider][prefix] = list of entries
|
||||
*/
|
||||
export const storage: Record<
|
||||
export const iconsStorage: Record<
|
||||
string,
|
||||
Record<string, IconifyMockAPI[]>
|
||||
Record<string, IconifyMockIconsAPI[]>
|
||||
> = Object.create(null);
|
||||
|
||||
/**
|
||||
* Fake API storage for custom queries
|
||||
*
|
||||
* [provider][uri] = response
|
||||
*/
|
||||
export const customProviderStorage: Record<
|
||||
string,
|
||||
Record<string, IconifyMockCustomAPI>
|
||||
> = Object.create(null);
|
||||
|
||||
/**
|
||||
* Fake API storage for custom queries
|
||||
*
|
||||
* [host][uri] = response
|
||||
*/
|
||||
export const customHostStorage: Record<
|
||||
string,
|
||||
Record<string, IconifyMockCustomHostAPI>
|
||||
> = Object.create(null);
|
||||
|
||||
/**
|
||||
* Set data for mocking API
|
||||
*/
|
||||
export function mockAPIData(data: IconifyMockAPI): void {
|
||||
const provider = data.provider;
|
||||
if (storage[provider] === void 0) {
|
||||
storage[provider] = Object.create(null);
|
||||
}
|
||||
const providerStorage = storage[provider];
|
||||
switch (data.type) {
|
||||
case 'icons': {
|
||||
const provider = data.provider;
|
||||
if (iconsStorage[provider] === void 0) {
|
||||
iconsStorage[provider] = Object.create(null);
|
||||
}
|
||||
const providerStorage = iconsStorage[provider];
|
||||
|
||||
const prefix = data.prefix;
|
||||
if (providerStorage[prefix] === void 0) {
|
||||
providerStorage[prefix] = [];
|
||||
}
|
||||
const prefix = data.prefix;
|
||||
if (providerStorage[prefix] === void 0) {
|
||||
providerStorage[prefix] = [];
|
||||
}
|
||||
|
||||
storage[provider][prefix].push(data);
|
||||
iconsStorage[provider][prefix].push(data);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'custom': {
|
||||
const provider = data.provider;
|
||||
if (customProviderStorage[provider] === void 0) {
|
||||
customProviderStorage[provider] = Object.create(null);
|
||||
}
|
||||
customProviderStorage[provider][data.uri] = data;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'host': {
|
||||
const host = data.host;
|
||||
if (customHostStorage[host] === void 0) {
|
||||
customHostStorage[host] = Object.create(null);
|
||||
}
|
||||
customHostStorage[host][data.uri] = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface MockAPIQueryParams extends APIQueryParams {
|
||||
interface MockAPIIconsQueryParams extends IconifyAPIIconsQueryParams {
|
||||
index: number;
|
||||
}
|
||||
|
||||
@ -71,21 +155,25 @@ export const mockAPIModule: IconifyAPIModule = {
|
||||
/**
|
||||
* Prepare params
|
||||
*/
|
||||
prepare: (provider: string, prefix: string, icons: string[]) => {
|
||||
if (
|
||||
storage[provider] === void 0 ||
|
||||
storage[provider][prefix] === void 0
|
||||
) {
|
||||
prepare: (
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
const type = 'icons';
|
||||
|
||||
if (!iconsStorage[provider] || !iconsStorage[provider][prefix]) {
|
||||
// No mock data: bundle all icons in one request that will return 404
|
||||
return [
|
||||
{
|
||||
type,
|
||||
provider,
|
||||
prefix,
|
||||
icons,
|
||||
},
|
||||
];
|
||||
}
|
||||
const mockData = storage[provider][prefix];
|
||||
const mockData = iconsStorage[provider][prefix];
|
||||
|
||||
// Find catch all entry with error
|
||||
const catchAllIndex = mockData.findIndex(
|
||||
@ -135,9 +223,10 @@ export const mockAPIModule: IconifyAPIModule = {
|
||||
});
|
||||
|
||||
// Sort results
|
||||
const results: APIQueryParams[] = [];
|
||||
const results: IconifyAPIIconsQueryParams[] = [];
|
||||
if (noMatch.length > 0) {
|
||||
results.push({
|
||||
type,
|
||||
provider,
|
||||
prefix,
|
||||
icons: noMatch,
|
||||
@ -146,11 +235,12 @@ export const mockAPIModule: IconifyAPIModule = {
|
||||
Object.keys(matches).forEach((key) => {
|
||||
const index = parseInt(key);
|
||||
results.push({
|
||||
type,
|
||||
provider,
|
||||
prefix,
|
||||
icons: matches[index],
|
||||
index,
|
||||
} as APIQueryParams);
|
||||
} as IconifyAPIIconsQueryParams);
|
||||
});
|
||||
|
||||
return results;
|
||||
@ -159,24 +249,46 @@ export const mockAPIModule: IconifyAPIModule = {
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
send: (host: string, params: APIQueryParams, status: PendingQueryItem) => {
|
||||
send: (
|
||||
host: string,
|
||||
params: IconifyAPIQueryParams,
|
||||
status: PendingQueryItem
|
||||
) => {
|
||||
const provider = params.provider;
|
||||
const prefix = params.prefix;
|
||||
const index = (params as MockAPIQueryParams).index;
|
||||
let data: IconifyMockAPI;
|
||||
|
||||
// Get item
|
||||
if (
|
||||
storage[provider] === void 0 ||
|
||||
storage[provider][prefix] === void 0 ||
|
||||
storage[provider][prefix][index] === void 0
|
||||
) {
|
||||
// No entry
|
||||
switch (params.type) {
|
||||
case 'icons': {
|
||||
if (provider === void 0) {
|
||||
// Fail: return 400 Bad Request
|
||||
status.done(void 0, 400);
|
||||
return;
|
||||
}
|
||||
const index = (params as MockAPIIconsQueryParams).index;
|
||||
data = iconsStorage[provider]?.[params.prefix]?.[index];
|
||||
break;
|
||||
}
|
||||
|
||||
case 'custom': {
|
||||
data = (
|
||||
provider === void 0
|
||||
? customHostStorage[host]
|
||||
: customProviderStorage[provider]
|
||||
)?.[params.uri];
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Fail: return 400 Bad Request
|
||||
status.done(void 0, 400);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data === void 0) {
|
||||
status.done(void 0, 404);
|
||||
return;
|
||||
}
|
||||
|
||||
const data = storage[provider][prefix][index];
|
||||
|
||||
// Get delay
|
||||
const delay = data.delay;
|
||||
let callback: IconifyMockAPIDelayCallback;
|
||||
|
59
packages/core/src/api/params.ts
Normal file
59
packages/core/src/api/params.ts
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* API query parameters
|
||||
*/
|
||||
type APIQueryParamValue = number | string | boolean | undefined;
|
||||
export type IconifyAPIMergeQueryParams = Record<string, APIQueryParamValue>;
|
||||
|
||||
/**
|
||||
* Type for mergeParams()
|
||||
*/
|
||||
export type MergeParams = (
|
||||
base: string,
|
||||
params: IconifyAPIMergeQueryParams
|
||||
) => string;
|
||||
|
||||
/**
|
||||
* Add parameters to query
|
||||
*/
|
||||
export const mergeParams: MergeParams = (
|
||||
base: string,
|
||||
params: IconifyAPIMergeQueryParams
|
||||
): string => {
|
||||
let result = base,
|
||||
hasParams = result.indexOf('?') !== -1;
|
||||
|
||||
/**
|
||||
* Convertion of parameters to string, only allows simple types used by Iconify API
|
||||
*/
|
||||
function paramToString(value: APIQueryParamValue): string {
|
||||
switch (typeof value) {
|
||||
case 'boolean':
|
||||
return value ? 'true' : 'false';
|
||||
|
||||
case 'number':
|
||||
return encodeURIComponent(value);
|
||||
|
||||
case 'string':
|
||||
return encodeURIComponent(value);
|
||||
|
||||
default:
|
||||
throw new Error('Invalid parameter');
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(params).forEach((key: string) => {
|
||||
let value;
|
||||
|
||||
try {
|
||||
value = paramToString(params[key]);
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
result +=
|
||||
(hasParams ? '&' : '?') + encodeURIComponent(key) + '=' + value;
|
||||
hasParams = true;
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
109
packages/core/src/api/query.ts
Normal file
109
packages/core/src/api/query.ts
Normal file
@ -0,0 +1,109 @@
|
||||
import type {
|
||||
Redundancy,
|
||||
QueryDoneCallback,
|
||||
QueryAbortCallback,
|
||||
QueryModuleCallback,
|
||||
} from '@iconify/api-redundancy';
|
||||
import { initRedundancy } from '@iconify/api-redundancy';
|
||||
import {
|
||||
getAPIModule,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPISendQuery,
|
||||
} from './modules';
|
||||
import {
|
||||
createAPIConfig,
|
||||
IconifyAPIConfig,
|
||||
PartialIconifyAPIConfig,
|
||||
} from './config';
|
||||
import { getAPIConfig } from './config';
|
||||
|
||||
// Empty abort callback
|
||||
function emptyCallback(): void {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Redundancy instances cache, sorted by provider
|
||||
interface IconifyAPIInternalStorage {
|
||||
config: IconifyAPIConfig;
|
||||
redundancy: Redundancy;
|
||||
}
|
||||
const redundancyCache: Record<string, IconifyAPIInternalStorage> =
|
||||
Object.create(null);
|
||||
|
||||
/**
|
||||
* Get Redundancy instance for provider
|
||||
*/
|
||||
function getRedundancyCache(
|
||||
provider: string
|
||||
): IconifyAPIInternalStorage | undefined {
|
||||
if (redundancyCache[provider] === void 0) {
|
||||
const config = getAPIConfig(provider);
|
||||
if (!config) {
|
||||
// Configuration is not set!
|
||||
return;
|
||||
}
|
||||
|
||||
const redundancy = initRedundancy(config);
|
||||
const cachedReundancy = {
|
||||
config,
|
||||
redundancy,
|
||||
};
|
||||
redundancyCache[provider] = cachedReundancy;
|
||||
}
|
||||
|
||||
return redundancyCache[provider];
|
||||
}
|
||||
|
||||
/**
|
||||
* Send API query
|
||||
*/
|
||||
export function sendAPIQuery(
|
||||
target: string | PartialIconifyAPIConfig,
|
||||
query: IconifyAPIQueryParams,
|
||||
callback: QueryDoneCallback
|
||||
): QueryAbortCallback {
|
||||
let redundancy: Redundancy | undefined;
|
||||
let send: IconifyAPISendQuery | undefined;
|
||||
|
||||
if (typeof target === 'string') {
|
||||
// Get API module
|
||||
const api = getAPIModule(target);
|
||||
if (!api) {
|
||||
// No API module
|
||||
// Return "424 Failed Dependency" (its not meant to be used like that, but it is the closest match)
|
||||
callback(void 0, 424);
|
||||
return emptyCallback;
|
||||
}
|
||||
send = api.send;
|
||||
|
||||
// Get Redundancy instance
|
||||
const cached = getRedundancyCache(target);
|
||||
if (cached) {
|
||||
redundancy = cached.redundancy;
|
||||
}
|
||||
} else {
|
||||
const config = createAPIConfig(target);
|
||||
if (config) {
|
||||
redundancy = initRedundancy(config);
|
||||
|
||||
// Use host instead of API provider (defaults to '')
|
||||
const moduleKey = target.resources
|
||||
? (target.resources[0] as string)
|
||||
: '';
|
||||
const api = getAPIModule(moduleKey);
|
||||
if (api) {
|
||||
send = api.send;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!redundancy || !send) {
|
||||
// No way to load icons because configuration is not set!
|
||||
callback(void 0, 424);
|
||||
return emptyCallback;
|
||||
}
|
||||
|
||||
// Send API query, return function to abort query
|
||||
return redundancy.query(query, send as QueryModuleCallback, callback)()
|
||||
.abort;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
import type { CacheIcons, LoadIconsCache } from '../interfaces/cache';
|
||||
import type { CacheIcons, LoadIconsCache } from '../cache';
|
||||
import { getStorage, addIconSet } from '../storage/storage';
|
||||
|
||||
interface StorageType<T> {
|
||||
@ -68,7 +68,7 @@ export const emptyList: StorageEmptyList = {
|
||||
type FakeWindow = Record<string, typeof localStorage>;
|
||||
|
||||
let _window: FakeWindow =
|
||||
typeof window === 'undefined' ? {} : ((window as unknown) as FakeWindow);
|
||||
typeof window === 'undefined' ? {} : (window as unknown as FakeWindow);
|
||||
export function mock(fakeWindow: FakeWindow): void {
|
||||
loaded = false;
|
||||
_window = fakeWindow;
|
||||
|
@ -9,3 +9,13 @@ export type CacheIcons = (provider: string, data: IconifyJSON) => void;
|
||||
* Function to load icons from cache
|
||||
*/
|
||||
export type LoadIconsCache = () => void;
|
||||
|
||||
/**
|
||||
* Module
|
||||
*/
|
||||
interface CacheModule {
|
||||
store?: CacheIcons;
|
||||
load?: LoadIconsCache;
|
||||
}
|
||||
|
||||
export const cache: CacheModule = {};
|
@ -1,15 +0,0 @@
|
||||
import type { IconifyLoadIcons } from './loader';
|
||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||
|
||||
/**
|
||||
* Function to check if icon is pending
|
||||
*/
|
||||
export type IsPending = (icon: IconifyIconName) => boolean;
|
||||
|
||||
/**
|
||||
* API interface
|
||||
*/
|
||||
export interface IconifyAPI {
|
||||
isPending: IsPending;
|
||||
loadIcons: IconifyLoadIcons;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||
|
||||
/**
|
||||
* Function to abort loading (usually just removes callback because loading is already in progress)
|
||||
*/
|
||||
export type IconifyIconLoaderAbort = () => void;
|
||||
|
||||
/**
|
||||
* Loader callback
|
||||
*
|
||||
* Provides list of icons that have been loaded
|
||||
*/
|
||||
export type IconifyIconLoaderCallback = (
|
||||
loaded: IconifyIconName[],
|
||||
missing: IconifyIconName[],
|
||||
pending: IconifyIconName[],
|
||||
unsubscribe: IconifyIconLoaderAbort
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Function to load icons
|
||||
*/
|
||||
export type IconifyLoadIcons = (
|
||||
icons: (IconifyIconName | string)[],
|
||||
callback?: IconifyIconLoaderCallback
|
||||
) => IconifyIconLoaderAbort;
|
@ -1,18 +0,0 @@
|
||||
import type { CacheIcons } from './interfaces/cache';
|
||||
import type { IconifyAPI } from './interfaces/api';
|
||||
|
||||
/**
|
||||
* Dynamic modules.
|
||||
*
|
||||
* Used as storage for optional functions that may or may not exist.
|
||||
* Each module must be set after including correct function for it, see build files as examples.
|
||||
*/
|
||||
interface Modules {
|
||||
// API module
|
||||
api?: IconifyAPI;
|
||||
|
||||
// Cache module (only function that stores cache. loading cache should be done when assigning module)
|
||||
cache?: CacheIcons;
|
||||
}
|
||||
|
||||
export const coreModules: Modules = {};
|
34
packages/core/tests/30-api/10-merge-params-test.ts
Normal file
34
packages/core/tests/30-api/10-merge-params-test.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { mergeParams } from '../../lib/api/params';
|
||||
|
||||
describe('Testing mergeParams', () => {
|
||||
it('mergeParams()', () => {
|
||||
// Nothing
|
||||
expect(mergeParams('/foo', {})).to.be.equal('/foo');
|
||||
|
||||
// Simple variables
|
||||
expect(
|
||||
mergeParams('/foo', {
|
||||
foo: 1,
|
||||
bar: 'baz',
|
||||
baz: true,
|
||||
})
|
||||
).to.be.equal('/foo?foo=1&bar=baz&baz=true');
|
||||
|
||||
// More parameters to existing query
|
||||
expect(
|
||||
mergeParams('/foo?bar=baz', {
|
||||
foo: false,
|
||||
})
|
||||
).to.be.equal('/foo?bar=baz&foo=false');
|
||||
|
||||
// Escaping characters
|
||||
expect(
|
||||
mergeParams('/foo', {
|
||||
'2&2': '1=1',
|
||||
'3 z': '?3',
|
||||
})
|
||||
).to.be.equal('/foo?2%262=1%3D1&3%20z=%3F3');
|
||||
});
|
||||
});
|
@ -6,7 +6,7 @@ import type { IconifyMockAPI } from '../../lib/api/modules/mock';
|
||||
import {
|
||||
mockAPIModule,
|
||||
mockAPIData,
|
||||
storage,
|
||||
iconsStorage,
|
||||
} from '../../lib/api/modules/mock';
|
||||
|
||||
describe('Testing mock API module prepare function', () => {
|
||||
@ -27,6 +27,7 @@ describe('Testing mock API module prepare function', () => {
|
||||
const prefix = nextPrefix();
|
||||
|
||||
const item: IconifyMockAPI = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
@ -34,13 +35,14 @@ describe('Testing mock API module prepare function', () => {
|
||||
mockAPIData(item);
|
||||
|
||||
// Make sure item is stored correctly
|
||||
expect(typeof storage[provider]).to.be.equal('object');
|
||||
expect(storage[provider][prefix]).to.be.eql([item]);
|
||||
expect(typeof iconsStorage[provider]).to.be.equal('object');
|
||||
expect(iconsStorage[provider][prefix]).to.be.eql([item]);
|
||||
|
||||
// Find item for icons
|
||||
const result = prepare(provider, prefix, ['foo', 'bar', 'baz']);
|
||||
expect(result).to.be.eql([
|
||||
{
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['foo', 'bar', 'baz'],
|
||||
@ -54,18 +56,21 @@ describe('Testing mock API module prepare function', () => {
|
||||
const prefix = nextPrefix();
|
||||
|
||||
const item1: IconifyMockAPI = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
icons: ['foo', 'bar'],
|
||||
};
|
||||
const item2: IconifyMockAPI = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
icons: 'baz',
|
||||
};
|
||||
const item3: IconifyMockAPI = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -82,8 +87,8 @@ describe('Testing mock API module prepare function', () => {
|
||||
mockAPIData(item3);
|
||||
|
||||
// Make sure item is stored correctly
|
||||
expect(typeof storage[provider]).to.be.equal('object');
|
||||
expect(storage[provider][prefix]).to.be.eql([item1, item2, item3]);
|
||||
expect(typeof iconsStorage[provider]).to.be.equal('object');
|
||||
expect(iconsStorage[provider][prefix]).to.be.eql([item1, item2, item3]);
|
||||
|
||||
// Find items for icons
|
||||
const result = prepare(provider, prefix, [
|
||||
@ -97,23 +102,27 @@ describe('Testing mock API module prepare function', () => {
|
||||
expect(result).to.be.eql([
|
||||
// Unknown icons first
|
||||
{
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['test1', 'test2'],
|
||||
},
|
||||
{
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['foo', 'bar'],
|
||||
index: 0,
|
||||
},
|
||||
{
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['baz'],
|
||||
index: 1,
|
||||
},
|
||||
{
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['test10'],
|
||||
@ -127,6 +136,7 @@ describe('Testing mock API module prepare function', () => {
|
||||
const prefix = nextPrefix();
|
||||
|
||||
const item: IconifyMockAPI = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
@ -135,19 +145,21 @@ describe('Testing mock API module prepare function', () => {
|
||||
mockAPIData(item);
|
||||
|
||||
// Make sure item is stored correctly
|
||||
expect(typeof storage[provider]).to.be.equal('object');
|
||||
expect(storage[provider][prefix]).to.be.eql([item]);
|
||||
expect(typeof iconsStorage[provider]).to.be.equal('object');
|
||||
expect(iconsStorage[provider][prefix]).to.be.eql([item]);
|
||||
|
||||
// Find item for icons
|
||||
const result = prepare(provider, prefix, ['foo', 'bar', 'baz']);
|
||||
expect(result).to.be.eql([
|
||||
// Missing icons first
|
||||
{
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['bar', 'baz'],
|
||||
},
|
||||
{
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['foo'],
|
||||
|
@ -5,7 +5,11 @@ import { expect } from 'chai';
|
||||
import type { PendingQueryItem } from '@iconify/api-redundancy';
|
||||
import type { IconifyAPIConfig } from '../../lib/api/config';
|
||||
import { setAPIConfig, getAPIConfig } from '../../lib/api/config';
|
||||
import type { APIQueryParams, IconifyAPIModule } from '../../lib/api/modules';
|
||||
import type {
|
||||
IconifyAPIIconsQueryParams,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPIModule,
|
||||
} from '../../lib/api/modules';
|
||||
import { setAPIModule, getAPIModule } from '../../lib/api/modules';
|
||||
|
||||
describe('Testing API modules', () => {
|
||||
@ -21,8 +25,9 @@ describe('Testing API modules', () => {
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
const item: APIQueryParams = {
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
const item: IconifyAPIIconsQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons,
|
||||
@ -32,7 +37,7 @@ describe('Testing API modules', () => {
|
||||
|
||||
const sendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
params: IconifyAPIQueryParams,
|
||||
item: PendingQueryItem
|
||||
): void => {
|
||||
throw new Error('Unexpected API call');
|
||||
|
@ -4,9 +4,12 @@ import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import type { PendingQueryItem } from '@iconify/api-redundancy';
|
||||
import { setAPIConfig } from '../../lib/api/config';
|
||||
import type { APIQueryParams } from '../../lib/api/modules';
|
||||
import type {
|
||||
IconifyAPIIconsQueryParams,
|
||||
IconifyAPIQueryParams,
|
||||
} from '../../lib/api/modules';
|
||||
import { setAPIModule } from '../../lib/api/modules';
|
||||
import { API } from '../../lib/api/';
|
||||
import { loadIcons, isPending } from '../../lib/api/icons';
|
||||
|
||||
describe('Testing API loadIcons', () => {
|
||||
let prefixCounter = 0;
|
||||
@ -32,8 +35,9 @@ describe('Testing API loadIcons', () => {
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
const item: APIQueryParams = {
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
const item: IconifyAPIIconsQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons,
|
||||
@ -44,7 +48,8 @@ describe('Testing API loadIcons', () => {
|
||||
asyncCounter++;
|
||||
|
||||
// Test input and return as one item
|
||||
const expected: APIQueryParams = {
|
||||
const expected: IconifyAPIIconsQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['icon1', 'icon2'],
|
||||
@ -56,16 +61,19 @@ describe('Testing API loadIcons', () => {
|
||||
|
||||
const sendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
params: IconifyAPIQueryParams,
|
||||
item: PendingQueryItem
|
||||
): void => {
|
||||
// This callback should be called after prepareQuery
|
||||
expect(asyncCounter).to.be.equal(2);
|
||||
asyncCounter++;
|
||||
|
||||
expect(params.type).to.be.equal('icons');
|
||||
|
||||
// Test input
|
||||
expect(host).to.be.equal('https://api1.local');
|
||||
const expected: APIQueryParams = {
|
||||
const expected: IconifyAPIQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['icon1', 'icon2'],
|
||||
@ -95,7 +103,7 @@ describe('Testing API loadIcons', () => {
|
||||
});
|
||||
|
||||
// Load icons
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
// as icon
|
||||
{
|
||||
@ -127,14 +135,14 @@ describe('Testing API loadIcons', () => {
|
||||
expect(pending).to.be.eql([]);
|
||||
|
||||
expect(
|
||||
API.isPending({
|
||||
isPending({
|
||||
provider,
|
||||
prefix,
|
||||
name: 'icon1',
|
||||
})
|
||||
).to.be.equal(false);
|
||||
expect(
|
||||
API.isPending({ provider, prefix, name: 'icon3' })
|
||||
isPending({ provider, prefix, name: 'icon3' })
|
||||
).to.be.equal(false);
|
||||
|
||||
done();
|
||||
@ -142,10 +150,10 @@ describe('Testing API loadIcons', () => {
|
||||
);
|
||||
|
||||
// Test isPending
|
||||
expect(API.isPending({ provider, prefix, name: 'icon1' })).to.be.equal(
|
||||
expect(isPending({ provider, prefix, name: 'icon1' })).to.be.equal(
|
||||
true
|
||||
);
|
||||
expect(API.isPending({ provider, prefix, name: 'icon3' })).to.be.equal(
|
||||
expect(isPending({ provider, prefix, name: 'icon3' })).to.be.equal(
|
||||
false
|
||||
);
|
||||
|
||||
@ -168,11 +176,12 @@ describe('Testing API loadIcons', () => {
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
// Split all icons in multiple queries, one icon per query
|
||||
const results: APIQueryParams[] = [];
|
||||
const results: IconifyAPIIconsQueryParams[] = [];
|
||||
icons.forEach((icon) => {
|
||||
const item: APIQueryParams = {
|
||||
const item: IconifyAPIIconsQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: [icon],
|
||||
@ -188,15 +197,21 @@ describe('Testing API loadIcons', () => {
|
||||
let queryCounter = 0;
|
||||
const sendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
params: IconifyAPIQueryParams,
|
||||
item: PendingQueryItem
|
||||
): void => {
|
||||
// Test input
|
||||
expect(host).to.be.equal('https://api1.local');
|
||||
|
||||
expect(params.type).to.be.equal('icons');
|
||||
if (params.type !== 'icons') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Icon names should match queryCounter: 'icon1' on first run, 'icon2' on second run
|
||||
queryCounter++;
|
||||
const expected: APIQueryParams = {
|
||||
const expected: IconifyAPIQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['icon' + queryCounter],
|
||||
@ -225,7 +240,7 @@ describe('Testing API loadIcons', () => {
|
||||
|
||||
// Load icons
|
||||
let callbackCalled = false;
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
provider + ':' + prefix + ':icon1',
|
||||
provider + ':' + prefix + ':icon2',
|
||||
@ -270,8 +285,9 @@ describe('Testing API loadIcons', () => {
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
const item: APIQueryParams = {
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
const item: IconifyAPIIconsQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons,
|
||||
@ -282,7 +298,7 @@ describe('Testing API loadIcons', () => {
|
||||
let queryCounter = 0;
|
||||
const sendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
params: IconifyAPIQueryParams,
|
||||
item: PendingQueryItem
|
||||
): void => {
|
||||
queryCounter++;
|
||||
@ -326,7 +342,7 @@ describe('Testing API loadIcons', () => {
|
||||
|
||||
// Load icons
|
||||
let callbackCalled = false;
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
provider + ':' + prefix + ':icon1',
|
||||
provider + ':' + prefix + ':icon2',
|
||||
@ -372,8 +388,9 @@ describe('Testing API loadIcons', () => {
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
const item: APIQueryParams = {
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
const item: IconifyAPIIconsQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons,
|
||||
@ -384,10 +401,16 @@ describe('Testing API loadIcons', () => {
|
||||
let queryCounter = 0;
|
||||
const sendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
params: IconifyAPIQueryParams,
|
||||
item: PendingQueryItem
|
||||
): void => {
|
||||
queryCounter++;
|
||||
|
||||
expect(params.type).to.be.equal('icons');
|
||||
if (params.type !== 'icons') {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (queryCounter) {
|
||||
case 1:
|
||||
// First call on api1
|
||||
@ -449,7 +472,7 @@ describe('Testing API loadIcons', () => {
|
||||
|
||||
// Load icons
|
||||
let callbackCalled = false;
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
provider + ':' + prefix + ':icon1',
|
||||
provider + ':' + prefix + ':icon2',
|
||||
@ -478,7 +501,7 @@ describe('Testing API loadIcons', () => {
|
||||
// Send another query on next tick
|
||||
setTimeout(() => {
|
||||
let callbackCalled = false;
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
provider + ':' + prefix + ':icon3',
|
||||
provider + ':' + prefix + ':icon4',
|
||||
@ -528,8 +551,9 @@ describe('Testing API loadIcons', () => {
|
||||
provider: string,
|
||||
prefix: string,
|
||||
icons: string[]
|
||||
): APIQueryParams[] => {
|
||||
const item: APIQueryParams = {
|
||||
): IconifyAPIIconsQueryParams[] => {
|
||||
const item: IconifyAPIIconsQueryParams = {
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons,
|
||||
@ -540,10 +564,16 @@ describe('Testing API loadIcons', () => {
|
||||
let queryCounter = 0;
|
||||
const sendQuery = (
|
||||
host: string,
|
||||
params: APIQueryParams,
|
||||
params: IconifyAPIQueryParams,
|
||||
item: PendingQueryItem
|
||||
): void => {
|
||||
queryCounter++;
|
||||
|
||||
expect(params.type).to.be.equal('icons');
|
||||
if (params.type !== 'icons') {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (queryCounter) {
|
||||
case 1:
|
||||
// First call on api1
|
||||
@ -608,7 +638,7 @@ describe('Testing API loadIcons', () => {
|
||||
|
||||
// Load icons
|
||||
let callbackCalled = false;
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
provider + ':' + prefix + ':icon1',
|
||||
provider + ':' + prefix + ':icon2',
|
||||
@ -637,7 +667,7 @@ describe('Testing API loadIcons', () => {
|
||||
// Send another query on next tick for different prefix that shares configuration
|
||||
setTimeout(() => {
|
||||
let callbackCalled = false;
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
provider + ':' + prefix2 + ':icon2',
|
||||
provider + ':' + prefix2 + ':icon4',
|
||||
|
@ -4,10 +4,11 @@ import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { setAPIConfig } from '../../lib/api/config';
|
||||
import { setAPIModule } from '../../lib/api/modules';
|
||||
import { API } from '../../lib/api/';
|
||||
import { loadIcons } from '../../lib/api/icons';
|
||||
import type { IconifyMockAPIDelayDoneCallback } from '../../lib/api/modules/mock';
|
||||
import { mockAPIModule, mockAPIData } from '../../lib/api/modules/mock';
|
||||
import { getStorage, iconExists } from '../../lib/storage/storage';
|
||||
import { sendAPIQuery } from '../../lib/api/query';
|
||||
|
||||
describe('Testing mock API module', () => {
|
||||
let prefixCounter = 0;
|
||||
@ -18,16 +19,20 @@ describe('Testing mock API module', () => {
|
||||
|
||||
// Set API module for provider
|
||||
const provider = nextPrefix();
|
||||
setAPIConfig(provider, {
|
||||
resources: ['https://api1.local'],
|
||||
|
||||
before(() => {
|
||||
setAPIConfig(provider, {
|
||||
resources: ['https://api1.local'],
|
||||
});
|
||||
setAPIModule(provider, mockAPIModule);
|
||||
});
|
||||
setAPIModule(provider, mockAPIModule);
|
||||
|
||||
// Tests
|
||||
it('404 response', (done) => {
|
||||
const prefix = nextPrefix();
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
icons: ['test1', 'test2'],
|
||||
@ -36,7 +41,7 @@ describe('Testing mock API module', () => {
|
||||
|
||||
let isSync = true;
|
||||
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
{
|
||||
provider,
|
||||
@ -66,6 +71,7 @@ describe('Testing mock API module', () => {
|
||||
const prefix = nextPrefix();
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -81,6 +87,7 @@ describe('Testing mock API module', () => {
|
||||
},
|
||||
});
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -98,7 +105,7 @@ describe('Testing mock API module', () => {
|
||||
|
||||
let isSync = true;
|
||||
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
{
|
||||
provider,
|
||||
@ -140,6 +147,7 @@ describe('Testing mock API module', () => {
|
||||
let next: IconifyMockAPIDelayDoneCallback | undefined;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -155,6 +163,7 @@ describe('Testing mock API module', () => {
|
||||
},
|
||||
});
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -175,7 +184,7 @@ describe('Testing mock API module', () => {
|
||||
|
||||
let callbackCounter = 0;
|
||||
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
{
|
||||
provider,
|
||||
@ -246,6 +255,7 @@ describe('Testing mock API module', () => {
|
||||
|
||||
// Mock data
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -272,7 +282,7 @@ describe('Testing mock API module', () => {
|
||||
});
|
||||
|
||||
// Load icons
|
||||
API.loadIcons([
|
||||
loadIcons([
|
||||
{
|
||||
provider,
|
||||
prefix,
|
||||
@ -280,4 +290,71 @@ describe('Testing mock API module', () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('Custom query', (done) => {
|
||||
mockAPIData({
|
||||
type: 'custom',
|
||||
provider,
|
||||
uri: '/test',
|
||||
response: {
|
||||
foo: true,
|
||||
},
|
||||
});
|
||||
|
||||
let isSync = true;
|
||||
|
||||
sendAPIQuery(
|
||||
provider,
|
||||
{
|
||||
type: 'custom',
|
||||
provider,
|
||||
uri: '/test',
|
||||
},
|
||||
(data, error) => {
|
||||
expect(error).to.be.equal(void 0);
|
||||
expect(data).to.be.eql({
|
||||
foo: true,
|
||||
});
|
||||
expect(isSync).to.be.equal(false);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
isSync = false;
|
||||
});
|
||||
|
||||
it('Custom query with host', (done) => {
|
||||
const host = 'http://' + nextPrefix();
|
||||
setAPIModule(host, mockAPIModule);
|
||||
mockAPIData({
|
||||
type: 'host',
|
||||
host,
|
||||
uri: '/test',
|
||||
response: {
|
||||
foo: 2,
|
||||
},
|
||||
});
|
||||
|
||||
let isSync = true;
|
||||
|
||||
sendAPIQuery(
|
||||
{
|
||||
resources: [host],
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
uri: '/test',
|
||||
},
|
||||
(data, error) => {
|
||||
expect(error).to.be.equal(void 0);
|
||||
expect(data).to.be.eql({
|
||||
foo: 2,
|
||||
});
|
||||
expect(isSync).to.be.equal(false);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
isSync = false;
|
||||
});
|
||||
});
|
||||
|
@ -2,18 +2,14 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { setAPIConfig } from '../../lib/api/config';
|
||||
import { setAPIModule } from '../../lib/api/modules';
|
||||
import { API } from '../../lib/api/';
|
||||
import { loadIcons } from '../../lib/api/icons';
|
||||
import { mockAPIModule, mockAPIData } from '../../lib/api/modules/mock';
|
||||
import { allowSimpleNames } from '../../lib/storage/functions';
|
||||
|
||||
describe('Testing simple names with API module', () => {
|
||||
// Set API config and allow simple names
|
||||
before(() => {
|
||||
setAPIConfig('', {
|
||||
resources: ['https://api1.local'],
|
||||
});
|
||||
allowSimpleNames(true);
|
||||
setAPIModule('', mockAPIModule);
|
||||
});
|
||||
@ -24,6 +20,7 @@ describe('Testing simple names with API module', () => {
|
||||
|
||||
it('Loading icons without prefix', (done) => {
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider: '',
|
||||
prefix: '',
|
||||
response: {
|
||||
@ -39,6 +36,7 @@ describe('Testing simple names with API module', () => {
|
||||
},
|
||||
});
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider: '',
|
||||
prefix: 'test200',
|
||||
response: {
|
||||
@ -54,7 +52,7 @@ describe('Testing simple names with API module', () => {
|
||||
},
|
||||
});
|
||||
|
||||
API.loadIcons(
|
||||
loadIcons(
|
||||
[
|
||||
{
|
||||
provider: '',
|
||||
|
86
packages/core/tests/30-api/50-fetch-test.ts
Normal file
86
packages/core/tests/30-api/50-fetch-test.ts
Normal file
@ -0,0 +1,86 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars-experimental */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import crossFetch from 'cross-fetch';
|
||||
import { sendAPIQuery } from '../../lib/api/query';
|
||||
import { setAPIModule } from '../../lib/api/modules';
|
||||
import { fetchAPIModule, setFetch } from '../../lib/api/modules/fetch';
|
||||
import { setAPIConfig } from '../../lib/api/config';
|
||||
import { mockAPIModule } from '../../lib/api/modules/mock';
|
||||
|
||||
describe('Testing live API with fetch', () => {
|
||||
let counter = 0;
|
||||
function nextProvider(): string {
|
||||
return 'fetch-' + counter++;
|
||||
}
|
||||
|
||||
const host = 'https://api.iconify.design';
|
||||
|
||||
// Set fetch module
|
||||
before(() => {
|
||||
setFetch(crossFetch);
|
||||
setAPIModule('', fetchAPIModule);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
setAPIModule('', mockAPIModule);
|
||||
});
|
||||
|
||||
it('Missing API configuration', (done) => {
|
||||
const provider = nextProvider();
|
||||
sendAPIQuery(
|
||||
provider,
|
||||
{
|
||||
type: 'custom',
|
||||
provider,
|
||||
uri: '/collections',
|
||||
},
|
||||
(data, error) => {
|
||||
expect(error).to.be.equal(424);
|
||||
expect(data).to.be.equal(void 0);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('Custom request with provider', (done) => {
|
||||
const provider = nextProvider();
|
||||
expect(
|
||||
setAPIConfig(provider, {
|
||||
resources: [host],
|
||||
})
|
||||
).to.be.equal(true);
|
||||
|
||||
sendAPIQuery(
|
||||
provider,
|
||||
{
|
||||
type: 'custom',
|
||||
provider,
|
||||
uri: '/collections',
|
||||
},
|
||||
(data, error) => {
|
||||
expect(error).to.be.equal(void 0);
|
||||
expect(typeof data).to.be.equal('object');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('Custom request with host', (done) => {
|
||||
sendAPIQuery(
|
||||
{
|
||||
resources: [host],
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
uri: '/collections',
|
||||
},
|
||||
(data, error) => {
|
||||
expect(error).to.be.equal(void 0);
|
||||
expect(typeof data).to.be.equal('object');
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
4228
packages/ember-demo/package-lock.json
generated
4228
packages/ember-demo/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,7 @@
|
||||
"@glimmer/component": "^1.0.4",
|
||||
"@glimmer/tracking": "^1.0.4",
|
||||
"@iconify-icons/mdi-light": "^1.1.0",
|
||||
"@iconify/ember": "^1.0.0-beta.1",
|
||||
"@iconify/ember": "^1.0.0-beta.3",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"broccoli-asset-rev": "^3.0.0",
|
||||
"ember-auto-import": "^1.11.3",
|
||||
|
1976
packages/ember/package-lock.json
generated
1976
packages/ember/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
"name": "@iconify/ember",
|
||||
"description": "Iconify icon component for Ember.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "1.0.0-beta.1",
|
||||
"version": "1.0.0-beta.3",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
@ -23,7 +23,7 @@
|
||||
"build:cleanup": "node cleanup"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.18.4",
|
||||
|
@ -7,8 +7,7 @@ import { getIconData } from '@iconify/core/lib/storage/functions';
|
||||
import { fullIcon, FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// API
|
||||
import { API } from '@iconify/core/lib/api/';
|
||||
import type { IconifyIconLoaderAbort } from '@iconify/core/lib/interfaces/loader';
|
||||
import { loadIcons, IconifyIconLoaderAbort } from '@iconify/core/lib/api/icons';
|
||||
|
||||
// Component stuff
|
||||
import type { IconifyIconProps } from './props';
|
||||
@ -127,7 +126,7 @@ export class IconifyIconComponent extends Component<IconifyIconProps> {
|
||||
this._icon = {
|
||||
name: icon,
|
||||
className,
|
||||
abort: API.loadIcons([iconName], () => {
|
||||
abort: loadIcons([iconName], () => {
|
||||
if (!this.isDestroyed && this._icon?.name === icon) {
|
||||
// Loaded
|
||||
const data = getIconData(iconName);
|
||||
|
@ -18,42 +18,41 @@ import {
|
||||
} from '@iconify/core/lib/builder/functions';
|
||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
|
||||
// API
|
||||
import { API, IconifyAPIInternalStorage } from '@iconify/core/lib/api/';
|
||||
import {
|
||||
IconifyAPIFunctions,
|
||||
IconifyAPIInternalFunctions,
|
||||
APIFunctions,
|
||||
APIInternalFunctions,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
} from '@iconify/core/lib/api/functions';
|
||||
import {
|
||||
setAPIModule,
|
||||
IconifyAPIModule,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIPrepareQuery,
|
||||
GetIconifyAPIModule,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
} from '@iconify/core/lib/api/modules';
|
||||
import { getAPIModule as getJSONPAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import { jsonpAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import {
|
||||
getAPIModule as getFetchAPIModule,
|
||||
fetchAPIModule,
|
||||
getFetch,
|
||||
setFetch,
|
||||
} from '@iconify/core/lib/api/modules/fetch';
|
||||
import {
|
||||
setAPIConfig,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIConfig,
|
||||
getAPIConfig,
|
||||
GetAPIConfig,
|
||||
} from '@iconify/core/lib/api/config';
|
||||
import type {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '@iconify/core/lib/interfaces/loader';
|
||||
} from '@iconify/core/lib/api/icons';
|
||||
|
||||
// Cache
|
||||
import { cache } from '@iconify/core/lib/cache';
|
||||
import { storeCache, loadCache } from '@iconify/core/lib/browser-storage';
|
||||
import { toggleBrowserCache } from '@iconify/core/lib/browser-storage/functions';
|
||||
import type {
|
||||
@ -102,12 +101,14 @@ export {
|
||||
IconifyAPIConfig,
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyAPIInternalStorage,
|
||||
IconifyAPIModule,
|
||||
GetAPIConfig,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
};
|
||||
|
||||
// Builder functions
|
||||
@ -189,33 +190,15 @@ export const _api = APIInternalFunctions;
|
||||
// Enable short names
|
||||
allowSimpleNames(true);
|
||||
|
||||
// Set API
|
||||
coreModules.api = API;
|
||||
|
||||
// Use Fetch API by default
|
||||
let getAPIModule: GetIconifyAPIModule = getFetchAPIModule;
|
||||
try {
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// If window and document exist, attempt to load whatever module is available, otherwise use Fetch API
|
||||
getAPIModule =
|
||||
typeof fetch === 'function' && typeof Promise === 'function'
|
||||
? getFetchAPIModule
|
||||
: getJSONPAPIModule;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
// Set API module
|
||||
setAPIModule('', getFetch() ? fetchAPIModule : jsonpAPIModule);
|
||||
|
||||
/**
|
||||
* Function to enable node-fetch for getting icons on server side
|
||||
*/
|
||||
_api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
setFetch(nodeFetch);
|
||||
if (getAPIModule !== getFetchAPIModule) {
|
||||
getAPIModule = getFetchAPIModule;
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
}
|
||||
setAPIModule('', fetchAPIModule);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -223,7 +206,7 @@ _api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
*/
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// Set cache and load existing cache
|
||||
coreModules.cache = storeCache;
|
||||
cache.store = storeCache;
|
||||
loadCache();
|
||||
|
||||
interface WindowWithIconifyStuff {
|
||||
|
@ -21,13 +21,13 @@ Iconify SVG framework is designed to be as easy to use as possible.
|
||||
Add this line to your page to load Iconify SVG framework (you can add it to `<head>` section of the page or before `</body>`):
|
||||
|
||||
```html
|
||||
<script src="https://code.iconify.design/2/2.0.4/iconify.min.js"></script>
|
||||
<script src="https://code.iconify.design/2/2.1.0-beta.2/iconify.min.js"></script>
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/@iconify/iconify@2.0.4/dist/iconify.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@iconify/iconify@2.1.0-beta.2/dist/iconify.min.js"></script>
|
||||
```
|
||||
|
||||
or, if you are building a project with something like WebPack or Rollup, you can include the script by installing `@iconify/iconify` as a dependency and importing it in your project:
|
||||
|
26
packages/iconify/package-lock.json
generated
26
packages/iconify/package-lock.json
generated
@ -1,18 +1,18 @@
|
||||
{
|
||||
"name": "@iconify/iconify",
|
||||
"version": "2.0.3",
|
||||
"version": "2.1.0-beta.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@iconify/iconify",
|
||||
"version": "2.0.3",
|
||||
"version": "2.1.0-beta.2",
|
||||
"license": "(Apache-2.0 OR GPL-2.0)",
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.0.6"
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.12.0",
|
||||
@ -75,14 +75,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.3.tgz",
|
||||
"integrity": "sha512-THaYuyvpqlgwHo9P1NIA904s9TKWbX9IUu9zw4v1Q3BokkAirThOoZL7LiTwDGknYwLKe7525qiyuNzxojgclw==",
|
||||
"version": "1.2.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.2.tgz",
|
||||
"integrity": "sha512-BnlanmZB5h+OXP0FIsfjMqsrAaDdHxVN5Y5jjYU4KrqaEwh9BiaIIr7lS/rXGk4UdnLps2NDjhkobuC7DXqm6A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
@ -2291,14 +2292,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.3.tgz",
|
||||
"integrity": "sha512-THaYuyvpqlgwHo9P1NIA904s9TKWbX9IUu9zw4v1Q3BokkAirThOoZL7LiTwDGknYwLKe7525qiyuNzxojgclw==",
|
||||
"version": "1.2.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.2.tgz",
|
||||
"integrity": "sha512-BnlanmZB5h+OXP0FIsfjMqsrAaDdHxVN5Y5jjYU4KrqaEwh9BiaIIr7lS/rXGk4UdnLps2NDjhkobuC7DXqm6A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@iconify/iconify",
|
||||
"description": "Unified SVG framework with over 70,000 icons to choose from",
|
||||
"description": "Unified SVG framework with over 100,000 icons to choose from",
|
||||
"author": "Vjacheslav Trushkin <cyberalien@gmail.com> (https://iconify.design)",
|
||||
"version": "2.0.4",
|
||||
"version": "2.1.0-beta.2",
|
||||
"license": "(Apache-2.0 OR GPL-2.0)",
|
||||
"main": "./dist/iconify.min.js",
|
||||
"types": "./dist/iconify.d.ts",
|
||||
@ -27,10 +27,10 @@
|
||||
"pretest": "npm run build && npm run build:tests"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.0.6"
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.12.0",
|
||||
|
@ -17,11 +17,9 @@ import {
|
||||
builderFunctions,
|
||||
} from '@iconify/core/lib/builder/functions';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
|
||||
// Cache
|
||||
import { storeCache, loadCache } from '@iconify/core/lib/browser-storage/';
|
||||
import { cache } from '@iconify/core/lib/cache';
|
||||
import {
|
||||
IconifyBrowserCacheFunctions,
|
||||
IconifyBrowserCacheType,
|
||||
@ -34,31 +32,32 @@ import {
|
||||
IconifyAPIInternalFunctions,
|
||||
APIFunctions,
|
||||
APIInternalFunctions,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
} from '@iconify/core/lib/api/functions';
|
||||
import { API, IconifyAPIInternalStorage } from '@iconify/core/lib/api/';
|
||||
import {
|
||||
setAPIModule,
|
||||
IconifyAPIModule,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIPrepareQuery,
|
||||
GetIconifyAPIModule,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
} from '@iconify/core/lib/api/modules';
|
||||
import {
|
||||
setAPIConfig,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIConfig,
|
||||
getAPIConfig,
|
||||
GetAPIConfig,
|
||||
} from '@iconify/core/lib/api/config';
|
||||
import { getAPIModule as getJSONPAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import { jsonpAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import {
|
||||
getAPIModule as getFetchAPIModule,
|
||||
fetchAPIModule,
|
||||
getFetch,
|
||||
setFetch,
|
||||
} from '@iconify/core/lib/api/modules/fetch';
|
||||
import {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '@iconify/core/lib/interfaces/loader';
|
||||
} from '@iconify/core/lib/api/icons';
|
||||
|
||||
// Other
|
||||
import { IconifyCommonFunctions, commonFunctions } from './common';
|
||||
@ -94,15 +93,19 @@ export {
|
||||
IconifyAPIConfig,
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyAPIInternalStorage,
|
||||
IconifyAPIModule,
|
||||
GetAPIConfig,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
IconifyBrowserCacheType,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
};
|
||||
|
||||
// Cache
|
||||
export { IconifyBrowserCacheType };
|
||||
|
||||
/**
|
||||
* Iconify interface
|
||||
*/
|
||||
@ -150,33 +153,15 @@ const Iconify = {
|
||||
/**
|
||||
* Initialise stuff
|
||||
*/
|
||||
// Set API
|
||||
coreModules.api = API;
|
||||
|
||||
// Check for Fetch API
|
||||
let getAPIModule: GetIconifyAPIModule = getFetchAPIModule;
|
||||
try {
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// If window and document exist, attempt to load whatever module is available, otherwise use Fetch API
|
||||
getAPIModule =
|
||||
typeof fetch === 'function' && typeof Promise === 'function'
|
||||
? getFetchAPIModule
|
||||
: getJSONPAPIModule;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
// Set API module
|
||||
setAPIModule('', getFetch() ? fetchAPIModule : jsonpAPIModule);
|
||||
|
||||
/**
|
||||
* Function to enable node-fetch for getting icons on server side
|
||||
*/
|
||||
Iconify._api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
setFetch(nodeFetch);
|
||||
if (getAPIModule !== getFetchAPIModule) {
|
||||
getAPIModule = getFetchAPIModule;
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
}
|
||||
setAPIModule('', fetchAPIModule);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -184,7 +169,7 @@ Iconify._api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
*/
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// Set cache and load existing cache
|
||||
coreModules.cache = storeCache;
|
||||
cache.store = storeCache;
|
||||
loadCache();
|
||||
|
||||
interface WindowWithIconifyStuff {
|
||||
|
@ -6,7 +6,7 @@ interface OldIEElement extends HTMLElement {
|
||||
/**
|
||||
* Execute function when DOM is ready
|
||||
*/
|
||||
export function onReady(callback): void {
|
||||
export function onReady(callback: () => void): void {
|
||||
const doc = document;
|
||||
if (
|
||||
doc.readyState === 'complete' ||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||
import { getStorage, getIcon } from '@iconify/core/lib/storage/storage';
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
import { isPending, loadIcons } from '@iconify/core/lib/api/icons';
|
||||
import { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import { findPlaceholders } from './finder';
|
||||
import { IconifyElementData, elementDataProperty } from './element';
|
||||
@ -12,7 +12,7 @@ import {
|
||||
removeObservedNode,
|
||||
observeNode,
|
||||
} from './observer';
|
||||
import { findRootNode, addRootNode, listRootNodes } from './root';
|
||||
import { findRootNode, listRootNodes } from './root';
|
||||
|
||||
/**
|
||||
* Flag to avoid scanning DOM too often
|
||||
@ -77,8 +77,10 @@ export function scanDOM(node?: ObservedNode, addTempNode = false): void {
|
||||
scanQueued = false;
|
||||
|
||||
// List of icons to load: [provider][prefix][name] = boolean
|
||||
const loadIcons: Record<string, Record<string, Record<string, boolean>>> =
|
||||
Object.create(null);
|
||||
const iconsToLoad: Record<
|
||||
string,
|
||||
Record<string, Record<string, boolean>>
|
||||
> = Object.create(null);
|
||||
|
||||
// Get placeholders
|
||||
(node ? [node] : listRootNodes()).forEach((node) => {
|
||||
@ -112,8 +114,7 @@ export function scanDOM(node?: ObservedNode, addTempNode = false): void {
|
||||
|
||||
case 'loading':
|
||||
if (
|
||||
coreModules.api &&
|
||||
coreModules.api.isPending({
|
||||
isPending({
|
||||
provider,
|
||||
prefix,
|
||||
name,
|
||||
@ -162,18 +163,16 @@ export function scanDOM(node?: ObservedNode, addTempNode = false): void {
|
||||
return;
|
||||
}
|
||||
|
||||
if (coreModules.api) {
|
||||
if (!coreModules.api.isPending({ provider, prefix, name })) {
|
||||
// Add icon to loading queue
|
||||
if (loadIcons[provider] === void 0) {
|
||||
loadIcons[provider] = Object.create(null);
|
||||
}
|
||||
const providerLoadIcons = loadIcons[provider];
|
||||
if (providerLoadIcons[prefix] === void 0) {
|
||||
providerLoadIcons[prefix] = Object.create(null);
|
||||
}
|
||||
providerLoadIcons[prefix][name] = true;
|
||||
if (!isPending({ provider, prefix, name })) {
|
||||
// Add icon to loading queue
|
||||
if (iconsToLoad[provider] === void 0) {
|
||||
iconsToLoad[provider] = Object.create(null);
|
||||
}
|
||||
const providerIconsToLoad = iconsToLoad[provider];
|
||||
if (providerIconsToLoad[prefix] === void 0) {
|
||||
providerIconsToLoad[prefix] = Object.create(null);
|
||||
}
|
||||
providerIconsToLoad[prefix][name] = true;
|
||||
}
|
||||
|
||||
// Mark as loading
|
||||
@ -200,23 +199,20 @@ export function scanDOM(node?: ObservedNode, addTempNode = false): void {
|
||||
});
|
||||
|
||||
// Load icons
|
||||
if (coreModules.api) {
|
||||
const api = coreModules.api;
|
||||
Object.keys(loadIcons).forEach((provider) => {
|
||||
const providerLoadIcons = loadIcons[provider];
|
||||
Object.keys(providerLoadIcons).forEach((prefix) => {
|
||||
api.loadIcons(
|
||||
Object.keys(providerLoadIcons[prefix]).map((name) => {
|
||||
const icon: IconifyIconName = {
|
||||
provider,
|
||||
prefix,
|
||||
name,
|
||||
};
|
||||
return icon;
|
||||
}),
|
||||
checkPendingIcons
|
||||
);
|
||||
});
|
||||
Object.keys(iconsToLoad).forEach((provider) => {
|
||||
const providerIconsToLoad = iconsToLoad[provider];
|
||||
Object.keys(providerIconsToLoad).forEach((prefix) => {
|
||||
loadIcons(
|
||||
Object.keys(providerIconsToLoad[prefix]).map((name) => {
|
||||
const icon: IconifyIconName = {
|
||||
provider,
|
||||
prefix,
|
||||
name,
|
||||
};
|
||||
return icon;
|
||||
}),
|
||||
checkPendingIcons
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -15,14 +15,14 @@ Iconify._api.setAPIModule(provider, mockAPIModule);
|
||||
|
||||
// Set data
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
prefix,
|
||||
icons: {
|
||||
home: {
|
||||
body:
|
||||
'<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
body: '<path d="M10 20v-6h4v6h5v-8h3L12 3L2 12h3v8h5z" fill="currentColor"/>',
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
|
1425
packages/nextjs-demo/package-lock.json
generated
1425
packages/nextjs-demo/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@iconify/react": "^3.0.0",
|
||||
"@iconify/react": "^3.1.0-beta.1",
|
||||
"next": "^10.0.0",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1"
|
||||
|
@ -1,23 +1,34 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import Head from 'next/head';
|
||||
import { Icon, InlineIcon, addIcon } from '@iconify/react';
|
||||
import { Icon, InlineIcon, addIcon, loadIcons, getIcon } from '@iconify/react';
|
||||
|
||||
// Use Iconify to render logo
|
||||
addIcon('logo', {
|
||||
width: 283,
|
||||
height: 64,
|
||||
body:
|
||||
'<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="currentColor"/>',
|
||||
body: '<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="currentColor"/>',
|
||||
});
|
||||
|
||||
// Icon to test generating unique IDs
|
||||
const iconDataWithID = {
|
||||
body:
|
||||
'<defs><path id="ssvg-id-1st-place-medala" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medald" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medalf" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medalh" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medalj" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medalm" d="M.93.01h120.55v58.36H.93z"/><path d="M52.849 78.373v-3.908c3.681-.359 6.25-.958 7.703-1.798c1.454-.84 2.54-2.828 3.257-5.962h4.021v40.385h-5.437V78.373h-9.544z" id="ssvg-id-1st-place-medalp"/><linearGradient x1="49.998%" y1="-13.249%" x2="49.998%" y2="90.002%" id="ssvg-id-1st-place-medalb"><stop stop-color="#1E88E5" offset="13.55%"/><stop stop-color="#1565C0" offset="93.8%"/></linearGradient><linearGradient x1="26.648%" y1="2.735%" x2="77.654%" y2="105.978%" id="ssvg-id-1st-place-medalk"><stop stop-color="#64B5F6" offset="13.55%"/><stop stop-color="#2196F3" offset="94.62%"/></linearGradient><radialGradient cx="22.368%" cy="12.5%" fx="22.368%" fy="12.5%" r="95.496%" id="ssvg-id-1st-place-medalo"><stop stop-color="#FFEB3B" offset="29.72%"/><stop stop-color="#FBC02D" offset="95.44%"/></radialGradient></defs><g fill="none" fill-rule="evenodd"><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medalc" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medala"/></mask><path fill="url(#ssvg-id-1st-place-medalb)" fill-rule="nonzero" mask="url(#ssvg-id-1st-place-medalc)" d="M45.44 42.18h31.43l30-48.43H75.44z"/></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medale" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medald"/></mask><g opacity=".2" mask="url(#ssvg-id-1st-place-medale)" fill="#424242" fill-rule="nonzero"><path d="M101.23-3L75.2 39H50.85L77.11-3h24.12zm5.64-3H75.44l-30 48h31.42l30.01-48z"/></g></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medalg" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medalf"/></mask><path d="M79 30H43c-4.42 0-8 3.58-8 8v16.04c0 2.17 1.8 3.95 4.02 3.96h.01c2.23-.01 4.97-1.75 4.97-3.96V44c0-1.1.9-2 2-2h30c1.1 0 2 .9 2 2v9.93c0 1.98 2.35 3.68 4.22 4.04c.26.05.52.08.78.08c2.21 0 4-1.79 4-4V38c0-4.42-3.58-8-8-8z" fill="#FDD835" fill-rule="nonzero" mask="url(#ssvg-id-1st-place-medalg)"/></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medali" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medalh"/></mask><g opacity=".2" mask="url(#ssvg-id-1st-place-medali)" fill="#424242" fill-rule="nonzero"><path d="M79 32c3.31 0 6 2.69 6 6v16.04A2.006 2.006 0 0 1 82.59 56c-1.18-.23-2.59-1.35-2.59-2.07V44c0-2.21-1.79-4-4-4H46c-2.21 0-4 1.79-4 4v10.04c0 .88-1.64 1.96-2.97 1.96c-1.12-.01-2.03-.89-2.03-1.96V38c0-3.31 2.69-6 6-6h36zm0-2H43c-4.42 0-8 3.58-8 8v16.04c0 2.17 1.8 3.95 4.02 3.96h.01c2.23-.01 4.97-1.75 4.97-3.96V44c0-1.1.9-2 2-2h30c1.1 0 2 .9 2 2v9.93c0 1.98 2.35 3.68 4.22 4.04c.26.05.52.08.78.08c2.21 0 4-1.79 4-4V38c0-4.42-3.58-8-8-8z"/></g></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medall" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medalj"/></mask><path fill="url(#ssvg-id-1st-place-medalk)" fill-rule="nonzero" mask="url(#ssvg-id-1st-place-medall)" d="M76.87 42.18H45.44l-30-48.43h31.43z"/></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medaln" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medalm"/></mask><g opacity=".2" mask="url(#ssvg-id-1st-place-medaln)" fill="#424242" fill-rule="nonzero"><path d="M45.1-3l26.35 42H47.1L20.86-3H45.1zm1.77-3H15.44l30 48h31.42L46.87-6z"/></g></g><circle fill="url(#ssvg-id-1st-place-medalo)" fill-rule="nonzero" cx="64" cy="86" r="38"/><path d="M64 51c19.3 0 35 15.7 35 35s-15.7 35-35 35s-35-15.7-35-35s15.7-35 35-35zm0-3c-20.99 0-38 17.01-38 38s17.01 38 38 38s38-17.01 38-38s-17.01-38-38-38z" opacity=".2" fill="#424242" fill-rule="nonzero"/><path d="M47.3 63.59h33.4v44.4H47.3z"/><use fill="#000" xlink:href="#ssvg-id-1st-place-medalp"/><use fill="#FFA000" xlink:href="#ssvg-id-1st-place-medalp"/></g>',
|
||||
body: '<defs><path id="ssvg-id-1st-place-medala" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medald" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medalf" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medalh" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medalj" d="M.93.01h120.55v58.36H.93z"/><path id="ssvg-id-1st-place-medalm" d="M.93.01h120.55v58.36H.93z"/><path d="M52.849 78.373v-3.908c3.681-.359 6.25-.958 7.703-1.798c1.454-.84 2.54-2.828 3.257-5.962h4.021v40.385h-5.437V78.373h-9.544z" id="ssvg-id-1st-place-medalp"/><linearGradient x1="49.998%" y1="-13.249%" x2="49.998%" y2="90.002%" id="ssvg-id-1st-place-medalb"><stop stop-color="#1E88E5" offset="13.55%"/><stop stop-color="#1565C0" offset="93.8%"/></linearGradient><linearGradient x1="26.648%" y1="2.735%" x2="77.654%" y2="105.978%" id="ssvg-id-1st-place-medalk"><stop stop-color="#64B5F6" offset="13.55%"/><stop stop-color="#2196F3" offset="94.62%"/></linearGradient><radialGradient cx="22.368%" cy="12.5%" fx="22.368%" fy="12.5%" r="95.496%" id="ssvg-id-1st-place-medalo"><stop stop-color="#FFEB3B" offset="29.72%"/><stop stop-color="#FBC02D" offset="95.44%"/></radialGradient></defs><g fill="none" fill-rule="evenodd"><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medalc" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medala"/></mask><path fill="url(#ssvg-id-1st-place-medalb)" fill-rule="nonzero" mask="url(#ssvg-id-1st-place-medalc)" d="M45.44 42.18h31.43l30-48.43H75.44z"/></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medale" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medald"/></mask><g opacity=".2" mask="url(#ssvg-id-1st-place-medale)" fill="#424242" fill-rule="nonzero"><path d="M101.23-3L75.2 39H50.85L77.11-3h24.12zm5.64-3H75.44l-30 48h31.42l30.01-48z"/></g></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medalg" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medalf"/></mask><path d="M79 30H43c-4.42 0-8 3.58-8 8v16.04c0 2.17 1.8 3.95 4.02 3.96h.01c2.23-.01 4.97-1.75 4.97-3.96V44c0-1.1.9-2 2-2h30c1.1 0 2 .9 2 2v9.93c0 1.98 2.35 3.68 4.22 4.04c.26.05.52.08.78.08c2.21 0 4-1.79 4-4V38c0-4.42-3.58-8-8-8z" fill="#FDD835" fill-rule="nonzero" mask="url(#ssvg-id-1st-place-medalg)"/></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medali" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medalh"/></mask><g opacity=".2" mask="url(#ssvg-id-1st-place-medali)" fill="#424242" fill-rule="nonzero"><path d="M79 32c3.31 0 6 2.69 6 6v16.04A2.006 2.006 0 0 1 82.59 56c-1.18-.23-2.59-1.35-2.59-2.07V44c0-2.21-1.79-4-4-4H46c-2.21 0-4 1.79-4 4v10.04c0 .88-1.64 1.96-2.97 1.96c-1.12-.01-2.03-.89-2.03-1.96V38c0-3.31 2.69-6 6-6h36zm0-2H43c-4.42 0-8 3.58-8 8v16.04c0 2.17 1.8 3.95 4.02 3.96h.01c2.23-.01 4.97-1.75 4.97-3.96V44c0-1.1.9-2 2-2h30c1.1 0 2 .9 2 2v9.93c0 1.98 2.35 3.68 4.22 4.04c.26.05.52.08.78.08c2.21 0 4-1.79 4-4V38c0-4.42-3.58-8-8-8z"/></g></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medall" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medalj"/></mask><path fill="url(#ssvg-id-1st-place-medalk)" fill-rule="nonzero" mask="url(#ssvg-id-1st-place-medall)" d="M76.87 42.18H45.44l-30-48.43h31.43z"/></g><g transform="translate(3 4)"><mask id="ssvg-id-1st-place-medaln" fill="#fff"><use xlink:href="#ssvg-id-1st-place-medalm"/></mask><g opacity=".2" mask="url(#ssvg-id-1st-place-medaln)" fill="#424242" fill-rule="nonzero"><path d="M45.1-3l26.35 42H47.1L20.86-3H45.1zm1.77-3H15.44l30 48h31.42L46.87-6z"/></g></g><circle fill="url(#ssvg-id-1st-place-medalo)" fill-rule="nonzero" cx="64" cy="86" r="38"/><path d="M64 51c19.3 0 35 15.7 35 35s-15.7 35-35 35s-35-15.7-35-35s15.7-35 35-35zm0-3c-20.99 0-38 17.01-38 38s17.01 38 38 38s38-17.01 38-38s-17.01-38-38-38z" opacity=".2" fill="#424242" fill-rule="nonzero"/><path d="M47.3 63.59h33.4v44.4H47.3z"/><use fill="#000" xlink:href="#ssvg-id-1st-place-medalp"/><use fill="#FFA000" xlink:href="#ssvg-id-1st-place-medalp"/></g>',
|
||||
width: 128,
|
||||
height: 128,
|
||||
};
|
||||
|
||||
export default function Home() {
|
||||
const [data, setData] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = loadIcons(['carbon:home'], (loaded) => {
|
||||
const data = getIcon('carbon:home');
|
||||
if (data) {
|
||||
setData(data);
|
||||
}
|
||||
});
|
||||
return unsubscribe;
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
<Head>
|
||||
@ -97,6 +108,17 @@ export default function Home() {
|
||||
<InlineIcon icon={iconDataWithID} />
|
||||
<InlineIcon icon={iconDataWithID} />
|
||||
</p>
|
||||
<p>
|
||||
Testing 'carbon:home':
|
||||
{data
|
||||
? ' icon is ' +
|
||||
data.width +
|
||||
' x ' +
|
||||
data.height +
|
||||
' '
|
||||
: ' loading...'}
|
||||
{data && <Icon icon={data} inline={true} />}
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
|
3250
packages/react-demo/package-lock.json
generated
3250
packages/react-demo/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,8 @@
|
||||
"devDependencies": {
|
||||
"@iconify-icons/mdi-light": "^1.1.0",
|
||||
"@iconify-icons/uil": "^1.1.1",
|
||||
"@iconify/core": "^1.0.0",
|
||||
"@iconify/react": "^3.0.0",
|
||||
"@iconify/core": "^1.2.0-beta.1",
|
||||
"@iconify/react": "^3.1.0-beta.1",
|
||||
"react-scripts": "^4.0.3"
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ const prefix = 'demo';
|
||||
|
||||
// Set API module for provider
|
||||
addAPIProvider(provider, {
|
||||
resources: 'http://localhost',
|
||||
resources: ['http://localhost'],
|
||||
rotate: 10000,
|
||||
timeout: 10000,
|
||||
});
|
||||
@ -18,6 +18,7 @@ _api.setAPIModule(provider, mockAPIModule);
|
||||
|
||||
// Set mock data
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
56
packages/react/package-lock.json
generated
56
packages/react/package-lock.json
generated
@ -1,17 +1,20 @@
|
||||
{
|
||||
"name": "@iconify/react",
|
||||
"version": "3.0.0-beta.1",
|
||||
"version": "3.1.0-beta.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@iconify/react",
|
||||
"version": "3.0.0-beta.1",
|
||||
"version": "3.1.0-beta.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.14.2",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.13.5",
|
||||
@ -1705,14 +1708,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.3.tgz",
|
||||
"integrity": "sha512-THaYuyvpqlgwHo9P1NIA904s9TKWbX9IUu9zw4v1Q3BokkAirThOoZL7LiTwDGknYwLKe7525qiyuNzxojgclw==",
|
||||
"version": "1.2.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.2.tgz",
|
||||
"integrity": "sha512-BnlanmZB5h+OXP0FIsfjMqsrAaDdHxVN5Y5jjYU4KrqaEwh9BiaIIr7lS/rXGk4UdnLps2NDjhkobuC7DXqm6A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
@ -3639,6 +3643,14 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"dependencies": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@ -6988,6 +7000,14 @@
|
||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-int64": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||
@ -10646,14 +10666,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.3.tgz",
|
||||
"integrity": "sha512-THaYuyvpqlgwHo9P1NIA904s9TKWbX9IUu9zw4v1Q3BokkAirThOoZL7LiTwDGknYwLKe7525qiyuNzxojgclw==",
|
||||
"version": "1.2.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.2.tgz",
|
||||
"integrity": "sha512-BnlanmZB5h+OXP0FIsfjMqsrAaDdHxVN5Y5jjYU4KrqaEwh9BiaIIr7lS/rXGk4UdnLps2NDjhkobuC7DXqm6A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
@ -12210,6 +12231,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"requires": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@ -14774,6 +14803,11 @@
|
||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||
},
|
||||
"node-int64": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "@iconify/react",
|
||||
"description": "Iconify icon component for React.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "3.0.1",
|
||||
"version": "3.1.0-beta.2",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
@ -27,7 +27,7 @@
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.14.2",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.13.5",
|
||||
@ -40,5 +40,8 @@
|
||||
"react-test-renderer": "^17.0.2",
|
||||
"rollup": "^2.50.0",
|
||||
"typescript": "^4.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
}
|
||||
|
@ -21,42 +21,41 @@ import {
|
||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
|
||||
// API
|
||||
import { API, IconifyAPIInternalStorage } from '@iconify/core/lib/api/';
|
||||
import {
|
||||
IconifyAPIFunctions,
|
||||
IconifyAPIInternalFunctions,
|
||||
APIFunctions,
|
||||
APIInternalFunctions,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
} from '@iconify/core/lib/api/functions';
|
||||
import {
|
||||
setAPIModule,
|
||||
IconifyAPIModule,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIPrepareQuery,
|
||||
GetIconifyAPIModule,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
} from '@iconify/core/lib/api/modules';
|
||||
import { getAPIModule as getJSONPAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import { jsonpAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import {
|
||||
getAPIModule as getFetchAPIModule,
|
||||
fetchAPIModule,
|
||||
getFetch,
|
||||
setFetch,
|
||||
} from '@iconify/core/lib/api/modules/fetch';
|
||||
import {
|
||||
setAPIConfig,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIConfig,
|
||||
getAPIConfig,
|
||||
GetAPIConfig,
|
||||
} from '@iconify/core/lib/api/config';
|
||||
import type {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '@iconify/core/lib/interfaces/loader';
|
||||
} from '@iconify/core/lib/api/icons';
|
||||
|
||||
// Cache
|
||||
import { cache } from '@iconify/core/lib/cache';
|
||||
import { storeCache, loadCache } from '@iconify/core/lib/browser-storage';
|
||||
import { toggleBrowserCache } from '@iconify/core/lib/browser-storage/functions';
|
||||
import type {
|
||||
@ -108,12 +107,14 @@ export {
|
||||
IconifyAPIConfig,
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyAPIInternalStorage,
|
||||
IconifyAPIModule,
|
||||
GetAPIConfig,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
};
|
||||
|
||||
// Builder functions
|
||||
@ -195,33 +196,15 @@ export const _api = APIInternalFunctions;
|
||||
// Enable short names
|
||||
allowSimpleNames(true);
|
||||
|
||||
// Set API
|
||||
coreModules.api = API;
|
||||
|
||||
// Use Fetch API by default
|
||||
let getAPIModule: GetIconifyAPIModule = getFetchAPIModule;
|
||||
try {
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// If window and document exist, attempt to load whatever module is available, otherwise use Fetch API
|
||||
getAPIModule =
|
||||
typeof fetch === 'function' && typeof Promise === 'function'
|
||||
? getFetchAPIModule
|
||||
: getJSONPAPIModule;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
// Set API module
|
||||
setAPIModule('', getFetch() ? fetchAPIModule : jsonpAPIModule);
|
||||
|
||||
/**
|
||||
* Function to enable node-fetch for getting icons on server side
|
||||
*/
|
||||
_api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
setFetch(nodeFetch);
|
||||
if (getAPIModule !== getFetchAPIModule) {
|
||||
getAPIModule = getFetchAPIModule;
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
}
|
||||
setAPIModule('', fetchAPIModule);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -229,7 +212,7 @@ _api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
*/
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// Set cache and load existing cache
|
||||
coreModules.cache = storeCache;
|
||||
cache.store = storeCache;
|
||||
loadCache();
|
||||
|
||||
interface WindowWithIconifyStuff {
|
||||
@ -397,7 +380,7 @@ class IconComponent extends React.Component<
|
||||
this._setData(null);
|
||||
this._loading = {
|
||||
name: icon,
|
||||
abort: API.loadIcons(
|
||||
abort: loadIcons(
|
||||
[iconName],
|
||||
this._checkIcon.bind(this, false)
|
||||
),
|
||||
|
@ -8,6 +8,7 @@ describe('Testing fake API', () => {
|
||||
const name = 'mock-test';
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
@ -19,6 +19,7 @@ describe('Rendering icon', () => {
|
||||
let onLoadCalled = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -94,6 +95,7 @@ describe('Rendering icon', () => {
|
||||
let onLoadCalled = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -187,6 +189,7 @@ describe('Rendering icon', () => {
|
||||
const name = 'missing-icon';
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
|
@ -46,6 +46,7 @@ describe('Rendering icon', () => {
|
||||
};
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -110,6 +111,7 @@ describe('Rendering icon', () => {
|
||||
});
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -197,6 +199,7 @@ describe('Rendering icon', () => {
|
||||
let isSync = true;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -215,6 +218,7 @@ describe('Rendering icon', () => {
|
||||
});
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -300,6 +304,7 @@ describe('Rendering icon', () => {
|
||||
const className = `iconify iconify--${prefix} iconify--${provider}`;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
@ -17,6 +17,7 @@ describe('Testing references', () => {
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -81,6 +82,7 @@ describe('Testing references', () => {
|
||||
let gotRef = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -139,6 +141,7 @@ describe('Testing references', () => {
|
||||
let gotRef = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
|
154
packages/sapper-demo/package-lock.json
generated
154
packages/sapper-demo/package-lock.json
generated
@ -20,7 +20,7 @@
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@iconify-icons/bi": "^1.0.0",
|
||||
"@iconify-icons/openmoji": "^1.0.9",
|
||||
"@iconify/svelte": "^2.0.0-alpha.0",
|
||||
"@iconify/svelte": "^2.1.0-beta.1",
|
||||
"@rollup/plugin-babel": "^5.2.1",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
@ -1263,10 +1263,16 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/svelte": {
|
||||
"version": "2.0.0-alpha.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.0.0-alpha.0.tgz",
|
||||
"integrity": "sha512-sJK4q/prxg96r+i8AWdVniNXt3p1uIaxOXec0royd/K/GBkJO7zdq/J9XxAan+RogUganqplYL07Ecet7jJsaA==",
|
||||
"dev": true
|
||||
"version": "2.1.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.1.0-beta.1.tgz",
|
||||
"integrity": "sha512-6ekq4sbkwV/DmaKr0A4o5OVxWIyn0SRm3KW/zvDx0XO7r8yXlmwkVi9l3jXP4+wObozA3CTaSnkqjn1eaqCYkw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "http://github.com/sponsors/cyberalien"
|
||||
}
|
||||
},
|
||||
"node_modules/@polka/url": {
|
||||
"version": "0.5.0",
|
||||
@ -1444,16 +1450,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/browserslist": {
|
||||
"version": "4.16.0",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.0.tgz",
|
||||
"integrity": "sha512-/j6k8R0p3nxOC6kx5JGAxsnhc9ixaWJfYc+TNTzxg6+ARaESAvQGV7h0uNOB4t+pLQJZWzcrMxXOxjgsCj3dqQ==",
|
||||
"version": "4.17.0",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.17.0.tgz",
|
||||
"integrity": "sha512-g2BJ2a0nEYvEFQC208q8mVAhfNwpZ5Mu8BwgtCdZKO3qx98HChmeg448fPdUzld8aFmfLgVh7yymqV+q1lJZ5g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"caniuse-lite": "^1.0.30001165",
|
||||
"colorette": "^1.2.1",
|
||||
"electron-to-chromium": "^1.3.621",
|
||||
"caniuse-lite": "^1.0.30001254",
|
||||
"colorette": "^1.3.0",
|
||||
"electron-to-chromium": "^1.3.830",
|
||||
"escalade": "^3.1.1",
|
||||
"node-releases": "^1.1.67"
|
||||
"node-releases": "^1.1.75"
|
||||
},
|
||||
"bin": {
|
||||
"browserslist": "cli.js"
|
||||
@ -1513,10 +1519,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001165",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001165.tgz",
|
||||
"integrity": "sha512-8cEsSMwXfx7lWSUMA2s08z9dIgsnR5NAqjXP23stdsU3AUWkCr/rr4s4OFtHXn5XXr6+7kam3QFVoYyXNPdJPA==",
|
||||
"dev": true
|
||||
"version": "1.0.30001254",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001254.tgz",
|
||||
"integrity": "sha512-GxeHOvR0LFMYPmFGA+NiTOt9uwYDxB3h154tW2yBYwfz2EMX3i1IBgr6gmJGfU0K8KQsqPa5XqLD8zVdP5lUzA==",
|
||||
"dev": true,
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/browserslist"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "2.4.2",
|
||||
@ -1569,9 +1579,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/colorette": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",
|
||||
"integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.3.0.tgz",
|
||||
"integrity": "sha512-ecORCqbSFP7Wm8Y6lyqMJjexBQqXSF7SSeaTyGGphogUjBlFP9m9o08wy86HL2uB7fMTxtOUzLMk7ogKcxMg1w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/commander": {
|
||||
@ -1665,6 +1675,15 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "6.0.5",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
|
||||
@ -1720,9 +1739,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.3.625",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.625.tgz",
|
||||
"integrity": "sha512-CsLk/r0C9dAzVPa9QF74HIXduxaucsaRfqiOYvIv2PRhvyC6EOqc/KbpgToQuDVgPf3sNAFZi3iBu4vpGOwGag==",
|
||||
"version": "1.3.830",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.830.tgz",
|
||||
"integrity": "sha512-gBN7wNAxV5vl1430dG+XRcQhD4pIeYeak6p6rjdCtlz5wWNwDad8jwvphe5oi1chL5MV6RNRikfffBBiFuj+rQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/error-ex": {
|
||||
@ -2314,10 +2333,19 @@
|
||||
"lower-case": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-releases": {
|
||||
"version": "1.1.67",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.67.tgz",
|
||||
"integrity": "sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg==",
|
||||
"version": "1.1.75",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.75.tgz",
|
||||
"integrity": "sha512-Qe5OUajvqrqDSy6wrWFmMwfJ0jVgwiw4T3KqmbTcZ62qW0gQkheXYhcFM1+lOVcGUoRxcEcfyvFMAnDgaF1VWw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/normalize-package-data": {
|
||||
@ -2451,9 +2479,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/path-parse": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
|
||||
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/path-type": {
|
||||
@ -4118,10 +4146,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/svelte": {
|
||||
"version": "2.0.0-alpha.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.0.0-alpha.0.tgz",
|
||||
"integrity": "sha512-sJK4q/prxg96r+i8AWdVniNXt3p1uIaxOXec0royd/K/GBkJO7zdq/J9XxAan+RogUganqplYL07Ecet7jJsaA==",
|
||||
"dev": true
|
||||
"version": "2.1.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.1.0-beta.1.tgz",
|
||||
"integrity": "sha512-6ekq4sbkwV/DmaKr0A4o5OVxWIyn0SRm3KW/zvDx0XO7r8yXlmwkVi9l3jXP4+wObozA3CTaSnkqjn1eaqCYkw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"@polka/url": {
|
||||
"version": "0.5.0",
|
||||
@ -4261,16 +4292,16 @@
|
||||
}
|
||||
},
|
||||
"browserslist": {
|
||||
"version": "4.16.0",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.0.tgz",
|
||||
"integrity": "sha512-/j6k8R0p3nxOC6kx5JGAxsnhc9ixaWJfYc+TNTzxg6+ARaESAvQGV7h0uNOB4t+pLQJZWzcrMxXOxjgsCj3dqQ==",
|
||||
"version": "4.17.0",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.17.0.tgz",
|
||||
"integrity": "sha512-g2BJ2a0nEYvEFQC208q8mVAhfNwpZ5Mu8BwgtCdZKO3qx98HChmeg448fPdUzld8aFmfLgVh7yymqV+q1lJZ5g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"caniuse-lite": "^1.0.30001165",
|
||||
"colorette": "^1.2.1",
|
||||
"electron-to-chromium": "^1.3.621",
|
||||
"caniuse-lite": "^1.0.30001254",
|
||||
"colorette": "^1.3.0",
|
||||
"electron-to-chromium": "^1.3.830",
|
||||
"escalade": "^3.1.1",
|
||||
"node-releases": "^1.1.67"
|
||||
"node-releases": "^1.1.75"
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
@ -4311,9 +4342,9 @@
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001165",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001165.tgz",
|
||||
"integrity": "sha512-8cEsSMwXfx7lWSUMA2s08z9dIgsnR5NAqjXP23stdsU3AUWkCr/rr4s4OFtHXn5XXr6+7kam3QFVoYyXNPdJPA==",
|
||||
"version": "1.0.30001254",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001254.tgz",
|
||||
"integrity": "sha512-GxeHOvR0LFMYPmFGA+NiTOt9uwYDxB3h154tW2yBYwfz2EMX3i1IBgr6gmJGfU0K8KQsqPa5XqLD8zVdP5lUzA==",
|
||||
"dev": true
|
||||
},
|
||||
"chalk": {
|
||||
@ -4360,9 +4391,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"colorette": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",
|
||||
"integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/colorette/-/colorette-1.3.0.tgz",
|
||||
"integrity": "sha512-ecORCqbSFP7Wm8Y6lyqMJjexBQqXSF7SSeaTyGGphogUjBlFP9m9o08wy86HL2uB7fMTxtOUzLMk7ogKcxMg1w==",
|
||||
"dev": true
|
||||
},
|
||||
"commander": {
|
||||
@ -4447,6 +4478,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "6.0.5",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
|
||||
@ -4485,9 +4525,9 @@
|
||||
}
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.625",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.625.tgz",
|
||||
"integrity": "sha512-CsLk/r0C9dAzVPa9QF74HIXduxaucsaRfqiOYvIv2PRhvyC6EOqc/KbpgToQuDVgPf3sNAFZi3iBu4vpGOwGag==",
|
||||
"version": "1.3.830",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.830.tgz",
|
||||
"integrity": "sha512-gBN7wNAxV5vl1430dG+XRcQhD4pIeYeak6p6rjdCtlz5wWNwDad8jwvphe5oi1chL5MV6RNRikfffBBiFuj+rQ==",
|
||||
"dev": true
|
||||
},
|
||||
"error-ex": {
|
||||
@ -4932,10 +4972,16 @@
|
||||
"lower-case": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"dev": true
|
||||
},
|
||||
"node-releases": {
|
||||
"version": "1.1.67",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.67.tgz",
|
||||
"integrity": "sha512-V5QF9noGFl3EymEwUYzO+3NTDpGfQB4ve6Qfnzf3UNydMhjQRVPR1DZTuvWiLzaFJYw2fmDwAfnRNEVb64hSIg==",
|
||||
"version": "1.1.75",
|
||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.75.tgz",
|
||||
"integrity": "sha512-Qe5OUajvqrqDSy6wrWFmMwfJ0jVgwiw4T3KqmbTcZ62qW0gQkheXYhcFM1+lOVcGUoRxcEcfyvFMAnDgaF1VWw==",
|
||||
"dev": true
|
||||
},
|
||||
"normalize-package-data": {
|
||||
@ -5037,9 +5083,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"path-parse": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
|
||||
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
||||
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
||||
"dev": true
|
||||
},
|
||||
"path-type": {
|
||||
|
@ -24,7 +24,7 @@
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@iconify-icons/bi": "^1.0.0",
|
||||
"@iconify-icons/openmoji": "^1.0.9",
|
||||
"@iconify/svelte": "^2.0.0",
|
||||
"@iconify/svelte": "^2.1.0-beta.1",
|
||||
"@rollup/plugin-babel": "^5.2.1",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
|
60
packages/svelte-demo/package-lock.json
generated
60
packages/svelte-demo/package-lock.json
generated
@ -13,7 +13,7 @@
|
||||
"devDependencies": {
|
||||
"@iconify-icons/mdi-light": "^1.1.0",
|
||||
"@iconify-icons/uil": "^1.1.1",
|
||||
"@iconify/svelte": "^2.0.0-alpha.0",
|
||||
"@iconify/svelte": "^2.1.0-beta.1",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
"rollup": "^2.33.3",
|
||||
@ -71,10 +71,16 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/svelte": {
|
||||
"version": "2.0.0-alpha.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.0.0-alpha.7.tgz",
|
||||
"integrity": "sha512-qxrGMKGrCQps8gDSvbi4MXkzDnc1znKxFnK3na9GlKtIla/1CzN0ss+pSSfrafsCiQdUs1eF2cNB4wsDXeR2xg==",
|
||||
"dev": true
|
||||
"version": "2.1.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.1.0-beta.1.tgz",
|
||||
"integrity": "sha512-6ekq4sbkwV/DmaKr0A4o5OVxWIyn0SRm3KW/zvDx0XO7r8yXlmwkVi9l3jXP4+wObozA3CTaSnkqjn1eaqCYkw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "http://github.com/sponsors/cyberalien"
|
||||
}
|
||||
},
|
||||
"node_modules/@polka/url": {
|
||||
"version": "1.0.0-next.15",
|
||||
@ -322,6 +328,15 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/deepmerge": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz",
|
||||
@ -657,6 +672,15 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/normalize-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||
@ -1070,10 +1094,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/svelte": {
|
||||
"version": "2.0.0-alpha.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.0.0-alpha.7.tgz",
|
||||
"integrity": "sha512-qxrGMKGrCQps8gDSvbi4MXkzDnc1znKxFnK3na9GlKtIla/1CzN0ss+pSSfrafsCiQdUs1eF2cNB4wsDXeR2xg==",
|
||||
"dev": true
|
||||
"version": "2.1.0-beta.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.1.0-beta.1.tgz",
|
||||
"integrity": "sha512-6ekq4sbkwV/DmaKr0A4o5OVxWIyn0SRm3KW/zvDx0XO7r8yXlmwkVi9l3jXP4+wObozA3CTaSnkqjn1eaqCYkw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"@polka/url": {
|
||||
"version": "1.0.0-next.15",
|
||||
@ -1276,6 +1303,15 @@
|
||||
"resolved": "https://registry.npmjs.org/console-clear/-/console-clear-1.1.1.tgz",
|
||||
"integrity": "sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ=="
|
||||
},
|
||||
"cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"deepmerge": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz",
|
||||
@ -1531,6 +1567,12 @@
|
||||
"resolved": "https://registry.npmjs.org/mri/-/mri-1.1.6.tgz",
|
||||
"integrity": "sha512-oi1b3MfbyGa7FJMP9GmLTttni5JoICpYBRlq+x5V16fZbLsnL9N3wFqqIm/nIG43FjUFkFh9Epzp/kzUGUnJxQ=="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"dev": true
|
||||
},
|
||||
"normalize-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||
|
@ -10,7 +10,7 @@
|
||||
"devDependencies": {
|
||||
"@iconify-icons/mdi-light": "^1.1.0",
|
||||
"@iconify-icons/uil": "^1.1.1",
|
||||
"@iconify/svelte": "^2.0.0",
|
||||
"@iconify/svelte": "^2.1.0-beta.1",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
"rollup": "^2.33.3",
|
||||
|
56
packages/svelte/package-lock.json
generated
56
packages/svelte/package-lock.json
generated
@ -1,16 +1,19 @@
|
||||
{
|
||||
"name": "@iconify/svelte",
|
||||
"version": "2.0.0-beta.1",
|
||||
"version": "2.1.0-beta.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@iconify/svelte",
|
||||
"version": "2.0.0-beta.1",
|
||||
"version": "2.1.0-beta.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.14.2",
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.15.0",
|
||||
@ -1622,14 +1625,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.3.tgz",
|
||||
"integrity": "sha512-THaYuyvpqlgwHo9P1NIA904s9TKWbX9IUu9zw4v1Q3BokkAirThOoZL7LiTwDGknYwLKe7525qiyuNzxojgclw==",
|
||||
"version": "1.2.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.2.tgz",
|
||||
"integrity": "sha512-BnlanmZB5h+OXP0FIsfjMqsrAaDdHxVN5Y5jjYU4KrqaEwh9BiaIIr7lS/rXGk4UdnLps2NDjhkobuC7DXqm6A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
@ -3864,6 +3868,14 @@
|
||||
"url": "https://opencollective.com/core-js"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"dependencies": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@ -7438,6 +7450,14 @@
|
||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-int64": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||
@ -11277,14 +11297,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.3.tgz",
|
||||
"integrity": "sha512-THaYuyvpqlgwHo9P1NIA904s9TKWbX9IUu9zw4v1Q3BokkAirThOoZL7LiTwDGknYwLKe7525qiyuNzxojgclw==",
|
||||
"version": "1.2.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.2.tgz",
|
||||
"integrity": "sha512-BnlanmZB5h+OXP0FIsfjMqsrAaDdHxVN5Y5jjYU4KrqaEwh9BiaIIr7lS/rXGk4UdnLps2NDjhkobuC7DXqm6A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6"
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
@ -13082,6 +13103,14 @@
|
||||
"integrity": "sha512-D42L7RYh1J2grW8ttxoY1+17Y4wXZeKe7uyplAI3FkNQyI5OgBIAjUfFiTPfL1rs0qLpxaabITNbjKl1Sp82tA==",
|
||||
"dev": true
|
||||
},
|
||||
"cross-fetch": {
|
||||
"version": "3.1.4",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz",
|
||||
"integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==",
|
||||
"requires": {
|
||||
"node-fetch": "2.6.1"
|
||||
}
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@ -15855,6 +15884,11 @@
|
||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||
},
|
||||
"node-int64": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "@iconify/svelte",
|
||||
"description": "Iconify icon component for Svelte.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0-beta.2",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://github.com/iconify/iconify",
|
||||
@ -26,7 +26,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.14.2",
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.15.0",
|
||||
@ -44,6 +44,9 @@
|
||||
"svelte-preprocess": "^4.7.2",
|
||||
"ts-jest": "^26.5.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
"^.+\\.js$": "babel-jest",
|
||||
|
@ -20,42 +20,41 @@ import {
|
||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||
import { fullIcon, IconifyIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
|
||||
// API
|
||||
import { API, IconifyAPIInternalStorage } from '@iconify/core/lib/api/';
|
||||
import {
|
||||
IconifyAPIFunctions,
|
||||
IconifyAPIInternalFunctions,
|
||||
APIFunctions,
|
||||
APIInternalFunctions,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
} from '@iconify/core/lib/api/functions';
|
||||
import {
|
||||
setAPIModule,
|
||||
IconifyAPIModule,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIPrepareQuery,
|
||||
GetIconifyAPIModule,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
} from '@iconify/core/lib/api/modules';
|
||||
import { getAPIModule as getJSONPAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import { jsonpAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import {
|
||||
getAPIModule as getFetchAPIModule,
|
||||
fetchAPIModule,
|
||||
getFetch,
|
||||
setFetch,
|
||||
} from '@iconify/core/lib/api/modules/fetch';
|
||||
import {
|
||||
setAPIConfig,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIConfig,
|
||||
getAPIConfig,
|
||||
GetAPIConfig,
|
||||
} from '@iconify/core/lib/api/config';
|
||||
import type {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '@iconify/core/lib/interfaces/loader';
|
||||
} from '@iconify/core/lib/api/icons';
|
||||
|
||||
// Cache
|
||||
import { cache } from '@iconify/core/lib/cache';
|
||||
import { storeCache, loadCache } from '@iconify/core/lib/browser-storage';
|
||||
import { toggleBrowserCache } from '@iconify/core/lib/browser-storage/functions';
|
||||
import type {
|
||||
@ -105,12 +104,14 @@ export {
|
||||
IconifyAPIConfig,
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyAPIInternalStorage,
|
||||
IconifyAPIModule,
|
||||
GetAPIConfig,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
};
|
||||
|
||||
// Builder functions
|
||||
@ -192,33 +193,15 @@ export const _api = APIInternalFunctions;
|
||||
// Enable short names
|
||||
allowSimpleNames(true);
|
||||
|
||||
// Set API
|
||||
coreModules.api = API;
|
||||
|
||||
// Use Fetch API by default
|
||||
let getAPIModule: GetIconifyAPIModule = getFetchAPIModule;
|
||||
try {
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// If window and document exist, attempt to load whatever module is available, otherwise use Fetch API
|
||||
getAPIModule =
|
||||
typeof fetch === 'function' && typeof Promise === 'function'
|
||||
? getFetchAPIModule
|
||||
: getJSONPAPIModule;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
// Set API module
|
||||
setAPIModule('', getFetch() ? fetchAPIModule : jsonpAPIModule);
|
||||
|
||||
/**
|
||||
* Function to enable node-fetch for getting icons on server side
|
||||
*/
|
||||
_api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
setFetch(nodeFetch);
|
||||
if (getAPIModule !== getFetchAPIModule) {
|
||||
getAPIModule = getFetchAPIModule;
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
}
|
||||
setAPIModule('', fetchAPIModule);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -226,7 +209,7 @@ _api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
*/
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// Set cache and load existing cache
|
||||
coreModules.cache = storeCache;
|
||||
cache.store = storeCache;
|
||||
loadCache();
|
||||
|
||||
interface WindowWithIconifyStuff {
|
||||
@ -375,7 +358,7 @@ export function checkIconState(
|
||||
state.name = '';
|
||||
state.loading = {
|
||||
name: icon,
|
||||
abort: API.loadIcons([iconName], callback),
|
||||
abort: loadIcons([iconName], callback),
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
@ -28,12 +28,14 @@ export {
|
||||
IconifyAPIConfig,
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyAPIInternalStorage,
|
||||
IconifyAPIModule,
|
||||
GetAPIConfig,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
} from './functions';
|
||||
|
||||
// Builder functions
|
||||
|
@ -8,6 +8,7 @@ describe('Testing fake API', () => {
|
||||
const name = 'mock-test';
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
@ -18,6 +18,7 @@ describe('Rendering icon', () => {
|
||||
let onLoadCalled = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -79,6 +80,7 @@ describe('Rendering icon', () => {
|
||||
let onLoadCalled = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -152,6 +154,7 @@ describe('Rendering icon', () => {
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
|
@ -29,6 +29,7 @@ describe('Rendering icon', () => {
|
||||
let triggerSwap;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -78,6 +79,7 @@ describe('Rendering icon', () => {
|
||||
});
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -172,6 +174,7 @@ describe('Rendering icon', () => {
|
||||
let triggerSwap;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -193,6 +196,7 @@ describe('Rendering icon', () => {
|
||||
});
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -280,6 +284,7 @@ describe('Rendering icon', () => {
|
||||
let triggerSwap;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
18
packages/utils/package-lock.json
generated
18
packages/utils/package-lock.json
generated
@ -1,18 +1,18 @@
|
||||
{
|
||||
"name": "@iconify/utils",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@iconify/utils",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/library-builder": "^1.0.0",
|
||||
"@iconify/library-builder": "^1.0.2",
|
||||
"@types/chai": "^4.2.18",
|
||||
"@types/mocha": "^8.2.2",
|
||||
"@typescript-eslint/eslint-plugin": "^4.31.1",
|
||||
@ -167,9 +167,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/library-builder": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/library-builder/-/library-builder-1.0.0.tgz",
|
||||
"integrity": "sha512-xdzmA5JrD+LBPfR2b2e9lb+pQXgK+nkJhL7qTaGpNCHwCsa8HeQZyuEtvTdMUKqONeEEvZkvdUdv/lK1fn3Jtw==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/library-builder/-/library-builder-1.0.2.tgz",
|
||||
"integrity": "sha512-3fxQIxApNwTrlzdEC2wYstYgAdzsAYOHHpDn4TEddBb/mTxmI5eZwWIDsMLdqXrr1iMoxSAqeipp19JaC2e1Gg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "^15.3.0",
|
||||
@ -2554,9 +2554,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/library-builder": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/library-builder/-/library-builder-1.0.0.tgz",
|
||||
"integrity": "sha512-xdzmA5JrD+LBPfR2b2e9lb+pQXgK+nkJhL7qTaGpNCHwCsa8HeQZyuEtvTdMUKqONeEEvZkvdUdv/lK1fn3Jtw==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/library-builder/-/library-builder-1.0.2.tgz",
|
||||
"integrity": "sha512-3fxQIxApNwTrlzdEC2wYstYgAdzsAYOHHpDn4TEddBb/mTxmI5eZwWIDsMLdqXrr1iMoxSAqeipp19JaC2e1Gg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "^15.3.0",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "@iconify/utils",
|
||||
"description": "Common functions for working with Iconify icon sets used by various packages.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
@ -111,7 +111,7 @@
|
||||
"@iconify/types": "^1.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/library-builder": "^1.0.0",
|
||||
"@iconify/library-builder": "^1.0.2",
|
||||
"@types/chai": "^4.2.18",
|
||||
"@types/mocha": "^8.2.2",
|
||||
"@typescript-eslint/eslint-plugin": "^4.31.1",
|
||||
|
1462
packages/vue-demo/package-lock.json
generated
1462
packages/vue-demo/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@
|
||||
"@iconify-icons/bx": "^1.0.2",
|
||||
"@iconify-icons/dashicons": "^1.0.0",
|
||||
"@iconify/types": "^1.0.5",
|
||||
"@iconify/vue": "^3.0.0",
|
||||
"@iconify/vue": "^3.1.0-beta.1",
|
||||
"@vue/compiler-sfc": "^3.0.2",
|
||||
"typescript": "^4.1.2",
|
||||
"vite": "^1.0.0-rc.9"
|
||||
|
2422
packages/vue/package-lock.json
generated
2422
packages/vue/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
"name": "@iconify/vue",
|
||||
"description": "Iconify icon component for Vue 3.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0-beta.2",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
@ -25,7 +25,7 @@
|
||||
"module": "dist/iconify.mjs",
|
||||
"types": "dist/iconify.d.ts",
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.15.2",
|
||||
@ -44,6 +44,9 @@
|
||||
"vue-jest": "^5.0.0-alpha.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^3.0.11"
|
||||
"vue": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
}
|
||||
|
@ -30,42 +30,41 @@ import {
|
||||
import { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||
import { fullIcon, IconifyIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
|
||||
// API
|
||||
import { API, IconifyAPIInternalStorage } from '@iconify/core/lib/api/';
|
||||
import {
|
||||
IconifyAPIFunctions,
|
||||
IconifyAPIInternalFunctions,
|
||||
APIFunctions,
|
||||
APIInternalFunctions,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
} from '@iconify/core/lib/api/functions';
|
||||
import {
|
||||
setAPIModule,
|
||||
IconifyAPIModule,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIPrepareQuery,
|
||||
GetIconifyAPIModule,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
} from '@iconify/core/lib/api/modules';
|
||||
import { getAPIModule as getJSONPAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import { jsonpAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import {
|
||||
getAPIModule as getFetchAPIModule,
|
||||
fetchAPIModule,
|
||||
getFetch,
|
||||
setFetch,
|
||||
} from '@iconify/core/lib/api/modules/fetch';
|
||||
import {
|
||||
setAPIConfig,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIConfig,
|
||||
getAPIConfig,
|
||||
GetAPIConfig,
|
||||
} from '@iconify/core/lib/api/config';
|
||||
import {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '@iconify/core/lib/interfaces/loader';
|
||||
} from '@iconify/core/lib/api/icons';
|
||||
|
||||
// Cache
|
||||
import { cache } from '@iconify/core/lib/cache';
|
||||
import { storeCache, loadCache } from '@iconify/core/lib/browser-storage';
|
||||
import { toggleBrowserCache } from '@iconify/core/lib/browser-storage/functions';
|
||||
import {
|
||||
@ -116,12 +115,14 @@ export {
|
||||
IconifyAPIConfig,
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyAPIInternalStorage,
|
||||
IconifyAPIModule,
|
||||
GetAPIConfig,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
};
|
||||
|
||||
// Builder functions
|
||||
@ -203,33 +204,15 @@ export const _api = APIInternalFunctions;
|
||||
// Enable short names
|
||||
allowSimpleNames(true);
|
||||
|
||||
// Set API
|
||||
coreModules.api = API;
|
||||
|
||||
// Use Fetch API by default
|
||||
let getAPIModule: GetIconifyAPIModule = getFetchAPIModule;
|
||||
try {
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// If window and document exist, attempt to load whatever module is available, otherwise use Fetch API
|
||||
getAPIModule =
|
||||
typeof fetch === 'function' && typeof Promise === 'function'
|
||||
? getFetchAPIModule
|
||||
: getJSONPAPIModule;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
// Set API module
|
||||
setAPIModule('', getFetch() ? fetchAPIModule : jsonpAPIModule);
|
||||
|
||||
/**
|
||||
* Function to enable node-fetch for getting icons on server side
|
||||
*/
|
||||
_api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
setFetch(nodeFetch);
|
||||
if (getAPIModule !== getFetchAPIModule) {
|
||||
getAPIModule = getFetchAPIModule;
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
}
|
||||
setAPIModule('', fetchAPIModule);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -237,7 +220,7 @@ _api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
*/
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// Set cache and load existing cache
|
||||
coreModules.cache = storeCache;
|
||||
cache.store = storeCache;
|
||||
loadCache();
|
||||
|
||||
interface WindowWithIconifyStuff {
|
||||
@ -383,7 +366,7 @@ export const Icon = defineComponent({
|
||||
this._name = '';
|
||||
this._loadingIcon = {
|
||||
name: icon,
|
||||
abort: API.loadIcons([iconName], () => {
|
||||
abort: loadIcons([iconName], () => {
|
||||
this.counter++;
|
||||
}),
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ describe('Testing fake API', () => {
|
||||
const name = 'mock-test';
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
@ -19,6 +19,7 @@ describe('Rendering icon', () => {
|
||||
let onLoadCalled = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -84,6 +85,7 @@ describe('Rendering icon', () => {
|
||||
let onLoadCalled = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -163,6 +165,7 @@ describe('Rendering icon', () => {
|
||||
const name = 'missing-icon';
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
|
@ -47,6 +47,7 @@ describe('Rendering icon', () => {
|
||||
};
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -90,6 +91,7 @@ describe('Rendering icon', () => {
|
||||
});
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -160,6 +162,7 @@ describe('Rendering icon', () => {
|
||||
let isSync = true;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -178,6 +181,7 @@ describe('Rendering icon', () => {
|
||||
});
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -245,6 +249,7 @@ describe('Rendering icon', () => {
|
||||
const className = `iconify iconify--${prefix} iconify--${provider}`;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
2637
packages/vue2-demo/package-lock.json
generated
2637
packages/vue2-demo/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
||||
"devDependencies": {
|
||||
"@iconify-icons/bx": "^1.1.0",
|
||||
"@iconify-icons/dashicons": "^1.1.0",
|
||||
"@iconify/vue2": "^1.0.0",
|
||||
"@iconify/vue2": "^1.1.0-beta.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.22.1",
|
||||
"@typescript-eslint/parser": "^4.22.1",
|
||||
"@vue/cli-plugin-babel": "^4.5.12",
|
||||
|
1381
packages/vue2/package-lock.json
generated
1381
packages/vue2/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
"name": "@iconify/vue2",
|
||||
"description": "Iconify icon component for Vue 2.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0-beta.2",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
@ -25,7 +25,7 @@
|
||||
"module": "dist/iconify.mjs",
|
||||
"types": "dist/iconify.d.ts",
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.1.3",
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@microsoft/api-extractor": "^7.15.1",
|
||||
@ -46,5 +46,8 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "2.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
}
|
||||
|
@ -22,42 +22,41 @@ import {
|
||||
import { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||
import { fullIcon, IconifyIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
|
||||
// API
|
||||
import { API, IconifyAPIInternalStorage } from '@iconify/core/lib/api/';
|
||||
import {
|
||||
IconifyAPIFunctions,
|
||||
IconifyAPIInternalFunctions,
|
||||
APIFunctions,
|
||||
APIInternalFunctions,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
} from '@iconify/core/lib/api/functions';
|
||||
import {
|
||||
setAPIModule,
|
||||
IconifyAPIModule,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIPrepareQuery,
|
||||
GetIconifyAPIModule,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
} from '@iconify/core/lib/api/modules';
|
||||
import { getAPIModule as getJSONPAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import { jsonpAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import {
|
||||
getAPIModule as getFetchAPIModule,
|
||||
fetchAPIModule,
|
||||
getFetch,
|
||||
setFetch,
|
||||
} from '@iconify/core/lib/api/modules/fetch';
|
||||
import {
|
||||
setAPIConfig,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIConfig,
|
||||
getAPIConfig,
|
||||
GetAPIConfig,
|
||||
} from '@iconify/core/lib/api/config';
|
||||
import {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '@iconify/core/lib/interfaces/loader';
|
||||
} from '@iconify/core/lib/api/icons';
|
||||
|
||||
// Cache
|
||||
import { cache } from '@iconify/core/lib/cache';
|
||||
import { storeCache, loadCache } from '@iconify/core/lib/browser-storage';
|
||||
import { toggleBrowserCache } from '@iconify/core/lib/browser-storage/functions';
|
||||
import {
|
||||
@ -108,12 +107,14 @@ export {
|
||||
IconifyAPIConfig,
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
IconifyAPIInternalStorage,
|
||||
IconifyAPIModule,
|
||||
GetAPIConfig,
|
||||
IconifyAPIPrepareQuery,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
IconifyAPISendQuery,
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
};
|
||||
|
||||
// Builder functions
|
||||
@ -195,33 +196,15 @@ export const _api = APIInternalFunctions;
|
||||
// Enable short names
|
||||
allowSimpleNames(true);
|
||||
|
||||
// Set API
|
||||
coreModules.api = API;
|
||||
|
||||
// Use Fetch API by default
|
||||
let getAPIModule: GetIconifyAPIModule = getFetchAPIModule;
|
||||
try {
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// If window and document exist, attempt to load whatever module is available, otherwise use Fetch API
|
||||
getAPIModule =
|
||||
typeof fetch === 'function' && typeof Promise === 'function'
|
||||
? getFetchAPIModule
|
||||
: getJSONPAPIModule;
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
// Set API module
|
||||
setAPIModule('', getFetch() ? fetchAPIModule : jsonpAPIModule);
|
||||
|
||||
/**
|
||||
* Function to enable node-fetch for getting icons on server side
|
||||
*/
|
||||
_api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
setFetch(nodeFetch);
|
||||
if (getAPIModule !== getFetchAPIModule) {
|
||||
getAPIModule = getFetchAPIModule;
|
||||
setAPIModule('', getAPIModule(getAPIConfig));
|
||||
}
|
||||
setAPIModule('', fetchAPIModule);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -229,7 +212,7 @@ _api.setFetch = (nodeFetch: typeof fetch) => {
|
||||
*/
|
||||
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
// Set cache and load existing cache
|
||||
coreModules.cache = storeCache;
|
||||
cache.store = storeCache;
|
||||
loadCache();
|
||||
|
||||
interface WindowWithIconifyStuff {
|
||||
@ -373,7 +356,7 @@ export const Icon = Vue.extend({
|
||||
this._name = '';
|
||||
this._loadingIcon = {
|
||||
name: icon,
|
||||
abort: API.loadIcons([iconName], () => {
|
||||
abort: loadIcons([iconName], () => {
|
||||
this.$forceUpdate();
|
||||
}),
|
||||
};
|
||||
|
@ -3,11 +3,12 @@ import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
||||
import { provider, nextPrefix } from './load';
|
||||
|
||||
describe('Testing fake API', () => {
|
||||
test('using fake API to load icon', done => {
|
||||
test('using fake API to load icon', (done) => {
|
||||
const prefix = nextPrefix();
|
||||
const name = 'mock-test';
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
@ -18,6 +18,7 @@ describe('Rendering icon', () => {
|
||||
let onLoadCalled = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -83,6 +84,7 @@ describe('Rendering icon', () => {
|
||||
let onLoadCalled = false;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -163,6 +165,7 @@ describe('Rendering icon', () => {
|
||||
const name = 'missing-icon';
|
||||
const iconName = `@${provider}:${prefix}:${name}`;
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: 404,
|
||||
|
@ -45,6 +45,7 @@ describe('Rendering icon', () => {
|
||||
};
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -88,6 +89,7 @@ describe('Rendering icon', () => {
|
||||
});
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -156,6 +158,7 @@ describe('Rendering icon', () => {
|
||||
let isSync = true;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -174,6 +177,7 @@ describe('Rendering icon', () => {
|
||||
});
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
@ -240,6 +244,7 @@ describe('Rendering icon', () => {
|
||||
const className = `iconify iconify--${prefix} iconify--${provider}`;
|
||||
|
||||
mockAPIData({
|
||||
type: 'icons',
|
||||
provider,
|
||||
prefix,
|
||||
response: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user