@iconify/json 2.0.0-beta.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collections.json +64 -21
- package/collections.md +39 -31
- package/composer.json +13 -0
- package/json/akar-icons.json +28 -13
- package/json/bi.json +116 -113
- package/json/carbon.json +244 -12
- package/json/codicon.json +6 -3
- package/json/fluent.json +2328 -99
- package/json/gala.json +181 -0
- package/json/gis.json +1 -1
- package/json/grommet-icons.json +1 -1
- package/json/ic.json +1106 -6
- package/json/ion.json +2 -2
- package/json/lucide.json +24 -3
- package/json/mdi.json +289 -36
- package/json/mono-icons.json +2 -1
- package/json/prime.json +742 -0
- package/json/simple-icons.json +118 -7
- package/json/tabler.json +237 -15
- package/package.json +6 -4
- package/readme.md +86 -5
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@iconify/json",
|
|
3
3
|
"description": "Iconify icons collection in JSON format",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"tag": "next"
|
|
8
8
|
},
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"url": "git+ssh://git@github.com/iconify/collections-json.git"
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
|
+
"./*": "./*",
|
|
16
17
|
".": {
|
|
17
18
|
"require": "./dist/index.js",
|
|
18
19
|
"import": "./dist/index.mjs"
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"lib",
|
|
25
26
|
"collections.json",
|
|
26
27
|
"collections.md",
|
|
27
|
-
"composer.
|
|
28
|
+
"composer.json",
|
|
28
29
|
"readme.md"
|
|
29
30
|
],
|
|
30
31
|
"main": "dist/index.js",
|
|
@@ -37,7 +38,8 @@
|
|
|
37
38
|
"test-locate-esm": "jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --config=jest.esm.config.ts src/locate.esm.test.ts -i",
|
|
38
39
|
"test-locate-cjs": "npm run build && jest --clearCache && jest --config=jest.cjs.config.ts src/locate.cjs.test.ts -i",
|
|
39
40
|
"test": "npm run test-esm && npm run test-cjs && npm run test-locate-esm && npm run test-locate-cjs",
|
|
40
|
-
"
|
|
41
|
+
"version": "node sync-version",
|
|
42
|
+
"prepublishOnly": "npm run build && npm run version"
|
|
41
43
|
},
|
|
42
44
|
"dependencies": {
|
|
43
45
|
"@iconify/types": "^1.0.9",
|
|
@@ -57,4 +59,4 @@
|
|
|
57
59
|
"tsup": "^4.14.0",
|
|
58
60
|
"typescript": "^4.4.3"
|
|
59
61
|
}
|
|
60
|
-
}
|
|
62
|
+
}
|
package/readme.md
CHANGED
|
@@ -152,10 +152,79 @@ For PHP use [Iconify JSON Tools](https://docs.iconify.design/tools/json/).
|
|
|
152
152
|
|
|
153
153
|
For JavaScript use [Iconify Utils](https://docs.iconify.design/tools/utils/), though Iconify JSON Tools are also available (but deprecated).
|
|
154
154
|
|
|
155
|
-
Example using Iconify Utils:
|
|
155
|
+
Example using Iconify Utils (TypeScript):
|
|
156
156
|
|
|
157
|
-
```
|
|
157
|
+
```ts
|
|
158
|
+
import { promises as fs } from 'fs';
|
|
159
|
+
|
|
160
|
+
// Function to locate JSON file
|
|
161
|
+
import { locate } from '@iconify/json';
|
|
162
|
+
|
|
163
|
+
// Various functions from Iconify Utils
|
|
164
|
+
import { parseIconSet } from '@iconify/utils/lib/icon-set/parse';
|
|
165
|
+
import { iconToSVG } from '@iconify/utils/lib/svg/build';
|
|
166
|
+
import { defaults } from '@iconify/utils/lib/customisations';
|
|
167
|
+
|
|
168
|
+
(async () => {
|
|
169
|
+
// Locate icons
|
|
170
|
+
const filename = locate('mdi');
|
|
171
|
+
|
|
172
|
+
// Load icon set
|
|
173
|
+
const icons = JSON.parse(await fs.readFile(filename, 'utf8'));
|
|
174
|
+
|
|
175
|
+
// Parse all icons
|
|
176
|
+
const exportedSVG: Record<string, string> = Object.create(null);
|
|
177
|
+
parseIconSet(icons, (iconName, iconData) => {
|
|
178
|
+
if (!iconData) {
|
|
179
|
+
// Invalid icon
|
|
180
|
+
console.error(`Error parsing icon ${iconName}`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Render icon
|
|
185
|
+
const renderData = iconToSVG(iconData, {
|
|
186
|
+
...defaults,
|
|
187
|
+
height: 'auto',
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Generate attributes for SVG element
|
|
191
|
+
const svgAttributes: Record<string, string> = {
|
|
192
|
+
'xmlns': 'http://www.w3.org/2000/svg',
|
|
193
|
+
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
|
194
|
+
...renderData.attributes,
|
|
195
|
+
};
|
|
196
|
+
const svgAttributesStr = Object.keys(svgAttributes)
|
|
197
|
+
.map(
|
|
198
|
+
(attr) =>
|
|
199
|
+
// No need to check attributes for special characters, such as quotes,
|
|
200
|
+
// they cannot contain anything that needs escaping.
|
|
201
|
+
`${attr}="${svgAttributes[attr as keyof typeof svgAttributes]}"`
|
|
202
|
+
)
|
|
203
|
+
.join(' ');
|
|
204
|
+
|
|
205
|
+
// Generate SVG
|
|
206
|
+
const svg = `<svg ${svgAttributesStr}>${renderData.body}</svg>`;
|
|
207
|
+
exportedSVG[iconName] = svg;
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Output directory
|
|
211
|
+
const outputDir = 'mdi-export';
|
|
212
|
+
try {
|
|
213
|
+
await fs.mkdir(outputDir, {
|
|
214
|
+
recursive: true,
|
|
215
|
+
});
|
|
216
|
+
} catch (err) {
|
|
217
|
+
//
|
|
218
|
+
}
|
|
158
219
|
|
|
220
|
+
// Save all files
|
|
221
|
+
const filenames = Object.keys(exportedSVG);
|
|
222
|
+
for (let i = 0; i < filenames.length; i++) {
|
|
223
|
+
const filename = filenames[i];
|
|
224
|
+
const svg = exportedSVG[filename];
|
|
225
|
+
await fs.writeFile(outputDir + '/' + filename + '.svg', svg, 'utf8');
|
|
226
|
+
}
|
|
227
|
+
})();
|
|
159
228
|
```
|
|
160
229
|
|
|
161
230
|
Example using Iconify JSON Tools:
|
|
@@ -164,12 +233,21 @@ Example using Iconify JSON Tools:
|
|
|
164
233
|
const fs = require('fs');
|
|
165
234
|
const { SVG, Collection } = require('@iconify/json-tools');
|
|
166
235
|
|
|
167
|
-
|
|
236
|
+
const outputDir = 'mdi-export';
|
|
237
|
+
try {
|
|
238
|
+
fs.mkdirSync(outputDir, {
|
|
239
|
+
recursive: true,
|
|
240
|
+
});
|
|
241
|
+
} catch (err) {
|
|
242
|
+
//
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const collection = new Collection();
|
|
168
246
|
collection.loadIconifyCollection('mdi');
|
|
169
247
|
collection.listIcons(true).forEach((icon) => {
|
|
170
248
|
let svg = new SVG(collection.getIconData(icon));
|
|
171
249
|
fs.writeFileSync(
|
|
172
|
-
'
|
|
250
|
+
outputDir + '/' + icon + '.svg',
|
|
173
251
|
svg.getSVG({
|
|
174
252
|
height: 'auto',
|
|
175
253
|
})
|
|
@@ -181,11 +259,14 @@ collection.listIcons(true).forEach((icon) => {
|
|
|
181
259
|
use \Iconify\JSONTools\Collection;
|
|
182
260
|
use \Iconify\JSONTools\SVG;
|
|
183
261
|
|
|
262
|
+
$outputDir = 'mdi-export';
|
|
263
|
+
@mkdir($outputDir, 0777, true);
|
|
264
|
+
|
|
184
265
|
$collection = new Collection();
|
|
185
266
|
$collection->loadIconifyCollection('mdi');
|
|
186
267
|
foreach ($collection->listIcons(true) as $icon) {
|
|
187
268
|
$svg = new SVG($collection->getIconData($icon));
|
|
188
|
-
file_put_contents('
|
|
269
|
+
file_put_contents($outputDir . '/' . $icon . '.svg', $svg->getSVG([
|
|
189
270
|
'height' => 'auto'
|
|
190
271
|
]));
|
|
191
272
|
}
|