mirror of
https://github.com/iconify/iconify.git
synced 2025-01-05 15:02:09 +00:00
Split common functions from Core to Utils package, remove buble from build process and use spread operator
This commit is contained in:
parent
375bfcd6ca
commit
ebeb8de02c
@ -64,7 +64,8 @@ There are several Iconify implementations included in this repository:
|
||||
Other packages:
|
||||
|
||||
- [Iconify types](./packages/types/) - TypeScript types used by various implementations.
|
||||
- [Iconify core](./packages/core/) - common files used by various implementations.
|
||||
- [Iconify utils](./packages/utils/) - common files used by various Iconify projects (including tools, API, etc...).
|
||||
- [Iconify core](./packages/core/) - common files used by various implementations (code specific to components and SVG framework).
|
||||
- [React demo](./packages/react-demo/) - demo for React component. Run `npm start` to start demo.
|
||||
- [Next.js demo](./packages/nextjs-demo/) - demo for React component with Next.js. Run `npm run build` to build it and `npm start` to start demo.
|
||||
- [Vue 3 demo](./packages/vue-demo/) - demo for Vue component. Run `npm run dev` to start demo.
|
||||
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
2
archive/react-with-api/build.js
vendored
2
archive/react-with-api/build.js
vendored
@ -2,7 +2,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const child_process = require('child_process');
|
||||
|
||||
const packagesDir = path.dirname(__dirname);
|
||||
const packagesDir = path.dirname(path.dirname(__dirname)) + '/packages';
|
||||
|
||||
// List of commands to run
|
||||
const commands = [];
|
||||
|
201
archive/react-with-api/package-lock.json
generated
201
archive/react-with-api/package-lock.json
generated
@ -12,10 +12,9 @@
|
||||
"@babel/core": "^7.13.15",
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@iconify/core": "^1.0.0-rc.4",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/react": "^2.0.0-rc.8",
|
||||
"@microsoft/api-extractor": "^7.13.5",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^18.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@types/react": "^17.0.3",
|
||||
@ -1334,13 +1333,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.0.0-rc.5",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.0-rc.5.tgz",
|
||||
"integrity": "sha512-1VFvNlBqsX/pMRI3nd00UzEqAS7weayJ/CyCD18b8+kFa9PvoVcGAmob1bTTm++v+QKVqQs+8iQaBFl/DrrsvA==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/react": {
|
||||
@ -1355,6 +1355,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@microsoft/api-extractor": {
|
||||
"version": "7.13.5",
|
||||
"resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.13.5.tgz",
|
||||
@ -1430,23 +1439,6 @@
|
||||
"integrity": "sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@rollup/plugin-buble": {
|
||||
"version": "0.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz",
|
||||
"integrity": "sha512-Iv8cCuFPnMdqV4pcyU+OrfjOfagPArRQ1PyQjx5KgHk3dARedI+8PNTLSMpJts0lQJr8yF2pAU4GxpxCBJ9HYw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.0.8",
|
||||
"@types/buble": "^0.19.2",
|
||||
"buble": "^0.20.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs": {
|
||||
"version": "18.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0.tgz",
|
||||
@ -1584,15 +1576,6 @@
|
||||
"integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/buble": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz",
|
||||
"integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"magic-string": "^0.25.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
@ -1637,36 +1620,6 @@
|
||||
"integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "6.4.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
|
||||
"integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-dynamic-import": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
|
||||
"integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-jsx": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-styles": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
||||
@ -1775,41 +1728,6 @@
|
||||
"url": "https://opencollective.com/browserslist"
|
||||
}
|
||||
},
|
||||
"node_modules/buble": {
|
||||
"version": "0.20.0",
|
||||
"resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz",
|
||||
"integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"acorn": "^6.4.1",
|
||||
"acorn-dynamic-import": "^4.0.0",
|
||||
"acorn-jsx": "^5.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"magic-string": "^0.25.7",
|
||||
"minimist": "^1.2.5",
|
||||
"regexpu-core": "4.5.4"
|
||||
},
|
||||
"bin": {
|
||||
"buble": "bin/buble"
|
||||
}
|
||||
},
|
||||
"node_modules/buble/node_modules/regexpu-core": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz",
|
||||
"integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"regenerate": "^1.4.0",
|
||||
"regenerate-unicode-properties": "^8.0.2",
|
||||
"regjsgen": "^0.5.0",
|
||||
"regjsparser": "^0.6.0",
|
||||
"unicode-match-property-ecmascript": "^1.0.4",
|
||||
"unicode-match-property-value-ecmascript": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
@ -3919,13 +3837,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.0.0-rc.5",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.0-rc.5.tgz",
|
||||
"integrity": "sha512-1VFvNlBqsX/pMRI3nd00UzEqAS7weayJ/CyCD18b8+kFa9PvoVcGAmob1bTTm++v+QKVqQs+8iQaBFl/DrrsvA==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"@iconify/react": {
|
||||
@ -3940,6 +3859,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"@microsoft/api-extractor": {
|
||||
"version": "7.13.5",
|
||||
"resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.13.5.tgz",
|
||||
@ -3998,17 +3926,6 @@
|
||||
"integrity": "sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg==",
|
||||
"dev": true
|
||||
},
|
||||
"@rollup/plugin-buble": {
|
||||
"version": "0.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz",
|
||||
"integrity": "sha512-Iv8cCuFPnMdqV4pcyU+OrfjOfagPArRQ1PyQjx5KgHk3dARedI+8PNTLSMpJts0lQJr8yF2pAU4GxpxCBJ9HYw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@rollup/pluginutils": "^3.0.8",
|
||||
"@types/buble": "^0.19.2",
|
||||
"buble": "^0.20.0"
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-commonjs": {
|
||||
"version": "18.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0.tgz",
|
||||
@ -4125,15 +4042,6 @@
|
||||
"integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/buble": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz",
|
||||
"integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"magic-string": "^0.25.0"
|
||||
}
|
||||
},
|
||||
"@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
@ -4178,26 +4086,6 @@
|
||||
"integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
"version": "6.4.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
|
||||
"integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn-dynamic-import": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
|
||||
"integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"acorn-jsx": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"ansi-styles": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
||||
@ -4284,37 +4172,6 @@
|
||||
"node-releases": "^1.1.71"
|
||||
}
|
||||
},
|
||||
"buble": {
|
||||
"version": "0.20.0",
|
||||
"resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz",
|
||||
"integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"acorn": "^6.4.1",
|
||||
"acorn-dynamic-import": "^4.0.0",
|
||||
"acorn-jsx": "^5.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"magic-string": "^0.25.7",
|
||||
"minimist": "^1.2.5",
|
||||
"regexpu-core": "4.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"regexpu-core": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz",
|
||||
"integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"regenerate": "^1.4.0",
|
||||
"regenerate-unicode-properties": "^8.0.2",
|
||||
"regjsgen": "^0.5.0",
|
||||
"regjsparser": "^0.6.0",
|
||||
"unicode-match-property-ecmascript": "^1.0.4",
|
||||
"unicode-match-property-value-ecmascript": "^1.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
|
@ -24,10 +24,10 @@
|
||||
"@babel/core": "^7.13.15",
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@iconify/core": "^1.0.0-rc.4",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/react": "^2.0.0-rc.8",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.13.5",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^18.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@types/react": "^17.0.3",
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { writeFileSync, mkdirSync } from 'fs';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import buble from '@rollup/plugin-buble';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
|
||||
const name = 'icon';
|
||||
@ -38,7 +37,6 @@ const config = [
|
||||
commonjs({
|
||||
ignore: ['cross-fetch'],
|
||||
}),
|
||||
buble(),
|
||||
],
|
||||
},
|
||||
// Dev build
|
||||
@ -56,7 +54,6 @@ const config = [
|
||||
commonjs({
|
||||
ignore: ['cross-fetch'],
|
||||
}),
|
||||
buble(),
|
||||
],
|
||||
},
|
||||
// Production
|
||||
@ -74,7 +71,6 @@ const config = [
|
||||
commonjs({
|
||||
ignore: ['cross-fetch'],
|
||||
}),
|
||||
buble(),
|
||||
terser(),
|
||||
],
|
||||
},
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
IconifyIconSize,
|
||||
IconifyHorizontalIconAlignment,
|
||||
IconifyVerticalIconAlignment,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
IconifyStorageFunctions,
|
||||
storageFunctions,
|
||||
@ -25,7 +25,7 @@ import {
|
||||
IconifyBuilderFunctions,
|
||||
builderFunctions,
|
||||
} from '@iconify/core/lib/builder/functions';
|
||||
import { IconifyIcon } from '@iconify/core/lib/icon';
|
||||
import { IconifyIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
@ -338,10 +338,10 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
IconifyPreload: IconifyJSON[] | IconifyJSON;
|
||||
}
|
||||
if (
|
||||
((_window as unknown) as WindowWithIconifyPreload).IconifyPreload !==
|
||||
(_window as unknown as WindowWithIconifyPreload).IconifyPreload !==
|
||||
void 0
|
||||
) {
|
||||
const preload = ((_window as unknown) as WindowWithIconifyPreload)
|
||||
const preload = (_window as unknown as WindowWithIconifyPreload)
|
||||
.IconifyPreload;
|
||||
const err = 'Invalid IconifyPreload syntax.';
|
||||
if (typeof preload === 'object' && preload !== null) {
|
||||
@ -372,10 +372,10 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
||||
IconifyProviders: Record<string, PartialIconifyAPIConfig>;
|
||||
}
|
||||
if (
|
||||
((_window as unknown) as WindowWithIconifyProviders)
|
||||
.IconifyProviders !== void 0
|
||||
(_window as unknown as WindowWithIconifyProviders).IconifyProviders !==
|
||||
void 0
|
||||
) {
|
||||
const providers = ((_window as unknown) as WindowWithIconifyProviders)
|
||||
const providers = (_window as unknown as WindowWithIconifyProviders)
|
||||
.IconifyProviders;
|
||||
if (typeof providers === 'object' && providers !== null) {
|
||||
for (let key in providers) {
|
||||
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
@ -2,7 +2,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const child_process = require('child_process');
|
||||
|
||||
const packagesDir = path.dirname(__dirname);
|
||||
const packagesDir = path.dirname(path.dirname(__dirname)) + '/packages';
|
||||
|
||||
// List of commands to run
|
||||
const commands = [];
|
||||
|
206
archive/react/package-lock.json
generated
206
archive/react/package-lock.json
generated
@ -1,19 +1,19 @@
|
||||
{
|
||||
"name": "@iconify/react",
|
||||
"version": "2.0.0-rc.8",
|
||||
"version": "2.0.0-rc.9",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@iconify/react",
|
||||
"version": "2.0.0-rc.8",
|
||||
"version": "2.0.0-rc.9",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@iconify/core": "^1.0.0-rc.4",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.13.5",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^18.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@types/react": "^17.0.3",
|
||||
@ -1381,13 +1381,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.0.0-rc.5",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.0-rc.5.tgz",
|
||||
"integrity": "sha512-1VFvNlBqsX/pMRI3nd00UzEqAS7weayJ/CyCD18b8+kFa9PvoVcGAmob1bTTm++v+QKVqQs+8iQaBFl/DrrsvA==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
@ -1396,6 +1397,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
@ -2100,23 +2110,6 @@
|
||||
"integrity": "sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@rollup/plugin-buble": {
|
||||
"version": "0.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz",
|
||||
"integrity": "sha512-Iv8cCuFPnMdqV4pcyU+OrfjOfagPArRQ1PyQjx5KgHk3dARedI+8PNTLSMpJts0lQJr8yF2pAU4GxpxCBJ9HYw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.0.8",
|
||||
"@types/buble": "^0.19.2",
|
||||
"buble": "^0.20.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs": {
|
||||
"version": "18.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0.tgz",
|
||||
@ -2313,15 +2306,6 @@
|
||||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/buble": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz",
|
||||
"integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"magic-string": "^0.25.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
@ -2438,27 +2422,6 @@
|
||||
"integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "6.4.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
|
||||
"integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-dynamic-import": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
|
||||
"integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-globals": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz",
|
||||
@ -2481,15 +2444,6 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-jsx": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-walk": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz",
|
||||
@ -2984,41 +2938,6 @@
|
||||
"node-int64": "^0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/buble": {
|
||||
"version": "0.20.0",
|
||||
"resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz",
|
||||
"integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"acorn": "^6.4.1",
|
||||
"acorn-dynamic-import": "^4.0.0",
|
||||
"acorn-jsx": "^5.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"magic-string": "^0.25.7",
|
||||
"minimist": "^1.2.5",
|
||||
"regexpu-core": "4.5.4"
|
||||
},
|
||||
"bin": {
|
||||
"buble": "bin/buble"
|
||||
}
|
||||
},
|
||||
"node_modules/buble/node_modules/regexpu-core": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz",
|
||||
"integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"regenerate": "^1.4.0",
|
||||
"regenerate-unicode-properties": "^8.0.2",
|
||||
"regjsgen": "^0.5.0",
|
||||
"regjsparser": "^0.6.0",
|
||||
"unicode-match-property-ecmascript": "^1.0.4",
|
||||
"unicode-match-property-value-ecmascript": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
@ -10719,13 +10638,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.0.0-rc.5",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.0-rc.5.tgz",
|
||||
"integrity": "sha512-1VFvNlBqsX/pMRI3nd00UzEqAS7weayJ/CyCD18b8+kFa9PvoVcGAmob1bTTm++v+QKVqQs+8iQaBFl/DrrsvA==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
@ -10734,6 +10654,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
@ -11278,17 +11207,6 @@
|
||||
"integrity": "sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg==",
|
||||
"dev": true
|
||||
},
|
||||
"@rollup/plugin-buble": {
|
||||
"version": "0.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz",
|
||||
"integrity": "sha512-Iv8cCuFPnMdqV4pcyU+OrfjOfagPArRQ1PyQjx5KgHk3dARedI+8PNTLSMpJts0lQJr8yF2pAU4GxpxCBJ9HYw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@rollup/pluginutils": "^3.0.8",
|
||||
"@types/buble": "^0.19.2",
|
||||
"buble": "^0.20.0"
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-commonjs": {
|
||||
"version": "18.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0.tgz",
|
||||
@ -11464,15 +11382,6 @@
|
||||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"@types/buble": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz",
|
||||
"integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"magic-string": "^0.25.0"
|
||||
}
|
||||
},
|
||||
"@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
@ -11589,19 +11498,6 @@
|
||||
"integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
"version": "6.4.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
|
||||
"integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn-dynamic-import": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
|
||||
"integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"acorn-globals": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz",
|
||||
@ -11620,13 +11516,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"acorn-jsx": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"acorn-walk": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz",
|
||||
@ -12006,37 +11895,6 @@
|
||||
"node-int64": "^0.4.0"
|
||||
}
|
||||
},
|
||||
"buble": {
|
||||
"version": "0.20.0",
|
||||
"resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz",
|
||||
"integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"acorn": "^6.4.1",
|
||||
"acorn-dynamic-import": "^4.0.0",
|
||||
"acorn-jsx": "^5.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"magic-string": "^0.25.7",
|
||||
"minimist": "^1.2.5",
|
||||
"regexpu-core": "4.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"regexpu-core": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz",
|
||||
"integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"regenerate": "^1.4.0",
|
||||
"regenerate-unicode-properties": "^8.0.2",
|
||||
"regjsgen": "^0.5.0",
|
||||
"regjsparser": "^0.6.0",
|
||||
"unicode-match-property-ecmascript": "^1.0.4",
|
||||
"unicode-match-property-value-ecmascript": "^1.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
|
@ -25,9 +25,9 @@
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@iconify/core": "^1.0.0-rc.4",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.13.5",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^18.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@types/react": "^17.0.3",
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { writeFileSync, mkdirSync } from 'fs';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import buble from '@rollup/plugin-buble';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
|
||||
const name = 'icon';
|
||||
@ -33,7 +32,7 @@ const config = [
|
||||
},
|
||||
],
|
||||
external: ['react'],
|
||||
plugins: [resolve(), commonjs(), buble()],
|
||||
plugins: [resolve(), commonjs()],
|
||||
},
|
||||
// Dev build
|
||||
{
|
||||
@ -45,7 +44,7 @@ const config = [
|
||||
},
|
||||
],
|
||||
external: ['react'],
|
||||
plugins: [resolve(), commonjs(), buble()],
|
||||
plugins: [resolve(), commonjs()],
|
||||
},
|
||||
// Production
|
||||
{
|
||||
@ -57,7 +56,7 @@ const config = [
|
||||
},
|
||||
],
|
||||
external: ['react'],
|
||||
plugins: [resolve(), commonjs(), buble(), terser()],
|
||||
plugins: [resolve(), commonjs(), terser()],
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -8,16 +8,15 @@ import type {
|
||||
IconifyVerticalIconAlignment,
|
||||
IconifyIconSize,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
import { defaults } from '@iconify/core/lib/customisations';
|
||||
import { defaults } from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
flipFromString,
|
||||
alignmentFromString,
|
||||
} from '@iconify/core/lib/customisations/shorthand';
|
||||
import { rotateFromString } from '@iconify/core/lib/customisations/rotate';
|
||||
import { fullIcon } from '@iconify/core/lib/icon';
|
||||
} from '@iconify/utils/lib/customisations/shorthand';
|
||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
import { iconToSVG } from '@iconify/core/lib/builder';
|
||||
import { replaceIDs } from '@iconify/core/lib/builder/ids';
|
||||
import { merge } from '@iconify/core/lib/misc/merge';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
import { parseIconSet } from '@iconify/core/lib/icon/icon-set';
|
||||
|
||||
/**
|
||||
@ -86,9 +85,7 @@ const svgDefaults: IconifySVGProps = {
|
||||
/**
|
||||
* Default values for customisations for inline icon
|
||||
*/
|
||||
const inlineDefaults = merge(defaults, {
|
||||
inline: true,
|
||||
} as IconifyIconCustomisations) as FullIconCustomisations;
|
||||
const inlineDefaults = { ...defaults, inline: true } as FullIconCustomisations;
|
||||
|
||||
/**
|
||||
* Storage for icons referred by name
|
||||
@ -125,11 +122,8 @@ const component = (
|
||||
: React.createElement('span', {});
|
||||
}
|
||||
|
||||
const customisations = merge(
|
||||
defaults,
|
||||
props as IconifyIconCustomisations
|
||||
) as FullIconCustomisations;
|
||||
const componentProps = merge(svgDefaults);
|
||||
const customisations = { ...defaults, props };
|
||||
const componentProps = { ...svgDefaults };
|
||||
|
||||
// Add reference
|
||||
componentProps.ref = ref;
|
||||
|
@ -18,7 +18,7 @@
|
||||
"build:dist": "rollup -c rollup.config.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.0.0",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/iconify": "^2.0.0",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
|
@ -40,7 +40,9 @@ const config = files.map((file) => {
|
||||
commonjs({
|
||||
ignore: ['cross-fetch'],
|
||||
}),
|
||||
buble(),
|
||||
buble({
|
||||
objectAssign: 'Object.assign',
|
||||
}),
|
||||
],
|
||||
};
|
||||
});
|
||||
|
13
packages/core/package-lock.json
generated
13
packages/core/package-lock.json
generated
@ -9,8 +9,7 @@
|
||||
"version": "1.0.1",
|
||||
"license": "(Apache-2.0 OR GPL-2.0)",
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@cyberalien/redundancy": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.16",
|
||||
@ -171,11 +170,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"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=="
|
||||
},
|
||||
"node_modules/@nodelib/fs.scandir": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz",
|
||||
@ -2690,11 +2684,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.6.tgz",
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg=="
|
||||
},
|
||||
"@nodelib/fs.scandir": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz",
|
||||
|
@ -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.0.1",
|
||||
"version": "1.1.0",
|
||||
"license": "(Apache-2.0 OR GPL-2.0)",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
@ -36,6 +36,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
import { replaceIDs } from './ids';
|
||||
import { calculateSize } from './calc-size';
|
||||
import { fullIcon, IconifyIcon } from '../icon';
|
||||
import { defaults, mergeCustomisations } from '../customisations';
|
||||
import type { IconifyIconCustomisations } from '../customisations';
|
||||
import type { IconifyIcon } from '@iconify/types';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||
import {
|
||||
defaults,
|
||||
mergeCustomisations,
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import type { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import { iconToSVG } from '.';
|
||||
import type { IconifyIconBuildResult } from '.';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { FullIconifyIcon } from '../icon';
|
||||
import type { FullIconCustomisations } from '../customisations';
|
||||
import { calculateSize } from './calc-size';
|
||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import { calculateSize } from '@iconify/utils/lib/svg/size';
|
||||
|
||||
/**
|
||||
* Get preserveAspectRatio value
|
||||
|
@ -6,10 +6,9 @@ import type {
|
||||
IconifyIcons,
|
||||
IconifyAliases,
|
||||
} from '@iconify/types';
|
||||
import type { FullIconifyIcon } from '.';
|
||||
import { iconDefaults } from '.';
|
||||
import { merge } from '../misc/merge';
|
||||
import { mergeIcons } from './merge';
|
||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import { iconDefaults } from '@iconify/utils/lib/icon';
|
||||
import { mergeIconData } from '@iconify/utils/lib/icon/merge';
|
||||
|
||||
/**
|
||||
* What to track when adding icon set:
|
||||
@ -46,7 +45,7 @@ function resolveAlias(
|
||||
): IconifyIcon | null {
|
||||
const parent = alias.parent;
|
||||
if (icons[parent] !== void 0) {
|
||||
return mergeIcons(icons[parent], (alias as unknown) as IconifyIcon);
|
||||
return mergeIconData(icons[parent], alias);
|
||||
}
|
||||
if (aliases[parent] !== void 0) {
|
||||
if (level > 2) {
|
||||
@ -55,7 +54,7 @@ function resolveAlias(
|
||||
}
|
||||
const icon = resolveAlias(aliases[parent], icons, aliases, level + 1);
|
||||
if (icon) {
|
||||
return mergeIcons(icon, (alias as unknown) as IconifyIcon);
|
||||
return mergeIconData(icon, alias);
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +108,10 @@ export function parseIconSet(
|
||||
}
|
||||
|
||||
// Freeze icon to make sure it will not be modified
|
||||
callback(name, Object.freeze(merge(iconDefaults, defaults, icon)));
|
||||
callback(
|
||||
name,
|
||||
Object.freeze({ ...iconDefaults, ...defaults, ...icon })
|
||||
);
|
||||
added.push(name);
|
||||
});
|
||||
|
||||
@ -122,7 +124,7 @@ export function parseIconSet(
|
||||
// Freeze icon to make sure it will not be modified
|
||||
callback(
|
||||
name,
|
||||
Object.freeze(merge(iconDefaults, defaults, icon))
|
||||
Object.freeze({ ...iconDefaults, ...defaults, ...icon })
|
||||
);
|
||||
added.push(name);
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
import type { IconifyIcon } from '@iconify/types';
|
||||
import { merge } from '../misc/merge';
|
||||
|
||||
export { IconifyIcon };
|
||||
export type FullIconifyIcon = Required<IconifyIcon>;
|
||||
|
||||
/**
|
||||
* Default values for IconifyIcon properties
|
||||
*/
|
||||
export const iconDefaults: FullIconifyIcon = Object.freeze({
|
||||
body: '',
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: 16,
|
||||
height: 16,
|
||||
rotate: 0,
|
||||
vFlip: false,
|
||||
hFlip: false,
|
||||
});
|
||||
|
||||
/**
|
||||
* Create new icon with all properties
|
||||
*/
|
||||
export function fullIcon(icon: IconifyIcon): FullIconifyIcon {
|
||||
return merge(iconDefaults, icon as FullIconifyIcon) as FullIconifyIcon;
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
import type { IconifyIcon } from '.';
|
||||
import { iconDefaults } from '.';
|
||||
|
||||
/**
|
||||
* Icon keys
|
||||
*/
|
||||
const iconKeys = Object.keys(iconDefaults) as (keyof IconifyIcon)[];
|
||||
|
||||
/**
|
||||
* Merge two icons
|
||||
*
|
||||
* icon2 overrides icon1
|
||||
*/
|
||||
export function mergeIcons(
|
||||
icon1: IconifyIcon,
|
||||
icon2: IconifyIcon
|
||||
): IconifyIcon {
|
||||
const icon = Object.create(null);
|
||||
iconKeys.forEach((key) => {
|
||||
if (icon1[key] === void 0) {
|
||||
if (icon2[key] !== void 0) {
|
||||
icon[key] = icon2[key];
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (icon2[key] === void 0) {
|
||||
icon[key] = icon1[key];
|
||||
return;
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case 'rotate':
|
||||
icon[key] =
|
||||
((icon1[key] as number) + (icon2[key] as number)) % 4;
|
||||
return;
|
||||
|
||||
case 'hFlip':
|
||||
case 'vFlip':
|
||||
icon[key] = icon1[key] !== icon2[key];
|
||||
return;
|
||||
|
||||
default:
|
||||
icon[key] = icon2[key];
|
||||
}
|
||||
});
|
||||
|
||||
return icon;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
type MergeObject = Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* Merge two objects
|
||||
*
|
||||
* Replacement for Object.assign() that is not supported by IE, so it cannot be used in production yet.
|
||||
*/
|
||||
export function merge<T>(item1: T, item2?: T, item3?: T): T {
|
||||
const result: MergeObject = Object.create(null);
|
||||
const items = [item1, item2, item3];
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const item = items[i];
|
||||
if (typeof item === 'object' && item) {
|
||||
for (const key in item) {
|
||||
const value = (item as MergeObject)[key];
|
||||
if (value !== void 0) {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result as T;
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
import type { FullIconifyIcon, IconifyIcon } from '../icon';
|
||||
import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import { parseIconSet } from '../icon/icon-set';
|
||||
import type { IconifyIconName } from '../icon/name';
|
||||
import { stringToIcon, validateIcon } from '../icon/name';
|
||||
import { merge } from '../misc/merge';
|
||||
import {
|
||||
getStorage,
|
||||
getIcon,
|
||||
@ -136,7 +135,7 @@ export const storageFunctions: IconifyStorageFunctions = {
|
||||
// Get raw icon data
|
||||
getIcon: (name) => {
|
||||
const result = getIconData(name);
|
||||
return result ? merge(result) : null;
|
||||
return result ? { ...result } : null;
|
||||
},
|
||||
|
||||
// List icons
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||
import type { FullIconifyIcon } from '../icon';
|
||||
import { fullIcon } from '../icon';
|
||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
import type { AddIconSetTracking } from '../icon/icon-set';
|
||||
import { parseIconSet } from '../icon/icon-set';
|
||||
|
||||
@ -22,9 +22,8 @@ export interface IconStorage {
|
||||
/**
|
||||
* Storage by provider and prefix
|
||||
*/
|
||||
const storage: Record<string, Record<string, IconStorage>> = Object.create(
|
||||
null
|
||||
);
|
||||
const storage: Record<string, Record<string, IconStorage>> =
|
||||
Object.create(null);
|
||||
|
||||
/**
|
||||
* Create new storage
|
||||
|
@ -2,7 +2,7 @@ import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
import { parseIconSet } from '../../lib/icon/icon-set';
|
||||
import type { FullIconifyIcon } from '../../lib/icon';
|
||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
describe('Testing parsing icon set', () => {
|
||||
it('Simple icon set', () => {
|
||||
@ -349,7 +349,7 @@ describe('Testing parsing icon set', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const iconSet: IconifyJSON = ({
|
||||
const iconSet: IconifyJSON = {
|
||||
icons: {
|
||||
icon1: {
|
||||
body: '<path d="icon1" />',
|
||||
@ -372,7 +372,7 @@ describe('Testing parsing icon set', () => {
|
||||
foo: 1,
|
||||
},
|
||||
hFlip: null,
|
||||
} as unknown) as IconifyJSON;
|
||||
} as unknown as IconifyJSON;
|
||||
|
||||
// Do stuff
|
||||
expect(
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
getStorage,
|
||||
listIcons,
|
||||
} from '../../lib/storage/storage';
|
||||
import type { FullIconifyIcon, IconifyIcon } from '../../lib/icon';
|
||||
import type { IconifyIcon, FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
describe('Testing storage', () => {
|
||||
it('Adding icon', () => {
|
||||
@ -40,7 +40,7 @@ describe('Testing storage', () => {
|
||||
storage.missing['not-really-missing'] = Date.now();
|
||||
|
||||
// Add invalid icon
|
||||
addIcon(storage, 'invalid', ({} as unknown) as IconifyIcon);
|
||||
addIcon(storage, 'invalid', {} as unknown as IconifyIcon);
|
||||
|
||||
// Should not include 'invalid'
|
||||
expect(Object.keys(storage.icons)).to.be.eql([
|
||||
|
@ -2,15 +2,18 @@ import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import type { IconifyIconBuildResult } from '../../lib/builder';
|
||||
import { iconToSVG } from '../../lib/builder';
|
||||
import type { FullIconifyIcon } from '../../lib/icon';
|
||||
import { iconDefaults, fullIcon } from '../../lib/icon';
|
||||
import type { FullIconCustomisations } from '../../lib/customisations';
|
||||
import { defaults, mergeCustomisations } from '../../lib/customisations';
|
||||
import type { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import { fullIcon, iconDefaults } from '@iconify/utils/lib/icon';
|
||||
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
defaults,
|
||||
mergeCustomisations,
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
|
||||
describe('Testing iconToSVG', () => {
|
||||
it('Empty icon', () => {
|
||||
const custom: FullIconCustomisations = defaults;
|
||||
const icon: FullIconifyIcon = iconDefaults;
|
||||
const icon: FullIconifyIcon = { ...iconDefaults, body: '' };
|
||||
const expected: IconifyIconBuildResult = {
|
||||
attributes: {
|
||||
width: '1em',
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
storageFunctions,
|
||||
allowSimpleNames,
|
||||
} from '../../lib/storage/functions';
|
||||
import { fullIcon } from '../../lib/icon';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
describe('Testing IconifyStorageFunctions', () => {
|
||||
let count = 0;
|
||||
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
39
packages/iconify/package-lock.json
generated
39
packages/iconify/package-lock.json
generated
@ -12,8 +12,9 @@
|
||||
"cross-fetch": "^3.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.0.1",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.12.0",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
@ -62,13 +63,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.1.tgz",
|
||||
"integrity": "sha512-gbPClcrRJ7sIKgwcEPLUaT1u8PzpOGdsCM3O63wJa5FYosC3ZZBymqR1LFT6MSiPWGlF2XowabzoHS8HaICEpg==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
@ -77,6 +79,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@microsoft/api-extractor": {
|
||||
"version": "7.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.12.1.tgz",
|
||||
@ -2180,13 +2191,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.1.tgz",
|
||||
"integrity": "sha512-gbPClcrRJ7sIKgwcEPLUaT1u8PzpOGdsCM3O63wJa5FYosC3ZZBymqR1LFT6MSiPWGlF2XowabzoHS8HaICEpg==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
@ -2195,6 +2207,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"@microsoft/api-extractor": {
|
||||
"version": "7.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.12.1.tgz",
|
||||
|
@ -29,8 +29,9 @@
|
||||
"cross-fetch": "^3.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/core": "^1.0.1",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.12.0",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
|
@ -92,7 +92,9 @@ names.forEach((name) => {
|
||||
ignore: ['cross-fetch'],
|
||||
}),
|
||||
replace(replacements),
|
||||
buble(),
|
||||
buble({
|
||||
objectAssign: 'Object.assign',
|
||||
}),
|
||||
],
|
||||
};
|
||||
if (compress) {
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
IconifyIconCustomisations,
|
||||
defaults,
|
||||
mergeCustomisations,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
storageFunctions,
|
||||
getIconData,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IconifyFinder } from './interface';
|
||||
import { IconifyElement } from '../modules/element';
|
||||
import { IconifyIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import { finder as iconifyFinder } from './iconify';
|
||||
|
||||
const selector = 'iconify-icon';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IconifyFinder } from './interface';
|
||||
import { IconifyElement } from '../modules/element';
|
||||
import { IconifyIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import { finder as iconifyFinder } from './iconify-v1';
|
||||
|
||||
const selector = 'iconify-icon';
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { IconifyFinder } from './interface';
|
||||
import { IconifyElement } from '../modules/element';
|
||||
import { IconifyIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import { rotateFromString } from '@iconify/core/lib/customisations/rotate';
|
||||
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||
import {
|
||||
flipFromString,
|
||||
alignmentFromString,
|
||||
} from '@iconify/core/lib/customisations/shorthand';
|
||||
} from '@iconify/utils/lib/customisations/shorthand';
|
||||
|
||||
/**
|
||||
* Check if attribute exists
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { IconifyFinder } from './interface';
|
||||
import { IconifyElement } from '../modules/element';
|
||||
import { IconifyIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import { rotateFromString } from '@iconify/core/lib/customisations/rotate';
|
||||
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||
import {
|
||||
flipFromString,
|
||||
alignmentFromString,
|
||||
} from '@iconify/core/lib/customisations/shorthand';
|
||||
} from '@iconify/utils/lib/customisations/shorthand';
|
||||
|
||||
/**
|
||||
* Check if attribute exists
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IconifyElement } from '../modules/element';
|
||||
import { IconifyIconName } from '@iconify/core/lib/icon/name';
|
||||
import { IconifyIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
|
||||
/**
|
||||
* find - find elements that match plugin within root element
|
||||
|
@ -1,13 +1,12 @@
|
||||
// Core
|
||||
import { IconifyJSON } from '@iconify/types';
|
||||
import { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||
import { IconifyIconName } from '@iconify/core/lib/icon/name';
|
||||
import { IconifyIcon } from '@iconify/core/lib/icon';
|
||||
import {
|
||||
IconifyIconCustomisations,
|
||||
IconifyIconSize,
|
||||
IconifyHorizontalIconAlignment,
|
||||
IconifyVerticalIconAlignment,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import { IconifyIconBuildResult } from '@iconify/core/lib/builder';
|
||||
import {
|
||||
IconifyStorageFunctions,
|
||||
|
@ -1,13 +1,12 @@
|
||||
// Core
|
||||
import { IconifyJSON } from '@iconify/types';
|
||||
import { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||
import { IconifyIconName } from '@iconify/core/lib/icon/name';
|
||||
import { IconifyIcon } from '@iconify/core/lib/icon';
|
||||
import {
|
||||
IconifyIconCustomisations,
|
||||
IconifyIconSize,
|
||||
IconifyHorizontalIconAlignment,
|
||||
IconifyVerticalIconAlignment,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import { IconifyIconBuildResult } from '@iconify/core/lib/builder';
|
||||
import {
|
||||
IconifyStorageFunctions,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IconifyIconName } from '@iconify/core/lib/icon/name';
|
||||
import { IconifyIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import { IconifyFinder } from '../finders/interface';
|
||||
|
||||
/**
|
||||
@ -35,8 +35,8 @@ export interface IconifyElement
|
||||
/**
|
||||
* Names of properties to add to nodes
|
||||
*/
|
||||
export const elementFinderProperty: keyof IconifyElementStoredFinder = ('iconifyFinder' +
|
||||
Date.now()) as keyof IconifyElementStoredFinder;
|
||||
export const elementFinderProperty: keyof IconifyElementStoredFinder =
|
||||
('iconifyFinder' + Date.now()) as keyof IconifyElementStoredFinder;
|
||||
|
||||
export const elementDataProperty: keyof IconifyElementStoredData = ('iconifyData' +
|
||||
Date.now()) as keyof IconifyElementStoredData;
|
||||
export const elementDataProperty: keyof IconifyElementStoredData =
|
||||
('iconifyData' + Date.now()) as keyof IconifyElementStoredData;
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
stringToIcon,
|
||||
validateIcon,
|
||||
} from '@iconify/core/lib/icon/name';
|
||||
import { IconifyIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import { IconifyIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import { IconifyFinder } from '../finders/interface';
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { FullIconifyIcon } from '@iconify/core/lib/icon';
|
||||
import { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import {
|
||||
IconifyIconCustomisations,
|
||||
mergeCustomisations,
|
||||
defaults,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import { iconToSVG } from '@iconify/core/lib/builder';
|
||||
import { replaceIDs } from '@iconify/core/lib/builder/ids';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
import { PlaceholderElement } from './finder';
|
||||
import {
|
||||
IconifyElement,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { IconifyIconName } from '@iconify/core/lib/icon/name';
|
||||
import { getStorage, getIcon } from '@iconify/core/lib/storage/storage';
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
import { FullIconifyIcon } from '@iconify/core/lib/icon';
|
||||
import { FullIconifyIcon } from '@iconify/utils/lib/icon';
|
||||
import { findPlaceholders } from './finder';
|
||||
import { IconifyElementData, elementDataProperty } from './element';
|
||||
import { renderIcon } from './render';
|
||||
@ -77,10 +77,8 @@ 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 loadIcons: Record<string, Record<string, Record<string, boolean>>> =
|
||||
Object.create(null);
|
||||
|
||||
// Get placeholders
|
||||
(node ? [node] : listRootNodes()).forEach((node) => {
|
||||
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
202
packages/react/package-lock.json
generated
202
packages/react/package-lock.json
generated
@ -11,10 +11,10 @@
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@iconify/core": "^1.0.1",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.13.5",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^18.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@types/react": "^17.0.3",
|
||||
@ -1381,13 +1381,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.1.tgz",
|
||||
"integrity": "sha512-gbPClcrRJ7sIKgwcEPLUaT1u8PzpOGdsCM3O63wJa5FYosC3ZZBymqR1LFT6MSiPWGlF2XowabzoHS8HaICEpg==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
@ -1396,6 +1397,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
@ -2100,23 +2110,6 @@
|
||||
"integrity": "sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@rollup/plugin-buble": {
|
||||
"version": "0.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz",
|
||||
"integrity": "sha512-Iv8cCuFPnMdqV4pcyU+OrfjOfagPArRQ1PyQjx5KgHk3dARedI+8PNTLSMpJts0lQJr8yF2pAU4GxpxCBJ9HYw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.0.8",
|
||||
"@types/buble": "^0.19.2",
|
||||
"buble": "^0.20.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/plugin-commonjs": {
|
||||
"version": "18.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0.tgz",
|
||||
@ -2313,15 +2306,6 @@
|
||||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/buble": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz",
|
||||
"integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"magic-string": "^0.25.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
@ -2438,27 +2422,6 @@
|
||||
"integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "6.4.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
|
||||
"integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-dynamic-import": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
|
||||
"integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-globals": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz",
|
||||
@ -2481,15 +2444,6 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-jsx": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-walk": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz",
|
||||
@ -2984,41 +2938,6 @@
|
||||
"node-int64": "^0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/buble": {
|
||||
"version": "0.20.0",
|
||||
"resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz",
|
||||
"integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"acorn": "^6.4.1",
|
||||
"acorn-dynamic-import": "^4.0.0",
|
||||
"acorn-jsx": "^5.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"magic-string": "^0.25.7",
|
||||
"minimist": "^1.2.5",
|
||||
"regexpu-core": "4.5.4"
|
||||
},
|
||||
"bin": {
|
||||
"buble": "bin/buble"
|
||||
}
|
||||
},
|
||||
"node_modules/buble/node_modules/regexpu-core": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz",
|
||||
"integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"regenerate": "^1.4.0",
|
||||
"regenerate-unicode-properties": "^8.0.2",
|
||||
"regjsgen": "^0.5.0",
|
||||
"regjsparser": "^0.6.0",
|
||||
"unicode-match-property-ecmascript": "^1.0.4",
|
||||
"unicode-match-property-value-ecmascript": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
@ -10661,13 +10580,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.1.tgz",
|
||||
"integrity": "sha512-gbPClcrRJ7sIKgwcEPLUaT1u8PzpOGdsCM3O63wJa5FYosC3ZZBymqR1LFT6MSiPWGlF2XowabzoHS8HaICEpg==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
@ -10676,6 +10596,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
@ -11220,17 +11149,6 @@
|
||||
"integrity": "sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg==",
|
||||
"dev": true
|
||||
},
|
||||
"@rollup/plugin-buble": {
|
||||
"version": "0.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-buble/-/plugin-buble-0.21.3.tgz",
|
||||
"integrity": "sha512-Iv8cCuFPnMdqV4pcyU+OrfjOfagPArRQ1PyQjx5KgHk3dARedI+8PNTLSMpJts0lQJr8yF2pAU4GxpxCBJ9HYw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@rollup/pluginutils": "^3.0.8",
|
||||
"@types/buble": "^0.19.2",
|
||||
"buble": "^0.20.0"
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-commonjs": {
|
||||
"version": "18.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-18.0.0.tgz",
|
||||
@ -11406,15 +11324,6 @@
|
||||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"@types/buble": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/buble/-/buble-0.19.2.tgz",
|
||||
"integrity": "sha512-uUD8zIfXMKThmFkahTXDGI3CthFH1kMg2dOm3KLi4GlC5cbARA64bEcUMbbWdWdE73eoc/iBB9PiTMqH0dNS2Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"magic-string": "^0.25.0"
|
||||
}
|
||||
},
|
||||
"@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||
@ -11531,19 +11440,6 @@
|
||||
"integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
"version": "6.4.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.2.tgz",
|
||||
"integrity": "sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn-dynamic-import": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
|
||||
"integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"acorn-globals": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz",
|
||||
@ -11562,13 +11458,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"acorn-jsx": {
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
|
||||
"integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"acorn-walk": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz",
|
||||
@ -11948,37 +11837,6 @@
|
||||
"node-int64": "^0.4.0"
|
||||
}
|
||||
},
|
||||
"buble": {
|
||||
"version": "0.20.0",
|
||||
"resolved": "https://registry.npmjs.org/buble/-/buble-0.20.0.tgz",
|
||||
"integrity": "sha512-/1gnaMQE8xvd5qsNBl+iTuyjJ9XxeaVxAMF86dQ4EyxFJOZtsgOS8Ra+7WHgZTam5IFDtt4BguN0sH0tVTKrOw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"acorn": "^6.4.1",
|
||||
"acorn-dynamic-import": "^4.0.0",
|
||||
"acorn-jsx": "^5.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"magic-string": "^0.25.7",
|
||||
"minimist": "^1.2.5",
|
||||
"regexpu-core": "4.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"regexpu-core": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.5.4.tgz",
|
||||
"integrity": "sha512-BtizvGtFQKGPUcTy56o3nk1bGRp4SZOTYrDtGNlqCQufptV5IkkLN6Emw+yunAJjzf+C9FQFtvq7IoA3+oMYHQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"regenerate": "^1.4.0",
|
||||
"regenerate-unicode-properties": "^8.0.2",
|
||||
"regjsgen": "^0.5.0",
|
||||
"regjsparser": "^0.6.0",
|
||||
"unicode-match-property-ecmascript": "^1.0.4",
|
||||
"unicode-match-property-value-ecmascript": "^1.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
|
@ -26,10 +26,10 @@
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.13.15",
|
||||
"@babel/preset-react": "^7.13.13",
|
||||
"@iconify/core": "^1.0.1",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.13.5",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^18.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@types/react": "^17.0.3",
|
||||
|
@ -1,6 +1,5 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import buble from '@rollup/plugin-buble';
|
||||
|
||||
const names = ['offline', 'iconify'];
|
||||
|
||||
@ -18,7 +17,7 @@ names.forEach((name) => {
|
||||
},
|
||||
],
|
||||
external: ['react'],
|
||||
plugins: [resolve(), commonjs(), buble()],
|
||||
plugins: [resolve(), commonjs()],
|
||||
});
|
||||
|
||||
// CommonJS module
|
||||
@ -31,7 +30,7 @@ names.forEach((name) => {
|
||||
},
|
||||
],
|
||||
external: ['react'],
|
||||
plugins: [resolve(), commonjs(), buble()],
|
||||
plugins: [resolve(), commonjs()],
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
import type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||
|
||||
// Core
|
||||
import { IconifyIconName, stringToIcon } from '@iconify/core/lib/icon/name';
|
||||
@ -7,7 +7,7 @@ import type {
|
||||
IconifyIconSize,
|
||||
IconifyHorizontalIconAlignment,
|
||||
IconifyVerticalIconAlignment,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
IconifyStorageFunctions,
|
||||
storageFunctions,
|
||||
@ -19,7 +19,7 @@ import {
|
||||
builderFunctions,
|
||||
} from '@iconify/core/lib/builder/functions';
|
||||
import type { IconifyIconBuildResult } from '@iconify/core/lib/builder';
|
||||
import { fullIcon, IconifyIcon } from '@iconify/core/lib/icon';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
@ -76,7 +76,6 @@ import type {
|
||||
|
||||
// Render SVG
|
||||
import { render } from './render';
|
||||
import { merge } from '@iconify/core/lib/misc/merge';
|
||||
|
||||
/**
|
||||
* Export required types
|
||||
@ -473,12 +472,13 @@ class IconComponent extends React.Component<
|
||||
// Add classes
|
||||
let newProps = props;
|
||||
if (icon.classes) {
|
||||
newProps = merge(props, {
|
||||
newProps = {
|
||||
...props,
|
||||
className:
|
||||
(typeof props.className === 'string'
|
||||
? props.className + ' '
|
||||
: '') + icon.classes.join(' '),
|
||||
} as typeof props);
|
||||
};
|
||||
}
|
||||
|
||||
// Render icon
|
||||
@ -498,10 +498,11 @@ export type Component = (props: IconProps) => JSX.Element;
|
||||
*/
|
||||
export const Icon: Component = React.forwardRef(
|
||||
(props: IconProps, ref?: IconRef) => {
|
||||
const newProps = merge(props as Partial<InternalIconProps>, {
|
||||
const newProps = {
|
||||
...props,
|
||||
_ref: ref,
|
||||
_inline: false,
|
||||
}) as InternalIconProps;
|
||||
};
|
||||
return React.createElement(IconComponent, newProps);
|
||||
}
|
||||
);
|
||||
@ -513,10 +514,7 @@ export const Icon: Component = React.forwardRef(
|
||||
*/
|
||||
export const InlineIcon: Component = React.forwardRef(
|
||||
(props: IconProps, ref?: IconRef) => {
|
||||
const newProps = merge(props as Partial<InternalIconProps>, {
|
||||
_ref: ref,
|
||||
_inline: true,
|
||||
}) as InternalIconProps;
|
||||
const newProps = { ...props, _ref: ref, _inline: true };
|
||||
return React.createElement(IconComponent, newProps);
|
||||
}
|
||||
);
|
||||
|
@ -4,8 +4,8 @@ import type {
|
||||
IconifyHorizontalIconAlignment,
|
||||
IconifyVerticalIconAlignment,
|
||||
IconifyIconSize,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
import { fullIcon } from '@iconify/core/lib/icon';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
import { parseIconSet } from '@iconify/core/lib/icon/icon-set';
|
||||
import type {
|
||||
IconifyIconCustomisations,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { HTMLProps, RefObject } from 'react';
|
||||
import type { IconifyIcon } from '@iconify/types';
|
||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
|
||||
export { RawIconCustomisations };
|
||||
|
||||
|
@ -1,19 +1,18 @@
|
||||
import type { SVGProps } from 'react';
|
||||
import React from 'react';
|
||||
import type { IconifyIcon } from '@iconify/types';
|
||||
import type { FullIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import type { FullIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
defaults,
|
||||
mergeCustomisations,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
flipFromString,
|
||||
alignmentFromString,
|
||||
} from '@iconify/core/lib/customisations/shorthand';
|
||||
import { rotateFromString } from '@iconify/core/lib/customisations/rotate';
|
||||
} from '@iconify/utils/lib/customisations/shorthand';
|
||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||
import { iconToSVG } from '@iconify/core/lib/builder';
|
||||
import { replaceIDs } from '@iconify/core/lib/builder/ids';
|
||||
import { merge } from '@iconify/core/lib/misc/merge';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
import type { IconifyIconCustomisations, IconProps, IconRef } from './props';
|
||||
|
||||
/**
|
||||
@ -30,9 +29,7 @@ const svgDefaults: SVGProps<SVGElement> = {
|
||||
/**
|
||||
* Default values for customisations for inline icon
|
||||
*/
|
||||
const inlineDefaults = merge(defaults, {
|
||||
inline: true,
|
||||
} as IconifyIconCustomisations) as FullIconCustomisations;
|
||||
const inlineDefaults = { ...defaults, inline: true } as FullIconCustomisations;
|
||||
|
||||
/**
|
||||
* Render icon
|
||||
@ -66,10 +63,7 @@ export const render = (
|
||||
: {};
|
||||
|
||||
// Create SVG component properties
|
||||
const componentProps = merge(svgDefaults, {
|
||||
ref,
|
||||
style,
|
||||
});
|
||||
const componentProps = { ...svgDefaults, ref, style };
|
||||
|
||||
// Get element properties
|
||||
for (let key in props) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {
|
||||
|
39
packages/svelte/package-lock.json
generated
39
packages/svelte/package-lock.json
generated
@ -10,8 +10,9 @@
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.14.0",
|
||||
"@iconify/core": "^1.0.1",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.15.0",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
@ -1484,13 +1485,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/core": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.1.tgz",
|
||||
"integrity": "sha512-gbPClcrRJ7sIKgwcEPLUaT1u8PzpOGdsCM3O63wJa5FYosC3ZZBymqR1LFT6MSiPWGlF2XowabzoHS8HaICEpg==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@iconify/types": {
|
||||
@ -1499,6 +1501,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
@ -9800,13 +9811,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/core": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.0.1.tgz",
|
||||
"integrity": "sha512-gbPClcrRJ7sIKgwcEPLUaT1u8PzpOGdsCM3O63wJa5FYosC3ZZBymqR1LFT6MSiPWGlF2XowabzoHS8HaICEpg==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/core/-/core-1.1.0.tgz",
|
||||
"integrity": "sha512-2H0ESSla+uHHFpqVMnwKw3iknpL6fU72io+RjTSCPCQJeRApzHTUBcPUPXSi84qpEUouPW2uGQL5DDhMoTCEDw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cyberalien/redundancy": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6"
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"@iconify/types": {
|
||||
@ -9815,6 +9827,15 @@
|
||||
"integrity": "sha512-eG74WPaqjBGnZ3Xy36X4LRDA/ZlhCK6T0zbsAAIYObY2Qija/379iXx+e2wWwEIXS46B62nGaUcuI0MpUnTSrg==",
|
||||
"dev": true
|
||||
},
|
||||
"@iconify/utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-1.0.0.tgz",
|
||||
"integrity": "sha512-0JWDeQ7lX8X12ZikX1+lIY5x6ObfmFRevSFtGVCySRynlcFAvoRqwHIaxnc3vv4alx0g+zepixeNUjM/l7f8hg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
|
@ -25,8 +25,9 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.14.0",
|
||||
"@iconify/core": "^1.0.1",
|
||||
"@iconify/core": "^1.1.0",
|
||||
"@iconify/types": "^1.0.6",
|
||||
"@iconify/utils": "^1.0.0",
|
||||
"@microsoft/api-extractor": "^7.15.0",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
|
@ -6,7 +6,7 @@ import type {
|
||||
IconifyIconSize,
|
||||
IconifyHorizontalIconAlignment,
|
||||
IconifyVerticalIconAlignment,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
IconifyStorageFunctions,
|
||||
storageFunctions,
|
||||
@ -18,7 +18,7 @@ import {
|
||||
builderFunctions,
|
||||
} from '@iconify/core/lib/builder/functions';
|
||||
import type { IconifyIconBuildResult } from '@iconify/core/lib/builder';
|
||||
import { fullIcon, IconifyIcon } from '@iconify/core/lib/icon';
|
||||
import { fullIcon, IconifyIcon } from '@iconify/utils/lib/icon';
|
||||
|
||||
// Modules
|
||||
import { coreModules } from '@iconify/core/lib/modules';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
||||
import { fullIcon } from '@iconify/core/lib/icon';
|
||||
import { fullIcon } from '@iconify/utils/lib/icon';
|
||||
import { parseIconSet } from '@iconify/core/lib/icon/icon-set';
|
||||
import { render } from './render';
|
||||
import type { RenderResult } from './render';
|
||||
|
@ -1,11 +1,10 @@
|
||||
// Types
|
||||
export type { IconifyJSON } from '@iconify/types';
|
||||
export type { IconifyIcon } from '@iconify/core/lib/icon';
|
||||
export type { IconifyJSON, IconifyIcon } from '@iconify/types';
|
||||
export type {
|
||||
IconifyIconSize,
|
||||
IconifyHorizontalIconAlignment,
|
||||
IconifyVerticalIconAlignment,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
|
||||
// Types from props.ts
|
||||
export type { IconifyIconCustomisations, IconProps } from './props';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { IconifyIcon } from '@iconify/types';
|
||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/core/lib/customisations';
|
||||
import type { IconifyIconCustomisations as RawIconCustomisations } from '@iconify/utils/lib/customisations';
|
||||
|
||||
export { RawIconCustomisations };
|
||||
|
||||
|
@ -2,15 +2,14 @@ import type { IconifyIcon } from '@iconify/types';
|
||||
import {
|
||||
defaults,
|
||||
mergeCustomisations,
|
||||
} from '@iconify/core/lib/customisations';
|
||||
} from '@iconify/utils/lib/customisations';
|
||||
import {
|
||||
flipFromString,
|
||||
alignmentFromString,
|
||||
} from '@iconify/core/lib/customisations/shorthand';
|
||||
import { rotateFromString } from '@iconify/core/lib/customisations/rotate';
|
||||
} from '@iconify/utils/lib/customisations/shorthand';
|
||||
import { rotateFromString } from '@iconify/utils/lib/customisations/rotate';
|
||||
import { iconToSVG } from '@iconify/core/lib/builder';
|
||||
import { replaceIDs } from '@iconify/core/lib/builder/ids';
|
||||
import { merge } from '@iconify/core/lib/misc/merge';
|
||||
import { replaceIDs } from '@iconify/utils/lib/svg/id';
|
||||
import type { IconProps } from './props';
|
||||
|
||||
/**
|
||||
@ -44,7 +43,7 @@ export function render(
|
||||
defaults,
|
||||
props as typeof defaults
|
||||
);
|
||||
const componentProps = merge(svgDefaults) as Record<string, unknown>;
|
||||
const componentProps = { ...svgDefaults } as Record<string, unknown>;
|
||||
|
||||
// Create style if missing
|
||||
let style = typeof props.style === 'string' ? props.style : '';
|
||||
|
13
packages/utils/.editorconfig
Normal file
13
packages/utils/.editorconfig
Normal file
@ -0,0 +1,13 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[{*.json,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
8
packages/utils/.gitignore
vendored
Normal file
8
packages/utils/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
.idea
|
||||
.DS_Store
|
||||
*.map
|
||||
node_modules
|
||||
npm-debug.log
|
||||
yarn.lock
|
||||
lib
|
||||
tests-compiled
|
9
packages/utils/.npmignore
Normal file
9
packages/utils/.npmignore
Normal file
@ -0,0 +1,9 @@
|
||||
.idea
|
||||
.DS_Store
|
||||
*.map
|
||||
node_modules
|
||||
npm-debug.log
|
||||
yarn.lock
|
||||
src
|
||||
tests
|
||||
tests-compiled
|
8
packages/utils/.prettierrc
Normal file
8
packages/utils/.prettierrc
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"trailingComma": "es5",
|
||||
"singleQuote": true,
|
||||
"useTabs": true,
|
||||
"semi": true,
|
||||
"quoteProps": "consistent",
|
||||
"endOfLine": "lf"
|
||||
}
|
21
packages/utils/license.txt
Normal file
21
packages/utils/license.txt
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Vjacheslav Trushkin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
2008
packages/utils/package-lock.json
generated
Normal file
2008
packages/utils/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
33
packages/utils/package.json
Normal file
33
packages/utils/package.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@iconify/utils",
|
||||
"description": "Common functions for working with Iconify icon sets used by various packages.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/iconify/iconify.git",
|
||||
"directory": "packages/utils"
|
||||
},
|
||||
"scripts": {
|
||||
"cleanup": "rm -rf lib compiled-tests",
|
||||
"lint": "npx eslint {src,tests}/**/*.ts",
|
||||
"build": "npx tsc -b",
|
||||
"build:src": "npx tsc --project src/tsconfig.json",
|
||||
"test": "npx mocha tests-compiled/*-test.js",
|
||||
"pretest": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@iconify/types": "^1.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.18",
|
||||
"@types/mocha": "^8.2.2",
|
||||
"@types/node": "^15.3.0",
|
||||
"chai": "^4.3.4",
|
||||
"mocha": "^8.4.0",
|
||||
"typescript": "^4.2.4"
|
||||
}
|
||||
}
|
19
packages/utils/readme.md
Normal file
19
packages/utils/readme.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Iconify Utils
|
||||
|
||||
This is a set of helper functions that deal with Iconify icon sets.
|
||||
|
||||
Functions are split into a separate library because they are reused in many projects.
|
||||
|
||||
## Installation
|
||||
|
||||
To install the library run this command:
|
||||
|
||||
```
|
||||
npm install @iconify/utils --save
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
The library is released with MIT license.
|
||||
|
||||
© 2021 Vjacheslav Trushkin / Iconify OÜ
|
27
packages/utils/src/icon-set/expand.ts
Normal file
27
packages/utils/src/icon-set/expand.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
import { minifyProps } from '../icon';
|
||||
|
||||
/**
|
||||
* Expand minified icon set
|
||||
*
|
||||
* Opposite of minifyIconSet() from ./minify.ts
|
||||
*/
|
||||
export function expandIconSet(data: IconifyJSON): void {
|
||||
const icons = Object.keys(data.icons);
|
||||
|
||||
minifyProps.forEach((prop) => {
|
||||
if (typeof data[prop] !== 'number') {
|
||||
return;
|
||||
}
|
||||
const value = data[prop];
|
||||
|
||||
icons.forEach((name) => {
|
||||
const item = data.icons[name];
|
||||
if (item[prop] === void 0) {
|
||||
item[prop] = value;
|
||||
}
|
||||
});
|
||||
|
||||
delete data[prop];
|
||||
});
|
||||
}
|
124
packages/utils/src/icon-set/index.ts
Normal file
124
packages/utils/src/icon-set/index.ts
Normal file
@ -0,0 +1,124 @@
|
||||
import type { IconifyIcon, IconifyJSON } from '@iconify/types';
|
||||
import { propsToCopy, fullIcon } from '../icon';
|
||||
import { mergeIconData } from '../icon/merge';
|
||||
|
||||
/**
|
||||
* Extract icons from icon set
|
||||
*/
|
||||
export function getIcons(
|
||||
data: IconifyJSON,
|
||||
icons: string[],
|
||||
not_found?: boolean
|
||||
): IconifyJSON | null {
|
||||
const result: IconifyJSON = {
|
||||
prefix: data.prefix,
|
||||
icons: Object.create(null),
|
||||
};
|
||||
const tested: Set<string> = new Set();
|
||||
let empty = true;
|
||||
|
||||
function copy(name: string, iteration: number): boolean {
|
||||
if (iteration > 5 || tested.has(name)) {
|
||||
// Already copied or too much nesting
|
||||
return true;
|
||||
}
|
||||
tested.add(name);
|
||||
|
||||
// Check for icon
|
||||
if (data.icons[name] !== void 0) {
|
||||
empty = false;
|
||||
result.icons[name] = { ...data.icons[name] };
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for alias
|
||||
if (data.aliases?.[name] !== void 0) {
|
||||
const copied = copy(data.aliases[name].parent, iteration + 1);
|
||||
if (copied) {
|
||||
if (result.aliases === void 0) {
|
||||
result.aliases = Object.create(null);
|
||||
}
|
||||
result.aliases![name] = { ...data.aliases[name] };
|
||||
}
|
||||
return copied;
|
||||
}
|
||||
|
||||
// Check for character, return as alias
|
||||
if (data.chars?.[name] !== void 0) {
|
||||
const parent = data.chars?.[name];
|
||||
const copied = copy(parent, iteration + 1);
|
||||
if (copied) {
|
||||
if (result.aliases === void 0) {
|
||||
result.aliases = Object.create(null);
|
||||
}
|
||||
result.aliases![name] = {
|
||||
parent,
|
||||
};
|
||||
}
|
||||
return copied;
|
||||
}
|
||||
|
||||
// Not found
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copy common properties
|
||||
propsToCopy.forEach((attr) => {
|
||||
if (data[attr] !== void 0) {
|
||||
(result as unknown as Record<string, unknown>)[attr] = data[attr];
|
||||
}
|
||||
});
|
||||
|
||||
// Copy all icons
|
||||
icons.forEach((name) => {
|
||||
if (!copy(name, 0) && not_found === true) {
|
||||
if (result.not_found === void 0) {
|
||||
result.not_found = [];
|
||||
}
|
||||
result.not_found.push(name);
|
||||
}
|
||||
});
|
||||
|
||||
return empty && not_found !== true ? null : result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for icon
|
||||
*/
|
||||
export function getIconData(
|
||||
data: IconifyJSON,
|
||||
name: string,
|
||||
full = false
|
||||
): IconifyIcon | null {
|
||||
function getIcon(name: string, iteration: number): IconifyIcon | null {
|
||||
if (data.icons[name] !== void 0) {
|
||||
// Return icon
|
||||
return Object.assign({}, data.icons[name]);
|
||||
}
|
||||
|
||||
// Check loop
|
||||
if (iteration > 5) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if alias exists
|
||||
if (data.aliases?.[name] !== void 0) {
|
||||
const item = data.aliases?.[name];
|
||||
const result = getIcon(item.parent, iteration + 1);
|
||||
if (result) {
|
||||
mergeIconData(result, item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if character exists
|
||||
if (iteration === 0 && data.chars?.[name] !== void 0) {
|
||||
return getIcon(data.chars?.[name], iteration + 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const result = getIcon(name, 0);
|
||||
return result && full ? fullIcon(result) : result;
|
||||
}
|
136
packages/utils/src/icon-set/minify.ts
Normal file
136
packages/utils/src/icon-set/minify.ts
Normal file
@ -0,0 +1,136 @@
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
import { minifyProps, iconDefaults } from '../icon';
|
||||
|
||||
/**
|
||||
* Minify icon set
|
||||
*
|
||||
* Function finds common values for few numeric properties, such as 'width' and 'height' (see minifyProps for list of properties),
|
||||
* removes entries from icons and sets default entry in root of icon set object.
|
||||
*
|
||||
* For example, this:
|
||||
* {
|
||||
* icons: {
|
||||
* foo: {
|
||||
* body: '<g />',
|
||||
* width: 24
|
||||
* },
|
||||
* bar: {
|
||||
* body: '<g />',
|
||||
* width: 24
|
||||
* },
|
||||
* baz: {
|
||||
* body: '<g />',
|
||||
* width: 16
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* is changed to this:
|
||||
* {
|
||||
* icons: {
|
||||
* foo: {
|
||||
* body: '<g />'
|
||||
* },
|
||||
* bar: {
|
||||
* body: '<g />'
|
||||
* },
|
||||
* baz: {
|
||||
* body: '<g />',
|
||||
* width: 16
|
||||
* }
|
||||
* },
|
||||
* width: 24
|
||||
* }
|
||||
*/
|
||||
export function minifyIconSet(data: IconifyJSON): void {
|
||||
const icons = Object.keys(data.icons);
|
||||
|
||||
minifyProps.forEach((prop) => {
|
||||
// Check for default value for property
|
||||
const hasIconDefault = typeof iconDefaults[prop] === 'number';
|
||||
if (hasIconDefault && data[prop] === iconDefaults[prop]) {
|
||||
delete data[prop];
|
||||
}
|
||||
|
||||
// Check for previously minified value
|
||||
const hasMinifiedDefault = typeof data[prop] === 'number';
|
||||
|
||||
// Find value that is used by most icons
|
||||
let maxCount = 0,
|
||||
maxValue: number | null = null,
|
||||
counters: Map<number, number> = new Map();
|
||||
|
||||
for (let i = 0; i < icons.length; i++) {
|
||||
let item = data.icons[icons[i]];
|
||||
|
||||
let value: number;
|
||||
if (typeof item[prop] === 'number') {
|
||||
value = item[prop]!;
|
||||
} else if (hasMinifiedDefault) {
|
||||
value = data[prop]!;
|
||||
} else if (hasIconDefault) {
|
||||
value = iconDefaults[prop];
|
||||
} else {
|
||||
// Cannot minify property
|
||||
maxValue = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i === 0) {
|
||||
// First item
|
||||
maxCount = 1;
|
||||
maxValue = value;
|
||||
counters.set(value, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!counters.has(value)) {
|
||||
// First entry for new value
|
||||
counters.set(value, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
const count = counters.get(value)! + 1;
|
||||
counters.set(value, count);
|
||||
if (count > maxCount) {
|
||||
maxCount = count;
|
||||
maxValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Found value to minify
|
||||
const canMinify = maxValue !== null && maxCount > 1;
|
||||
const oldDefault = hasMinifiedDefault ? data[prop] : null;
|
||||
|
||||
// Change global value
|
||||
if (!canMinify) {
|
||||
delete data[prop];
|
||||
} else {
|
||||
data[prop] = maxValue!;
|
||||
}
|
||||
|
||||
// Check if new minified value matches default value
|
||||
if (hasIconDefault && data[prop] === iconDefaults[prop]) {
|
||||
delete data[prop];
|
||||
}
|
||||
|
||||
// Minify stuff
|
||||
icons.forEach((key) => {
|
||||
const item = data.icons[key];
|
||||
if (canMinify && item[prop] === maxValue) {
|
||||
// New value matches minified value
|
||||
delete item[prop];
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasMinifiedDefault && item[prop] === void 0) {
|
||||
// Old value matches old minified value
|
||||
item[prop] = oldDefault!;
|
||||
}
|
||||
|
||||
if (!canMinify && item[prop] === iconDefaults[prop]) {
|
||||
// Current value (after changes above) matches default and there is no minified value
|
||||
delete item[prop];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
326
packages/utils/src/icon-set/validate.ts
Normal file
326
packages/utils/src/icon-set/validate.ts
Normal file
@ -0,0 +1,326 @@
|
||||
import type { IconifyJSON, IconifyOptional } from '@iconify/types';
|
||||
import { minifyProps, matchName } from '../icon';
|
||||
|
||||
/**
|
||||
* Match character
|
||||
*/
|
||||
export const matchChar = /^[a-f0-9]+(-[a-f0-9]+)*$/;
|
||||
|
||||
/**
|
||||
* Validate icon
|
||||
*
|
||||
* Returns name of property that failed validation or null on success
|
||||
*/
|
||||
function validateIconProps(item: IconifyOptional, fix: boolean): string | null {
|
||||
// Check other properties
|
||||
for (const key in item) {
|
||||
const attr = key as keyof typeof item;
|
||||
const value = item[attr];
|
||||
const type = typeof value;
|
||||
|
||||
if (type === 'undefined') {
|
||||
// Undefined was passed ???
|
||||
delete item[attr];
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case 'body':
|
||||
case 'parent':
|
||||
if (type !== 'string') {
|
||||
return key;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'hFlip':
|
||||
case 'vFlip':
|
||||
case 'hidden':
|
||||
if (type !== 'boolean') {
|
||||
if (fix) {
|
||||
delete item[attr];
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'width':
|
||||
case 'height':
|
||||
case 'left':
|
||||
case 'top':
|
||||
case 'rotate':
|
||||
// Legacy properties
|
||||
case 'inlineHeight':
|
||||
case 'inlineTop':
|
||||
case 'verticalAlign':
|
||||
if (type !== 'number') {
|
||||
if (fix) {
|
||||
delete item[attr];
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unknown property, make sure its not object
|
||||
if (type === 'object') {
|
||||
if (fix) {
|
||||
delete item[attr];
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export interface IconSetValidationOptions {
|
||||
// If true, validation function will attempt to fix icon set instead of throwing errors.
|
||||
fix?: boolean;
|
||||
|
||||
// Values for provider and prefix. If missing, validation should add them.
|
||||
prefix?: string;
|
||||
provider?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate icon set, return it as IconifyJSON type on success, throw error on failure
|
||||
*/
|
||||
export function validateIconSet(
|
||||
obj: unknown,
|
||||
options?: IconSetValidationOptions
|
||||
): IconifyJSON {
|
||||
const fix = !!options?.fix;
|
||||
|
||||
// Check for object with 'icons' nested object
|
||||
if (
|
||||
typeof obj !== 'object' ||
|
||||
obj === null ||
|
||||
typeof (obj as Record<string, unknown>).icons !== 'object' ||
|
||||
!(obj as Record<string, unknown>).icons
|
||||
) {
|
||||
throw new Error('Bad icon set');
|
||||
}
|
||||
|
||||
// Convert type
|
||||
const data = obj as IconifyJSON;
|
||||
|
||||
// Set or validate prefix
|
||||
if (typeof options?.prefix === 'string') {
|
||||
data.prefix = options.prefix;
|
||||
} else if (
|
||||
typeof data.prefix !== 'string' ||
|
||||
!data.prefix.match(matchName)
|
||||
) {
|
||||
throw new Error('Invalid prefix');
|
||||
}
|
||||
|
||||
// Set or validate provider
|
||||
if (typeof options?.provider === 'string') {
|
||||
data.provider = options.provider;
|
||||
} else if (data.provider !== void 0) {
|
||||
const value = data.provider;
|
||||
if (
|
||||
typeof value !== 'string' ||
|
||||
(value !== '' && !value.match(matchName))
|
||||
) {
|
||||
if (fix) {
|
||||
delete data.provider;
|
||||
} else {
|
||||
throw new Error('Invalid provider');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate all icons
|
||||
const icons = data.icons;
|
||||
Object.keys(icons).forEach((name) => {
|
||||
if (!name.match(matchName)) {
|
||||
if (fix) {
|
||||
delete icons[name];
|
||||
return;
|
||||
}
|
||||
throw new Error(`Invalid icon name: "${name}"`);
|
||||
}
|
||||
|
||||
const item = icons[name];
|
||||
if (
|
||||
typeof item !== 'object' ||
|
||||
item === null ||
|
||||
typeof item.body !== 'string'
|
||||
) {
|
||||
if (fix) {
|
||||
delete icons[name];
|
||||
return;
|
||||
}
|
||||
throw new Error(`Invalid icon: "${name}"`);
|
||||
}
|
||||
|
||||
// Check other properties
|
||||
const key =
|
||||
typeof (item as unknown as Record<string, unknown>).parent ===
|
||||
'string'
|
||||
? 'parent'
|
||||
: validateIconProps(item, fix);
|
||||
if (key !== null) {
|
||||
if (fix) {
|
||||
delete icons[name];
|
||||
return;
|
||||
}
|
||||
throw new Error(`Invalid property "${key}" in icon "${name}"`);
|
||||
}
|
||||
});
|
||||
|
||||
// Make sure icons list is not empty
|
||||
if (!Object.keys(data.icons).length) {
|
||||
throw new Error('Icon set is empty');
|
||||
}
|
||||
|
||||
// Validate aliases
|
||||
if (data.aliases !== void 0) {
|
||||
if (typeof data.aliases !== 'object' || data.aliases === null) {
|
||||
if (fix) {
|
||||
delete data.aliases;
|
||||
} else {
|
||||
throw new Error('Invalid aliases list');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof data.aliases === 'object') {
|
||||
const aliases = data.aliases;
|
||||
const validatedAliases: Set<string> = new Set();
|
||||
const failedAliases: Set<string> = new Set();
|
||||
|
||||
function validateAlias(name: string, iteration: number): boolean {
|
||||
// Check if alias has already been validated
|
||||
if (validatedAliases.has(name)) {
|
||||
return !failedAliases.has(name);
|
||||
}
|
||||
|
||||
const item = aliases[name];
|
||||
if (
|
||||
// Loop or very long chain: invalidate all aliases
|
||||
iteration > 5 ||
|
||||
// Check if value is a valid object
|
||||
typeof item !== 'object' ||
|
||||
item === null ||
|
||||
typeof item.parent !== 'string' ||
|
||||
// Check if name is valid
|
||||
!name.match(matchName)
|
||||
) {
|
||||
if (fix) {
|
||||
delete aliases[name];
|
||||
failedAliases.add(name);
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Invalid icon alias: "${name}"`);
|
||||
}
|
||||
|
||||
// Check if parent icon/alias exists
|
||||
const parent = item.parent;
|
||||
if (data.icons[parent] === void 0) {
|
||||
// Check for parent alias
|
||||
if (
|
||||
aliases[parent] === void 0 ||
|
||||
!validateAlias(parent, iteration + 1)
|
||||
) {
|
||||
if (fix) {
|
||||
delete aliases[name];
|
||||
failedAliases.add(name);
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Missing parent icon for alias "${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Check other properties
|
||||
if (
|
||||
fix &&
|
||||
(item as unknown as Record<string, unknown>).body !== void 0
|
||||
) {
|
||||
delete (item as unknown as Record<string, unknown>).body;
|
||||
}
|
||||
const key =
|
||||
(item as unknown as Record<string, unknown>).body !== void 0
|
||||
? 'body'
|
||||
: validateIconProps(item, fix);
|
||||
if (key !== null) {
|
||||
if (fix) {
|
||||
delete aliases[name];
|
||||
failedAliases.add(name);
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Invalid property "${key}" in alias "${name}"`);
|
||||
}
|
||||
|
||||
validatedAliases.add(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
Object.keys(aliases).forEach((name) => {
|
||||
validateAlias(name, 0);
|
||||
});
|
||||
|
||||
// Delete empty aliases object
|
||||
if (fix && !Object.keys(data.aliases).length) {
|
||||
delete data.aliases;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate all properties that can be optimised, must be numbers
|
||||
minifyProps.forEach((prop) => {
|
||||
if (
|
||||
data[prop as keyof IconifyJSON] !== void 0 &&
|
||||
typeof data[prop as keyof IconifyJSON] !== 'number'
|
||||
) {
|
||||
throw new Error(`Invalid value type for "${prop}"`);
|
||||
}
|
||||
});
|
||||
|
||||
// Validate characters map
|
||||
if (data.chars !== void 0) {
|
||||
if (typeof data.chars !== 'object' || data.chars === null) {
|
||||
if (fix) {
|
||||
delete data.chars;
|
||||
} else {
|
||||
throw new Error('Invalid characters map');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof data.chars === 'object') {
|
||||
const chars = data.chars;
|
||||
Object.keys(chars).forEach((char) => {
|
||||
if (!char.match(matchChar) || typeof chars[char] !== 'string') {
|
||||
if (fix) {
|
||||
delete chars[char];
|
||||
return;
|
||||
}
|
||||
throw new Error(`Invalid character "${char}"`);
|
||||
}
|
||||
const target = chars[char];
|
||||
if (
|
||||
data.icons[target] === void 0 &&
|
||||
data.aliases?.[target] === void 0
|
||||
) {
|
||||
if (fix) {
|
||||
delete chars[char];
|
||||
return;
|
||||
}
|
||||
throw new Error(
|
||||
`Character "${char}" points to missing icon "${target}"`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Delete empty aliases object
|
||||
if (fix && !Object.keys(data.chars).length) {
|
||||
delete data.chars;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
55
packages/utils/src/icon/index.ts
Normal file
55
packages/utils/src/icon/index.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import type {
|
||||
IconifyOptional,
|
||||
IconifyJSON,
|
||||
IconifyDimenisons,
|
||||
IconifyIcon,
|
||||
} from '@iconify/types';
|
||||
|
||||
// Export icon and full icon types
|
||||
export { IconifyIcon };
|
||||
export type FullIconifyIcon = Required<IconifyIcon>;
|
||||
|
||||
/**
|
||||
* Expression to test part of icon name.
|
||||
*/
|
||||
export const matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
||||
|
||||
/**
|
||||
* Properties that can be minified
|
||||
*
|
||||
* Values of all these properties are awalys numbers
|
||||
*/
|
||||
export const minifyProps: (keyof IconifyDimenisons)[] = [
|
||||
// All IconifyDimenisons properties
|
||||
'width',
|
||||
'height',
|
||||
'top',
|
||||
'left',
|
||||
];
|
||||
|
||||
/**
|
||||
* Optional properties that must be copied when copying icon set
|
||||
*/
|
||||
export const propsToCopy: (keyof IconifyJSON)[] = (
|
||||
minifyProps as (keyof IconifyJSON)[]
|
||||
).concat(['provider']);
|
||||
|
||||
/**
|
||||
* Default values for all optional IconifyIcon properties
|
||||
*/
|
||||
export const iconDefaults: Required<IconifyOptional> = Object.freeze({
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: 16,
|
||||
height: 16,
|
||||
rotate: 0,
|
||||
vFlip: false,
|
||||
hFlip: false,
|
||||
});
|
||||
|
||||
/**
|
||||
* Add optional properties to icon
|
||||
*/
|
||||
export function fullIcon(data: IconifyIcon): FullIconifyIcon {
|
||||
return { ...iconDefaults, ...data };
|
||||
}
|
43
packages/utils/src/icon/merge.ts
Normal file
43
packages/utils/src/icon/merge.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import type { IconifyOptional } from '@iconify/types';
|
||||
import type { FullIconifyIcon, IconifyIcon } from '.';
|
||||
import { iconDefaults } from '.';
|
||||
|
||||
/**
|
||||
* Merge icon and alias
|
||||
*/
|
||||
export function mergeIconData<T extends IconifyIcon | FullIconifyIcon>(
|
||||
icon: T,
|
||||
alias: IconifyOptional
|
||||
): T {
|
||||
const result = { ...icon };
|
||||
for (const key in iconDefaults) {
|
||||
const prop = key as keyof IconifyOptional;
|
||||
if (alias[prop] !== void 0) {
|
||||
const value = alias[prop];
|
||||
|
||||
if (result[prop] === void 0) {
|
||||
// Missing value
|
||||
(result as unknown as Record<string, unknown>)[prop] = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (prop) {
|
||||
case 'rotate':
|
||||
(result[prop] as number) =
|
||||
((result[prop] as number) + (value as number)) % 4;
|
||||
break;
|
||||
|
||||
case 'hFlip':
|
||||
case 'vFlip':
|
||||
result[prop] = value !== result[prop];
|
||||
break;
|
||||
|
||||
default:
|
||||
// Overwrite value
|
||||
(result as unknown as Record<string, unknown>)[prop] =
|
||||
value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
0
packages/utils/src/svg/build.ts
Normal file
0
packages/utils/src/svg/build.ts
Normal file
@ -54,7 +54,7 @@ export function replaceIDs(
|
||||
}
|
||||
|
||||
// Replace with unique ids
|
||||
ids.forEach(id => {
|
||||
ids.forEach((id) => {
|
||||
const newID =
|
||||
typeof prefix === 'function' ? prefix() : prefix + counter++;
|
||||
body = strReplace('="' + id + '"', '="' + newID + '"', body);
|
7
packages/utils/src/tsconfig.json
Normal file
7
packages/utils/src/tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../lib",
|
||||
"rootDir": "."
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { calculateSize } from '../../lib/builder/calc-size';
|
||||
import { calculateSize } from '../lib/svg/size';
|
||||
|
||||
describe('Testing calcSize', () => {
|
||||
it('Simple size', () => {
|
51
packages/utils/tests/get-icon-data-test.ts
Normal file
51
packages/utils/tests/get-icon-data-test.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { getIconData } from '../lib/icon-set';
|
||||
|
||||
describe('Testing getting icon data', () => {
|
||||
it('Simple icon', () => {
|
||||
// Short icon
|
||||
const result1 = getIconData(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
},
|
||||
},
|
||||
},
|
||||
'bar',
|
||||
false
|
||||
);
|
||||
expect(result1).to.be.eql({
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
});
|
||||
|
||||
// Full icon
|
||||
const result2 = getIconData(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
},
|
||||
},
|
||||
},
|
||||
'bar',
|
||||
true
|
||||
);
|
||||
expect(result2).to.be.eql({
|
||||
body: '<g />',
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: 24,
|
||||
height: 16,
|
||||
rotate: 0,
|
||||
vFlip: false,
|
||||
hFlip: false,
|
||||
});
|
||||
});
|
||||
});
|
183
packages/utils/tests/get-icons-test.ts
Normal file
183
packages/utils/tests/get-icons-test.ts
Normal file
@ -0,0 +1,183 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { getIcons } from '../lib/icon-set';
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
|
||||
describe('Testing retrieving icons from icon set', () => {
|
||||
it('Simple icon set', () => {
|
||||
const data: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g id="bar" />',
|
||||
},
|
||||
baz: {
|
||||
body: '<g id="baz" />',
|
||||
},
|
||||
foo: {
|
||||
body: '<g id="foo" />',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Missing icon
|
||||
expect(getIcons(data, ['missing-icon'])).to.be.eql(null);
|
||||
|
||||
expect(getIcons(data, ['missing-icon'], true)).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {},
|
||||
not_found: ['missing-icon'],
|
||||
});
|
||||
|
||||
// Icon
|
||||
expect(getIcons(data, ['bar'])).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g id="bar" />',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Same icon multiple times
|
||||
expect(getIcons(data, ['bar', 'bar', 'bar'])).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g id="bar" />',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Mutliple icons
|
||||
expect(getIcons(data, ['foo', 'bar'])).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g id="bar" />',
|
||||
},
|
||||
foo: {
|
||||
body: '<g id="foo" />',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('Aliases and characters', () => {
|
||||
const data: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
bar2: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
'foo': {
|
||||
parent: 'bar',
|
||||
hFlip: true,
|
||||
},
|
||||
'foo2': {
|
||||
parent: 'foo',
|
||||
},
|
||||
'missing-alias': {
|
||||
parent: 'missing-icon',
|
||||
},
|
||||
},
|
||||
chars: {
|
||||
f00: 'bar2',
|
||||
f01: 'bar',
|
||||
f02: 'foo',
|
||||
f03: 'foo2',
|
||||
f04: 'missing-icon',
|
||||
},
|
||||
};
|
||||
|
||||
// Alias
|
||||
expect(getIcons(data, ['foo'])).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
foo: {
|
||||
parent: 'bar',
|
||||
hFlip: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Alias of alias
|
||||
expect(getIcons(data, ['foo2'])).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
foo: {
|
||||
parent: 'bar',
|
||||
hFlip: true,
|
||||
},
|
||||
foo2: {
|
||||
parent: 'foo',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Bad alias
|
||||
expect(getIcons(data, ['missing-alias'])).to.be.equal(null);
|
||||
expect(getIcons(data, ['missing-alias'], true)).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {},
|
||||
not_found: ['missing-alias'],
|
||||
});
|
||||
|
||||
// Character
|
||||
expect(getIcons(data, ['f00'])).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar2: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
f00: {
|
||||
parent: 'bar2',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Character that points to alias
|
||||
expect(getIcons(data, ['f02'])).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
f02: {
|
||||
parent: 'foo',
|
||||
},
|
||||
foo: {
|
||||
parent: 'bar',
|
||||
hFlip: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Bad character
|
||||
expect(getIcons(data, ['f04'])).to.be.equal(null);
|
||||
expect(getIcons(data, ['f04'], true)).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {},
|
||||
not_found: ['f04'],
|
||||
});
|
||||
});
|
||||
});
|
79
packages/utils/tests/merge-icon-data-test.ts
Normal file
79
packages/utils/tests/merge-icon-data-test.ts
Normal file
@ -0,0 +1,79 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { mergeIconData } from '../lib/icon/merge';
|
||||
import type { IconifyIcon } from '@iconify/types';
|
||||
|
||||
describe('Testing merging icon data', () => {
|
||||
it('Test', () => {
|
||||
// Nothing to merge
|
||||
const icon: IconifyIcon = {
|
||||
body: '<g />',
|
||||
};
|
||||
const expected: IconifyIcon = {
|
||||
body: '<g />',
|
||||
};
|
||||
// Check hint manually: supposed to be IconifyIcon
|
||||
const result = mergeIconData(icon, {});
|
||||
expect(result).to.be.eql(expected);
|
||||
|
||||
// TypeScript full icon test
|
||||
const icon2: Required<IconifyIcon> = {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 24,
|
||||
left: 0,
|
||||
top: 0,
|
||||
rotate: 0,
|
||||
hFlip: false,
|
||||
vFlip: false,
|
||||
};
|
||||
const expected2: Required<IconifyIcon> = {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 24,
|
||||
left: 0,
|
||||
top: 0,
|
||||
rotate: 0,
|
||||
hFlip: false,
|
||||
vFlip: false,
|
||||
};
|
||||
// Check hint manually: supposed to be Required<IconifyIcon>
|
||||
const result2 = mergeIconData(icon2, {});
|
||||
expect(result2).to.be.eql(expected2);
|
||||
|
||||
// Copy values
|
||||
expect(
|
||||
mergeIconData(
|
||||
{
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
},
|
||||
{
|
||||
height: 32,
|
||||
}
|
||||
)
|
||||
).to.be.eql({
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 32,
|
||||
});
|
||||
|
||||
// Override values
|
||||
expect(
|
||||
mergeIconData(
|
||||
{
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 24,
|
||||
},
|
||||
{
|
||||
height: 32,
|
||||
}
|
||||
)
|
||||
).to.be.eql({
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 32,
|
||||
});
|
||||
});
|
||||
});
|
198
packages/utils/tests/minify-test.ts
Normal file
198
packages/utils/tests/minify-test.ts
Normal file
@ -0,0 +1,198 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { minifyIconSet } from '../lib/icon-set/minify';
|
||||
import type { IconifyJSON } from '@iconify/types';
|
||||
|
||||
describe('Testing minifying icon set', () => {
|
||||
it('Nothing to minify', () => {
|
||||
const item: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
foo: {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 24,
|
||||
},
|
||||
},
|
||||
};
|
||||
const expected: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
foo: {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 24,
|
||||
},
|
||||
},
|
||||
};
|
||||
minifyIconSet(item);
|
||||
expect(item).to.be.eql(expected);
|
||||
});
|
||||
|
||||
it('No common values', () => {
|
||||
const item: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
'foo-24': {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 24,
|
||||
},
|
||||
'foo-16': {
|
||||
body: '<g />',
|
||||
width: 12,
|
||||
height: 12,
|
||||
},
|
||||
},
|
||||
};
|
||||
const expected: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
'foo-24': {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 24,
|
||||
},
|
||||
'foo-16': {
|
||||
body: '<g />',
|
||||
width: 12,
|
||||
height: 12,
|
||||
},
|
||||
},
|
||||
};
|
||||
minifyIconSet(item);
|
||||
expect(item).to.be.eql(expected);
|
||||
});
|
||||
|
||||
it('Default values', () => {
|
||||
const item: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
foo: {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
// Height matches default
|
||||
height: 16,
|
||||
},
|
||||
bar: {
|
||||
body: '<g />',
|
||||
// Width matches default
|
||||
width: 16,
|
||||
height: 12,
|
||||
},
|
||||
},
|
||||
};
|
||||
const expected: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
foo: {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
},
|
||||
bar: {
|
||||
body: '<g />',
|
||||
height: 12,
|
||||
},
|
||||
},
|
||||
};
|
||||
minifyIconSet(item);
|
||||
expect(item).to.be.eql(expected);
|
||||
});
|
||||
|
||||
it('Common value', () => {
|
||||
const item: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
// 2 icons have the same height, 2 icons have the same width
|
||||
'foo-wide': {
|
||||
body: '<g />',
|
||||
width: 32,
|
||||
height: 24,
|
||||
},
|
||||
'foo-square': {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 24,
|
||||
},
|
||||
'foo-tiny-wide': {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 16,
|
||||
},
|
||||
'foo-tiny-square': {
|
||||
body: '<g />',
|
||||
width: 16,
|
||||
height: 16,
|
||||
},
|
||||
},
|
||||
};
|
||||
const expected: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
'foo-wide': {
|
||||
body: '<g />',
|
||||
width: 32,
|
||||
},
|
||||
'foo-square': {
|
||||
body: '<g />',
|
||||
},
|
||||
'foo-tiny-wide': {
|
||||
body: '<g />',
|
||||
height: 16,
|
||||
},
|
||||
'foo-tiny-square': {
|
||||
body: '<g />',
|
||||
width: 16,
|
||||
height: 16,
|
||||
},
|
||||
},
|
||||
width: 24,
|
||||
height: 24,
|
||||
};
|
||||
minifyIconSet(item);
|
||||
expect(item).to.be.eql(expected);
|
||||
});
|
||||
|
||||
it('Common value that matches default', () => {
|
||||
const item: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
// 2 icons have the same height of 16, which is default value
|
||||
'foo-wide': {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
height: 16,
|
||||
},
|
||||
'foo-square': {
|
||||
body: '<g />',
|
||||
width: 16,
|
||||
height: 16,
|
||||
},
|
||||
'foo-tiny': {
|
||||
body: '<g />',
|
||||
width: 12,
|
||||
height: 16,
|
||||
},
|
||||
},
|
||||
};
|
||||
const expected: IconifyJSON = {
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
'foo-wide': {
|
||||
body: '<g />',
|
||||
width: 24,
|
||||
},
|
||||
'foo-square': {
|
||||
body: '<g />',
|
||||
// Should not have width because it matches default value
|
||||
},
|
||||
'foo-tiny': {
|
||||
body: '<g />',
|
||||
width: 12,
|
||||
},
|
||||
},
|
||||
};
|
||||
minifyIconSet(item);
|
||||
expect(item).to.be.eql(expected);
|
||||
});
|
||||
});
|
8
packages/utils/tests/tsconfig.json
Normal file
8
packages/utils/tests/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"types": ["node", "mocha"],
|
||||
"outDir": "../tests-compiled",
|
||||
"rootDir": "."
|
||||
}
|
||||
}
|
333
packages/utils/tests/validate-alias-test.ts
Normal file
333
packages/utils/tests/validate-alias-test.ts
Normal file
@ -0,0 +1,333 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { validateIconSet } from '../lib/icon-set/validate';
|
||||
|
||||
describe('Testing validating alias', () => {
|
||||
it('Empty', () => {
|
||||
expect(
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {},
|
||||
})
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {},
|
||||
});
|
||||
|
||||
// Fix it
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {},
|
||||
},
|
||||
{ fix: true }
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('Null', (done) => {
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: null,
|
||||
});
|
||||
done('Expected to throw error when aliases is null');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
// Fix it
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: null,
|
||||
},
|
||||
{ fix: true }
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('Invalid parent', (done) => {
|
||||
try {
|
||||
const result = validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'missing',
|
||||
},
|
||||
},
|
||||
});
|
||||
done(
|
||||
'Expected to throw error when alias has missing parent, got ' +
|
||||
JSON.stringify(result)
|
||||
);
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
// Fix it
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'missing',
|
||||
},
|
||||
},
|
||||
},
|
||||
{ fix: true }
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('Invalid parent, 2 levels', (done) => {
|
||||
try {
|
||||
const result = validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'missing',
|
||||
},
|
||||
baz2: {
|
||||
parent: 'baz',
|
||||
},
|
||||
},
|
||||
});
|
||||
done(
|
||||
'Expected to throw error when alias has missing parent, got ' +
|
||||
JSON.stringify(result)
|
||||
);
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
// Fix it
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'missing',
|
||||
},
|
||||
baz2: {
|
||||
parent: 'baz',
|
||||
},
|
||||
},
|
||||
},
|
||||
{ fix: true }
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('Invalid parent, 2 levels, reverse order', (done) => {
|
||||
try {
|
||||
const result = validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'baz2',
|
||||
},
|
||||
baz2: {
|
||||
parent: 'missing',
|
||||
},
|
||||
},
|
||||
});
|
||||
done(
|
||||
'Expected to throw error when alias has missing parent, got ' +
|
||||
JSON.stringify(result)
|
||||
);
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
// Fix it
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'baz2',
|
||||
},
|
||||
baz2: {
|
||||
parent: 'missing',
|
||||
},
|
||||
},
|
||||
},
|
||||
{ fix: true }
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('Parent loop', (done) => {
|
||||
try {
|
||||
const result = validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'baz2',
|
||||
},
|
||||
baz2: {
|
||||
parent: 'baz',
|
||||
},
|
||||
baz3: {
|
||||
parent: 'bar',
|
||||
},
|
||||
},
|
||||
});
|
||||
done(
|
||||
'Expected to throw error when alias has missing parent, got ' +
|
||||
JSON.stringify(result)
|
||||
);
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
// Fix it
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'baz2',
|
||||
},
|
||||
baz2: {
|
||||
parent: 'baz',
|
||||
},
|
||||
baz3: {
|
||||
parent: 'bar',
|
||||
},
|
||||
},
|
||||
},
|
||||
{ fix: true }
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz3: {
|
||||
parent: 'bar',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
406
packages/utils/tests/validate-icon-test.ts
Normal file
406
packages/utils/tests/validate-icon-test.ts
Normal file
@ -0,0 +1,406 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { validateIconSet } from '../lib/icon-set/validate';
|
||||
|
||||
describe('Testing validating icon', () => {
|
||||
// Add various types for testing
|
||||
const validationValues = new Map();
|
||||
validationValues.set(true, {
|
||||
text: 'true',
|
||||
type: 'boolean',
|
||||
});
|
||||
validationValues.set(false, {
|
||||
text: 'false',
|
||||
type: 'boolean',
|
||||
});
|
||||
validationValues.set(
|
||||
{},
|
||||
{
|
||||
text: 'object',
|
||||
type: 'object',
|
||||
}
|
||||
);
|
||||
validationValues.set([], {
|
||||
text: 'array',
|
||||
type: 'object',
|
||||
});
|
||||
validationValues.set(24, {
|
||||
text: 'number',
|
||||
type: 'number',
|
||||
});
|
||||
validationValues.set(-2, {
|
||||
text: 'negative number',
|
||||
type: 'number',
|
||||
});
|
||||
validationValues.set(0, {
|
||||
text: 'zero',
|
||||
type: 'number',
|
||||
});
|
||||
validationValues.set('test', {
|
||||
text: 'string',
|
||||
type: 'string',
|
||||
});
|
||||
validationValues.set('', {
|
||||
text: 'empty string',
|
||||
type: 'string',
|
||||
});
|
||||
|
||||
// Required string
|
||||
it('body', (done) => {
|
||||
// Missing body
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
width: 16,
|
||||
},
|
||||
},
|
||||
});
|
||||
done('Expected to throw error when body is missing');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
try {
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
width: 16,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fix: true,
|
||||
}
|
||||
);
|
||||
done(
|
||||
'Expected to throw error when body is missing and cannot be fixed'
|
||||
);
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
try {
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
width: 16,
|
||||
},
|
||||
baz: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fix: true,
|
||||
}
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
baz: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
done(
|
||||
'Expected to not throw error when body is missing, but icon set can be fixed'
|
||||
);
|
||||
//
|
||||
}
|
||||
|
||||
validationValues.forEach((item, value) => {
|
||||
// Validate without fixing
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: value,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (item.type !== 'string') {
|
||||
done(`Expected to throw error when body is ${item.text}`);
|
||||
}
|
||||
} catch (err) {
|
||||
if (item.type === 'string') {
|
||||
done(`Expected to pass when body is ${item.text}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to fix (will fail because icon set is empty after failing icon is removed)
|
||||
try {
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: value,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fix: true,
|
||||
}
|
||||
);
|
||||
|
||||
if (item.type !== 'string') {
|
||||
done(`Expected to throw error when body is ${item.text}`);
|
||||
}
|
||||
} catch (err) {
|
||||
if (item.type === 'string') {
|
||||
done(`Expected to pass when body is ${item.text}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to fix (will not fail because another icon is valid)
|
||||
try {
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: value,
|
||||
},
|
||||
baz: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fix: true,
|
||||
}
|
||||
);
|
||||
} catch (err) {
|
||||
done('Expected to pass when another icon is valid');
|
||||
}
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
// Numbers
|
||||
['width', 'height', 'left', 'top', 'rotate'].forEach((prop) => {
|
||||
it(prop, (done) => {
|
||||
// Validate without fixing
|
||||
validationValues.forEach((item, value) => {
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
[prop]: value,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (item.type !== 'number') {
|
||||
done(
|
||||
`Expected to throw error when ${prop} is ${item.text}`
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
if (item.type === 'number') {
|
||||
done(`Expected to pass when ${prop} is ${item.text}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Fix
|
||||
validationValues.forEach((item, value) => {
|
||||
try {
|
||||
const result = validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
[prop]: value,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fix: true,
|
||||
}
|
||||
);
|
||||
|
||||
const icon =
|
||||
item.type === 'number'
|
||||
? {
|
||||
body: '<g />',
|
||||
[prop]: value,
|
||||
}
|
||||
: {
|
||||
// [prop] should be deleted
|
||||
body: '<g />',
|
||||
};
|
||||
|
||||
expect(result).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: icon,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
done(
|
||||
`Expected to not throw error when ${prop} is being fixed`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// Boolean
|
||||
['hFlip', 'vFlip', 'hidden'].forEach((prop) => {
|
||||
it(prop, (done) => {
|
||||
validationValues.forEach((item, value) => {
|
||||
// Validate
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
[prop]: value,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (item.type !== 'boolean') {
|
||||
done(
|
||||
`Expected to throw error when ${prop} is ${item.text}`
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
if (item.type === 'boolean') {
|
||||
done(`Expected to pass when ${prop} is ${item.text}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Fix
|
||||
validationValues.forEach((item, value) => {
|
||||
try {
|
||||
const result = validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
[prop]: value,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fix: true,
|
||||
}
|
||||
);
|
||||
|
||||
const icon =
|
||||
item.type === 'boolean'
|
||||
? {
|
||||
body: '<g />',
|
||||
[prop]: value,
|
||||
}
|
||||
: {
|
||||
// [prop] should be deleted
|
||||
body: '<g />',
|
||||
};
|
||||
|
||||
expect(result).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: icon,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
done(
|
||||
`Expected to not throw error when ${prop} is being fixed`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// Unexpected field
|
||||
it('foo', (done) => {
|
||||
validationValues.forEach((item, value) => {
|
||||
// Validate
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
foo: value,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (item.type === 'object') {
|
||||
done(`Expected to throw error when value is ${item.text}`);
|
||||
}
|
||||
} catch (err) {
|
||||
if (item.type !== 'object') {
|
||||
done(`Expected to pass when value is ${item.text}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Fix
|
||||
validationValues.forEach((item, value) => {
|
||||
try {
|
||||
const result = validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
foo: value,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fix: true,
|
||||
}
|
||||
);
|
||||
|
||||
const icon =
|
||||
item.type !== 'object'
|
||||
? {
|
||||
body: '<g />',
|
||||
foo: value,
|
||||
}
|
||||
: {
|
||||
// should be deleted
|
||||
body: '<g />',
|
||||
};
|
||||
|
||||
expect(result).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: icon,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
done(`Expected to not throw error when value is being fixed`);
|
||||
}
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
223
packages/utils/tests/validate-test.ts
Normal file
223
packages/utils/tests/validate-test.ts
Normal file
@ -0,0 +1,223 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { validateIconSet } from '../lib/icon-set/validate';
|
||||
|
||||
describe('Testing validation', () => {
|
||||
it('Not object', (done) => {
|
||||
try {
|
||||
validateIconSet(void 0);
|
||||
done('Expected to throw error on undefined');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
try {
|
||||
validateIconSet({});
|
||||
done('Expected to throw error on empty object');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
try {
|
||||
validateIconSet(null);
|
||||
done('Expected to throw error on null');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
try {
|
||||
validateIconSet([]);
|
||||
done('Expected to throw error on array');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('Valid set', () => {
|
||||
expect(
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
})
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('Missing stuff', (done) => {
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
});
|
||||
done('Expected to throw error when icons are missing');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {},
|
||||
});
|
||||
done('Expected to throw error when icons are empty');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
try {
|
||||
validateIconSet([]);
|
||||
done('Expected to throw error on array');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('Characters', (done) => {
|
||||
// Correct icon set
|
||||
expect(
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'bar',
|
||||
hFlip: true,
|
||||
},
|
||||
},
|
||||
chars: {
|
||||
e00: 'bar',
|
||||
e01: 'baz',
|
||||
},
|
||||
})
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
aliases: {
|
||||
baz: {
|
||||
parent: 'bar',
|
||||
hFlip: true,
|
||||
},
|
||||
},
|
||||
chars: {
|
||||
e00: 'bar',
|
||||
e01: 'baz',
|
||||
},
|
||||
});
|
||||
|
||||
// Missing icon
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
chars: {
|
||||
e01: 'baz',
|
||||
},
|
||||
});
|
||||
done(
|
||||
'Expected to throw error when character points to missing icon'
|
||||
);
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
chars: {
|
||||
e01: 'baz',
|
||||
},
|
||||
},
|
||||
{ fix: true }
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Bad character
|
||||
try {
|
||||
validateIconSet({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
chars: {
|
||||
test: 'bar',
|
||||
},
|
||||
});
|
||||
done('Expected to throw error when character is invalid');
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
|
||||
expect(
|
||||
validateIconSet(
|
||||
{
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
chars: {
|
||||
// Valid character
|
||||
'e000-f123': 'bar',
|
||||
// Multiple invalid characters
|
||||
'test': 'bar',
|
||||
'E0': 'bar',
|
||||
},
|
||||
},
|
||||
{ fix: true }
|
||||
)
|
||||
).to.be.eql({
|
||||
prefix: 'foo',
|
||||
icons: {
|
||||
bar: {
|
||||
body: '<g />',
|
||||
},
|
||||
},
|
||||
chars: {
|
||||
'e000-f123': 'bar',
|
||||
},
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
15
packages/utils/tsconfig-base.json
Normal file
15
packages/utils/tsconfig-base.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"composite": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"importsNotUsedAsValues": "error"
|
||||
}
|
||||
}
|
12
packages/utils/tsconfig.json
Normal file
12
packages/utils/tsconfig.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./src/tsconfig.json"
|
||||
},
|
||||
{
|
||||
"path": "./tests/tsconfig.json"
|
||||
}
|
||||
]
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
@ -4,6 +4,7 @@
|
||||
"bundledPackages": [
|
||||
"@iconify/types",
|
||||
"@iconify/core",
|
||||
"@iconify/utils",
|
||||
"@cyberalien/redundancy"
|
||||
],
|
||||
"compiler": {},
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user