mirror of
https://github.com/iconify/iconify.git
synced 2024-11-09 23:00:56 +00:00
Update Ember component for new code
This commit is contained in:
parent
933202d617
commit
f3dffba74f
@ -1 +1,2 @@
|
||||
export { default } from '@iconify/ember/components/iconify-icon';
|
||||
import Icon from '@iconify/ember/components/iconify-icon';
|
||||
export default Icon;
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable */
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const child_process = require('child_process');
|
||||
@ -57,7 +58,7 @@ const fileExists = (file) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
if (compile.lib && !fileExists(packagesDir + '/core/lib/modules.js')) {
|
||||
if (compile.lib && !fileExists(packagesDir + '/core/lib/cache.js')) {
|
||||
compile.core = true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,35 @@
|
||||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* Fix default export syntax
|
||||
*/
|
||||
function fixDefaultExport(filename) {
|
||||
const source = __dirname + '/' + filename;
|
||||
const data = fs.readFileSync(source, 'utf8');
|
||||
const search = 'IconifyIconComponent as default';
|
||||
if (data.indexOf(search) === -1) {
|
||||
console.log(`Exports are fine in ${filename}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let foundMatch = 0;
|
||||
const lines = data.split(',').filter((line) => {
|
||||
if (line.trim() === search) {
|
||||
foundMatch++;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (foundMatch !== 1) {
|
||||
throw new Error(`Error fixing exports in ${filename}`);
|
||||
}
|
||||
const newCode =
|
||||
lines.join(',') + '\nexport default IconifyIconComponent;\n';
|
||||
|
||||
fs.writeFileSync(source, newCode, 'utf8');
|
||||
console.log(`Fixed default export in ${filename}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore decorator in component
|
||||
*/
|
||||
@ -128,5 +158,6 @@ function copyFile(source, target) {
|
||||
}
|
||||
|
||||
restoreDecorator('lib/component.js');
|
||||
fixDefaultExport('addon/components/iconify-icon.js');
|
||||
restoreDecorator('addon/components/iconify-icon.js');
|
||||
copyFile('src/iconify-icon.hbs', 'addon/components/iconify-icon.hbs');
|
||||
|
159
packages/ember/package-lock.json
generated
159
packages/ember/package-lock.json
generated
@ -15,11 +15,8 @@
|
||||
"ember-cli-htmlbars": "^5.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@iconify/core": "^1.2.0-beta.3",
|
||||
"@microsoft/api-extractor": "^7.18.4",
|
||||
"@rollup/plugin-commonjs": "^18.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@rollup/plugin-typescript": "^8.2.3",
|
||||
"rollup": "^2.53.2",
|
||||
@ -1596,12 +1593,6 @@
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@cyberalien/redundancy": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@cyberalien/redundancy/-/redundancy-1.1.0.tgz",
|
||||
"integrity": "sha512-+ZvuwtVXzyxX1CWnP+X5XgDelseU9KSYgmPu3/DSraR7Qyi/vLZwuRRX0sYO24M/gZaChNXRBEK6RHRe3uBndw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@ember-data/rfc395-data": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@ember-data/rfc395-data/-/rfc395-data-0.0.4.tgz",
|
||||
@ -1665,31 +1656,37 @@
|
||||
"resolved": "https://registry.npmjs.org/@glimmer/validator/-/validator-0.44.0.tgz",
|
||||
"integrity": "sha512-i01plR0EgFVz69GDrEuFgq1NheIjZcyTy3c7q+w7d096ddPVeVcRzU3LKaqCfovvLJ+6lJx40j45ecycASUUyw=="
|
||||
},
|
||||
"node_modules/@iconify/api-redundancy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/api-redundancy/-/api-redundancy-1.0.2.tgz",
|
||||
"integrity": "sha512-/i2sIQSL+ygsPXPkmj368mf0UAaJRMd4+TVAvWPQQU0aaS0Km9p+0ZTR0UtD07F9O1oAgfzGAzkMYIh0gAhvJg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"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==",
|
||||
"version": "1.2.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.3.tgz",
|
||||
"integrity": "sha512-B9N0jdk1Ik2r/BpKfZGj+BPLUd5rNuwwyWaCiHSwlnt/n3jORwLtt689OPo2lVCaIcgwI9Uvw6I0O53smIKayQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"@iconify/api-redundancy": "^1.0.2",
|
||||
"@iconify/types": "^1.0.7",
|
||||
"@iconify/utils": "^1.0.9",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.7.tgz",
|
||||
"integrity": "sha512-zdwkVc67O9SqI/svsogD2s+XB3Uk4Xx+PrMEn5Qm3ktKSXFveZL0iP3yzqbrFg1KRRd93nRs4QycLaIRMhA0Pg==",
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.9.tgz",
|
||||
"integrity": "sha512-ALO6IGXBEztcySLq+vGJrgUJqGgiZJ8sTQ8mM6e3i77okM9fw8F23h6GLbbaMz/pNfeK8QHJBAOmx3LjhZ3YZw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/utils": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.7.tgz",
|
||||
"integrity": "sha512-ciJNYlqSxWdIZcCbE9FPL3o9o/U8ok0s8B7uf4lcGR57qyMaz3IUfihiBIb8YBr4eVp7eQDT2zV1Xpikkh/ePg==",
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.9.tgz",
|
||||
"integrity": "sha512-HgHho6s0hQ7hIgx27J6YBg/4Jse0OZxQGQqE8ZT1lELWDOqrvR4RB1AIR2O3JFIts8u0a7uBwDhbjZPBwzj4TQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@microsoft/api-extractor": {
|
||||
@ -1770,27 +1767,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs": {
|
||||
"version": "18.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.1.0.tgz",
|
||||
"integrity": "sha512-h3e6T9rUxVMAQswpDIobfUHn/doMzM9sgkMrsMWCFLmB84PSoC8mV8tOloAJjSRwdqhXBqstlX2BwBpHJvbhxg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"commondir": "^1.0.1",
|
||||
"estree-walker": "^2.0.1",
|
||||
"glob": "^7.1.6",
|
||||
"is-reference": "^1.2.1",
|
||||
"magic-string": "^0.25.7",
|
||||
"resolve": "^1.17.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.30.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-node-resolve": {
|
||||
"version": "11.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz",
|
||||
@ -2641,12 +2617,6 @@
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/commondir": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
|
||||
"integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
@ -3380,12 +3350,6 @@
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
@ -3926,15 +3890,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-reference": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
|
||||
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/is-regex": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz",
|
||||
@ -6193,12 +6148,6 @@
|
||||
"to-fast-properties": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"@cyberalien/redundancy": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@cyberalien/redundancy/-/redundancy-1.1.0.tgz",
|
||||
"integrity": "sha512-+ZvuwtVXzyxX1CWnP+X5XgDelseU9KSYgmPu3/DSraR7Qyi/vLZwuRRX0sYO24M/gZaChNXRBEK6RHRe3uBndw==",
|
||||
"dev": true
|
||||
},
|
||||
"@ember-data/rfc395-data": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@ember-data/rfc395-data/-/rfc395-data-0.0.4.tgz",
|
||||
@ -6259,31 +6208,37 @@
|
||||
"resolved": "https://registry.npmjs.org/@glimmer/validator/-/validator-0.44.0.tgz",
|
||||
"integrity": "sha512-i01plR0EgFVz69GDrEuFgq1NheIjZcyTy3c7q+w7d096ddPVeVcRzU3LKaqCfovvLJ+6lJx40j45ecycASUUyw=="
|
||||
},
|
||||
"@iconify/api-redundancy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/api-redundancy/-/api-redundancy-1.0.2.tgz",
|
||||
"integrity": "sha512-/i2sIQSL+ygsPXPkmj368mf0UAaJRMd4+TVAvWPQQU0aaS0Km9p+0ZTR0UtD07F9O1oAgfzGAzkMYIh0gAhvJg==",
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"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==",
|
||||
"version": "1.2.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.2.0-beta.3.tgz",
|
||||
"integrity": "sha512-B9N0jdk1Ik2r/BpKfZGj+BPLUd5rNuwwyWaCiHSwlnt/n3jORwLtt689OPo2lVCaIcgwI9Uvw6I0O53smIKayQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.6",
|
||||
"@iconify/api-redundancy": "^1.0.2",
|
||||
"@iconify/types": "^1.0.7",
|
||||
"@iconify/utils": "^1.0.9",
|
||||
"cross-fetch": "^3.1.4"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.7.tgz",
|
||||
"integrity": "sha512-zdwkVc67O9SqI/svsogD2s+XB3Uk4Xx+PrMEn5Qm3ktKSXFveZL0iP3yzqbrFg1KRRd93nRs4QycLaIRMhA0Pg==",
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.9.tgz",
|
||||
"integrity": "sha512-ALO6IGXBEztcySLq+vGJrgUJqGgiZJ8sTQ8mM6e3i77okM9fw8F23h6GLbbaMz/pNfeK8QHJBAOmx3LjhZ3YZw==",
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/utils": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.7.tgz",
|
||||
"integrity": "sha512-ciJNYlqSxWdIZcCbE9FPL3o9o/U8ok0s8B7uf4lcGR57qyMaz3IUfihiBIb8YBr4eVp7eQDT2zV1Xpikkh/ePg==",
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.9.tgz",
|
||||
"integrity": "sha512-HgHho6s0hQ7hIgx27J6YBg/4Jse0OZxQGQqE8ZT1lELWDOqrvR4RB1AIR2O3JFIts8u0a7uBwDhbjZPBwzj4TQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.7"
|
||||
}
|
||||
},
|
||||
"@microsoft/api-extractor": {
|
||||
@ -6355,21 +6310,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-commonjs": {
|
||||
"version": "18.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.1.0.tgz",
|
||||
"integrity": "sha512-h3e6T9rUxVMAQswpDIobfUHn/doMzM9sgkMrsMWCFLmB84PSoC8mV8tOloAJjSRwdqhXBqstlX2BwBpHJvbhxg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"commondir": "^1.0.1",
|
||||
"estree-walker": "^2.0.1",
|
||||
"glob": "^7.1.6",
|
||||
"is-reference": "^1.2.1",
|
||||
"magic-string": "^0.25.7",
|
||||
"resolve": "^1.17.0"
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-node-resolve": {
|
||||
"version": "11.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz",
|
||||
@ -7084,12 +7024,6 @@
|
||||
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz",
|
||||
"integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw=="
|
||||
},
|
||||
"commondir": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
|
||||
"integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=",
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
@ -7665,12 +7599,6 @@
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
|
||||
},
|
||||
"estree-walker": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||
"dev": true
|
||||
},
|
||||
"esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
@ -8091,15 +8019,6 @@
|
||||
"has-tostringtag": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-reference": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
|
||||
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"is-regex": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz",
|
||||
|
@ -23,11 +23,8 @@
|
||||
"build:cleanup": "node cleanup"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.2.0-beta.2",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.7",
|
||||
"@iconify/core": "^1.2.0-beta.3",
|
||||
"@microsoft/api-extractor": "^7.18.4",
|
||||
"@rollup/plugin-commonjs": "^18.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@rollup/plugin-typescript": "^8.2.3",
|
||||
"rollup": "^2.53.2",
|
||||
|
@ -1,5 +1,4 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
|
||||
// Write all packages
|
||||
@ -13,7 +12,13 @@ const config = [
|
||||
},
|
||||
],
|
||||
external: ['@glimmer/component', '@glimmer/tracking'],
|
||||
plugins: [resolve(), commonjs(), typescript()],
|
||||
plugins: [
|
||||
resolve({
|
||||
browser: true,
|
||||
extensions: ['.ts', '.mjs', '.js'],
|
||||
}),
|
||||
typescript(),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -2,12 +2,15 @@ import Component from '@glimmer/component';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
|
||||
// Core
|
||||
import { IconifyIconName, stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||
import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
||||
import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
||||
import { getIconData } from '@iconify/core/lib/storage/functions';
|
||||
import { fullIcon, FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// API
|
||||
import { loadIcons, IconifyIconLoaderAbort } from '@iconify/core/lib/api/icons';
|
||||
import type { IconifyIconLoaderAbort } from '@iconify/core/lib/api/icons';
|
||||
import { loadIcons } from '@iconify/core/lib/api/icons';
|
||||
|
||||
// Component stuff
|
||||
import type { IconifyIconProps } from './props';
|
||||
|
@ -7,49 +7,53 @@ import type {
|
||||
IconifyHorizontalIconAlignment,
|
||||
IconifyVerticalIconAlignment,
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||
import {
|
||||
IconifyStorageFunctions,
|
||||
storageFunctions,
|
||||
iconExists,
|
||||
getIcon,
|
||||
addIcon,
|
||||
addCollection,
|
||||
allowSimpleNames,
|
||||
} from '@iconify/core/lib/storage/functions';
|
||||
import {
|
||||
IconifyBuilderFunctions,
|
||||
builderFunctions,
|
||||
} from '@iconify/core/lib/builder/functions';
|
||||
import { listIcons } from '@iconify/core/lib/storage/storage';
|
||||
import type { IconifyBuilderFunctions } from '@iconify/core/lib/builder/functions';
|
||||
import { buildIcon } from '@iconify/core/lib/builder/functions';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||
|
||||
// API
|
||||
import {
|
||||
import type {
|
||||
IconifyAPIFunctions,
|
||||
IconifyAPIInternalFunctions,
|
||||
APIFunctions,
|
||||
APIInternalFunctions,
|
||||
IconifyAPIQueryParams,
|
||||
IconifyAPICustomQueryParams,
|
||||
IconifyAPIMergeQueryParams,
|
||||
} from '@iconify/core/lib/api/functions';
|
||||
import {
|
||||
setAPIModule,
|
||||
import type {
|
||||
IconifyAPIModule,
|
||||
IconifyAPISendQuery,
|
||||
IconifyAPIPrepareIconsQuery,
|
||||
} from '@iconify/core/lib/api/modules';
|
||||
import { jsonpAPIModule } from '@iconify/core/lib/api/modules/jsonp';
|
||||
import {
|
||||
fetchAPIModule,
|
||||
getFetch,
|
||||
setFetch,
|
||||
} from '@iconify/core/lib/api/modules/fetch';
|
||||
import {
|
||||
setAPIConfig,
|
||||
import { setAPIModule } from '@iconify/core/lib/api/modules';
|
||||
import type {
|
||||
PartialIconifyAPIConfig,
|
||||
IconifyAPIConfig,
|
||||
GetAPIConfig,
|
||||
} from '@iconify/core/lib/api/config';
|
||||
import {
|
||||
addAPIProvider,
|
||||
getAPIConfig,
|
||||
listAPIProviders,
|
||||
} from '@iconify/core/lib/api/config';
|
||||
import { fetchAPIModule, setFetch } from '@iconify/core/lib/api/modules/fetch';
|
||||
import type {
|
||||
IconifyIconLoaderCallback,
|
||||
IconifyIconLoaderAbort,
|
||||
} from '@iconify/core/lib/api/icons';
|
||||
import { loadIcons } from '@iconify/core/lib/api/icons';
|
||||
import { sendAPIQuery } from '@iconify/core/lib/api/query';
|
||||
import { mergeParams } from '@iconify/core/lib/api/params';
|
||||
|
||||
// Cache
|
||||
import { cache } from '@iconify/core/lib/cache';
|
||||
@ -118,71 +122,18 @@ export { RawIconCustomisations, IconifyIconBuildResult };
|
||||
export { IconifyBrowserCacheType };
|
||||
|
||||
/**
|
||||
* Enable and disable browser cache
|
||||
* Enable cache
|
||||
*/
|
||||
export const enableCache = (storage: IconifyBrowserCacheType) =>
|
||||
function enableCache(storage: IconifyBrowserCacheType): void {
|
||||
toggleBrowserCache(storage, true);
|
||||
}
|
||||
|
||||
export const disableCache = (storage: IconifyBrowserCacheType) =>
|
||||
/**
|
||||
* Disable cache
|
||||
*/
|
||||
function disableCache(storage: IconifyBrowserCacheType): void {
|
||||
toggleBrowserCache(storage, false);
|
||||
|
||||
/* Storage functions */
|
||||
/**
|
||||
* Check if icon exists
|
||||
*/
|
||||
export const iconExists = storageFunctions.iconExists;
|
||||
|
||||
/**
|
||||
* Get icon data
|
||||
*/
|
||||
export const getIcon = storageFunctions.getIcon;
|
||||
|
||||
/**
|
||||
* List available icons
|
||||
*/
|
||||
export const listIcons = storageFunctions.listIcons;
|
||||
|
||||
/**
|
||||
* Add one icon
|
||||
*/
|
||||
export const addIcon = storageFunctions.addIcon;
|
||||
|
||||
/**
|
||||
* Add icon set
|
||||
*/
|
||||
export const addCollection = storageFunctions.addCollection;
|
||||
|
||||
/* Builder functions */
|
||||
/**
|
||||
* Calculate icon size
|
||||
*/
|
||||
export const calculateSize = builderFunctions.calculateSize;
|
||||
|
||||
/**
|
||||
* Replace unique ids in content
|
||||
*/
|
||||
export const replaceIDs = builderFunctions.replaceIDs;
|
||||
|
||||
/**
|
||||
* Build SVG
|
||||
*/
|
||||
export const buildIcon = builderFunctions.buildIcon;
|
||||
|
||||
/* API functions */
|
||||
/**
|
||||
* Load icons
|
||||
*/
|
||||
export const loadIcons = APIFunctions.loadIcons;
|
||||
|
||||
/**
|
||||
* Add API provider
|
||||
*/
|
||||
export const addAPIProvider = APIFunctions.addAPIProvider;
|
||||
|
||||
/**
|
||||
* Export internal functions that can be used by third party implementations
|
||||
*/
|
||||
export const _api = APIInternalFunctions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise stuff
|
||||
@ -191,15 +142,7 @@ export const _api = APIInternalFunctions;
|
||||
allowSimpleNames(true);
|
||||
|
||||
// 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);
|
||||
setAPIModule('', fetchAPIModule);
|
||||
};
|
||||
setAPIModule('', fetchAPIModule);
|
||||
|
||||
/**
|
||||
* Browser stuff
|
||||
@ -257,7 +200,7 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (!setAPIConfig(key, value)) {
|
||||
if (!addAPIProvider(key, value)) {
|
||||
console.error(err);
|
||||
}
|
||||
} catch (e) {
|
||||
@ -268,6 +211,36 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal API
|
||||
*/
|
||||
const _api: IconifyAPIInternalFunctions = {
|
||||
getAPIConfig,
|
||||
setAPIModule,
|
||||
sendAPIQuery,
|
||||
setFetch,
|
||||
listAPIProviders,
|
||||
mergeParams,
|
||||
};
|
||||
|
||||
/**
|
||||
* Export functions
|
||||
*/
|
||||
// IconifyAPIInternalFunctions
|
||||
export { _api };
|
||||
|
||||
// IconifyAPIFunctions
|
||||
export { addAPIProvider, loadIcons };
|
||||
|
||||
// IconifyStorageFunctions
|
||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
||||
|
||||
// IconifyBuilderFunctions
|
||||
export { replaceIDs, calculateSize, buildIcon };
|
||||
|
||||
// IconifyBrowserCacheFunctions
|
||||
export { enableCache, disableCache };
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user